diff options
Diffstat (limited to 'app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java')
-rw-r--r-- | app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java new file mode 100644 index 00000000..42b9c5cb --- /dev/null +++ b/app/src/main/java/it/niedermann/owncloud/notes/branding/BrandedSnackbar.java @@ -0,0 +1,31 @@ +package it.niedermann.owncloud.notes.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.owncloud.notes.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 (BrandingUtil.isBrandingEnabled(view.getContext())) { + int color = BrandingUtil.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 |