mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 13:19:52 +01:00
Fix disabled groups after screen rotation
isDissolved was reverted to LiveData that only shows a dialog when the activity was first opened
This commit is contained in:
@@ -79,9 +79,10 @@ public class GroupActivity extends
|
|||||||
|
|
||||||
// start with group disabled and enable when not dissolved
|
// start with group disabled and enable when not dissolved
|
||||||
setGroupEnabled(false);
|
setGroupEnabled(false);
|
||||||
viewModel.isDissolved().observeEvent(this, dissolved -> {
|
viewModel.isDissolved().observe(this, dissolved -> {
|
||||||
setGroupEnabled(!dissolved);
|
setGroupEnabled(!dissolved);
|
||||||
if (dissolved) onGroupDissolved();
|
// only show dialog when no prior state
|
||||||
|
if (dissolved && state == null) onGroupDissolved();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ public class GroupActivity extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onReplyClick(GroupMessageItem item) {
|
public void onReplyClick(GroupMessageItem item) {
|
||||||
Boolean isDissolved = viewModel.isDissolved().getLastValue();
|
Boolean isDissolved = viewModel.isDissolved().getValue();
|
||||||
if (isDissolved != null && !isDissolved) super.onReplyClick(item);
|
if (isDissolved != null && !isDissolved) super.onReplyClick(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ import org.briarproject.bramble.api.system.AndroidExecutor;
|
|||||||
import org.briarproject.bramble.api.system.Clock;
|
import org.briarproject.bramble.api.system.Clock;
|
||||||
import org.briarproject.briar.android.sharing.SharingController;
|
import org.briarproject.briar.android.sharing.SharingController;
|
||||||
import org.briarproject.briar.android.threaded.ThreadListViewModel;
|
import org.briarproject.briar.android.threaded.ThreadListViewModel;
|
||||||
import org.briarproject.briar.android.viewmodel.LiveEvent;
|
|
||||||
import org.briarproject.briar.android.viewmodel.MutableLiveEvent;
|
|
||||||
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
import org.briarproject.briar.api.android.AndroidNotificationManager;
|
||||||
import org.briarproject.briar.api.client.MessageTracker;
|
import org.briarproject.briar.api.client.MessageTracker;
|
||||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||||
@@ -71,8 +69,8 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
private final MutableLiveData<PrivateGroup> privateGroup =
|
private final MutableLiveData<PrivateGroup> privateGroup =
|
||||||
new MutableLiveData<>();
|
new MutableLiveData<>();
|
||||||
private final MutableLiveData<Boolean> isCreator = new MutableLiveData<>();
|
private final MutableLiveData<Boolean> isCreator = new MutableLiveData<>();
|
||||||
private final MutableLiveEvent<Boolean> isDissolved =
|
private final MutableLiveData<Boolean> isDissolved =
|
||||||
new MutableLiveEvent<>();
|
new MutableLiveData<>();
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GroupViewModel(Application application,
|
GroupViewModel(Application application,
|
||||||
@@ -129,7 +127,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
} else if (e instanceof GroupDissolvedEvent) {
|
} else if (e instanceof GroupDissolvedEvent) {
|
||||||
GroupDissolvedEvent g = (GroupDissolvedEvent) e;
|
GroupDissolvedEvent g = (GroupDissolvedEvent) e;
|
||||||
if (g.getGroupId().equals(groupId)) {
|
if (g.getGroupId().equals(groupId)) {
|
||||||
isDissolved.setEvent(true);
|
isDissolved.setValue(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.eventOccurred(e);
|
super.eventOccurred(e);
|
||||||
@@ -164,7 +162,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
loadList(txn -> {
|
loadList(txn -> {
|
||||||
// check first if group is dissolved
|
// check first if group is dissolved
|
||||||
isDissolved
|
isDissolved
|
||||||
.postEvent(privateGroupManager.isDissolved(txn, groupId));
|
.postValue(privateGroupManager.isDissolved(txn, groupId));
|
||||||
// now continue to load the items
|
// now continue to load the items
|
||||||
long start = now();
|
long start = now();
|
||||||
List<GroupMessageHeader> headers =
|
List<GroupMessageHeader> headers =
|
||||||
@@ -282,7 +280,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
return isCreator;
|
return isCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiveEvent<Boolean> isDissolved() {
|
LiveData<Boolean> isDissolved() {
|
||||||
return isDissolved;
|
return isDissolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user