SetupWizard: Distinguish interactive and wrapper subactivities

We were using the SubBaseActivity class for two different kind of
activities:
 (1) "Wrapper" activities, where we define an activity that on
     start simply launches another one
 (2) "Interactive" activities, where the user has to manually
     trigger the start of the subactivity, or skip the step.

When the subactivity ends, only in case (1) we want to finish our
activity as well, since we wouldn't have anything to show.

Change-Id: I1a3ae51f6146ac32b5e7542d9a18b0b032efe144
This commit is contained in:
Alessandro Astone
2020-11-13 21:56:33 +01:00
committed by Bruno Martins
parent b27895be85
commit 8ab720a45d
5 changed files with 41 additions and 6 deletions

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 The CyanogenMod Project
* Copyright (C) 2017 The LineageOS Project
* Copyright (C) 2017-2018,2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import android.util.Log;
import org.lineageos.setupwizard.util.SetupWizardUtils;
public class BluetoothSetupActivity extends SubBaseActivity {
public class BluetoothSetupActivity extends WrapperSubBaseActivity {
public static final String TAG = BluetoothSetupActivity.class.getSimpleName();

View File

@@ -34,7 +34,7 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.Random;
public class CaptivePortalSetupActivity extends SubBaseActivity {
public class CaptivePortalSetupActivity extends WrapperSubBaseActivity {
public static final String TAG = CaptivePortalSetupActivity.class.getSimpleName();

View File

@@ -40,6 +40,10 @@ public abstract class SubBaseActivity extends BaseSetupWizardActivity {
protected abstract void onStartSubactivity();
protected void onSubactivityCanceled(Intent data) {
// Do nothing.
}
@Override
protected void onCreate(Bundle savedInstanceState) {
if (LOGV) {
@@ -142,8 +146,7 @@ public abstract class SubBaseActivity extends BaseSetupWizardActivity {
nextAction(RESULT_ACTIVITY_NOT_FOUND);
finish();
} else {
applyBackwardTransition(getSubactivityPreviousTransition());
finishAction(RESULT_CANCELED, data);
onSubactivityCanceled(data);
}
}

View File

@@ -24,7 +24,7 @@ import android.content.Intent;
import org.lineageos.setupwizard.util.SetupWizardUtils;
public class WifiSetupActivity extends SubBaseActivity {
public class WifiSetupActivity extends WrapperSubBaseActivity {
public static final String TAG = WifiSetupActivity.class.getSimpleName();

View File

@@ -0,0 +1,32 @@
/*
* Copyright (C) 2020 The LineageOS Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.lineageos.setupwizard;
import android.content.Intent;
public abstract class WrapperSubBaseActivity extends SubBaseActivity {
@Override
protected void onSubactivityCanceled(Intent data) {
super.onSubactivityCanceled(data);
// As the subactivity we're wrapping finishes, we finish too
applyBackwardTransition(getSubactivityPreviousTransition());
finishAction(RESULT_CANCELED, data);
}
}