mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-16 13:55:03 -05:00
instrument: add helper method for snackbar checking
This commit is contained in:
parent
6f47c78981
commit
7998b2a262
@ -0,0 +1,27 @@
|
||||
package org.sufficientlysecure.keychain.actions;
|
||||
|
||||
|
||||
import android.support.annotation.ColorRes;
|
||||
import android.support.test.espresso.matcher.BoundedMatcher;
|
||||
import android.view.View;
|
||||
|
||||
import com.nispok.snackbar.Snackbar;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
|
||||
public abstract class CustomMatchers {
|
||||
|
||||
public static Matcher<View> withSnackbarLineColor(@ColorRes final int colorRes) {
|
||||
return new BoundedMatcher<View, Snackbar>(Snackbar.class) {
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("with color resource id: " + colorRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matchesSafely(Snackbar snackbar) {
|
||||
return snackbar.getResources().getColor(colorRes) == snackbar.getLineColor();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -38,25 +38,16 @@ import org.sufficientlysecure.keychain.util.FabContainer;
|
||||
public class Notify {
|
||||
|
||||
public static enum Style {
|
||||
OK, WARN, ERROR;
|
||||
OK (R.color.android_green_light), WARN(R.color.android_orange_light), ERROR(R.color.android_red_light);
|
||||
|
||||
public final int mLineColor;
|
||||
|
||||
Style(int color) {
|
||||
mLineColor = color;
|
||||
}
|
||||
|
||||
public void applyToBar(Snackbar bar) {
|
||||
|
||||
switch (this) {
|
||||
case OK:
|
||||
// bar.actionColorResource(R.color.android_green_light);
|
||||
bar.lineColorResource(R.color.android_green_light);
|
||||
break;
|
||||
case WARN:
|
||||
// bar.textColorResource(R.color.android_orange_light);
|
||||
bar.lineColorResource(R.color.android_orange_light);
|
||||
break;
|
||||
case ERROR:
|
||||
// bar.textColorResource(R.color.android_red_light);
|
||||
bar.lineColorResource(R.color.android_red_light);
|
||||
break;
|
||||
}
|
||||
|
||||
bar.lineColorResource(mLineColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user