aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util
diff options
context:
space:
mode:
authorVincent Breitmoser <valodim@mugenguild.com>2015-05-31 04:05:15 +0200
committerVincent Breitmoser <valodim@mugenguild.com>2015-05-31 05:18:58 +0200
commitcf5fadae760ebbf8b06a908027634d76d54f52b4 (patch)
treeea335770639c33a9d0eb5c3a5e88d03a9c0623c9 /OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util
parent5d87872245ed781fa610cfa61a35d5e3f85a984e (diff)
downloadopen-keychain-cf5fadae760ebbf8b06a908027634d76d54f52b4.tar.gz
open-keychain-cf5fadae760ebbf8b06a908027634d76d54f52b4.tar.bz2
open-keychain-cf5fadae760ebbf8b06a908027634d76d54f52b4.zip
implement sticky preferences
Diffstat (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util')
-rw-r--r--OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java38
1 files changed, 25 insertions, 13 deletions
diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java
index 7e07ed818..8c554dbde 100644
--- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java
+++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/ui/util/Notify.java
@@ -62,9 +62,10 @@ public class Notify {
public static final int LENGTH_INDEFINITE = 0;
public static final int LENGTH_LONG = 3500;
+ public static final int LENGTH_SHORT = 1500;
public static Showable create(final Activity activity, String text, int duration, Style style,
- final ActionListener actionListener, int actionResId) {
+ final ActionListener actionListener, Integer actionResId) {
final Snackbar snackbar = Snackbar.with(activity)
.type(SnackbarType.MULTI_LINE)
.text(text);
@@ -77,14 +78,16 @@ public class Notify {
style.applyToBar(snackbar);
+ if (actionResId != null) {
+ snackbar.actionLabel(actionResId);
+ }
if (actionListener != null) {
- snackbar.actionLabel(actionResId)
- .actionListener(new ActionClickListener() {
- @Override
- public void onActionClicked(Snackbar snackbar) {
- actionListener.onAction();
- }
- });
+ snackbar.actionListener(new ActionClickListener() {
+ @Override
+ public void onActionClicked(Snackbar snackbar) {
+ actionListener.onAction();
+ }
+ });
}
if (activity instanceof FabContainer) {
@@ -108,6 +111,13 @@ public class Notify {
}
@Override
+ public void show(Fragment fragment, boolean animate) {
+ snackbar.animation(animate);
+ snackbar.dismissOnActionClicked(animate);
+ show(fragment);
+ }
+
+ @Override
public void show(Fragment fragment) {
if (fragment != null) {
View view = fragment.getView();
@@ -134,7 +144,7 @@ public class Notify {
}
public static Showable create(Activity activity, String text, int duration, Style style) {
- return create(activity, text, duration, style, null, -1);
+ return create(activity, text, duration, style, null, null);
}
public static Showable create(Activity activity, String text, Style style) {
@@ -159,24 +169,26 @@ public class Notify {
/**
* Shows the notification on the bottom of the Activity.
*/
- public void show();
+ void show();
+
+ void show(Fragment fragment, boolean animate);
/**
* Shows the notification on the bottom of the Fragment.
*/
- public void show(Fragment fragment);
+ void show(Fragment fragment);
/**
* Shows the notification on the given ViewGroup.
* The viewGroup should be either a RelativeLayout or FrameLayout.
*/
- public void show(ViewGroup viewGroup);
+ void show(ViewGroup viewGroup);
}
public interface ActionListener {
- public void onAction();
+ void onAction();
}