mirror of
https://github.com/oxen-io/session-android.git
synced 2025-04-08 05:34:30 +00:00
Eliminate concept of group 'owner'.
This commit is contained in:
parent
da57a689c1
commit
315cf2d8e4
@ -284,7 +284,7 @@
|
|||||||
</string>
|
</string>
|
||||||
<string name="SmsMessageRecord_received_updated_but_unknown_identity_information">Received updated but unknown identity information. Tap to validate identity.</string>
|
<string name="SmsMessageRecord_received_updated_but_unknown_identity_information">Received updated but unknown identity information. Tap to validate identity.</string>
|
||||||
<string name="SmsMessageRecord_secure_session_ended">Secure session ended.</string>
|
<string name="SmsMessageRecord_secure_session_ended">Secure session ended.</string>
|
||||||
|
|
||||||
<!-- ThreadRecord -->
|
<!-- ThreadRecord -->
|
||||||
<string name="ThreadRecord_left_the_group">Left the group...</string>
|
<string name="ThreadRecord_left_the_group">Left the group...</string>
|
||||||
<string name="TheadRecord_secure_session_ended">Secure session ended.</string>
|
<string name="TheadRecord_secure_session_ended">Secure session ended.</string>
|
||||||
|
@ -670,7 +670,7 @@ public class GroupCreateActivity extends PassphraseRequiredSherlockFragmentActiv
|
|||||||
existingAvatarBmp = BitmapUtil.getCircleCroppedBitmap(
|
existingAvatarBmp = BitmapUtil.getCircleCroppedBitmap(
|
||||||
BitmapFactory.decodeByteArray(existingAvatar, 0, existingAvatar.length));
|
BitmapFactory.decodeByteArray(existingAvatar, 0, existingAvatar.length));
|
||||||
}
|
}
|
||||||
return (group.getOwner() != null && group.getOwner().equals(TextSecurePreferences.getLocalNumber(GroupCreateActivity.this)));
|
return true;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -642,7 +642,7 @@ public class DatabaseFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (oldVersion < INTRODUCED_GROUP_DATABASE_VERSION) {
|
if (oldVersion < INTRODUCED_GROUP_DATABASE_VERSION) {
|
||||||
db.execSQL("CREATE TABLE groups (_id INTEGER PRIMARY KEY, group_id TEXT, owner TEXT, title TEXT, members TEXT, avatar BLOB, avatar_id INTEGER, avatar_key BLOB, avatar_content_type TEXT, avatar_relay TEXT, timestamp INTEGER, active INTEGER DEFAULT 1);");
|
db.execSQL("CREATE TABLE groups (_id INTEGER PRIMARY KEY, group_id TEXT, title TEXT, members TEXT, avatar BLOB, avatar_id INTEGER, avatar_key BLOB, avatar_content_type TEXT, avatar_relay TEXT, timestamp INTEGER, active INTEGER DEFAULT 1);");
|
||||||
db.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS group_id_index ON groups (GROUP_ID);");
|
db.execSQL("CREATE UNIQUE INDEX IF NOT EXISTS group_id_index ON groups (GROUP_ID);");
|
||||||
db.execSQL("ALTER TABLE push ADD COLUMN device_id INTEGER DEFAULT 1;");
|
db.execSQL("ALTER TABLE push ADD COLUMN device_id INTEGER DEFAULT 1;");
|
||||||
db.execSQL("ALTER TABLE sms ADD COLUMN address_device_id INTEGER DEFAULT 1;");
|
db.execSQL("ALTER TABLE sms ADD COLUMN address_device_id INTEGER DEFAULT 1;");
|
||||||
|
@ -31,7 +31,6 @@ public class GroupDatabase extends Database {
|
|||||||
private static final String TABLE_NAME = "groups";
|
private static final String TABLE_NAME = "groups";
|
||||||
private static final String ID = "_id";
|
private static final String ID = "_id";
|
||||||
private static final String GROUP_ID = "group_id";
|
private static final String GROUP_ID = "group_id";
|
||||||
private static final String OWNER = "owner";
|
|
||||||
private static final String TITLE = "title";
|
private static final String TITLE = "title";
|
||||||
private static final String MEMBERS = "members";
|
private static final String MEMBERS = "members";
|
||||||
private static final String AVATAR = "avatar";
|
private static final String AVATAR = "avatar";
|
||||||
@ -46,7 +45,6 @@ public class GroupDatabase extends Database {
|
|||||||
"CREATE TABLE " + TABLE_NAME +
|
"CREATE TABLE " + TABLE_NAME +
|
||||||
" (" + ID + " INTEGER PRIMARY KEY, " +
|
" (" + ID + " INTEGER PRIMARY KEY, " +
|
||||||
GROUP_ID + " TEXT, " +
|
GROUP_ID + " TEXT, " +
|
||||||
OWNER + " TEXT, " +
|
|
||||||
TITLE + " TEXT, " +
|
TITLE + " TEXT, " +
|
||||||
MEMBERS + " TEXT, " +
|
MEMBERS + " TEXT, " +
|
||||||
AVATAR + " BLOB, " +
|
AVATAR + " BLOB, " +
|
||||||
@ -112,7 +110,6 @@ public class GroupDatabase extends Database {
|
|||||||
|
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
contentValues.put(GROUP_ID, GroupUtil.getEncodedId(groupId));
|
contentValues.put(GROUP_ID, GroupUtil.getEncodedId(groupId));
|
||||||
contentValues.put(OWNER, owner);
|
|
||||||
contentValues.put(TITLE, title);
|
contentValues.put(TITLE, title);
|
||||||
contentValues.put(MEMBERS, Util.join(filteredMembers, ","));
|
contentValues.put(MEMBERS, Util.join(filteredMembers, ","));
|
||||||
|
|
||||||
@ -129,7 +126,7 @@ public class GroupDatabase extends Database {
|
|||||||
databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
|
databaseHelper.getWritableDatabase().insert(TABLE_NAME, null, contentValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(byte[] groupId, String source, String title, AttachmentPointer avatar) {
|
public void update(byte[] groupId, String title, AttachmentPointer avatar) {
|
||||||
ContentValues contentValues = new ContentValues();
|
ContentValues contentValues = new ContentValues();
|
||||||
if (title != null) contentValues.put(TITLE, title);
|
if (title != null) contentValues.put(TITLE, title);
|
||||||
|
|
||||||
@ -140,8 +137,8 @@ public class GroupDatabase extends Database {
|
|||||||
}
|
}
|
||||||
|
|
||||||
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
|
databaseHelper.getWritableDatabase().update(TABLE_NAME, contentValues,
|
||||||
GROUP_ID + " = ? AND " + OWNER + " = ?",
|
GROUP_ID + " = ?",
|
||||||
new String[] {GroupUtil.getEncodedId(groupId), source});
|
new String[] {GroupUtil.getEncodedId(groupId)});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTitle(byte[] groupId, String title) {
|
public void updateTitle(byte[] groupId, String title) {
|
||||||
@ -224,27 +221,6 @@ public class GroupDatabase extends Database {
|
|||||||
database.update(TABLE_NAME, values, GROUP_ID + " = ?", new String[] {GroupUtil.getEncodedId(id)});
|
database.update(TABLE_NAME, values, GROUP_ID + " = ?", new String[] {GroupUtil.getEncodedId(id)});
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwner(byte[] id) {
|
|
||||||
Cursor cursor = null;
|
|
||||||
|
|
||||||
try {
|
|
||||||
SQLiteDatabase readableDatabase = databaseHelper.getReadableDatabase();
|
|
||||||
if (readableDatabase == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
cursor = databaseHelper.getReadableDatabase().query(TABLE_NAME, new String[] {OWNER},
|
|
||||||
GROUP_ID + " = ?",
|
|
||||||
new String[] {GroupUtil.getEncodedId(id)},
|
|
||||||
null, null, null);
|
|
||||||
if (cursor != null && cursor.moveToFirst()) {
|
|
||||||
return cursor.getString(cursor.getColumnIndexOrThrow(OWNER));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
} finally {
|
|
||||||
if (cursor != null)
|
|
||||||
cursor.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] allocateGroupId() {
|
public byte[] allocateGroupId() {
|
||||||
try {
|
try {
|
||||||
@ -272,7 +248,6 @@ public class GroupDatabase extends Database {
|
|||||||
|
|
||||||
return new GroupRecord(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID)),
|
return new GroupRecord(cursor.getString(cursor.getColumnIndexOrThrow(GROUP_ID)),
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(TITLE)),
|
cursor.getString(cursor.getColumnIndexOrThrow(TITLE)),
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(OWNER)),
|
|
||||||
cursor.getString(cursor.getColumnIndexOrThrow(MEMBERS)),
|
cursor.getString(cursor.getColumnIndexOrThrow(MEMBERS)),
|
||||||
cursor.getBlob(cursor.getColumnIndexOrThrow(AVATAR)),
|
cursor.getBlob(cursor.getColumnIndexOrThrow(AVATAR)),
|
||||||
cursor.getLong(cursor.getColumnIndexOrThrow(AVATAR_ID)),
|
cursor.getLong(cursor.getColumnIndexOrThrow(AVATAR_ID)),
|
||||||
@ -292,7 +267,6 @@ public class GroupDatabase extends Database {
|
|||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final String title;
|
private final String title;
|
||||||
private final String owner;
|
|
||||||
private final List<String> members;
|
private final List<String> members;
|
||||||
private final byte[] avatar;
|
private final byte[] avatar;
|
||||||
private final long avatarId;
|
private final long avatarId;
|
||||||
@ -301,13 +275,12 @@ public class GroupDatabase extends Database {
|
|||||||
private final String relay;
|
private final String relay;
|
||||||
private final boolean active;
|
private final boolean active;
|
||||||
|
|
||||||
public GroupRecord(String id, String title, String owner, String members, byte[] avatar,
|
public GroupRecord(String id, String title, String members, byte[] avatar,
|
||||||
long avatarId, byte[] avatarKey, String avatarContentType,
|
long avatarId, byte[] avatarKey, String avatarContentType,
|
||||||
String relay, boolean active)
|
String relay, boolean active)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.owner = owner;
|
|
||||||
this.members = Util.split(members, ",");
|
this.members = Util.split(members, ",");
|
||||||
this.avatar = avatar;
|
this.avatar = avatar;
|
||||||
this.avatarId = avatarId;
|
this.avatarId = avatarId;
|
||||||
@ -329,10 +302,6 @@ public class GroupDatabase extends Database {
|
|||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwner() {
|
|
||||||
return owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getMembers() {
|
public List<String> getMembers() {
|
||||||
return members;
|
return members;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class GroupReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (group.hasName() || group.hasAvatar()) {
|
if (group.hasName() || group.hasAvatar()) {
|
||||||
database.update(id, message.getSource(), group.getName(), group.getAvatar());
|
database.update(id, group.getName(), group.getAvatar());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (group.hasName() && group.getName() != null && group.getName().equals(groupRecord.getTitle())) {
|
if (group.hasName() && group.getName() != null && group.getName().equals(groupRecord.getTitle())) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user