android:exported="false"
android:windowSoftInputMode="stateVisible|adjustResize"/>
+ <activity android:name="SetupChooseLockGeneric"
+ android:taskAffinity="com.android.wizard"
+ android:theme="@style/SetupWizardDisableAppStartingTheme"
+ android:label="@string/lockpassword_choose_lock_generic_header">
+ <intent-filter>
+ <action android:name="com.android.settings.SETUP_LOCK_SCREEN" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ </activity>
+
<activity android:name="ChooseLockGeneric"
android:label="@string/lockpassword_choose_lock_generic_header"
android:excludeFromRecents="true" >
<item name="android:windowBackground">@null</item>
</style>
- <style name="SetupWizardWifiTheme" parent="android:Theme.Material.NoActionBar">
+ <style name="SetupWizardTheme" parent="android:Theme.Material.NoActionBar">
<item name="android:alertDialogTheme">@style/Theme.WifiDialog</item>
<item name="android:colorAccent">@color/setup_wizard_color_accent_dark</item>
<item name="android:listPreferredItemPaddingEnd">@dimen/setup_wizard_margin_sides</item>
<item name="preferenceBackgroundColor">?android:attr/colorBackground</item>
</style>
- <style name="SetupWizardWifiTheme.Light" parent="android:Theme.Material.Light.NoActionBar">
+ <style name="SetupWizardTheme.Light" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:alertDialogTheme">@style/Theme.Light.WifiDialog</item>
<item name="android:colorAccent">@color/setup_wizard_color_accent_light</item>
<item name="android:listPreferredItemPaddingEnd">@dimen/setup_wizard_margin_sides</item>
import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.ActivityManagerNative;
+import android.app.Fragment;
import android.app.PendingIntent;
import android.app.admin.DevicePolicyManager;
import android.content.Context;
@Override
public Intent getIntent() {
Intent modIntent = new Intent(super.getIntent());
- modIntent.putExtra(EXTRA_SHOW_FRAGMENT, ChooseLockGenericFragment.class.getName());
+ modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
return modIntent;
}
return false;
}
+ /* package */ Class<? extends Fragment> getFragmentClass() {
+ return ChooseLockGenericFragment.class;
+ }
+
public static class InternalActivity extends ChooseLockGeneric {
}
--- /dev/null
+/*
+ * Copyright (C) 2014 The Android Open Source 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 com.android.settings;
+
+import com.android.setupwizard.navigationbar.SetupWizardNavBar;
+
+
+import android.content.res.Resources;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListView;
+
+public class SetupChooseLockGeneric extends ChooseLockGeneric
+ implements SetupWizardNavBar.NavigationBarListener {
+
+ @Override
+ protected boolean isValidFragment(String fragmentName) {
+ return SetupChooseLockGenericFragment.class.getName().equals(fragmentName);
+ }
+
+ @Override
+ /* package */ Class<? extends PreferenceFragment> getFragmentClass() {
+ return SetupChooseLockGenericFragment.class;
+ }
+
+ @Override
+ protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
+ resid = SetupWizardUtils.getTheme(getIntent(), resid);
+ super.onApplyThemeResource(theme, resid, first);
+ }
+
+ @Override
+ public void onNavigationBarCreated(SetupWizardNavBar bar) {
+ SetupWizardUtils.setImmersiveMode(this, bar);
+ bar.getNextButton().setEnabled(false);
+ }
+
+ @Override
+ public void onNavigateBack() {
+ onBackPressed();
+ }
+
+ @Override
+ public void onNavigateNext() {
+ }
+
+ public static class SetupChooseLockGenericFragment extends ChooseLockGenericFragment {
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ final View view = inflater.inflate(R.layout.setup_preference, container, false);
+ ListView list = (ListView) view.findViewById(android.R.id.list);
+ View title = view.findViewById(R.id.title);
+ if (title == null) {
+ final View header = inflater.inflate(R.layout.setup_wizard_header, list, false);
+ list.addHeaderView(header, null, false);
+ }
+ return view;
+ }
+
+ @Override
+ public void onViewCreated(View view, Bundle savedInstanceState) {
+ super.onViewCreated(view, savedInstanceState);
+ SetupWizardUtils.setHeaderText(getActivity(), getActivity().getTitle());
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2014 The Android Open Source 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 com.android.settings;
+
+import com.android.setupwizard.navigationbar.SetupWizardNavBar;
+
+
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Color;
+import android.view.Window;
+import android.widget.TextView;
+
+public class SetupWizardUtils {
+ private static final String TAG = "SetupWizardUtils";
+
+ // Extra containing the resource name of the theme to be used
+ public static final String EXTRA_THEME = "theme";
+ public static final String THEME_HOLO = "holo";
+ public static final String THEME_HOLO_LIGHT = "holo_light";
+ public static final String THEME_MATERIAL = "material";
+ public static final String THEME_MATERIAL_LIGHT = "material_light";
+
+ public static final String EXTRA_USE_IMMERSIVE_MODE = "useImmersiveMode";
+
+ // From WizardManager (must match constants maintained there)
+ public static final String ACTION_NEXT = "com.android.wizard.NEXT";
+ public static final String EXTRA_SCRIPT_URI = "scriptUri";
+ public static final String EXTRA_ACTION_ID = "actionId";
+ public static final String EXTRA_RESULT_CODE = "com.android.setupwizard.ResultCode";
+ public static final int NEXT_REQUEST = 10000;
+
+ public static boolean isUsingWizardManager(Activity activity) {
+ 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 = 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_THEME, intent.getStringExtra(EXTRA_THEME));
+ nextIntent.putExtra(EXTRA_RESULT_CODE, resultCode);
+ activity.startActivityForResult(nextIntent, NEXT_REQUEST);
+ }
+
+ public static int getTheme(Intent intent, int defaultResId) {
+ final String themeName = intent.getStringExtra(EXTRA_THEME);
+ int resid = defaultResId;
+ if (THEME_HOLO_LIGHT.equalsIgnoreCase(themeName) ||
+ THEME_MATERIAL_LIGHT.equalsIgnoreCase(themeName)) {
+ resid = R.style.SetupWizardTheme_Light;
+ } else if (THEME_HOLO.equalsIgnoreCase(themeName) ||
+ THEME_MATERIAL.equalsIgnoreCase(themeName)) {
+ resid = R.style.SetupWizardTheme;
+ }
+ return resid;
+ }
+
+ /**
+ * Sets the immersive mode related flags based on the extra in the intent which started the
+ * activity.
+ */
+ public static void setImmersiveMode(Activity activity, SetupWizardNavBar navBar) {
+ final boolean useImmersiveMode =
+ activity.getIntent().getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false);
+ navBar.setUseImmersiveMode(useImmersiveMode);
+ if (useImmersiveMode) {
+ final Window window = activity.getWindow();
+ window.setNavigationBarColor(Color.TRANSPARENT);
+ window.setStatusBarColor(Color.TRANSPARENT);
+ }
+ }
+
+ public static TextView getHeader(Activity activity) {
+ return (TextView) activity.findViewById(R.id.title);
+ }
+
+ public static void setHeaderText(Activity activity, int text) {
+ getHeader(activity).setText(text);
+ }
+
+ public static void setHeaderText(Activity activity, CharSequence text) {
+ getHeader(activity).setText(text);
+ }
+}
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
-import android.graphics.Color;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.WifiManager;
import com.android.settings.ButtonBarHandler;
import com.android.settings.R;
+import com.android.settings.SetupWizardUtils;
import com.android.setupwizard.navigationbar.SetupWizardNavBar;
import com.android.setupwizard.navigationbar.SetupWizardNavBar.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 specifies whether to auto finish when connection is established
private static final String EXTRA_AUTO_FINISH_ON_CONNECT = "wifi_auto_finish_on_connect";
private static final String EXTRA_REQUIRE_USER_NETWORK_SELECTION =
"wifi_require_user_network_selection";
- // 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";
-
// Key for whether the user selected network in saved instance state bundle
private static final String PARAM_USER_SELECTED_NETWORK = "userSelectedNetwork";
// 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;
-
// Whether we allow skipping without a valid network connection
private boolean mAllowSkip = true;
// Whether to auto finish when the user selected a network and successfully connected
@Override
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
- String themeName = getIntent().getStringExtra(EXTRA_THEME);
- 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;
- }
+ resid = SetupWizardUtils.getTheme(getIntent(), resid);
super.onApplyThemeResource(theme, resid, first);
}
*/
public void finishOrNext(int resultCode) {
Log.d(TAG, "finishOrNext resultCode=" + resultCode
- + " isUsingWizardManager=" + isUsingWizardManager());
- if (isUsingWizardManager()) {
- sendResultsToSetupWizard(resultCode);
+ + " isUsingWizardManager=" + SetupWizardUtils.isUsingWizardManager(this));
+ if (SetupWizardUtils.isUsingWizardManager(this)) {
+ SetupWizardUtils.sendResultsToSetupWizard(this, 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_THEME, intent.getStringExtra(EXTRA_THEME));
- nextIntent.putExtra(EXTRA_RESULT_CODE, resultCode);
- startActivityForResult(nextIntent, NEXT_REQUEST);
- }
-
@Override
public void onNavigationBarCreated(final SetupWizardNavBar bar) {
mNavigationBar = bar;
- final boolean useImmersiveMode =
- getIntent().getBooleanExtra(EXTRA_USE_IMMERSIVE_MODE, false);
- bar.setUseImmersiveMode(useImmersiveMode);
- if (useImmersiveMode) {
- getWindow().setNavigationBarColor(Color.TRANSPARENT);
- getWindow().setStatusBarColor(Color.TRANSPARENT);
- }
+ SetupWizardUtils.setImmersiveMode(this, bar);
}
@Override