mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 03:39:05 +01:00
Store schema version in database. Dev task #50.
If the schema of the database is incompatible with the schema expected by the code, the database throws a DbSchemaException. LifecycleManager indicates the error to BriarService, which uses HomeScreenActivity to show a notification and quit the app.
This commit is contained in:
@@ -69,17 +69,17 @@ SelectContactsDialog.Listener {
|
||||
super.onCreate(state);
|
||||
|
||||
Intent i = getIntent();
|
||||
byte[] b = i.getByteArrayExtra("org.briarproject.GROUP_ID");
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
GroupId id = new GroupId(b);
|
||||
String name = i.getStringExtra("org.briarproject.GROUP_NAME");
|
||||
String name = i.getStringExtra("briar.GROUP_NAME");
|
||||
if(name == null) throw new IllegalStateException();
|
||||
setTitle(name);
|
||||
b = i.getByteArrayExtra("org.briarproject.GROUP_SALT");
|
||||
b = i.getByteArrayExtra("briar.GROUP_SALT");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
group = new Group(id, name, b);
|
||||
subscribed = i.getBooleanExtra("org.briarproject.SUBSCRIBED", false);
|
||||
boolean all = i.getBooleanExtra("org.briarproject.VISIBLE_TO_ALL", false);
|
||||
subscribed = i.getBooleanExtra("briar.SUBSCRIBED", false);
|
||||
boolean all = i.getBooleanExtra("briar.VISIBLE_TO_ALL", false);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
|
||||
@@ -67,10 +67,10 @@ OnClickListener, OnItemClickListener {
|
||||
super.onCreate(state);
|
||||
|
||||
Intent i = getIntent();
|
||||
byte[] b = i.getByteArrayExtra("org.briarproject.GROUP_ID");
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
groupName = i.getStringExtra("org.briarproject.GROUP_NAME");
|
||||
groupName = i.getStringExtra("briar.GROUP_NAME");
|
||||
if(groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
|
||||
@@ -210,7 +210,7 @@ OnClickListener, OnItemClickListener {
|
||||
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
||||
i.putExtra("org.briarproject.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
@@ -222,16 +222,16 @@ OnClickListener, OnItemClickListener {
|
||||
private void displayMessage(int position) {
|
||||
MessageHeader item = adapter.getItem(position);
|
||||
Intent i = new Intent(this, ReadGroupPostActivity.class);
|
||||
i.putExtra("org.briarproject.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("org.briarproject.GROUP_NAME", groupName);
|
||||
i.putExtra("org.briarproject.MESSAGE_ID", item.getId().getBytes());
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", groupName);
|
||||
i.putExtra("briar.MESSAGE_ID", item.getId().getBytes());
|
||||
Author author = item.getAuthor();
|
||||
if(author != null) {
|
||||
i.putExtra("org.briarproject.AUTHOR_ID", author.getId().getBytes());
|
||||
i.putExtra("org.briarproject.AUTHOR_NAME", author.getName());
|
||||
i.putExtra("briar.AUTHOR_ID", author.getId().getBytes());
|
||||
i.putExtra("briar.AUTHOR_NAME", author.getName());
|
||||
}
|
||||
i.putExtra("org.briarproject.CONTENT_TYPE", item.getContentType());
|
||||
i.putExtra("org.briarproject.TIMESTAMP", item.getTimestamp());
|
||||
i.putExtra("briar.CONTENT_TYPE", item.getContentType());
|
||||
i.putExtra("briar.TIMESTAMP", item.getTimestamp());
|
||||
startActivityForResult(i, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,8 +347,8 @@ implements EventListener, OnClickListener, OnItemClickListener {
|
||||
} else {
|
||||
Intent i = new Intent(this, GroupActivity.class);
|
||||
Group g = item.getGroup();
|
||||
i.putExtra("org.briarproject.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("org.briarproject.GROUP_NAME", g.getName());
|
||||
i.putExtra("briar.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", g.getName());
|
||||
startActivity(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,11 +132,11 @@ implements EventListener, OnItemClickListener {
|
||||
GroupStatus s = item.getGroupStatus();
|
||||
Group g = s.getGroup();
|
||||
Intent i = new Intent(this, ConfigureGroupActivity.class);
|
||||
i.putExtra("org.briarproject.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("org.briarproject.GROUP_NAME", g.getName());
|
||||
i.putExtra("org.briarproject.GROUP_SALT", g.getSalt());
|
||||
i.putExtra("org.briarproject.SUBSCRIBED", s.isSubscribed());
|
||||
i.putExtra("org.briarproject.VISIBLE_TO_ALL", s.isVisibleToAll());
|
||||
i.putExtra("briar.GROUP_ID", g.getId().getBytes());
|
||||
i.putExtra("briar.GROUP_NAME", g.getName());
|
||||
i.putExtra("briar.GROUP_SALT", g.getSalt());
|
||||
i.putExtra("briar.SUBSCRIBED", s.isSubscribed());
|
||||
i.putExtra("briar.VISIBLE_TO_ALL", s.isVisibleToAll());
|
||||
startActivity(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,26 +69,26 @@ implements OnClickListener {
|
||||
super.onCreate(state);
|
||||
|
||||
Intent i = getIntent();
|
||||
byte[] b = i.getByteArrayExtra("org.briarproject.GROUP_ID");
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
String groupName = i.getStringExtra("org.briarproject.GROUP_NAME");
|
||||
String groupName = i.getStringExtra("briar.GROUP_NAME");
|
||||
if(groupName == null) throw new IllegalStateException();
|
||||
setTitle(groupName);
|
||||
b = i.getByteArrayExtra("org.briarproject.MESSAGE_ID");
|
||||
b = i.getByteArrayExtra("briar.MESSAGE_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
messageId = new MessageId(b);
|
||||
String contentType = i.getStringExtra("org.briarproject.CONTENT_TYPE");
|
||||
String contentType = i.getStringExtra("briar.CONTENT_TYPE");
|
||||
if(contentType == null) throw new IllegalStateException();
|
||||
timestamp = i.getLongExtra("org.briarproject.TIMESTAMP", -1);
|
||||
timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
|
||||
if(timestamp == -1) throw new IllegalStateException();
|
||||
String authorName = i.getStringExtra("org.briarproject.AUTHOR_NAME");
|
||||
String authorName = i.getStringExtra("briar.AUTHOR_NAME");
|
||||
|
||||
if(state == null) {
|
||||
read = false;
|
||||
setReadInDatabase(true);
|
||||
} else {
|
||||
read = state.getBoolean("org.briarproject.READ");
|
||||
read = state.getBoolean("briar.READ");
|
||||
}
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
@@ -255,7 +255,7 @@ implements OnClickListener {
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle state) {
|
||||
super.onSaveInstanceState(state);
|
||||
state.putBoolean("org.briarproject.READ", read);
|
||||
state.putBoolean("briar.READ", read);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
@@ -269,9 +269,9 @@ implements OnClickListener {
|
||||
finish();
|
||||
} else if(view == replyButton) {
|
||||
Intent i = new Intent(this, WriteGroupPostActivity.class);
|
||||
i.putExtra("org.briarproject.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("org.briarproject.PARENT_ID", messageId.getBytes());
|
||||
i.putExtra("org.briarproject.TIMESTAMP", timestamp);
|
||||
i.putExtra("briar.GROUP_ID", groupId.getBytes());
|
||||
i.putExtra("briar.PARENT_ID", messageId.getBytes());
|
||||
i.putExtra("briar.TIMESTAMP", timestamp);
|
||||
startActivity(i);
|
||||
setResult(RESULT_REPLY);
|
||||
finish();
|
||||
|
||||
@@ -89,16 +89,16 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
super.onCreate(state);
|
||||
|
||||
Intent i = getIntent();
|
||||
byte[] b = i.getByteArrayExtra("org.briarproject.GROUP_ID");
|
||||
byte[] b = i.getByteArrayExtra("briar.GROUP_ID");
|
||||
if(b == null) throw new IllegalStateException();
|
||||
groupId = new GroupId(b);
|
||||
|
||||
b = i.getByteArrayExtra("org.briarproject.PARENT_ID");
|
||||
b = i.getByteArrayExtra("briar.PARENT_ID");
|
||||
if(b != null) parentId = new MessageId(b);
|
||||
timestamp = i.getLongExtra("org.briarproject.TIMESTAMP", -1);
|
||||
timestamp = i.getLongExtra("briar.TIMESTAMP", -1);
|
||||
|
||||
if(state != null) {
|
||||
b = state.getByteArray("org.briarproject.LOCAL_AUTHOR_ID");
|
||||
b = state.getByteArray("briar.LOCAL_AUTHOR_ID");
|
||||
if(b != null) localAuthorId = new AuthorId(b);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
super.onSaveInstanceState(state);
|
||||
if(localAuthorId != null) {
|
||||
byte[] b = localAuthorId.getBytes();
|
||||
state.putByteArray("org.briarproject.LOCAL_AUTHOR_ID", b);
|
||||
state.putByteArray("briar.LOCAL_AUTHOR_ID", b);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user