Merge pull request #2193 from hagau/fix_notifications

Fix showing of some notifications
This commit is contained in:
Vincent Breitmoser
2017-10-23 21:17:05 +02:00
committed by GitHub
4 changed files with 12 additions and 4 deletions

View File

@@ -201,7 +201,7 @@ public abstract class DecryptFragment extends Fragment implements LoaderManager.
startActivity(viewKeyIntent); startActivity(viewKeyIntent);
} catch (PgpKeyNotFoundException e) { } catch (PgpKeyNotFoundException e) {
Notify.create(getActivity(), R.string.error_key_not_found, Style.ERROR); Notify.create(getActivity(), R.string.error_key_not_found, Style.ERROR).show();
} }
} }

View File

@@ -207,7 +207,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
if (toClipboard) { if (toClipboard) {
ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipMan == null) { if (clipMan == null) {
Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR); Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR).show();
return; return;
} }
@@ -278,7 +278,7 @@ public class ViewKeyAdvShareFragment extends LoaderFragment implements
if (toClipboard) { if (toClipboard) {
ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE); ClipboardManager clipMan = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
if (clipMan == null) { if (clipMan == null) {
Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR); Notify.create(activity, R.string.error_clipboard_copy, Style.ERROR).show();
return; return;
} }

View File

@@ -126,7 +126,7 @@ public class LinkedIdCreateHttpsStep2Fragment extends LinkedIdCreateFinalFragmen
private void proofSave () { private void proofSave () {
String state = Environment.getExternalStorageState(); String state = Environment.getExternalStorageState();
if (!Environment.MEDIA_MOUNTED.equals(state)) { if (!Environment.MEDIA_MOUNTED.equals(state)) {
Notify.create(getActivity(), "External storage not available!", Style.ERROR); Notify.create(getActivity(), "External storage not available!", Style.ERROR).show();
return; return;
} }

View File

@@ -18,6 +18,7 @@
package org.sufficientlysecure.keychain.ui.util; package org.sufficientlysecure.keychain.ui.util;
import android.app.Activity; import android.app.Activity;
import android.support.annotation.CheckResult;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@@ -55,6 +56,7 @@ public class Notify {
public static final int LENGTH_LONG = 3500; public static final int LENGTH_LONG = 3500;
public static final int LENGTH_SHORT = 1500; public static final int LENGTH_SHORT = 1500;
@CheckResult
public static Showable create(final Activity activity, String text, int duration, Style style, public static Showable create(final Activity activity, String text, int duration, Style style,
final ActionListener actionListener, Integer actionResId) { final ActionListener actionListener, Integer actionResId) {
final Snackbar snackbar = Snackbar.with(activity) final Snackbar snackbar = Snackbar.with(activity)
@@ -134,28 +136,34 @@ public class Notify {
}; };
} }
@CheckResult
public static Showable create(Activity activity, String text, int duration, Style style) { public static Showable create(Activity activity, String text, int duration, Style style) {
return create(activity, text, duration, style, null, null); return create(activity, text, duration, style, null, null);
} }
@CheckResult
public static Showable create(Activity activity, String text, Style style) { public static Showable create(Activity activity, String text, Style style) {
return create(activity, text, LENGTH_LONG, style); return create(activity, text, LENGTH_LONG, style);
} }
@CheckResult
public static Showable create(Activity activity, int textResId, Style style, public static Showable create(Activity activity, int textResId, Style style,
ActionListener actionListener, int actionResId) { ActionListener actionListener, int actionResId) {
return create(activity, textResId, LENGTH_LONG, style, actionListener, actionResId); return create(activity, textResId, LENGTH_LONG, style, actionListener, actionResId);
} }
@CheckResult
public static Showable create(Activity activity, int textResId, int duration, Style style, public static Showable create(Activity activity, int textResId, int duration, Style style,
ActionListener actionListener, int actionResId) { ActionListener actionListener, int actionResId) {
return create(activity, activity.getString(textResId), duration, style, actionListener, actionResId); return create(activity, activity.getString(textResId), duration, style, actionListener, actionResId);
} }
@CheckResult
public static Showable create(Activity activity, int textResId, int duration, Style style) { public static Showable create(Activity activity, int textResId, int duration, Style style) {
return create(activity, activity.getString(textResId), duration, style); return create(activity, activity.getString(textResId), duration, style);
} }
@CheckResult
public static Showable create(Activity activity, int textResId, Style style) { public static Showable create(Activity activity, int textResId, Style style) {
return create(activity, activity.getString(textResId), style); return create(activity, activity.getString(textResId), style);
} }