diff --git a/Android.mk b/Android.mk
index 023e0c0031d..d6155470c16 100644
--- a/Android.mk
+++ b/Android.mk
@@ -10,6 +10,8 @@ LOCAL_SRC_FILES := \
$(call all-java-files-under, src) \
src/com/android/settings/EventLogTags.logtags
+LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res
+
LOCAL_PACKAGE_NAME := Settings
LOCAL_CERTIFICATE := platform
LOCAL_PRIVILEGED_MODULE := true
@@ -18,9 +20,11 @@ LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_AAPT_FLAGS += -c zz_ZZ
+include frameworks/opt/setupwizard/navigationbar/common.mk
+
include $(BUILD_PACKAGE)
-# Use the folloing include to make our test apk.
+# Use the following include to make our test apk.
ifeq (,$(ONE_SHOT_MAKEFILE))
include $(call all-makefiles-under,$(LOCAL_PATH))
endif
diff --git a/res/layout/setup_preference.xml b/res/layout/setup_preference.xml
index dc6130db4a2..195214fc587 100644
--- a/res/layout/setup_preference.xml
+++ b/res/layout/setup_preference.xml
@@ -16,177 +16,189 @@
** limitations under the License.
*/
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_width="match_parent">
-
-
-
-
+ android:layout_alignParentTop="true"
+ android:gravity="bottom">
-
-
+
+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/com/android/settings/wifi/WifiPickerActivity.java b/src/com/android/settings/wifi/WifiPickerActivity.java
index 4cb78bdda69..eec9963c97f 100644
--- a/src/com/android/settings/wifi/WifiPickerActivity.java
+++ b/src/com/android/settings/wifi/WifiPickerActivity.java
@@ -20,6 +20,7 @@ import com.android.settings.SettingsActivity;
import com.android.settings.wifi.p2p.WifiP2pSettings;
import android.content.Intent;
+import android.preference.PreferenceFragment;
import java.lang.Class;
@@ -36,13 +37,13 @@ public class WifiPickerActivity extends SettingsActivity implements ButtonBarHan
@Override
protected boolean isValidFragment(String fragmentName) {
- if (getWifiSettingsClass().getName().equals(fragmentName)
+ if (WifiSettings.class.getName().equals(fragmentName)
|| WifiP2pSettings.class.getName().equals(fragmentName)
|| AdvancedWifiSettings.class.getName().equals(fragmentName)) return true;
return false;
}
- /* package */ Class getWifiSettingsClass() {
+ /* package */ Class extends PreferenceFragment> getWifiSettingsClass() {
return WifiSettings.class;
}
}
\ No newline at end of file
diff --git a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
index 17fca9f84e8..325e1eb2ce8 100644
--- a/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
+++ b/src/com/android/settings/wifi/WifiSettingsForSetupWizard.java
@@ -17,11 +17,8 @@
package com.android.settings.wifi;
import android.app.Activity;
-import android.app.AlertDialog;
-import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
-import android.content.DialogInterface;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.TypedArray;
@@ -63,25 +60,9 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
// this boolean extra specifies whether to auto finish when connection is established
private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
- // this boolean extra shows a custom button that we can control
- protected static final String EXTRA_SHOW_CUSTOM_BUTTON = "wifi_show_custom_button";
-
// show a text regarding data charges when wifi connection is required during setup wizard
protected static final String EXTRA_SHOW_WIFI_REQUIRED_INFO = "wifi_show_wifi_required_info";
- // this boolean extra is set if we are being invoked by the Setup Wizard
- private static final String EXTRA_IS_FIRST_RUN = "firstRun";
-
- // Activity result when pressing the Skip button
- private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
-
- // From WizardManager (must match constants maintained there)
- private static final String ACTION_NEXT = "com.android.wizard.NEXT";
- private static final String EXTRA_SCRIPT_URI = "scriptUri";
- private static final String EXTRA_ACTION_ID = "actionId";
- private static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode";
- private static final int NEXT_REQUEST = 10000;
-
// should Next button only be enabled when we have a connection?
private boolean mEnableNextOnConnection;
@@ -105,7 +86,8 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
changeNextButtonState(info.isConnected());
if (mAutoFinishOnConnection && info.isConnected()) {
Log.d(TAG, "mReceiver.onReceive context=" + context + " intent=" + intent);
- finishOrNext(Activity.RESULT_OK);
+ WifiSetupActivity activity = (WifiSetupActivity) getActivity();
+ activity.finishOrNext(Activity.RESULT_OK);
}
}
};
@@ -150,36 +132,6 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
}
final Intent intent = getActivity().getIntent();
- if (intent.getBooleanExtra(EXTRA_SHOW_CUSTOM_BUTTON, false)) {
- view.findViewById(R.id.button_bar).setVisibility(View.VISIBLE);
- view.findViewById(R.id.back_button).setVisibility(View.INVISIBLE);
- view.findViewById(R.id.skip_button).setVisibility(View.INVISIBLE);
- view.findViewById(R.id.next_button).setVisibility(View.INVISIBLE);
-
- Button customButton = (Button) view.findViewById(R.id.custom_button);
- customButton.setVisibility(View.VISIBLE);
- customButton.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- boolean isConnected = false;
- Activity activity = getActivity();
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null) {
- final NetworkInfo info = connectivity.getActiveNetworkInfo();
- isConnected = (info != null) && info.isConnected();
- }
- if (isConnected) {
- // Warn of possible data charges
- showDialog(WIFI_SKIPPED_DIALOG_ID);
- } else {
- // Warn of lack of updates
- showDialog(WIFI_AND_MOBILE_SKIPPED_DIALOG_ID);
- }
- }
- });
- }
-
if (intent.getBooleanExtra(EXTRA_SHOW_WIFI_REQUIRED_INFO, false)) {
view.findViewById(R.id.wifi_required_info).setVisibility(View.VISIBLE);
}
@@ -197,30 +149,32 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
View.STATUS_BAR_DISABLE_NOTIFICATION_ALERTS |
View.STATUS_BAR_DISABLE_CLOCK);
- final Activity activity = getActivity();
+ final WifiSetupActivity activity = (WifiSetupActivity) getActivity();
final Intent intent = activity.getIntent();
// first if we're supposed to finish once we have a connection
mAutoFinishOnConnection = intent.getBooleanExtra(EXTRA_AUTO_FINISH_ON_CONNECT, false);
- /*
- * When entering with a savedInstanceState, we may be returning from a later activity in the
- * setup flow. It's not clear yet if there are other possible circumstances. It's not
- * appropriate to refire our activity results, so we skip that here.
- */
- if (mAutoFinishOnConnection && null == savedInstanceState) {
+ if (mAutoFinishOnConnection) {
// Hide the next button
if (hasNextButton()) {
getNextButton().setVisibility(View.GONE);
}
- final ConnectivityManager connectivity = (ConnectivityManager)
- activity.getSystemService(Context.CONNECTIVITY_SERVICE);
- if (connectivity != null
- && connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) {
- Log.d(TAG, "onActivityCreated Auto-finishing");
- finishOrNext(Activity.RESULT_OK);
- return;
+ /*
+ * When entering with a savedInstanceState, we may be returning from a later activity in
+ * the setup flow. It's not clear yet if there are other possible circumstances. It's
+ * not appropriate to refire our activity results, so we skip that here.
+ */
+ if (savedInstanceState == null) {
+ final ConnectivityManager connectivity = (ConnectivityManager)
+ activity.getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null &&
+ connectivity.getNetworkInfo(ConnectivityManager.TYPE_WIFI).isConnected()) {
+ Log.d(TAG, "onActivityCreated Auto-finishing");
+ activity.finishOrNext(Activity.RESULT_OK);
+ return;
+ }
}
}
@@ -241,49 +195,6 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
}
}
- @Override
- public Dialog onCreateDialog(int dialogId) {
- switch (dialogId) {
- case WIFI_SKIPPED_DIALOG_ID:
- return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.wifi_skipped_message)
- .setCancelable(false)
- .setNegativeButton(R.string.wifi_skip_anyway,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- finishOrNext(RESULT_SKIP);
- }
- })
- .setPositiveButton(R.string.wifi_dont_skip,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- }
- })
- .create();
- case WIFI_AND_MOBILE_SKIPPED_DIALOG_ID:
- return new AlertDialog.Builder(getActivity())
- .setMessage(R.string.wifi_and_mobile_skipped_message)
- .setCancelable(false)
- .setNegativeButton(R.string.wifi_skip_anyway,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- finishOrNext(RESULT_SKIP);
- }
- })
- .setPositiveButton(R.string.wifi_dont_skip,
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int id) {
- }
- })
- .create();
- }
- return super.onCreateDialog(dialogId);
- }
-
@Override
public void onResume() {
super.onResume();
@@ -296,24 +207,6 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
getActivity().unregisterReceiver(mReceiver);
}
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == Activity.RESULT_CANCELED) {
- // Before returning to the settings panel, forget any current access point so it will
- // not attempt to automatically reconnect and advance
- // FIXME: when coming back, it would be better to keep the current connection and
- // override the auto-advance feature
- final WifiInfo info = mWifiManager.getConnectionInfo();
- if (null != info) {
- int netId = info.getNetworkId();
- if (netId != WifiConfiguration.INVALID_NETWORK_ID) {
- mWifiManager.forget(netId, null);
- }
- }
- }
- super.onActivityResult(requestCode, resultCode, data);
- }
-
@Override
public void registerForContextMenu(View view) {
// Suppressed during setup wizard
@@ -359,39 +252,4 @@ public class WifiSettingsForSetupWizard extends WifiSettings {
getNextButton().setEnabled(enabled);
}
}
-
- /**
- * Complete this activity and return the results to the caller. If using WizardManager, this
- * will invoke the next scripted action; otherwise, we simply finish.
- */
- private void finishOrNext(int resultCode) {
- Log.d(TAG, "finishOrNext resultCode=" + resultCode
- + " isUsingWizardManager=" + isUsingWizardManager());
- if (isUsingWizardManager()) {
- sendResultsToSetupWizard(resultCode);
- } else {
- Activity activity = getActivity();
- activity.setResult(resultCode);
- activity.finish();
- }
- }
-
- private boolean isUsingWizardManager() {
- return getActivity().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.
- */
- private void sendResultsToSetupWizard(int resultCode) {
- final Intent intent = getActivity().getIntent();
- final Intent nextIntent = new Intent(ACTION_NEXT);
- nextIntent.putExtra(EXTRA_SCRIPT_URI, intent.getStringExtra(EXTRA_SCRIPT_URI));
- nextIntent.putExtra(EXTRA_ACTION_ID, intent.getStringExtra(EXTRA_ACTION_ID));
- nextIntent.putExtra(EXTRA_RESULT_CODE, resultCode);
- startActivityForResult(nextIntent, NEXT_REQUEST);
- }
}
diff --git a/src/com/android/settings/wifi/WifiSetupActivity.java b/src/com/android/settings/wifi/WifiSetupActivity.java
index d4811edc65d..8e4ff481b0a 100644
--- a/src/com/android/settings/wifi/WifiSetupActivity.java
+++ b/src/com/android/settings/wifi/WifiSetupActivity.java
@@ -15,37 +15,210 @@
*/
package com.android.settings.wifi;
-import com.android.settings.ButtonBarHandler;
-
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.DialogFragment;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.Color;
+import android.net.ConnectivityManager;
+import android.net.NetworkInfo;
+import android.net.wifi.WifiConfiguration;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import android.util.Log;
-import java.lang.Class;
+import com.android.settings.ButtonBarHandler;
+import com.android.settings.R;
+import com.android.setupwizard.navigationbar.SetupWizardNavBar;
+import com.android.setupwizard.navigationbar.SetupWizardNavBar.NavigationBarListener;
+
+public class WifiSetupActivity extends WifiPickerActivity
+ implements ButtonBarHandler, NavigationBarListener {
+ private static final String TAG = "WifiSetupActivity";
+
+ private static final String EXTRA_ALLOW_SKIP = "allowSkip";
+ private static final String EXTRA_USE_IMMERSIVE_MODE = "useImmersiveMode";
+
+ // this boolean extra shows a custom button that we can control
+ protected static final String EXTRA_SHOW_CUSTOM_BUTTON = "wifi_show_custom_button";
-public class WifiSetupActivity extends WifiPickerActivity implements ButtonBarHandler {
// Extra containing the resource name of the theme to be used
private static final String EXTRA_THEME = "theme";
private static final String THEME_HOLO = "holo";
private static final String THEME_HOLO_LIGHT = "holo_light";
+ private static final String THEME_MATERIAL = "material";
+ private static final String THEME_MATERIAL_LIGHT = "material_light";
- // Style resources containing theme settings
- private static final String RESOURCE_THEME_DARK = "SetupWizardWifiTheme";
- private static final String RESOURCE_THEME_LIGHT = "SetupWizardWifiTheme.Light";
+ // Activity result when pressing the Skip button
+ private static final int RESULT_SKIP = Activity.RESULT_FIRST_USER;
+
+ // From WizardManager (must match constants maintained there)
+ private static final String ACTION_NEXT = "com.android.wizard.NEXT";
+ private static final String EXTRA_SCRIPT_URI = "scriptUri";
+ private static final String EXTRA_ACTION_ID = "actionId";
+ private static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode";
+ private static final int NEXT_REQUEST = 10000;
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
String themeName = getIntent().getStringExtra(EXTRA_THEME);
- if (THEME_HOLO_LIGHT.equalsIgnoreCase(themeName)) {
- resid = getResources().getIdentifier(RESOURCE_THEME_LIGHT, "style",
- getPackageName());
- } else if (THEME_HOLO.equalsIgnoreCase(themeName)) {
- resid = getResources().getIdentifier(RESOURCE_THEME_DARK, "style",
- getPackageName());
+ if (THEME_HOLO_LIGHT.equalsIgnoreCase(themeName) ||
+ THEME_MATERIAL_LIGHT.equalsIgnoreCase(themeName)) {
+ resid = R.style.SetupWizardWifiTheme_Light;
+ } else if (THEME_HOLO.equalsIgnoreCase(themeName) ||
+ THEME_MATERIAL.equalsIgnoreCase(themeName)) {
+ resid = R.style.SetupWizardWifiTheme;
}
super.onApplyThemeResource(theme, resid, first);
}
@Override
- /* package */ Class getWifiSettingsClass() {
+ protected boolean isValidFragment(String fragmentName) {
+ return WifiSettingsForSetupWizard.class.getName().equals(fragmentName);
+ }
+
+ @Override
+ /* package */ Class extends PreferenceFragment> getWifiSettingsClass() {
return WifiSettingsForSetupWizard.class;
}
+
+ @Override
+ public void onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (resultCode == Activity.RESULT_CANCELED) {
+ // Before returning to the settings panel, forget any current access point so it will
+ // not attempt to automatically reconnect and advance
+ // FIXME: when coming back, it would be better to keep the current connection and
+ // override the auto-advance feature
+ final WifiManager wifiManager = (WifiManager)(getSystemService(Context.WIFI_SERVICE));
+ if (wifiManager != null) {
+ final WifiInfo info = wifiManager.getConnectionInfo();
+ if (info != null) {
+ int netId = info.getNetworkId();
+ if (netId != WifiConfiguration.INVALID_NETWORK_ID) {
+ wifiManager.forget(netId, null);
+ }
+ }
+ }
+ }
+ super.onActivityResult(requestCode, resultCode, data);
+ }
+
+ /**
+ * Complete this activity and return the results to the caller. If using WizardManager, this
+ * will invoke the next scripted action; otherwise, we simply finish.
+ */
+ public void finishOrNext(int resultCode) {
+ Log.d(TAG, "finishOrNext resultCode=" + resultCode
+ + " isUsingWizardManager=" + isUsingWizardManager());
+ if (isUsingWizardManager()) {
+ sendResultsToSetupWizard(resultCode);
+ } else {
+ setResult(resultCode);
+ finish();
+ }
+ }
+
+ private boolean isUsingWizardManager() {
+ return 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.
+ */
+ private void sendResultsToSetupWizard(int resultCode) {
+ final Intent intent = getIntent();
+ final Intent nextIntent = new Intent(ACTION_NEXT);
+ nextIntent.putExtra(EXTRA_SCRIPT_URI, intent.getStringExtra(EXTRA_SCRIPT_URI));
+ nextIntent.putExtra(EXTRA_ACTION_ID, intent.getStringExtra(EXTRA_ACTION_ID));
+ nextIntent.putExtra(EXTRA_RESULT_CODE, resultCode);
+ startActivityForResult(nextIntent, NEXT_REQUEST);
+ }
+
+ @Override
+ public void onNavigationBarCreated(final SetupWizardNavBar bar) {
+ final boolean useImmersiveMode =
+ getIntent().getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false);
+ bar.setUseImmersiveMode(useImmersiveMode);
+ if (useImmersiveMode) {
+ getWindow().setNavigationBarColor(Color.TRANSPARENT);
+ getWindow().setStatusBarColor(Color.TRANSPARENT);
+ }
+ getIntent().putExtra(EXTRA_SHOW_CUSTOM_BUTTON, false);
+ bar.getNextButton().setText(R.string.skip_label);
+
+ if (!getIntent().getBooleanExtra(EXTRA_ALLOW_SKIP, true)) {
+ bar.getNextButton().setEnabled(false);
+ }
+ }
+
+ @Override
+ public void onNavigateBack() {
+ onBackPressed();
+ }
+
+ @Override
+ public void onNavigateNext() {
+ boolean isConnected = false;
+ final ConnectivityManager connectivity = (ConnectivityManager)
+ getSystemService(Context.CONNECTIVITY_SERVICE);
+ if (connectivity != null) {
+ final NetworkInfo info = connectivity.getActiveNetworkInfo();
+ isConnected = (info != null) && info.isConnected();
+ }
+ if (isConnected) {
+ // Warn of possible data charges
+ WifiSkipDialog.newInstance(R.string.wifi_skipped_message)
+ .show(getFragmentManager(), "dialog");
+ } else {
+ // Warn of lack of updates
+ WifiSkipDialog.newInstance(R.string.wifi_and_mobile_skipped_message)
+ .show(getFragmentManager(), "dialog");
+ }
+ }
+
+ private static class WifiSkipDialog extends DialogFragment {
+ public static WifiSkipDialog newInstance(int messageRes) {
+ final Bundle args = new Bundle();
+ args.putInt("messageRes", messageRes);
+ final WifiSkipDialog dialog = new WifiSkipDialog();
+ dialog.setArguments(args);
+ return dialog;
+ }
+
+ public WifiSkipDialog() {
+ // no-arg constructor for fragment
+ }
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+ int messageRes = getArguments().getInt("messageRes");
+ return new AlertDialog.Builder(getActivity())
+ .setMessage(messageRes)
+ .setCancelable(false)
+ .setNegativeButton(R.string.wifi_skip_anyway,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ WifiSetupActivity activity = (WifiSetupActivity) getActivity();
+ activity.finishOrNext(RESULT_SKIP);
+ }
+ })
+ .setPositiveButton(R.string.wifi_dont_skip,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int id) {
+ }
+ })
+ .create();
+ }
+ }
}