feat(theming): Align theming closer to files app

Follow-Up to https://github.com/nextcloud/notes-android/pull/1680

Signed-off-by: Stefan Niedermann <info@niedermann.it>
This commit is contained in:
Stefan Niedermann 2023-04-07 14:01:36 +02:00 committed by Andy Scherzinger
parent 1dbde30c46
commit 8eb9890c8a
10 changed files with 33 additions and 13 deletions

View file

@ -16,6 +16,7 @@ import android.widget.TextView;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.IdRes; import androidx.annotation.IdRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.appcompat.widget.SearchView;
import androidx.appcompat.widget.Toolbar; import androidx.appcompat.widget.Toolbar;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
@ -171,4 +172,24 @@ public class NotesViewThemeUtils extends ViewThemeUtilsBase {
return toolbar; 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;
});
}
} }

View file

@ -594,12 +594,13 @@ public class MainActivity extends LockedActivity implements NoteClickListener, A
@Override @Override
public void applyBrand(int color) { public void applyBrand(int color) {
final var util = BrandingUtil.of(color, this); final var util = BrandingUtil.of(color, this);
util.material.themeFAB(activityBinding.fabCreate);
util.androidx.themeSwipeRefreshLayout(activityBinding.swiperefreshlayout); util.androidx.themeSwipeRefreshLayout(activityBinding.swiperefreshlayout);
util.platform.colorCircularProgressBar(activityBinding.progressCircular, ColorRole.PRIMARY); util.platform.colorCircularProgressBar(activityBinding.progressCircular, ColorRole.PRIMARY);
util.platform.colorNavigationView(binding.navigationView); util.platform.colorNavigationView(binding.navigationView);
util.material.themeFAB(activityBinding.fabCreate);
util.notes.themeSearchCardView(binding.activityNotesListView.searchBarWrapper); util.notes.themeSearchCardView(binding.activityNotesListView.searchBarWrapper);
util.notes.themeSearchToolbar(binding.activityNotesListView.searchToolbar); util.notes.themeSearchToolbar(binding.activityNotesListView.searchToolbar);
util.notes.themeToolbarSearchView(binding.activityNotesListView.searchView);
binding.headerView.setBackgroundColor(color); binding.headerView.setBackgroundColor(color);
@ColorInt final int headerTextColor = ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(color); @ColorInt final int headerTextColor = ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(color);

View file

@ -16,7 +16,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:titleMarginStart="0dp"
tools:title="@string/simple_about" /> tools:title="@string/simple_about" />
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout

View file

@ -11,7 +11,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:titleMarginStart="0dp"
tools:title="Edit Sample note" /> tools:title="Edit Sample note" />
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView

View file

@ -11,7 +11,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:elevation="4dp" app:elevation="4dp"
app:titleMarginStart="0dp"
tools:title="@string/simple_exception" /> tools:title="@string/simple_exception" />
<TextView <TextView

View file

@ -11,8 +11,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:title="@string/action_formatting_help" app:title="@string/action_formatting_help" />
app:titleMarginStart="0dp" />
<ScrollView <ScrollView
android:id="@+id/scrollView" android:id="@+id/scrollView"

View file

@ -11,8 +11,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:title="@string/manage_accounts" app:title="@string/manage_accounts" />
app:titleMarginStart="0dp" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/accounts" android:id="@+id/accounts"

View file

@ -38,8 +38,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
app:contentInsetStartWithNavigation="0dp" app:contentInsetStartWithNavigation="0dp">
app:titleMarginStart="0dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -86,11 +85,11 @@
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/search_toolbar" android:id="@+id/search_toolbar"
style="@style/searchToolbarStyle"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:visibility="gone" android:visibility="gone"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:titleMarginStart="0dp"
tools:title="@string/app_name"> tools:title="@string/app_name">
<androidx.appcompat.widget.SearchView <androidx.appcompat.widget.SearchView

View file

@ -10,8 +10,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp" app:navigationIcon="@drawable/ic_arrow_back_grey600_24dp"
app:title="@string/action_settings" app:title="@string/action_settings" />
app:titleMarginStart="0dp" />
<androidx.fragment.app.FragmentContainerView <androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container_view" android:id="@+id/fragment_container_view"

View file

@ -51,6 +51,11 @@
<item name="android:paddingEnd">@dimen/spacer_activity_sides</item> <item name="android:paddingEnd">@dimen/spacer_activity_sides</item>
</style> </style>
<style name="searchToolbarStyle" parent="@style/Widget.Material3.Toolbar">
<item name="android:paddingStart">@dimen/spacer_activity_sides</item>
<item name="android:paddingEnd">@dimen/spacer_activity_sides</item>
</style>
<style name="tabStyle" parent="Widget.Material3.TabLayout"> <style name="tabStyle" parent="Widget.Material3.TabLayout">
<item name="backgroundColor">@android:color/transparent</item> <item name="backgroundColor">@android:color/transparent</item>
<item name="itemBackground">@android:color/transparent</item> <item name="itemBackground">@android:color/transparent</item>