Merge "[SetupWizard] Refactor WifiSetupActivity"
This commit is contained in:
@@ -33,24 +33,11 @@ public class SetupWizardUtils {
|
|||||||
|
|
||||||
// From WizardManager (must match constants maintained there)
|
// From WizardManager (must match constants maintained there)
|
||||||
public static final String EXTRA_SCRIPT_URI = "scriptUri";
|
public static final String EXTRA_SCRIPT_URI = "scriptUri";
|
||||||
public static final int NEXT_REQUEST = 10000;
|
|
||||||
|
|
||||||
public static boolean isUsingWizardManager(Activity activity) {
|
public static boolean isUsingWizardManager(Activity activity) {
|
||||||
return activity.getIntent().hasExtra(EXTRA_SCRIPT_URI);
|
return activity.getIntent().hasExtra(EXTRA_SCRIPT_URI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send the results of this activity to WizardManager, which will then send out the next
|
|
||||||
* scripted activity. WizardManager does not actually return an activity result, but if we
|
|
||||||
* invoke WizardManager without requesting a result, the framework will choose not to issue a
|
|
||||||
* call to onActivityResult with RESULT_CANCELED when navigating backward.
|
|
||||||
*/
|
|
||||||
public static void sendResultsToSetupWizard(Activity activity, int resultCode) {
|
|
||||||
final Intent intent = activity.getIntent();
|
|
||||||
final Intent nextIntent = WizardManagerHelper.getNextIntent(intent, resultCode);
|
|
||||||
activity.startActivityForResult(nextIntent, NEXT_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getTheme(Intent intent) {
|
public static int getTheme(Intent intent) {
|
||||||
if (WizardManagerHelper.isLightTheme(intent, true)) {
|
if (WizardManagerHelper.isLightTheme(intent, true)) {
|
||||||
return R.style.SetupWizardTheme_Light;
|
return R.style.SetupWizardTheme_Light;
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class WifiSetupActivity extends WifiPickerActivity
|
|||||||
if (isWifiConnected()) {
|
if (isWifiConnected()) {
|
||||||
if (mAutoFinishOnConnection && mUserSelectedNetwork) {
|
if (mAutoFinishOnConnection && mUserSelectedNetwork) {
|
||||||
Log.d(TAG, "Auto-finishing with connection");
|
Log.d(TAG, "Auto-finishing with connection");
|
||||||
finishOrNext(Activity.RESULT_OK);
|
finish(Activity.RESULT_OK);
|
||||||
// Require a user selection before auto-finishing next time we are here. The user
|
// Require a user selection before auto-finishing next time we are here. The user
|
||||||
// can either connect to a different network or press "next" to proceed.
|
// can either connect to a different network or press "next" to proceed.
|
||||||
mUserSelectedNetwork = false;
|
mUserSelectedNetwork = false;
|
||||||
@@ -195,18 +195,12 @@ public class WifiSetupActivity extends WifiPickerActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete this activity and return the results to the caller. If using WizardManager, this
|
* Complete this activity and return the results to the caller.
|
||||||
* will invoke the next scripted action; otherwise, we simply finish.
|
|
||||||
*/
|
*/
|
||||||
public void finishOrNext(int resultCode) {
|
public void finish(int resultCode) {
|
||||||
Log.d(TAG, "finishOrNext resultCode=" + resultCode
|
Log.d(TAG, "finishing, resultCode=" + resultCode);
|
||||||
+ " isUsingWizardManager=" + SetupWizardUtils.isUsingWizardManager(this));
|
setResult(resultCode);
|
||||||
if (SetupWizardUtils.isUsingWizardManager(this)) {
|
finish();
|
||||||
SetupWizardUtils.sendResultsToSetupWizard(this, resultCode);
|
|
||||||
} else {
|
|
||||||
setResult(resultCode);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -223,7 +217,7 @@ public class WifiSetupActivity extends WifiPickerActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onNavigateNext() {
|
public void onNavigateNext() {
|
||||||
if (mWifiConnected) {
|
if (mWifiConnected) {
|
||||||
finishOrNext(RESULT_OK);
|
finish(RESULT_OK);
|
||||||
} else {
|
} else {
|
||||||
// Warn of possible data charges if there is a network connection, or lack of updates
|
// Warn of possible data charges if there is a network connection, or lack of updates
|
||||||
// if there is none.
|
// if there is none.
|
||||||
@@ -271,7 +265,7 @@ public class WifiSetupActivity extends WifiPickerActivity
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
WifiSetupActivity activity = (WifiSetupActivity) getActivity();
|
||||||
activity.finishOrNext(RESULT_SKIP);
|
activity.finish(RESULT_SKIP);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.wifi_dont_skip,
|
.setNegativeButton(R.string.wifi_dont_skip,
|
||||||
|
|||||||
Reference in New Issue
Block a user