diff --git a/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt b/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt index ccd30f3b9..4b5baa820 100644 --- a/app/src/main/java/com/nextcloud/talk/activities/FullScreenTextViewerActivity.kt +++ b/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) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt index e868911c4..5351eb733 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ChatController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt index 04398483f..703926253 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ContactsController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt index 6347acbb8..6c9273789 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java index 29ade9e2f..d69d158ab 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationsListController.java +++ b/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 = diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt b/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt index add4ac128..a40f83bdd 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ProfileController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt index 3ad36737b..f031b283e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java b/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java index 3948032c9..d88b143ec 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/base/BaseController.java +++ b/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); } } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt b/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt index a26f39247..2bfd5f869 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/base/NewBaseController.kt +++ b/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) } } } } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.kt b/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.kt index c7e45e489..ccce01a7e 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/bottomsheet/EntryMenuController.kt +++ b/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 diff --git a/app/src/main/java/com/nextcloud/talk/shareditems/activities/SharedItemsActivity.kt b/app/src/main/java/com/nextcloud/talk/shareditems/activities/SharedItemsActivity.kt index 48b415c59..29b722a9b 100644 --- a/app/src/main/java/com/nextcloud/talk/shareditems/activities/SharedItemsActivity.kt +++ b/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)