mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 19:29:06 +01:00
Select newly created identity on return from CreateIdentityActivity.
This partially fixes dev task #40. CreateIdentityActivity is also called from AddContactActivity, but that's likely to change soon so I'm not going to fix it now.
This commit is contained in:
@@ -92,7 +92,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
|
||||
b = i.getByteArrayExtra("briar.PARENT_ID");
|
||||
if(b != null) parentId = new MessageId(b);
|
||||
timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
|
||||
@@ -218,6 +217,16 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
// This is the result of CreateIdentityActivity
|
||||
if(result == RESULT_CANCELED) return;
|
||||
byte[] b = data.getByteArrayExtra("briar.LOCAL_AUTHOR_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
localAuthorId = new AuthorId(b);
|
||||
loadAuthorsAndGroup();
|
||||
}
|
||||
|
||||
public void onItemSelected(AdapterView<?> parent, View view, int position,
|
||||
long id) {
|
||||
LocalAuthorItem item = adapter.getItem(position);
|
||||
@@ -227,7 +236,8 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
} else if(item == LocalAuthorItem.NEW) {
|
||||
localAuthor = null;
|
||||
localAuthorId = null;
|
||||
startActivity(new Intent(this, CreateIdentityActivity.class));
|
||||
Intent i = new Intent(this, CreateIdentityActivity.class);
|
||||
startActivityForResult(i, 0);
|
||||
} else {
|
||||
localAuthor = item.getLocalAuthor();
|
||||
localAuthorId = localAuthor.getId();
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
|
||||
import roboguice.activity.RoboActivity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
@@ -133,6 +134,14 @@ implements OnEditorActionListener, OnClickListener {
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validateNickname() {
|
||||
if(nicknameEntry.getText().toString().equals("")) return false;
|
||||
// Hide the soft keyboard
|
||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void storeLocalAuthor(final LocalAuthor a) {
|
||||
dbUiExecutor.execute(new Runnable() {
|
||||
public void run() {
|
||||
@@ -151,20 +160,19 @@ implements OnEditorActionListener, OnClickListener {
|
||||
LOG.info("Interrupted while waiting for database");
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
setResultAndFinish(a);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validateNickname() {
|
||||
if(nicknameEntry.getText().toString().equals("")) return false;
|
||||
// Hide the soft keyboard
|
||||
Object o = getSystemService(INPUT_METHOD_SERVICE);
|
||||
((InputMethodManager) o).toggleSoftInput(HIDE_IMPLICIT_ONLY, 0);
|
||||
return true;
|
||||
private void setResultAndFinish(final LocalAuthor a) {
|
||||
runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
Intent i = new Intent();
|
||||
i.putExtra("briar.LOCAL_AUTHOR_ID", a.getId().getBytes());
|
||||
setResult(RESULT_OK, i);
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user