diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 4fa4d8185..82b9eb143 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -2992,6 +2992,11 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke final Menu menu = popupMenu.getMenu(); menu.findItem(R.id.action_manage_accounts).setVisible(QuickConversationsService.isConversations()); popupMenu.setOnMenuItemClickListener(item -> { + final XmppActivity activity = this.activity; + if (activity == null) { + Log.e(Config.LOGTAG,"Unable to perform action. no context provided"); + return true; + } switch (item.getItemId()) { case R.id.action_show_qr_code: activity.showQrCode(conversation.getAccount().getShareableUri()); diff --git a/src/main/java/eu/siacs/conversations/utils/AccountUtils.java b/src/main/java/eu/siacs/conversations/utils/AccountUtils.java index a324b242e..8f0453218 100644 --- a/src/main/java/eu/siacs/conversations/utils/AccountUtils.java +++ b/src/main/java/eu/siacs/conversations/utils/AccountUtils.java @@ -17,7 +17,7 @@ import eu.siacs.conversations.ui.XmppActivity; public class AccountUtils { - public static final Class MANAGE_ACCOUNT_ACTIVITY; + public static final Class MANAGE_ACCOUNT_ACTIVITY; static { MANAGE_ACCOUNT_ACTIVITY = getManageAccountActivityClass(); @@ -78,7 +78,7 @@ public class AccountUtils { return pending; } - public static void launchManageAccounts(Activity activity) { + public static void launchManageAccounts(final Activity activity) { if (MANAGE_ACCOUNT_ACTIVITY != null) { activity.startActivity(new Intent(activity, MANAGE_ACCOUNT_ACTIVITY)); } else { @@ -86,15 +86,15 @@ public class AccountUtils { } } - public static void launchManageAccount(XmppActivity xmppActivity) { - Account account = getFirst(xmppActivity.xmppConnectionService); + public static void launchManageAccount(final XmppActivity xmppActivity) { + final Account account = getFirst(xmppActivity.xmppConnectionService); xmppActivity.switchToAccount(account); } - private static Class getManageAccountActivityClass() { + private static Class getManageAccountActivityClass() { try { return Class.forName("eu.siacs.conversations.ui.ManageAccountActivity"); - } catch (ClassNotFoundException e) { + } catch (final ClassNotFoundException e) { return null; } }