mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
Merge branch '2280-check-lifecycle-before-recreating-removable-drive-tasks' into 'master'
Check lifecycle state before recreating removable drive tasks Closes #2280 See merge request briar/briar!1629
This commit is contained in:
@@ -103,7 +103,8 @@ public class ReceiveFragment extends Fragment {
|
||||
// to prevent duplicates on the back stack.
|
||||
getParentFragmentManager().popBackStack();
|
||||
// Start again (picks up existing task or allows to start a new one)
|
||||
viewModel.startReceiveData();
|
||||
// unless the activity was recreated after the app was killed
|
||||
if (viewModel.isAccountSignedIn()) viewModel.startReceiveData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.app.Application;
|
||||
import android.net.Uri;
|
||||
|
||||
import org.briarproject.bramble.api.Consumer;
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
@@ -32,6 +33,7 @@ import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import static java.util.Locale.US;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
import static org.briarproject.bramble.api.lifecycle.LifecycleManager.LifecycleState.STARTING_SERVICES;
|
||||
import static org.briarproject.bramble.api.plugin.file.RemovableDriveConstants.PROP_URI;
|
||||
|
||||
@UiThread
|
||||
@@ -40,6 +42,7 @@ class RemovableDriveViewModel extends DbViewModel {
|
||||
|
||||
enum Action {SEND, RECEIVE}
|
||||
|
||||
private final AccountManager accountManager;
|
||||
private final RemovableDriveManager manager;
|
||||
|
||||
private final MutableLiveEvent<Action> action = new MutableLiveEvent<>();
|
||||
@@ -61,8 +64,10 @@ class RemovableDriveViewModel extends DbViewModel {
|
||||
LifecycleManager lifecycleManager,
|
||||
TransactionManager db,
|
||||
AndroidExecutor androidExecutor,
|
||||
AccountManager accountManager,
|
||||
RemovableDriveManager removableDriveManager) {
|
||||
super(app, dbExecutor, lifecycleManager, db, androidExecutor);
|
||||
this.accountManager = accountManager;
|
||||
this.manager = removableDriveManager;
|
||||
}
|
||||
|
||||
@@ -193,4 +198,8 @@ class RemovableDriveViewModel extends DbViewModel {
|
||||
return state;
|
||||
}
|
||||
|
||||
boolean isAccountSignedIn() {
|
||||
return accountManager.hasDatabaseKey() &&
|
||||
lifecycleManager.getLifecycleState().isAfter(STARTING_SERVICES);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +109,8 @@ public class SendFragment extends Fragment {
|
||||
// to prevent duplicates on the back stack.
|
||||
getParentFragmentManager().popBackStack();
|
||||
// Start again (picks up existing task or allows to start a new one)
|
||||
viewModel.startSendData();
|
||||
// unless the activity was recreated after the app was killed
|
||||
if (viewModel.isAccountSignedIn()) viewModel.startSendData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public abstract class DbViewModel extends AndroidViewModel {
|
||||
|
||||
@DatabaseExecutor
|
||||
private final Executor dbExecutor;
|
||||
private final LifecycleManager lifecycleManager;
|
||||
protected final LifecycleManager lifecycleManager;
|
||||
private final TransactionManager db;
|
||||
protected final AndroidExecutor androidExecutor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user