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:
authorStefan Niedermann <info@niedermann.it>2020-05-09 16:49:43 +0300
committerNiedermann IT-Dienstleistungen <stefan-niedermann@users.noreply.github.com>2020-05-09 17:19:41 +0300
commitf67438fb7749b6f724ecde1353d4b339fce66e40 (patch)
tree114e082d6a4ceec5b1e3ab685cc880ae517d0519 /app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java
parent8939f70076952be8240e377e86d45454a456b49c (diff)
Use BrandedSnackbar for centralizing branding stuff
Diffstat (limited to 'app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java')
-rw-r--r--app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java
new file mode 100644
index 000000000..b28b00ac0
--- /dev/null
+++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/branding/BrandedSnackbar.java
@@ -0,0 +1,33 @@
+package it.niedermann.nextcloud.deck.ui.branding;
+
+import android.graphics.Color;
+import android.view.View;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.StringRes;
+
+import com.google.android.material.snackbar.BaseTransientBottomBar;
+import com.google.android.material.snackbar.Snackbar;
+
+import it.niedermann.nextcloud.deck.Application;
+import it.niedermann.nextcloud.deck.util.ColorUtil;
+
+public class BrandedSnackbar {
+
+ @NonNull
+ public static Snackbar make(
+ @NonNull View view, @NonNull CharSequence text, @BaseTransientBottomBar.Duration int duration) {
+ final Snackbar snackbar = Snackbar.make(view, text, duration);
+ if (Application.isBrandingEnabled(view.getContext())) {
+ int color = Application.readBrandMainColor(view.getContext());
+ snackbar.setActionTextColor(ColorUtil.isColorDark(color) ? Color.WHITE : color);
+ }
+ return snackbar;
+ }
+
+ @NonNull
+ public static Snackbar make(@NonNull View view, @StringRes int resId, @BaseTransientBottomBar.Duration int duration) {
+ return make(view, view.getResources().getText(resId), duration);
+ }
+
+} \ No newline at end of file