Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/stefan-niedermann/nextcloud-deck.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java51
1 files changed, 39 insertions, 12 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
index db0134600..b325388b2 100644
--- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java
@@ -1,6 +1,7 @@
package it.niedermann.nextcloud.deck.ui.theme;
import static com.nextcloud.android.common.ui.util.ColorStateListUtilsKt.buildColorStateList;
+import static com.nextcloud.android.common.ui.util.PlatformThemeUtil.isDarkMode;
import static java.time.temporal.ChronoUnit.DAYS;
import android.content.Context;
@@ -24,6 +25,8 @@ import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.drawable.DrawableCompat;
import androidx.core.widget.TextViewCompat;
+import com.google.android.material.search.SearchBar;
+import com.google.android.material.search.SearchView;
import com.google.android.material.tabs.TabLayout;
import com.nextcloud.android.common.ui.theme.MaterialSchemes;
import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase;
@@ -58,21 +61,53 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase {
}
/**
+ * Themes the <code>tabLayout</code> using {@link MaterialViewThemeUtils#themeTabLayout(TabLayout)}
+ * and then applies <code>null</code> as {@link TabLayout#setBackground(Drawable)}.
+ */
+ public void themeTabLayoutOnTransparent(@NonNull TabLayout tabLayout) {
+ this.material.themeTabLayout(tabLayout);
+ tabLayout.setBackground(null);
+ }
+
+ /**
* Convenience method for calling {@link #themeTabLayout(TabLayout, int)} with the primary color
*/
public void themeTabLayout(@NonNull TabLayout tabLayout) {
themeTabLayout(tabLayout, ContextCompat.getColor(tabLayout.getContext(), R.color.primary));
}
- /**
- * Themes the <code>tabLayout</code> using {@link MaterialViewThemeUtils#themeTabLayout(TabLayout)}
- * and then applies <code>backgroundColor</code>.
- */
public void themeTabLayout(@NonNull TabLayout tabLayout, @ColorInt int backgroundColor) {
this.material.themeTabLayout(tabLayout);
tabLayout.setBackgroundColor(backgroundColor);
}
+ public void themeSearchBar(@NonNull SearchBar searchBar) {
+ withScheme(searchBar.getContext(), scheme -> {
+ final var colorStateList = ColorStateList.valueOf(
+ isDarkMode(searchBar.getContext())
+ ? scheme.getSurface()
+ : scheme.getSurfaceVariant());
+
+ searchBar.setBackgroundTintList(colorStateList);
+
+ final var menu = searchBar.getMenu();
+ for (int i = 0; i < menu.size(); i++) {
+ if (menu.getItem(i).getItemId() != R.id.avatar) {
+ platform.colorToolbarMenuIcon(searchBar.getContext(), menu.getItem(i));
+ }
+ }
+
+ return searchBar;
+ });
+ }
+
+ public void themeSearchView(@NonNull SearchView searchView) {
+ withScheme(searchView.getContext(), scheme -> {
+ searchView.setBackgroundTintList(ColorStateList.valueOf(scheme.getSurface()));
+ return searchView;
+ });
+ }
+
public Drawable themeNavigationViewIcon(@NonNull Context context, @DrawableRes int icon) {
return withScheme(context, scheme -> {
final var colorStateList = buildColorStateList(
@@ -110,14 +145,6 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase {
.ifPresent(drawable -> platform.tintDrawable(context, drawable, ColorRole.PRIMARY));
}
- /**
- * Use <strong>only</strong> for <code>@drawable/filter</code>
- */
- public void themeFilterIndicator(@NonNull Context context, @NonNull Drawable filter) {
- getStateDrawable(filter, android.R.attr.state_activated, R.id.indicator)
- .ifPresent(drawable -> platform.tintDrawable(context, drawable, ColorRole.PRIMARY));
- }
-
private Optional<Drawable> getStateDrawable(@NonNull Drawable drawable, @AttrRes int state, @IdRes int layerId) {
return getStateDrawable(drawable, new int[]{state}, layerId);
}