Welcome to mirror list, hosted at ThFree Co, Russian Federation.

BrandedSnackbar.java « branding « notes « owncloud « niedermann « it « java « main « src « app - github.com/stefan-niedermann/nextcloud-notes.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e3a4d9fe93548c869137a15ef6905e024b245b1 (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
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 var snackbar = Snackbar.make(view, text, duration);
        final 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);
    }

}