ui for registry.

This commit is contained in:
Daniel Gultsch 2014-03-13 04:21:59 +01:00
parent a80e3131be
commit 6db012ac6f
2 changed files with 23 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import android.app.AlertDialog;
import android.app.Dialog; import android.app.Dialog;
import android.app.DialogFragment; import android.app.DialogFragment;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.Button; import android.widget.Button;
@ -61,10 +62,12 @@ public class EditAccount extends DialogFragment {
} else { } else {
useTLS.setChecked(false); useTLS.setChecked(false);
} }
Log.d("xmppService","mein debugger. account != null");
if (account.isOptionSet(Account.OPTION_REGISTER)) { if (account.isOptionSet(Account.OPTION_REGISTER)) {
registerAccount.setChecked(true); registerAccount.setChecked(true);
builder.setTitle("Add account"); builder.setTitle("Add account");
okButtonDesc = "Register"; okButtonDesc = "Register";
passwordConfirm.setVisibility(View.VISIBLE);
} else { } else {
registerAccount.setVisibility(View.GONE); registerAccount.setVisibility(View.GONE);
builder.setTitle("Edit account"); builder.setTitle("Edit account");

View File

@ -79,7 +79,6 @@ public class ManageAccountActivity extends XmppActivity {
StringBuilder humanReadableSha = new StringBuilder(); StringBuilder humanReadableSha = new StringBuilder();
humanReadableSha.append(fingerprint); humanReadableSha.append(fingerprint);
for(int i = 2; i < 59; i += 3) { for(int i = 2; i < 59; i += 3) {
Log.d("gultsch","insert into "+i);
if ((i==14)||(i==29)||(i==44)) { if ((i==14)||(i==29)||(i==44)) {
humanReadableSha.insert(i, "\n"); humanReadableSha.insert(i, "\n");
} else { } else {
@ -184,6 +183,8 @@ public class ManageAccountActivity extends XmppActivity {
activity.xmppConnectionService.reconnectAccount(accountList.get(position),true); activity.xmppConnectionService.reconnectAccount(accountList.get(position),true);
} else if (account.getStatus() == Account.STATUS_ONLINE) { } else if (account.getStatus() == Account.STATUS_ONLINE) {
activity.startActivity(new Intent(activity.getApplicationContext(),NewConversationActivity.class)); activity.startActivity(new Intent(activity.getApplicationContext(),NewConversationActivity.class));
} else if (account.isOptionSet(Account.OPTION_REGISTER)) {
editAccount(account);
} }
} else { } else {
selectedAccountForActionMode = accountList.get(position); selectedAccountForActionMode = accountList.get(position);
@ -230,17 +231,7 @@ public class ManageAccountActivity extends XmppActivity {
@Override @Override
public boolean onActionItemClicked(final ActionMode mode, MenuItem item) { public boolean onActionItemClicked(final ActionMode mode, MenuItem item) {
if (item.getItemId()==R.id.mgmt_account_edit) { if (item.getItemId()==R.id.mgmt_account_edit) {
EditAccount dialog = new EditAccount(); editAccount(selectedAccountForActionMode);
dialog.setAccount(selectedAccountForActionMode);
dialog.setEditAccountListener(new EditAccountListener() {
@Override
public void onAccountEdited(Account account) {
xmppConnectionService.updateAccount(account);
actionMode.finish();
}
});
dialog.show(getFragmentManager(), "edit_account");
} else if (item.getItemId()==R.id.mgmt_account_disable) { } else if (item.getItemId()==R.id.mgmt_account_disable) {
selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, true); selectedAccountForActionMode.setOption(Account.OPTION_DISABLED, true);
xmppConnectionService.updateAccount(selectedAccountForActionMode); xmppConnectionService.updateAccount(selectedAccountForActionMode);
@ -303,6 +294,8 @@ public class ManageAccountActivity extends XmppActivity {
} }
return true; return true;
} }
})); }));
return true; return true;
} else { } else {
@ -355,6 +348,21 @@ public class ManageAccountActivity extends XmppActivity {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
private void editAccount(Account account) {
EditAccount dialog = new EditAccount();
dialog.setAccount(account);
dialog.setEditAccountListener(new EditAccountListener() {
@Override
public void onAccountEdited(Account account) {
xmppConnectionService.updateAccount(account);
actionMode.finish();
}
});
dialog.show(getFragmentManager(), "edit_account");
}
protected void addAccount() { protected void addAccount() {
final Activity activity = this; final Activity activity = this;
EditAccount dialog = new EditAccount(); EditAccount dialog = new EditAccount();