diff options
author | Stefan Niedermann <info@niedermann.it> | 2023-02-16 15:53:11 +0300 |
---|---|---|
committer | Stefan Niedermann <info@niedermann.it> | 2023-02-16 15:53:11 +0300 |
commit | 0fbb861259c47bd0fc24958feb204dfff1304f19 (patch) | |
tree | d8e2715496dac4b6b67a407456cbae5a03dc3d7a /app/src/main/java/it/niedermann/nextcloud/deck | |
parent | 5fcbdccbf3bb30d3a36f15c59f26c4b1ed073b04 (diff) |
feat(theming): Update android-common:ui to 0.6.0 and use new methods
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck')
3 files changed, 3 insertions, 78 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java index db6815685..6c861102b 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/MainActivity.java @@ -452,7 +452,7 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen final var scheme = ThemeUtils.createScheme(color, this); utils.deck.themeTabLayout(binding.stackTitles); - utils.deck.themeExtendedFAB(binding.fab); + utils.material.themeExtendedFAB(binding.fab); utils.androidx.themeSwipeRefreshLayout(binding.swipeRefreshLayout); utils.platform.colorEditText(binding.filterText); @@ -462,7 +462,7 @@ public class MainActivity extends AppCompatActivity implements DeleteStackListen private void applyAccountTheme(@ColorInt int accountColor) { final var utils = ThemeUtils.of(accountColor, this); - utils.deck.colorNavigationView(binding.navigationView); + utils.platform.colorNavigationView(binding.navigationView, false); headerBinding.headerView.setBackgroundColor(accountColor); @ColorInt final int headerTextColor = ColorUtil.INSTANCE.getForegroundColorForBackgroundColor(accountColor); diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java index e29f53904..fa2ff1abe 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/attachments/CardAttachmentsFragment.java @@ -524,7 +524,7 @@ public class CardAttachmentsFragment extends Fragment implements AttachmentDelet final var utils = ThemeUtils.of(color, requireContext()); utils.material.themeFAB(binding.fab); - utils.deck.colorBottomNavigationView(binding.bottomNavigation); + utils.platform.colorBottomNavigationView(binding.bottomNavigation); utils.platform.colorViewBackground(binding.pickerHeader, ColorRole.SURFACE); utils.platform.colorViewBackground(binding.pickerRecyclerView, ColorRole.SURFACE); 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 ee11cbbea..3e13d4256 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,24 +1,15 @@ package it.niedermann.nextcloud.deck.ui.theme; -import static com.nextcloud.android.common.ui.util.ColorStateListUtilsKt.buildColorStateList; - -import android.content.res.ColorStateList; -import android.graphics.Color; - import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; -import com.google.android.material.bottomnavigation.BottomNavigationView; -import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton; -import com.google.android.material.navigation.NavigationView; import com.google.android.material.tabs.TabLayout; import com.nextcloud.android.common.ui.theme.MaterialSchemes; import com.nextcloud.android.common.ui.theme.ViewThemeUtilsBase; import com.nextcloud.android.common.ui.theme.utils.MaterialViewThemeUtils; import it.niedermann.nextcloud.deck.R; -import kotlin.Pair; /** * UI Elements which are not yet supported by the <a href="https://github.com/nextcloud/android-common"><code>android-commons</code></a> library. @@ -37,72 +28,6 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase { } /** - * @param fab {@link ExtendedFloatingActionButton} - * @see <a href="https://github.com/nextcloud/android-common/pull/68">Upstream Pull Request</a> - */ - public void themeExtendedFAB(ExtendedFloatingActionButton fab) { - withScheme(fab, scheme -> { - fab.setBackgroundTintList(buildColorStateList( - new Pair<>(android.R.attr.state_enabled, scheme.getPrimaryContainer()), - new Pair<>(-android.R.attr.state_enabled, Color.GRAY) - )); - fab.setIconTint(buildColorStateList( - new Pair<>(android.R.attr.state_enabled, scheme.getOnPrimaryContainer()), - new Pair<>(-android.R.attr.state_enabled, Color.WHITE) - )); - return fab; - }); - } - - /** - * @param navigationView {@link NavigationView} - * @see <a href="https://github.com/nextcloud/android-common/pull/69">Upstream Pull Request</a> - */ - public void colorNavigationView(NavigationView navigationView) { - withScheme(navigationView, scheme -> { - if (navigationView.getItemBackground() != null) { - navigationView.getItemBackground().setTintList(buildColorStateList( - new Pair<>(android.R.attr.state_checked, scheme.getSecondaryContainer()), - new Pair<>(-android.R.attr.state_checked, Color.TRANSPARENT) - )); - } - // Fixes https://github.com/nextcloud/android-common/issues/66 - navigationView.getBackground().setTintList(ColorStateList.valueOf(scheme.getSurface())); - - final var colorStateList = buildColorStateList( - new Pair<>(android.R.attr.state_checked, scheme.getOnSecondaryContainer()), - new Pair<>(-android.R.attr.state_checked, scheme.getOnSurfaceVariant()) - ); - - navigationView.setItemTextColor(colorStateList); - // Fixes https://github.com/nextcloud/android-common/issues/64 - // navigationView.setItemIconTintList(colorStateList); - return navigationView; - }); - } - - /** - * @param bottomNavigationView {@link BottomNavigationView} - * @see <a href="https://github.com/nextcloud/android-common/pull/71">Upstream Pull Request</a> - */ - public void colorBottomNavigationView(BottomNavigationView bottomNavigationView) { - withScheme(bottomNavigationView, scheme -> { - bottomNavigationView.setBackgroundColor(scheme.getSurface()); - bottomNavigationView.setItemIconTintList(buildColorStateList( - new Pair<>(android.R.attr.state_checked, scheme.getOnSecondaryContainer()), - new Pair<>(-android.R.attr.state_checked, scheme.getOnSurfaceVariant()) - )); - bottomNavigationView.setItemTextColor(buildColorStateList( - new Pair<>(android.R.attr.state_checked, scheme.getOnSurface()), - new Pair<>(-android.R.attr.state_checked, scheme.getOnSurfaceVariant()) - )); - bottomNavigationView.setItemActiveIndicatorColor(ColorStateList.valueOf(scheme.getSecondaryContainer())); - - return bottomNavigationView; - }); - } - - /** * Convenience method for calling {@link #themeTabLayout(TabLayout, int)} with the primary color */ public void themeTabLayout(@NonNull TabLayout tabLayout) { |