added new menu item 'manage account' and show when on quick

This commit is contained in:
Daniel Gultsch 2018-10-17 22:50:34 +02:00
parent ae5a36076b
commit f10f3730e1
11 changed files with 47 additions and 2 deletions

View file

@ -57,6 +57,7 @@ import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.MucDetailsContextMenuHelper;
import eu.siacs.conversations.ui.util.MyLinkify;
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.StringUtils;
@ -419,6 +420,7 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.muc_details, menu);
AccountUtils.showHideMenuItems(menu);
return super.onCreateOptionsMenu(menu);
}

View file

@ -46,6 +46,7 @@ import eu.siacs.conversations.ui.util.Attachment;
import eu.siacs.conversations.ui.util.GridManager;
import eu.siacs.conversations.ui.util.JidDialog;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.Compatibility;
import eu.siacs.conversations.utils.IrregularUnicodeDetector;
import eu.siacs.conversations.utils.UIHelper;
@ -280,6 +281,7 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.contact_details, menu);
AccountUtils.showHideMenuItems(menu);
MenuItem block = menu.findItem(R.id.action_block);
MenuItem unblock = menu.findItem(R.id.action_unblock);
MenuItem edit = menu.findItem(R.id.action_edit_contact);

View file

@ -76,6 +76,7 @@ import eu.siacs.conversations.ui.util.ActivityResult;
import eu.siacs.conversations.ui.util.ConversationMenuConfigurator;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.EmojiWrapper;
import eu.siacs.conversations.utils.ExceptionHelper;
import eu.siacs.conversations.utils.SignupUtils;
@ -377,6 +378,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_conversations, menu);
AccountUtils.showHideMenuItems(menu);
MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);
if (qrCodeScanMenuItem != null) {
if (isCameraFeatureAvailable()) {

View file

@ -75,6 +75,7 @@ import eu.siacs.conversations.ui.util.JidDialog;
import eu.siacs.conversations.ui.util.MenuDoubleTabUtil;
import eu.siacs.conversations.ui.util.PendingItem;
import eu.siacs.conversations.ui.util.SoftKeyboardUtils;
import eu.siacs.conversations.utils.AccountUtils;
import eu.siacs.conversations.utils.XmppUri;
import eu.siacs.conversations.xmpp.OnUpdateBlocklist;
import eu.siacs.conversations.xmpp.XmppConnection;
@ -580,6 +581,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.start_conversation, menu);
AccountUtils.showHideMenuItems(menu);
MenuItem menuHideOffline = menu.findItem(R.id.action_hide_offline);
MenuItem joinGroupChat = menu.findItem(R.id.action_join_conference);
MenuItem qrCodeScanMenuItem = menu.findItem(R.id.action_scan_qr_code);

View file

@ -46,7 +46,6 @@ import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
@ -55,7 +54,6 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@ -341,6 +339,9 @@ public abstract class XmppActivity extends ActionBarActivity {
case R.id.action_accounts:
AccountUtils.launchManageAccounts(this);
break;
case R.id.action_account:
AccountUtils.launchManageAccount(this);
break;
case android.R.id.home:
finish();
break;

View file

@ -2,6 +2,8 @@ package eu.siacs.conversations.utils;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import java.util.List;
@ -9,6 +11,7 @@ import java.util.List;
import eu.siacs.conversations.R;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.XmppActivity;
public class AccountUtils {
@ -49,6 +52,11 @@ public class AccountUtils {
}
}
public static void launchManageAccount(XmppActivity xmppActivity) {
Account account = getFirstEnabled(xmppActivity.xmppConnectionService);
xmppActivity.switchToAccount(account);
}
private static Class getManageAccountActivityClass() {
try {
return Class.forName("eu.siacs.conversations.ui.ManageAccountActivity");
@ -56,4 +64,11 @@ public class AccountUtils {
return null;
}
}
public static void showHideMenuItems(final Menu menu) {
final MenuItem manageAccounts = menu.findItem(R.id.action_accounts);
final MenuItem manageAccount = menu.findItem(R.id.action_account);
manageAccount.setVisible(MANAGE_ACCOUNT_ACTIVITY == null);
manageAccounts.setVisible(MANAGE_ACCOUNT_ACTIVITY != null);
}
}

View file

@ -12,6 +12,11 @@
android:orderInCategory="90"
android:title="@string/action_accounts"
app:showAsAction="never"/>
<item
android:id="@+id/action_account"
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -50,6 +50,11 @@
android:orderInCategory="90"
app:showAsAction="never"
android:title="@string/action_accounts"/>
<item
android:id="@+id/action_account"
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -43,6 +43,11 @@
android:orderInCategory="90"
app:showAsAction="never"
android:title="@string/action_accounts"/>
<item
android:id="@+id/action_account"
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -30,6 +30,11 @@
android:orderInCategory="90"
android:title="@string/action_accounts"
app:showAsAction="never"/>
<item
android:id="@+id/action_account"
android:orderInCategory="90"
android:title="@string/action_account"
app:showAsAction="never"/>
<item
android:id="@+id/action_settings"
android:orderInCategory="100"

View file

@ -3,6 +3,7 @@
<string name="action_settings">Settings</string>
<string name="action_add">New conversation</string>
<string name="action_accounts">Manage accounts</string>
<string name="action_account">Manage account</string>
<string name="action_end_conversation">End this conversation</string>
<string name="action_contact_details">Contact details</string>
<string name="action_muc_details">Group chat details</string>