Эх сурвалжийг харах

Move theme utils reference to base class and use new status bar coloring in all relevant places

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
Andy Scherzinger 2 жил өмнө
parent
commit
4d93a2099f

+ 8 - 5
app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt

@@ -34,15 +34,20 @@ import com.nextcloud.talk.BuildConfig
 import com.nextcloud.talk.R
 import com.nextcloud.talk.application.NextcloudTalkApplication
 import com.nextcloud.talk.databinding.ActivityFullScreenTextBinding
+import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.Mimetype.TEXT_PREFIX_GENERIC
 import io.noties.markwon.Markwon
 import java.io.File
+import javax.inject.Inject
 
 @AutoInjector(NextcloudTalkApplication::class)
 class FullScreenTextViewerActivity : AppCompatActivity() {
     lateinit var binding: ActivityFullScreenTextBinding
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     private lateinit var path: String
 
     override fun onCreateOptionsMenu(menu: Menu?): Boolean {
@@ -77,6 +82,7 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
 
     override fun onCreate(savedInstanceState: Bundle?) {
         super.onCreate(savedInstanceState)
+        NextcloudTalkApplication.sharedApplication!!.componentApplication.inject(this)
 
         binding = ActivityFullScreenTextBinding.inflate(layoutInflater)
         setContentView(binding.root)
@@ -98,12 +104,9 @@ class FullScreenTextViewerActivity : AppCompatActivity() {
         supportActionBar?.title = fileName
         supportActionBar?.setDisplayHomeAsUpEnabled(true)
 
-        if (resources != null) {
-            DisplayUtils.applyColorToStatusBar(
-                this,
-                ResourcesCompat.getColor(resources, R.color.appbar, null)
-            )
+        viewThemeUtils.themeStatusBar(this, binding.textviewToolbar)
 
+        if (resources != null) {
             DisplayUtils.applyColorToNavigationBar(
                 this.window,
                 ResourcesCompat.getColor(resources, R.color.bg_default, null)

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt

@@ -155,7 +155,6 @@ import com.nextcloud.talk.ui.dialog.ShowReactionsDialog
 import com.nextcloud.talk.ui.recyclerview.MessageSwipeActions
 import com.nextcloud.talk.ui.recyclerview.MessageSwipeCallback
 import com.nextcloud.talk.ui.theme.ServerTheme
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.AttendeePermissionsUtil
 import com.nextcloud.talk.utils.ConductorRemapping
@@ -237,9 +236,6 @@ class ChatController(args: Bundle) :
     @Inject
     lateinit var permissionUtil: PlatformPermissionUtil
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     @Inject
     lateinit var serverTheme: ServerTheme
 

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt

@@ -65,7 +65,6 @@ import com.nextcloud.talk.models.json.converters.EnumActorTypeConverter
 import com.nextcloud.talk.models.json.participants.Participant
 import com.nextcloud.talk.ui.dialog.ContactsBottomDialog
 import com.nextcloud.talk.users.UserManager
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.ConductorRemapping
 import com.nextcloud.talk.utils.bundle.BundleKeys
@@ -104,9 +103,6 @@ class ContactsController(args: Bundle) :
     @Inject
     lateinit var ncApi: NcApi
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     private var credentials: String? = null
     private var currentUser: User? = null
     private var contactsQueryDisposable: Disposable? = null

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt

@@ -73,7 +73,6 @@ import com.nextcloud.talk.models.json.participants.Participant.ActorType.GROUPS
 import com.nextcloud.talk.models.json.participants.Participant.ActorType.USERS
 import com.nextcloud.talk.models.json.participants.ParticipantsOverall
 import com.nextcloud.talk.shareditems.activities.SharedItemsActivity
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.DateConstants
 import com.nextcloud.talk.utils.DateUtils
@@ -113,9 +112,6 @@ class ConversationInfoController(args: Bundle) :
     @Inject
     lateinit var eventBus: EventBus
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     private val conversationToken: String?
     private val conversationUser: User?
     private val hasAvatarSpacing: Boolean

+ 1 - 4
app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java

@@ -473,10 +473,7 @@ public class ConversationsListController extends BaseController implements Flexi
                         activity.binding.toolbar.setVisibility(View.GONE);
                         activity.binding.searchToolbar.setVisibility(View.VISIBLE);
                         if (getResources() != null) {
-                            DisplayUtils.applyColorToStatusBar(
-                                activity,
-                                ResourcesCompat.getColor(getResources(), R.color.bg_default, null)
-                                                              );
+                            viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar);
                         }
                     }
                     SmoothScrollLinearLayoutManager layoutManager =

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt

@@ -66,7 +66,6 @@ import com.nextcloud.talk.models.json.userprofile.UserProfileFieldsOverall
 import com.nextcloud.talk.models.json.userprofile.UserProfileOverall
 import com.nextcloud.talk.remotefilebrowser.activities.RemoteFileBrowserActivity
 import com.nextcloud.talk.ui.dialog.ScopeDialog
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.users.UserManager
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.DisplayUtils
@@ -108,9 +107,6 @@ class ProfileController : NewBaseController(R.layout.controller_profile) {
     @Inject
     lateinit var permissionUtil: PlatformPermissionUtil
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     private var currentUser: User? = null
     private var edit = false
     private var adapter: UserInfoAdapter? = null

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt

@@ -78,7 +78,6 @@ import com.nextcloud.talk.jobs.ContactAddressBookWorker.Companion.deleteAll
 import com.nextcloud.talk.models.json.generic.GenericOverall
 import com.nextcloud.talk.models.json.userprofile.UserProfileOverall
 import com.nextcloud.talk.users.UserManager
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.ApiUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.LoggingUtils.sendMailWithAttachment
@@ -119,9 +118,6 @@ class SettingsController : NewBaseController(R.layout.controller_settings) {
     @Inject
     lateinit var currentUserProvider: CurrentUserProviderNew
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     private var saveStateHandler: LovelySaveStateHandler? = null
     private var currentUser: User? = null
     private var credentials: String? = null

+ 2 - 8
app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java

@@ -186,15 +186,9 @@ public abstract class BaseController extends ButterKnifeController {
 
                 if ((getResources() != null)) {
                     if (showSearchBar) {
-                        DisplayUtils.applyColorToStatusBar(
-                                activity, ResourcesCompat.getColor(getResources(),
-                                        R.color.bg_default, null)
-                        );
+                        viewThemeUtils.resetStatusBar(activity, activity.binding.searchToolbar);
                     } else {
-                        DisplayUtils.applyColorToStatusBar(
-                                activity, ResourcesCompat.getColor(getResources(),
-                                        R.color.appbar, null)
-                        );
+                        viewThemeUtils.themeStatusBar(activity, activity.binding.searchToolbar);
                     }
                 }
             }

+ 19 - 17
app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt

@@ -56,6 +56,7 @@ import com.nextcloud.talk.controllers.WebViewLoginController
 import com.nextcloud.talk.controllers.base.providers.ActionBarProvider
 import com.nextcloud.talk.controllers.util.ControllerViewBindingDelegate
 import com.nextcloud.talk.databinding.ActivityMainBinding
+import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.utils.DisplayUtils
 import com.nextcloud.talk.utils.preferences.AppPreferences
 import javax.inject.Inject
@@ -73,6 +74,9 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
     @Inject
     lateinit var context: Context
 
+    @Inject
+    lateinit var viewThemeUtils: ViewThemeUtils
+
     protected open val title: String?
         get() = null
 
@@ -115,11 +119,19 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
     }
 
     protected open fun onViewBound(view: View) {
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences!!.isKeyboardIncognito) {
-            disableKeyboardPersonalisedLearning(view as ViewGroup)
-            if (activity != null && activity is MainActivity) {
-                val activity = activity as MainActivity?
-                disableKeyboardPersonalisedLearning(activity!!.binding.appBar)
+        var activity: MainActivity? = null
+
+        if (getActivity() != null && getActivity() is MainActivity) {
+            activity = getActivity() as MainActivity?
+            viewThemeUtils.themeCardView(activity!!.binding.searchToolbar)
+            viewThemeUtils.themeToolbar(activity.binding.toolbar)
+            viewThemeUtils.themeSearchBarText(activity.binding.searchText)
+        }
+
+        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && appPreferences.isKeyboardIncognito) {
+            disableKeyboardPersonalisedLearning((view as ViewGroup))
+            if (activity != null) {
+                disableKeyboardPersonalisedLearning(activity.binding.appBar)
             }
         }
     }
@@ -192,19 +204,9 @@ abstract class NewBaseController(@LayoutRes var layoutRes: Int, args: Bundle? =
     private fun colorizeStatusBar(showSearchBar: Boolean, activity: Activity?, resources: Resources?) {
         if (activity != null && resources != null) {
             if (showSearchBar) {
-                DisplayUtils.applyColorToStatusBar(
-                    activity,
-                    ResourcesCompat.getColor(
-                        resources, R.color.bg_default, null
-                    )
-                )
+                view?.let { viewThemeUtils.resetStatusBar(activity, it) }
             } else {
-                DisplayUtils.applyColorToStatusBar(
-                    activity,
-                    ResourcesCompat.getColor(
-                        resources, R.color.appbar, null
-                    )
-                )
+                view?.let { viewThemeUtils.themeStatusBar(activity, it) }
             }
         }
     }

+ 0 - 4
app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.kt

@@ -47,7 +47,6 @@ import com.nextcloud.talk.controllers.util.viewBinding
 import com.nextcloud.talk.databinding.ControllerEntryMenuBinding
 import com.nextcloud.talk.models.json.conversations.Conversation
 import com.nextcloud.talk.ui.theme.ServerTheme
-import com.nextcloud.talk.ui.theme.ViewThemeUtils
 import com.nextcloud.talk.users.UserManager
 import com.nextcloud.talk.utils.ShareUtils
 import com.nextcloud.talk.utils.UriUtils
@@ -74,9 +73,6 @@ class EntryMenuController(args: Bundle) :
     @Inject
     lateinit var userManager: UserManager
 
-    @Inject
-    lateinit var viewThemeUtils: ViewThemeUtils
-
     @Inject
     lateinit var serverTheme: ServerTheme
 

+ 2 - 8
app/src/main/java/com/nextcloud/talk/shareditems/activities/SharedItemsActivity.kt

@@ -73,14 +73,8 @@ class SharedItemsActivity : AppCompatActivity() {
         setSupportActionBar(binding.sharedItemsToolbar)
         setContentView(binding.root)
 
-        DisplayUtils.applyColorToStatusBar(
-            this,
-            ResourcesCompat.getColor(
-                resources,
-                R.color.appbar,
-                null
-            )
-        )
+        viewThemeUtils.themeStatusBar(this, binding.sharedItemsToolbar)
+
         DisplayUtils.applyColorToNavigationBar(
             this.window,
             ResourcesCompat.getColor(resources, R.color.bg_default, null)