mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Make more use of DbViewModel#handleException()
This commit is contained in:
4
.idea/inspectionProfiles/Project_Default.xml
generated
4
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,6 +1,10 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="MissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
|
<option name="ignoreObjectMethods" value="true" />
|
||||||
|
<option name="ignoreAnonymousClassMethods" value="false" />
|
||||||
|
</inspection_tool>
|
||||||
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
<inspection_tool class="WeakerAccess" enabled="true" level="WARNING" enabled_by_default="true">
|
||||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
|
<option name="SUGGEST_PACKAGE_LOCAL_FOR_MEMBERS" value="true" />
|
||||||
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" />
|
<option name="SUGGEST_PACKAGE_LOCAL_FOR_TOP_CLASSES" value="true" />
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class Author implements Nameable {
|
|||||||
/**
|
/**
|
||||||
* Returns the author's name.
|
* Returns the author's name.
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,10 +146,12 @@ abstract class PowerView extends ConstraintLayout {
|
|||||||
|
|
||||||
static final Parcelable.Creator<SavedState> CREATOR
|
static final Parcelable.Creator<SavedState> CREATOR
|
||||||
= new Parcelable.Creator<SavedState>() {
|
= new Parcelable.Creator<SavedState>() {
|
||||||
|
@Override
|
||||||
public SavedState createFromParcel(Parcel in) {
|
public SavedState createFromParcel(Parcel in) {
|
||||||
return new SavedState(in);
|
return new SavedState(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SavedState[] newArray(int size) {
|
public SavedState[] newArray(int size) {
|
||||||
return new SavedState[size];
|
return new SavedState[size];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ public class UnlockActivity extends BaseActivity {
|
|||||||
component.inject(this);
|
component.inject(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onCreate(@Nullable Bundle state) {
|
public void onCreate(@Nullable Bundle state) {
|
||||||
super.onCreate(state);
|
super.onCreate(state);
|
||||||
overridePendingTransition(0, 0);
|
overridePendingTransition(0, 0);
|
||||||
|
|||||||
@@ -19,23 +19,15 @@ import org.briarproject.briar.api.conversation.ConversationManager;
|
|||||||
import org.briarproject.briar.api.identity.AuthorManager;
|
import org.briarproject.briar.api.identity.AuthorManager;
|
||||||
|
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
class ContactListViewModel extends ContactsViewModel {
|
class ContactListViewModel extends ContactsViewModel {
|
||||||
|
|
||||||
private static final Logger LOG =
|
|
||||||
getLogger(ContactListViewModel.class.getName());
|
|
||||||
|
|
||||||
private final AndroidNotificationManager notificationManager;
|
private final AndroidNotificationManager notificationManager;
|
||||||
|
|
||||||
private final MutableLiveData<Boolean> hasPendingContacts =
|
private final MutableLiveData<Boolean> hasPendingContacts =
|
||||||
@@ -76,7 +68,7 @@ class ContactListViewModel extends ContactsViewModel {
|
|||||||
!contactManager.getPendingContacts().isEmpty();
|
!contactManager.getPendingContacts().isEmpty();
|
||||||
hasPendingContacts.postValue(hasPending);
|
hasPendingContacts.postValue(hasPending);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class AddContactViewModel extends DbViewModel {
|
|||||||
try {
|
try {
|
||||||
handshakeLink.postValue(contactManager.getHandshakeLink());
|
handshakeLink.postValue(contactManager.getHandshakeLink());
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
// the UI should stay disabled in this case,
|
// the UI should stay disabled in this case,
|
||||||
// leaving the user unable to proceed
|
// leaving the user unable to proceed
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,25 +26,18 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
|
||||||
import static org.briarproject.bramble.api.contact.PendingContactState.OFFLINE;
|
import static org.briarproject.bramble.api.contact.PendingContactState.OFFLINE;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class PendingContactListViewModel extends DbViewModel
|
public class PendingContactListViewModel extends DbViewModel
|
||||||
implements EventListener {
|
implements EventListener {
|
||||||
|
|
||||||
private final Logger LOG =
|
|
||||||
getLogger(PendingContactListViewModel.class.getName());
|
|
||||||
|
|
||||||
private final ContactManager contactManager;
|
private final ContactManager contactManager;
|
||||||
private final RendezvousPoller rendezvousPoller;
|
private final RendezvousPoller rendezvousPoller;
|
||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
@@ -106,7 +99,7 @@ public class PendingContactListViewModel extends DbViewModel
|
|||||||
pendingContacts.postValue(items);
|
pendingContacts.postValue(items);
|
||||||
hasInternetConnection.postValue(online);
|
hasInternetConnection.postValue(online);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -120,7 +113,7 @@ public class PendingContactListViewModel extends DbViewModel
|
|||||||
try {
|
try {
|
||||||
contactManager.removePendingContact(id);
|
contactManager.removePendingContact(id);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
} catch (NoSuchContactException e) {
|
} catch (NoSuchContactException e) {
|
||||||
contactDeleted.postValue(true);
|
contactDeleted.postValue(true);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
conversationManager.setReadFlag(g, m, true);
|
conversationManager.setReadFlag(g, m, true);
|
||||||
logDuration(LOG, "Marking read", start);
|
logDuration(LOG, "Marking read", start);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -261,7 +261,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
alias.isEmpty() ? null : alias);
|
alias.isEmpty() ? null : alias);
|
||||||
loadContact(contactId);
|
loadContact(contactId);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
autoDeleteManager.setAutoDeleteTimer(txn, c, timer));
|
autoDeleteManager.setAutoDeleteTimer(txn, c, timer));
|
||||||
autoDeleteTimer.postValue(timer);
|
autoDeleteTimer.postValue(timer);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -453,7 +453,7 @@ public class ConversationViewModel extends DbViewModel
|
|||||||
try {
|
try {
|
||||||
checkFeaturesAndOnboarding(contactId);
|
checkFeaturesAndOnboarding(contactId);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,10 +40,8 @@ import androidx.annotation.UiThread;
|
|||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_ID;
|
import static org.briarproject.briar.api.forum.ForumManager.CLIENT_ID;
|
||||||
|
|
||||||
@@ -126,7 +124,7 @@ class ForumListViewModel extends DbViewModel implements EventListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadForums() {
|
void loadForums() {
|
||||||
loadFromDb(this::loadForums, forumItems::setValue);
|
loadFromDb(this::loadForums, forumItems::setValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -169,7 +167,7 @@ class ForumListViewModel extends DbViewModel implements EventListener {
|
|||||||
logDuration(LOG, "Loading available", start);
|
logDuration(LOG, "Loading available", start);
|
||||||
numInvitations.postValue(available);
|
numInvitations.postValue(available);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,10 +50,8 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
|
|
||||||
import static android.widget.Toast.LENGTH_SHORT;
|
import static android.widget.Toast.LENGTH_SHORT;
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -116,6 +114,7 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void clearNotifications() {
|
protected void clearNotifications() {
|
||||||
notificationManager.clearForumPostNotification(groupId);
|
notificationManager.clearForumPostNotification(groupId);
|
||||||
}
|
}
|
||||||
@@ -127,7 +126,7 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
Forum f = forumManager.getForum(groupId);
|
Forum f = forumManager.getForum(groupId);
|
||||||
forum.postValue(f);
|
forum.postValue(f);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return forum;
|
return forum;
|
||||||
@@ -167,7 +166,7 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
clock.currentTimeMillis());
|
clock.currentTimeMillis());
|
||||||
createMessage(text, timestamp, parentId, author);
|
createMessage(text, timestamp, parentId, author);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -191,7 +190,7 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
ForumPostItem item = new ForumPostItem(header, text);
|
ForumPostItem item = new ForumPostItem(header, text);
|
||||||
addItem(item, true);
|
addItem(item, true);
|
||||||
});
|
});
|
||||||
}, e -> logException(LOG, WARNING, e));
|
}, this::handleException);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -200,11 +199,12 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
try {
|
try {
|
||||||
forumManager.setReadFlag(groupId, item.getId(), true);
|
forumManager.setReadFlag(groupId, item.getId(), true);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void loadSharingContacts() {
|
public void loadSharingContacts() {
|
||||||
runOnDbThread(true, txn -> {
|
runOnDbThread(true, txn -> {
|
||||||
Collection<Contact> contacts =
|
Collection<Contact> contacts =
|
||||||
@@ -212,7 +212,7 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
Collection<ContactId> contactIds = new ArrayList<>(contacts.size());
|
Collection<ContactId> contactIds = new ArrayList<>(contacts.size());
|
||||||
for (Contact c : contacts) contactIds.add(c.getId());
|
for (Contact c : contacts) contactIds.add(c.getId());
|
||||||
txn.attach(() -> sharingController.addAll(contactIds));
|
txn.attach(() -> sharingController.addAll(contactIds));
|
||||||
}, e -> logException(LOG, WARNING, e));
|
}, this::handleException);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deleteForum() {
|
void deleteForum() {
|
||||||
@@ -220,12 +220,13 @@ class ForumViewModel extends ThreadListViewModel<ForumPostItem> {
|
|||||||
try {
|
try {
|
||||||
Forum f = forumManager.getForum(groupId);
|
Forum f = forumManager.getForum(groupId);
|
||||||
forumManager.removeForum(f);
|
forumManager.removeForum(f);
|
||||||
|
androidExecutor.runOnUiThread(() -> Toast
|
||||||
|
.makeText(getApplication(), R.string.forum_left_toast,
|
||||||
|
LENGTH_SHORT).show());
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Toast.makeText(getApplication(), R.string.forum_left_toast,
|
|
||||||
LENGTH_SHORT).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class IntroductionViewModel extends ContactsViewModel {
|
|||||||
introductionInfo.postValue(
|
introductionInfo.postValue(
|
||||||
new IntroductionInfo(c1, c2, possible));
|
new IntroductionInfo(c1, c2, possible));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ public class NavDrawerViewModel extends DbViewModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -109,7 +109,7 @@ public class NavDrawerViewModel extends DbViewModel {
|
|||||||
settings.putInt(EXPIRY_DATE_WARNING, date);
|
settings.putInt(EXPIRY_DATE_WARNING, date);
|
||||||
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
|
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ public class NavDrawerViewModel extends DbViewModel {
|
|||||||
settings.getBoolean(SHOW_TRANSPORTS_ONBOARDING, true);
|
settings.getBoolean(SHOW_TRANSPORTS_ONBOARDING, true);
|
||||||
showTransportsOnboarding.postValue(show);
|
showTransportsOnboarding.postValue(show);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ public class NavDrawerViewModel extends DbViewModel {
|
|||||||
settings.putBoolean(SHOW_TRANSPORTS_ONBOARDING, false);
|
settings.putBoolean(SHOW_TRANSPORTS_ONBOARDING, false);
|
||||||
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
|
settingsManager.mergeSettings(settings, SETTINGS_NAMESPACE);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,12 +45,10 @@ import static android.bluetooth.BluetoothAdapter.ACTION_STATE_CHANGED;
|
|||||||
import static android.bluetooth.BluetoothAdapter.EXTRA_STATE;
|
import static android.bluetooth.BluetoothAdapter.EXTRA_STATE;
|
||||||
import static android.bluetooth.BluetoothAdapter.STATE_ON;
|
import static android.bluetooth.BluetoothAdapter.STATE_ON;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.PREF_PLUGIN_ENABLE;
|
import static org.briarproject.bramble.api.plugin.Plugin.PREF_PLUGIN_ENABLE;
|
||||||
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
import static org.briarproject.bramble.api.plugin.Plugin.State.STARTING_STOPPING;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
|
|
||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
@@ -197,7 +195,7 @@ public class PluginViewModel extends DbViewModel implements EventListener {
|
|||||||
BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE);
|
BluetoothConstants.DEFAULT_PREF_PLUGIN_ENABLE);
|
||||||
btEnabledSetting.postValue(bt);
|
btEnabledSetting.postValue(bt);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -228,7 +226,7 @@ public class PluginViewModel extends DbViewModel implements EventListener {
|
|||||||
settingsManager.mergeSettings(s, namespace);
|
settingsManager.mergeSettings(s, namespace);
|
||||||
logDuration(LOG, "Merging settings", start);
|
logDuration(LOG, "Merging settings", start);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,10 +51,8 @@ import androidx.lifecycle.LiveData;
|
|||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import static java.lang.Math.max;
|
import static java.lang.Math.max;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@@ -140,6 +138,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
loadPrivateGroup(groupId);
|
loadPrivateGroup(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
protected void clearNotifications() {
|
protected void clearNotifications() {
|
||||||
notificationManager.clearGroupMessageNotification(groupId);
|
notificationManager.clearGroupMessageNotification(groupId);
|
||||||
}
|
}
|
||||||
@@ -152,7 +151,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
Author author = identityManager.getLocalAuthor();
|
Author author = identityManager.getLocalAuthor();
|
||||||
isCreator.postValue(g.getCreator().equals(author));
|
isCreator.postValue(g.getCreator().equals(author));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -210,7 +209,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
timestamp = max(clock.currentTimeMillis(), timestamp + 1);
|
timestamp = max(clock.currentTimeMillis(), timestamp + 1);
|
||||||
createMessage(text, timestamp, parentId, author, previousMsgId);
|
createMessage(text, timestamp, parentId, author, previousMsgId);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -235,7 +234,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
txn.attach(() ->
|
txn.attach(() ->
|
||||||
addItem(buildItem(header, text), true)
|
addItem(buildItem(header, text), true)
|
||||||
);
|
);
|
||||||
}, e -> logException(LOG, WARNING, e));
|
}, this::handleException);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -244,11 +243,12 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
try {
|
try {
|
||||||
privateGroupManager.setReadFlag(groupId, item.getId(), true);
|
privateGroupManager.setReadFlag(groupId, item.getId(), true);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void loadSharingContacts() {
|
public void loadSharingContacts() {
|
||||||
runOnDbThread(true, txn -> {
|
runOnDbThread(true, txn -> {
|
||||||
Collection<GroupMember> members =
|
Collection<GroupMember> members =
|
||||||
@@ -259,7 +259,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
contactIds.add(m.getContactId());
|
contactIds.add(m.getContactId());
|
||||||
}
|
}
|
||||||
txn.attach(() -> sharingController.addAll(contactIds));
|
txn.attach(() -> sharingController.addAll(contactIds));
|
||||||
}, e -> logException(LOG, WARNING, e));
|
}, this::handleException);
|
||||||
}
|
}
|
||||||
|
|
||||||
void deletePrivateGroup() {
|
void deletePrivateGroup() {
|
||||||
@@ -267,7 +267,7 @@ class GroupViewModel extends ThreadListViewModel<GroupMessageItem> {
|
|||||||
try {
|
try {
|
||||||
privateGroupManager.removePrivateGroup(groupId);
|
privateGroupManager.removePrivateGroup(groupId);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,10 +48,8 @@ import androidx.lifecycle.LiveData;
|
|||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
import static org.briarproject.bramble.util.LogUtils.logDuration;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
import static org.briarproject.bramble.util.LogUtils.now;
|
import static org.briarproject.bramble.util.LogUtils.now;
|
||||||
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
|
import static org.briarproject.briar.api.privategroup.PrivateGroupManager.CLIENT_ID;
|
||||||
|
|
||||||
@@ -202,7 +200,7 @@ class GroupListViewModel extends DbViewModel implements EventListener {
|
|||||||
groupManager.removePrivateGroup(g);
|
groupManager.removePrivateGroup(g);
|
||||||
logDuration(LOG, "Removing group", start);
|
logDuration(LOG, "Removing group", start);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -213,7 +211,7 @@ class GroupListViewModel extends DbViewModel implements EventListener {
|
|||||||
int i = groupInvitationManager.getInvitations().size();
|
int i = groupInvitationManager.getInvitations().size();
|
||||||
numInvitations.postValue(i);
|
numInvitations.postValue(i);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
|||||||
settingsManager.getSettings(TOR_NAMESPACE));
|
settingsManager.getSettings(TOR_NAMESPACE));
|
||||||
logDuration(LOG, "Loading settings", start);
|
logDuration(LOG, "Loading settings", start);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ class SettingsViewModel extends DbViewModel implements EventListener {
|
|||||||
ownIdentityInfo.postValue(
|
ownIdentityInfo.postValue(
|
||||||
new OwnIdentityInfo(localAuthor, authorInfo));
|
new OwnIdentityInfo(localAuthor, authorInfo));
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,9 +41,7 @@ import androidx.lifecycle.MutableLiveData;
|
|||||||
|
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static java.util.logging.Level.INFO;
|
import static java.util.logging.Level.INFO;
|
||||||
import static java.util.logging.Level.WARNING;
|
|
||||||
import static java.util.logging.Logger.getLogger;
|
import static java.util.logging.Logger.getLogger;
|
||||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
|
||||||
|
|
||||||
@MethodsNotNullByDefault
|
@MethodsNotNullByDefault
|
||||||
@ParametersNotNullByDefault
|
@ParametersNotNullByDefault
|
||||||
@@ -160,7 +158,7 @@ public abstract class ThreadListViewModel<I extends ThreadItem>
|
|||||||
storedMessageId);
|
storedMessageId);
|
||||||
}
|
}
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -223,7 +221,7 @@ public abstract class ThreadListViewModel<I extends ThreadItem>
|
|||||||
try {
|
try {
|
||||||
messageTracker.storeMessageId(groupId, messageId);
|
messageTracker.storeMessageId(groupId, messageId);
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
logException(LOG, WARNING, e);
|
handleException(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ class IntroducerSession extends Session<IntroducerState> {
|
|||||||
this(sessionId, groupId, author, -1, null, null);
|
this(sessionId, groupId, author, -1, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public SessionId getSessionId() {
|
public SessionId getSessionId() {
|
||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user