blob: aabd3f048504188c5435db492947a2cce2fcce6c (
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
|
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.Snackbar;
import it.niedermann.android.util.ColorUtil;
public class BrandedSnackbar {
@NonNull
public static Snackbar make(@NonNull View view, @NonNull CharSequence text, @Snackbar.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.INSTANCE.isColorDark(color) ? Color.WHITE : color);
}
return snackbar;
}
@NonNull
public static Snackbar make(@NonNull View view, @StringRes int resId, @Snackbar.Duration int duration) {
return make(view, view.getResources().getText(resId), duration);
}
}
|