add change prescence to manage account context menu

This commit is contained in:
Daniel Gultsch 2016-04-23 12:33:56 +02:00
parent a9c1768107
commit cd1fbf60ec
3 changed files with 16 additions and 3 deletions

View File

@ -477,9 +477,6 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
final MenuItem renewCertificate = menu.findItem(R.id.action_renew_certificate); final MenuItem renewCertificate = menu.findItem(R.id.action_renew_certificate);
final MenuItem mamPrefs = menu.findItem(R.id.action_mam_prefs); final MenuItem mamPrefs = menu.findItem(R.id.action_mam_prefs);
final MenuItem changePresence = menu.findItem(R.id.action_change_presence); final MenuItem changePresence = menu.findItem(R.id.action_change_presence);
changePresence.setVisible(manuallyChangePresence());
renewCertificate.setVisible(mAccount != null && mAccount.getPrivateKeyAlias() != null); renewCertificate.setVisible(mAccount != null && mAccount.getPrivateKeyAlias() != null);
if (mAccount != null && mAccount.isOnlineAndConnected()) { if (mAccount != null && mAccount.isOnlineAndConnected()) {
@ -494,6 +491,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
if (otherDevices == null || otherDevices.isEmpty()) { if (otherDevices == null || otherDevices.isEmpty()) {
clearDevices.setVisible(false); clearDevices.setVisible(false);
} }
changePresence.setVisible(manuallyChangePresence());
} else { } else {
showQrCode.setVisible(false); showQrCode.setVisible(false);
showBlocklist.setVisible(false); showBlocklist.setVisible(false);
@ -501,6 +499,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
changePassword.setVisible(false); changePassword.setVisible(false);
clearDevices.setVisible(false); clearDevices.setVisible(false);
mamPrefs.setVisible(false); mamPrefs.setVisible(false);
changePresence.setVisible(false);
} }
return super.onCreateOptionsMenu(menu); return super.onCreateOptionsMenu(menu);
} }

View File

@ -121,9 +121,11 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
menu.findItem(R.id.mgmt_account_disable).setVisible(false); menu.findItem(R.id.mgmt_account_disable).setVisible(false);
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false); menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(false);
menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false); menu.findItem(R.id.mgmt_account_publish_avatar).setVisible(false);
menu.findItem(R.id.mgmt_account_change_presence).setVisible(false);
} else { } else {
menu.findItem(R.id.mgmt_account_enable).setVisible(false); menu.findItem(R.id.mgmt_account_enable).setVisible(false);
menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp()); menu.findItem(R.id.mgmt_account_announce_pgp).setVisible(Config.supportOpenPgp());
menu.findItem(R.id.mgmt_account_change_presence).setVisible(manuallyChangePresence());
} }
menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString()); menu.setHeaderTitle(this.selectedAccount.getJid().toBareJid().toString());
} }
@ -187,6 +189,9 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
case R.id.mgmt_account_announce_pgp: case R.id.mgmt_account_announce_pgp:
publishOpenPGPPublicKey(selectedAccount); publishOpenPGPPublicKey(selectedAccount);
return true; return true;
case R.id.mgmt_account_change_presence:
changePresence(selectedAccount);
return true;
default: default:
return super.onContextItemSelected(item); return super.onContextItemSelected(item);
} }
@ -235,6 +240,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
} }
} }
private void changePresence(Account account) {
Intent intent = new Intent(this, SetPresenceActivity.class);
intent.putExtra(SetPresenceActivity.EXTRA_ACCOUNT,account.getJid().toBareJid().toString());
startActivity(intent);
}
public void onClickTglAccountState(Account account, boolean enable) { public void onClickTglAccountState(Account account, boolean enable) {
if (enable) { if (enable) {
enableAccount(account); enableAccount(account);

View File

@ -4,6 +4,9 @@
<item <item
android:id="@+id/mgmt_account_enable" android:id="@+id/mgmt_account_enable"
android:title="@string/mgmt_account_enable"/> android:title="@string/mgmt_account_enable"/>
<item
android:id="@+id/mgmt_account_change_presence"
android:title="@string/change_presence"/>
<item <item
android:id="@+id/mgmt_account_publish_avatar" android:id="@+id/mgmt_account_publish_avatar"
android:title="@string/mgmt_account_publish_avatar"/> android:title="@string/mgmt_account_publish_avatar"/>