Add clear devices to overflow menu in EditAccount

This commit is contained in:
Andreas Straub 2015-07-19 23:35:03 +02:00
parent 14010bf5a6
commit 480b1cde81
3 changed files with 17 additions and 3 deletions

View file

@ -363,6 +363,7 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list); final MenuItem showBlocklist = menu.findItem(R.id.action_show_block_list);
final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more); final MenuItem showMoreInfo = menu.findItem(R.id.action_server_info_show_more);
final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server); final MenuItem changePassword = menu.findItem(R.id.action_change_password_on_server);
final MenuItem clearDevices = menu.findItem(R.id.action_clear_devices);
if (mAccount != null && mAccount.isOnlineAndConnected()) { if (mAccount != null && mAccount.isOnlineAndConnected()) {
if (!mAccount.getXmppConnection().getFeatures().blocking()) { if (!mAccount.getXmppConnection().getFeatures().blocking()) {
showBlocklist.setVisible(false); showBlocklist.setVisible(false);
@ -370,6 +371,10 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
if (!mAccount.getXmppConnection().getFeatures().register()) { if (!mAccount.getXmppConnection().getFeatures().register()) {
changePassword.setVisible(false); changePassword.setVisible(false);
} }
Set<Integer> otherDevices = mAccount.getAxolotlService().getOwnDeviceIds();
if (otherDevices == null || otherDevices.isEmpty()) {
clearDevices.setVisible(false);
}
} else { } else {
showQrCode.setVisible(false); showQrCode.setVisible(false);
showBlocklist.setVisible(false); showBlocklist.setVisible(false);
@ -440,6 +445,9 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
changePasswordIntent.putExtra("account", mAccount.getJid().toString()); changePasswordIntent.putExtra("account", mAccount.getJid().toString());
startActivity(changePasswordIntent); startActivity(changePasswordIntent);
break; break;
case R.id.action_clear_devices:
showWipePepDialog();
break;
} }
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -621,11 +629,11 @@ public class EditAccountActivity extends XmppActivity implements OnAccountUpdate
public void showWipePepDialog() { public void showWipePepDialog() {
Builder builder = new Builder(this); Builder builder = new Builder(this);
builder.setTitle("Wipe PEP"); builder.setTitle(getString(R.string.clear_other_devices));
builder.setIconAttribute(android.R.attr.alertDialogIcon); builder.setIconAttribute(android.R.attr.alertDialogIcon);
builder.setMessage("Are you sure you want to wipe all other devices from the PEP device ID list?"); builder.setMessage(getString(R.string.clear_other_devices_desc));
builder.setNegativeButton(getString(R.string.cancel), null); builder.setNegativeButton(getString(R.string.cancel), null);
builder.setPositiveButton("Yes", builder.setPositiveButton(getString(R.string.accept),
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {

View file

@ -20,4 +20,8 @@
<item android:id="@+id/action_change_password_on_server" <item android:id="@+id/action_change_password_on_server"
android:title="@string/change_password" android:title="@string/change_password"
android:showAsAction="never" /> android:showAsAction="never" />
<item android:id="@+id/action_clear_devices"
android:title="@string/clear_other_devices"
android:showAsAction="never"/>
</menu> </menu>

View file

@ -391,6 +391,8 @@
<string name="copy_axolotl_clipboard_description">Copy Axolotl fingerprint to clipboard</string> <string name="copy_axolotl_clipboard_description">Copy Axolotl fingerprint to clipboard</string>
<string name="regenerate_axolotl_key">Copy Axolotl fingerprint to clipboard</string> <string name="regenerate_axolotl_key">Copy Axolotl fingerprint to clipboard</string>
<string name="wipe_axolotl_pep">Wipe other devices from PEP</string> <string name="wipe_axolotl_pep">Wipe other devices from PEP</string>
<string name="clear_other_devices">Clear devices</string>
<string name="clear_other_devices_desc">Are you sure you want to clear all other devices from the axolotl announcement? The next time your devices connect, they will reannounce themselves, but they might not receive messages sent in the meantime.</string>
<string name="fetching_history_from_server">Fetching history from server</string> <string name="fetching_history_from_server">Fetching history from server</string>
<string name="no_more_history_on_server">No more history on server</string> <string name="no_more_history_on_server">No more history on server</string>
<string name="updating">Updating…</string> <string name="updating">Updating…</string>