diff --git a/src/main/java/eu/siacs/conversations/ui/util/SendButtonAction.java b/src/main/java/eu/siacs/conversations/ui/util/SendButtonAction.java index 074f57659..044bcdbf3 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/SendButtonAction.java +++ b/src/main/java/eu/siacs/conversations/ui/util/SendButtonAction.java @@ -38,7 +38,10 @@ import static eu.siacs.conversations.ui.ConversationFragment.ATTACHMENT_CHOICE_T public enum SendButtonAction { TEXT, TAKE_PHOTO, SEND_LOCATION, RECORD_VOICE, CANCEL, CHOOSE_PICTURE, RECORD_VIDEO; - public static SendButtonAction valueOfOrDefault(String setting, SendButtonAction text) { + public static SendButtonAction valueOfOrDefault(final String setting) { + if (setting == null) { + return TEXT; + } try { return valueOf(setting); } catch (IllegalArgumentException e) { diff --git a/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java b/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java index 9a92fbba9..66a355fe4 100644 --- a/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java +++ b/src/main/java/eu/siacs/conversations/ui/util/SendButtonTool.java @@ -42,7 +42,10 @@ import eu.siacs.conversations.utils.UIHelper; public class SendButtonTool { - public static SendButtonAction getAction(Activity activity, Conversation c, String text) { + public static SendButtonAction getAction(final Activity activity, final Conversation c, final String text) { + if (activity == null) { + return SendButtonAction.TEXT; + } final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); final boolean empty = text.length() == 0; final boolean conference = c.getMode() == Conversation.MODE_MULTI; @@ -60,14 +63,14 @@ public class SendButtonTool { return SendButtonAction.CANCEL; } else { String setting = preferences.getString("quick_action", activity.getResources().getString(R.string.quick_action)); - if (!setting.equals("none") && UIHelper.receivedLocationQuestion(c.getLatestMessage())) { + if (!"none".equals(setting) && UIHelper.receivedLocationQuestion(c.getLatestMessage())) { return SendButtonAction.SEND_LOCATION; } else { - if (setting.equals("recent")) { + if ("recent".equals(setting)) { setting = preferences.getString(ConversationFragment.RECENTLY_USED_QUICK_ACTION, SendButtonAction.TEXT.toString()); - return SendButtonAction.valueOfOrDefault(setting, SendButtonAction.TEXT); + return SendButtonAction.valueOfOrDefault(setting); } else { - return SendButtonAction.valueOfOrDefault(setting, SendButtonAction.TEXT); + return SendButtonAction.valueOfOrDefault(setting); } } }