Verified Commit 0266da99 authored by Torsten Grote's avatar Torsten Grote
Browse files

Reset plugin assignments when starting AddNearbyContactIntroFragment

parent 4c11f93e
Pipeline #6464 skipped with stage
......@@ -95,6 +95,9 @@ public class AddNearbyContactIntroFragment extends BaseFragment {
super.onStart();
// Permissions may have been granted manually while we were stopped
permissionManager.resetPermissions();
// Reset plugins in case they were assigned when we weren't signed-in
viewModel.resetPlugins();
// Scroll down in case the screen is small, so the button is visible
scrollView.post(() -> scrollView.fullScroll(FOCUS_DOWN));
}
......
......@@ -148,8 +148,8 @@ class AddNearbyContactViewModel extends AndroidViewModel
@Nullable
private final BluetoothAdapter bt;
@Nullable
private final Plugin wifiPlugin, bluetoothPlugin;
@Nullable // UiThread
private Plugin wifiPlugin, bluetoothPlugin;
// UiThread
private BluetoothDecision bluetoothDecision = BluetoothDecision.UNKNOWN;
......@@ -210,6 +210,17 @@ class AddNearbyContactViewModel extends AndroidViewModel
stopListening();
}
/**
* When this activity gets killed and re-created while the user is not
* signed-in (can happen when a permission is denied which terminates app),
* the plugins will be null, so we need to re-assign them after sign-in.
*/
@UiThread
void resetPlugins() {
wifiPlugin = pluginManager.getPlugin(LanTcpConstants.ID);
bluetoothPlugin = pluginManager.getPlugin(BluetoothConstants.ID);
}
@UiThread
void onContinueClicked() {
if (bluetoothDecision == REFUSED) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment