From 8eb9890c8a94ae52ac573afc9764d542e53aa163 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Fri, 7 Apr 2023 14:01:36 +0200 Subject: [PATCH] feat(theming): Align theming closer to files app Follow-Up to https://github.com/nextcloud/notes-android/pull/1680 Signed-off-by: Stefan Niedermann --- .../notes/branding/NotesViewThemeUtils.java | 21 +++++++++++++++++++ .../owncloud/notes/main/MainActivity.java | 3 ++- app/src/main/res/layout/activity_about.xml | 1 - app/src/main/res/layout/activity_edit.xml | 1 - .../main/res/layout/activity_exception.xml | 1 - .../res/layout/activity_formatting_help.xml | 3 +-- .../res/layout/activity_manage_accounts.xml | 3 +-- .../res/layout/activity_notes_list_view.xml | 5 ++--- .../main/res/layout/activity_preferences.xml | 3 +-- app/src/main/res/values/styles.xml | 5 +++++ 10 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java index c26b0bf1..f1862e4f 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/NotesViewThemeUtils.java @@ -16,6 +16,7 @@ import android.widget.TextView; import androidx.annotation.ColorInt; import androidx.annotation.IdRes; import androidx.annotation.NonNull; +import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.Toolbar; import androidx.core.content.ContextCompat; import androidx.core.graphics.drawable.DrawableCompat; @@ -171,4 +172,24 @@ public class NotesViewThemeUtils extends ViewThemeUtilsBase { return toolbar; }); } + + /** + * @deprecated Should be replaced with {@link com.google.android.material.search.SearchView} + * @see com.nextcloud.android.common.ui.theme.utils.AndroidXViewThemeUtils#themeToolbarSearchView(SearchView) + */ + @Deprecated + public void themeToolbarSearchView(@NonNull SearchView searchView) { + withScheme(searchView, scheme -> { + // hacky as no default way is provided + final var editText = (SearchView.SearchAutoComplete) searchView.findViewById(androidx.appcompat.R.id.search_src_text); + final var closeButton = (ImageView) searchView.findViewById(androidx.appcompat.R.id.search_close_btn); + final var searchButton = (ImageView) searchView.findViewById(androidx.appcompat.R.id.search_button); + editText.setHintTextColor(scheme.getOnSurfaceVariant()); + editText.setHighlightColor(scheme.getInverseOnSurface()); + editText.setTextColor(scheme.getOnSurface()); + closeButton.setColorFilter(scheme.getOnSurface()); + searchButton.setColorFilter(scheme.getOnSurface()); + return searchView; + }); + } } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java index bcba3df2..43e482a7 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java @@ -594,12 +594,13 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A @Override public void applyBrand(int color) { final var util = BrandingUtil.of(color, this); - util.material.themeFAB(activityBinding.fabCreate); util.androidx.themeSwipeRefreshLayout(activityBinding.swiperefreshlayout); util.platform.colorCircularProgressBar(activityBinding.progressCircular, ColorRole.PRIMARY); util.platform.colorNavigationView(binding.navigationView); + util.material.themeFAB(activityBinding.fabCreate); util.notes.themeSearchCardView(binding.activityNotesListView.searchBarWrapper); util.notes.themeSearchToolbar(binding.activityNotesListView.searchToolbar); + util.notes.themeToolbarSearchView(binding.activityNotesListView.searchView); binding.headerView.setBackgroundColor(color); @ColorInt final int headerTextColor = ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(color); diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index b560bf17..bf04d6f5 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -16,7 +16,6 @@ android:layout_width="match_parent" android:layout_height="wrap_content" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" - app:titleMarginStart="0dp" tools:title="@string/simple_about" /> + app:title="@string/action_formatting_help" /> + app:title="@string/manage_accounts" /> + app:contentInsetStartWithNavigation="0dp"> + app:title="@string/action_settings" /> @dimen/spacer_activity_sides + +