mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-12-17 21:02:17 -05:00
fab support for all notify types
This commit is contained in:
parent
e4d91de8d2
commit
f3710b12f6
@ -47,24 +47,8 @@ public class Notify {
|
|||||||
*/
|
*/
|
||||||
public static void showNotify(final Activity activity, CharSequence text, Style style) {
|
public static void showNotify(final Activity activity, CharSequence text, Style style) {
|
||||||
|
|
||||||
Snackbar bar = Snackbar.with(activity)
|
Snackbar bar = getSnackbar(activity)
|
||||||
.text(text)
|
.text(text);
|
||||||
.type(SnackbarType.MULTI_LINE)
|
|
||||||
.duration(SnackbarDuration.LENGTH_LONG);
|
|
||||||
|
|
||||||
if (activity instanceof FabContainer) {
|
|
||||||
bar.eventListener(new EventListenerAdapter() {
|
|
||||||
@Override
|
|
||||||
public void onShow(Snackbar snackbar) {
|
|
||||||
((FabContainer) activity).fabMoveUp(snackbar.getHeight());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDismiss(Snackbar snackbar) {
|
|
||||||
((FabContainer) activity).fabRestorePosition();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (style) {
|
switch (style) {
|
||||||
case OK:
|
case OK:
|
||||||
@ -82,9 +66,9 @@ public class Notify {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Showable createNotify (Activity activity, int resId, int duration, Style style) {
|
public static Showable createNotify (Activity activity, int resId, int duration, Style style) {
|
||||||
final Snackbar bar = Snackbar.with(activity)
|
final Snackbar bar = getSnackbar(activity)
|
||||||
.text(resId)
|
.text(resId);
|
||||||
.type(SnackbarType.MULTI_LINE);
|
|
||||||
if (duration == LENGTH_INDEFINITE) {
|
if (duration == LENGTH_INDEFINITE) {
|
||||||
bar.duration(SnackbarDuration.LENGTH_INDEFINITE);
|
bar.duration(SnackbarDuration.LENGTH_INDEFINITE);
|
||||||
} else {
|
} else {
|
||||||
@ -118,16 +102,17 @@ public class Notify {
|
|||||||
|
|
||||||
public static Showable createNotify(Activity activity, String msg, int duration, Style style,
|
public static Showable createNotify(Activity activity, String msg, int duration, Style style,
|
||||||
final ActionListener listener, int resIdAction) {
|
final ActionListener listener, int resIdAction) {
|
||||||
final Snackbar bar = Snackbar.with(activity)
|
|
||||||
|
final Snackbar bar = getSnackbar(activity)
|
||||||
.text(msg)
|
.text(msg)
|
||||||
.actionLabel(resIdAction)
|
.actionLabel(resIdAction)
|
||||||
.type(SnackbarType.MULTI_LINE)
|
|
||||||
.actionListener(new ActionClickListener() {
|
.actionListener(new ActionClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onActionClicked(Snackbar snackbar) {
|
public void onActionClicked(Snackbar snackbar) {
|
||||||
listener.onAction();
|
listener.onAction();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (duration == LENGTH_INDEFINITE) {
|
if (duration == LENGTH_INDEFINITE) {
|
||||||
bar.duration(SnackbarDuration.LENGTH_INDEFINITE);
|
bar.duration(SnackbarDuration.LENGTH_INDEFINITE);
|
||||||
} else {
|
} else {
|
||||||
@ -165,6 +150,27 @@ public class Notify {
|
|||||||
showNotify(activity, activity.getResources().getText(resId), style);
|
showNotify(activity, activity.getResources().getText(resId), style);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Snackbar getSnackbar(final Activity activity) {
|
||||||
|
Snackbar bar = Snackbar.with(activity)
|
||||||
|
.type(SnackbarType.MULTI_LINE)
|
||||||
|
.duration(SnackbarDuration.LENGTH_LONG);
|
||||||
|
|
||||||
|
if (activity instanceof FabContainer) {
|
||||||
|
bar.eventListener(new EventListenerAdapter() {
|
||||||
|
@Override
|
||||||
|
public void onShow(Snackbar snackbar) {
|
||||||
|
((FabContainer) activity).fabMoveUp(snackbar.getHeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDismiss(Snackbar snackbar) {
|
||||||
|
((FabContainer) activity).fabRestorePosition();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return bar;
|
||||||
|
}
|
||||||
|
|
||||||
public interface Showable {
|
public interface Showable {
|
||||||
public void show();
|
public void show();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user