mirror of
https://github.com/etesync/android
synced 2024-11-16 04:49:06 +00:00
Add support for read-only journals.
This change only works for calendars at the moment, because we don't have shared address books anyway. This is currently only implemented in the client, and only as a read-only attribute, you can't make a journal read-only yet. This requires server support that is not yet there, but it's better to be ready for this sooner rather than later.
This commit is contained in:
parent
df3db6b357
commit
1ab32be0f6
@ -228,7 +228,7 @@ public class App extends Application {
|
||||
public EntityDataStore<Persistable> getData() {
|
||||
if (dataStore == null) {
|
||||
// override onUpgrade to handle migrating to a new version
|
||||
DatabaseSource source = new MyDatabaseSource(this, Models.DEFAULT, 3);
|
||||
DatabaseSource source = new MyDatabaseSource(this, Models.DEFAULT, 4);
|
||||
Configuration configuration = source.getConfiguration();
|
||||
dataStore = new EntityDataStore<>(configuration);
|
||||
}
|
||||
|
@ -137,6 +137,9 @@ public class JournalManager extends BaseManager {
|
||||
@Getter
|
||||
private int version = -1;
|
||||
|
||||
@Getter
|
||||
private boolean readOnly = false;
|
||||
|
||||
private transient byte[] hmac = null;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
@ -43,8 +43,6 @@ public class CollectionInfo implements Serializable {
|
||||
|
||||
public String uid;
|
||||
|
||||
@Expose
|
||||
public boolean readOnly;
|
||||
@Expose
|
||||
public String displayName, description;
|
||||
@Expose
|
||||
@ -64,7 +62,6 @@ public class CollectionInfo implements Serializable {
|
||||
CollectionInfo info = new CollectionInfo();
|
||||
info.displayName = "Default";
|
||||
info.selected = true;
|
||||
info.readOnly = false;
|
||||
info.type = service;
|
||||
|
||||
return info;
|
||||
@ -85,7 +82,6 @@ public class CollectionInfo implements Serializable {
|
||||
info.serviceID = values.getAsInteger(Collections.SERVICE_ID);
|
||||
|
||||
info.uid = values.getAsString(Collections.URL);
|
||||
info.readOnly = values.getAsInteger(Collections.READ_ONLY) != 0;
|
||||
info.displayName = values.getAsString(Collections.DISPLAY_NAME);
|
||||
info.description = values.getAsString(Collections.DESCRIPTION);
|
||||
|
||||
|
@ -47,6 +47,9 @@ public class JournalModel {
|
||||
|
||||
boolean deleted;
|
||||
|
||||
@Column(value = "false")
|
||||
boolean readOnly;
|
||||
|
||||
@PostLoad
|
||||
void afterLoad() {
|
||||
this.info.serviceID = this.serviceModel.id;
|
||||
|
@ -103,7 +103,7 @@ public class LocalCalendar extends AndroidCalendar implements LocalCollection {
|
||||
if (withColor)
|
||||
values.put(Calendars.CALENDAR_COLOR, info.color != null ? info.color : defaultColor);
|
||||
|
||||
if (info.readOnly)
|
||||
if (journalEntity.isReadOnly())
|
||||
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_READ);
|
||||
else {
|
||||
values.put(Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER);
|
||||
|
@ -198,6 +198,7 @@ public abstract class SyncAdapterService extends Service {
|
||||
JournalEntity journalEntity = JournalEntity.fetchOrCreate(data, collection);
|
||||
journalEntity.setOwner(journal.getOwner());
|
||||
journalEntity.setEncryptedKey(journal.getKey());
|
||||
journalEntity.setReadOnly(journal.isReadOnly());
|
||||
journalEntity.setDeleted(false);
|
||||
data.upsert(journalEntity);
|
||||
|
||||
|
@ -414,7 +414,7 @@ public class AccountActivity extends AppCompatActivity implements Toolbar.OnMenu
|
||||
}
|
||||
|
||||
View readOnly = v.findViewById(R.id.read_only);
|
||||
readOnly.setVisibility(info.readOnly ? View.VISIBLE : View.GONE);
|
||||
readOnly.setVisibility(journalEntity.isReadOnly() ? View.VISIBLE : View.GONE);
|
||||
|
||||
final View shared = v.findViewById(R.id.shared);
|
||||
shared.setVisibility(account.name.equals(journalEntity.getOwner()) ? View.GONE : View.VISIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user