blob: 42b9c5cb0525930a54389f8c6f5c9b0e4a1b45d6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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);
}
}
|