summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/setupwizard
diff options
context:
space:
mode:
authorJoey Rizzoli <joey@lineageos.it>2016-12-29 17:28:02 +0100
committerAbhisek Devkota <ciwrl@lineageos.org>2017-01-14 18:36:57 -0800
commitd1331884a16916a36b16ca4d53d4c72d2bda6738 (patch)
tree3fe040402b001a5aa55b5bfd80a9089408158469 /src/com/cyanogenmod/setupwizard
parent65d6ac1299720f8cc8e40cc8cc875fe3da2337dd (diff)
downloadpackages_apps_SetupWizard-d1331884a16916a36b16ca4d53d4c72d2bda6738.tar.gz
packages_apps_SetupWizard-d1331884a16916a36b16ca4d53d4c72d2bda6738.tar.bz2
packages_apps_SetupWizard-d1331884a16916a36b16ca4d53d4c72d2bda6738.zip
SetupWizard: rebrand to LineageOS
* Rebrand UI * Add privacy guard to setup * Disable Cyngn inc MOD platform and account setup * Make privacy policy view-able again Change-Id: Iacd60886992ca72d3f75bb21a905d612432751fc Signed-off-by: Joey Rizzoli <joey@lineageos.it>
Diffstat (limited to 'src/com/cyanogenmod/setupwizard')
-rw-r--r--src/com/cyanogenmod/setupwizard/SetupWizardApp.java1
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java5
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java32
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java5
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java163
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java42
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/DateTimePage.java6
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/FingerprintSetupPage.java6
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/FinishPage.java54
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java6
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/LocalePage.java348
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java6
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java12
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/Page.java2
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/ScreenLockSetupPage.java14
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java7
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WelcomePage.java258
-rw-r--r--src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java5
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java12
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java20
-rw-r--r--src/com/cyanogenmod/setupwizard/ui/WebViewDialogFragment.java86
-rw-r--r--src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java9
22 files changed, 494 insertions, 605 deletions
diff --git a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java
index a327b38..f16dd9d 100644
--- a/src/com/cyanogenmod/setupwizard/SetupWizardApp.java
+++ b/src/com/cyanogenmod/setupwizard/SetupWizardApp.java
@@ -64,6 +64,7 @@ public class SetupWizardApp extends Application {
private static final String[] THEME_PACKAGES = {
"org.cyanogenmod.theme.chooser",
+ "org.cyanogenmod.theme.chooser2",
"com.cyngn.theme.chooser",
"com.cyngn.themestore"
};
diff --git a/src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java
index 915abec..d1532ac 100644
--- a/src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/BluetoothSetupPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -81,6 +82,10 @@ public class BluetoothSetupPage extends SetupPage {
return R.string.loading;
}
+ @Override
+ public int getIconResId() {
+ return -1;
+ }
@Override
public void doLoadAction(FragmentManager fragmentManager, int action) {
diff --git a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
index 7a20c58..3226044 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CMSetupWizardData.java
@@ -51,6 +51,8 @@ public class CMSetupWizardData extends AbstractSetupData {
pages.add(new BluetoothSetupPage(mContext, this));
}
pages.add(new WelcomePage(mContext, this));
+ pages.add(new LocalePage(mContext, this));
+ pages.add(new DateTimePage(mContext, this));
if (SetupWizardUtils.hasWifi(mContext)) {
pages.add(new WifiSetupPage(mContext, this));
}
@@ -70,19 +72,13 @@ public class CMSetupWizardData extends AbstractSetupData {
if (hasGMS) {
pages.add(new GmsAccountPage(mContext, this));
}
- if (!SetupWizardUtils.hasLeanback(mContext) &&
- SetupWizardUtils.isPackageInstalled(mContext,
- mContext.getString(R.string.cm_account_package_name))) {
- pages.add(new CyanogenServicesPage(mContext, this).setHidden(true));
- }
+ pages.add(new OtherSettingsPage(mContext, this).setHidden(!hasGMS));
if (SetupWizardUtils.hasFingerprint(mContext) && SetupWizardUtils.isOwner()) {
pages.add(new FingerprintSetupPage(mContext, this));
} else if (SetupWizardUtils.frpEnabled(mContext)) {
pages.add(new ScreenLockSetupPage(mContext, this));
}
pages.add(new CyanogenSettingsPage(mContext, this));
- pages.add(new OtherSettingsPage(mContext, this).setHidden(!hasGMS));
- pages.add(new DateTimePage(mContext, this));
pages.add(new FinishPage(mContext, this));
return new PageList(pages.toArray(new SetupPage[pages.size()]));
}
@@ -94,15 +90,13 @@ public class CMSetupWizardData extends AbstractSetupData {
showHideDataSimPage();
showHideSimMissingPage();
showHideMobileDataPage();
- updateWelcomePage();
+ updateLocalePage();
} else if (intent.getAction()
.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
showHideMobileDataPage();
- showHideAccountPages();
- } else if (intent.getAction()
+ } else if (intent.getAction()
.equals(TelephonyIntents.ACTION_ANY_DATA_CONNECTION_STATE_CHANGED)) {
showHideMobileDataPage();
- showHideAccountPages();
} else if (intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED) ||
intent.getAction().equals(TelephonyIntents.ACTION_NETWORK_SET_TIMEZONE)) {
mTimeZoneSet = true;
@@ -114,14 +108,6 @@ public class CMSetupWizardData extends AbstractSetupData {
}
}
- private void showHideAccountPages() {
- boolean isConnected = SetupWizardUtils.isNetworkConnected(mContext);
- CyanogenServicesPage cyanogenServicesPage =
- (CyanogenServicesPage) getPage(CyanogenServicesPage.TAG);
- if (cyanogenServicesPage != null) {
- cyanogenServicesPage.setHidden(!isConnected);
- }
- }
private void showHideSimMissingPage() {
SimCardMissingPage simCardMissingPage =
@@ -161,10 +147,10 @@ public class CMSetupWizardData extends AbstractSetupData {
}
}
- private void updateWelcomePage() {
- WelcomePage welcomePage = (WelcomePage) getPage(WelcomePage.TAG);
- if (welcomePage != null) {
- welcomePage.simChanged();
+ private void updateLocalePage() {
+ LocalePage localePage = (LocalePage) getPage(LocalePage.TAG);
+ if (localePage != null) {
+ localePage.simChanged();
}
}
diff --git a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
index adca459..3b9a5c9 100644
--- a/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/ChooseDataSimPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -85,6 +86,10 @@ public class ChooseDataSimPage extends SetupPage {
return R.string.setup_choose_data_sim;
}
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_sim;
+ }
public static class ChooseDataSimFragment extends SetupPageFragment {
diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java
deleted file mode 100644
index e71dd79..0000000
--- a/src/com/cyanogenmod/setupwizard/setup/CyanogenServicesPage.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (C) 2013 The CyanogenMod 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.cyanogenmod.setupwizard.setup;
-
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
-import android.accounts.AuthenticatorException;
-import android.accounts.OperationCanceledException;
-import android.app.Activity;
-import android.app.ActivityOptions;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.content.Context;
-import android.content.Intent;
-import android.os.Bundle;
-import android.util.Log;
-
-import com.cyanogenmod.setupwizard.R;
-import com.cyanogenmod.setupwizard.SetupWizardApp;
-import com.cyanogenmod.setupwizard.cmstats.SetupStats;
-import com.cyanogenmod.setupwizard.ui.LoadingFragment;
-import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
-
-import java.io.IOException;
-
-public class CyanogenServicesPage extends SetupPage {
-
- public static final String TAG = "CyanogenServicesPage";
-
- private Fragment mFragment;
-
- public CyanogenServicesPage(Context context, SetupDataCallbacks callbacks) {
- super(context, callbacks);
- }
-
- @Override
- public Fragment getFragment(FragmentManager fragmentManager, int action) {
- mFragment = fragmentManager.findFragmentByTag(getKey());
- if (mFragment == null) {
- Bundle args = new Bundle();
- args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
- args.putInt(Page.KEY_PAGE_ACTION, action);
- mFragment = new LoadingFragment();
- mFragment.setArguments(args);
- }
- return mFragment;
- }
-
- @Override
- public String getKey() {
- return TAG;
- }
-
- @Override
- public int getTitleResId() {
- return R.string.loading;
- }
-
- @Override
- public int getNextButtonTitleResId() {
- return R.string.skip;
- }
-
- @Override
- public void doLoadAction(FragmentManager fragmentManager, int action) {
- if (action == Page.ACTION_PREVIOUS) {
- getCallbacks().onPreviousPage();
- } else {
- if (!SetupWizardUtils.accountExists(mContext,
- mContext.getString(R.string.cm_account_type))) {
- super.doLoadAction(fragmentManager, action);
- launchCyanogenAccountSetup();
- } else {
- getCallbacks().onNextPage();
- }
- }
- }
-
- @Override
- public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
- if (requestCode == SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN) {
- if (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_FIRST_USER) {
- SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
- SetupStats.Action.EXTERNAL_PAGE_RESULT,
- SetupStats.Label.CYANOGEN_ACCOUNT,
- resultCode == Activity.RESULT_OK ? "success" : "skipped");
- if (SetupWizardUtils.accountExists(mContext,
- mContext.getString(R.string.cm_account_type))) {
- if (SetupWizardUtils.isDeviceLocked()) {
- ((SetupWizardApp) mContext.getApplicationContext()).setIsAuthorized(true);
- }
- setHidden(true);
- }
- getCallbacks().onNextPage();
- } else if (resultCode == Activity.RESULT_CANCELED) {
- SetupStats.addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
- SetupStats.Action.EXTERNAL_PAGE_RESULT,
- SetupStats.Label.CYANOGEN_ACCOUNT, "canceled");
- getCallbacks().onPreviousPage();
- }
- }
- return true;
- }
-
- private void launchCyanogenAccountSetup() {
- Bundle bundle = new Bundle();
- bundle.putBoolean(SetupWizardApp.EXTRA_FIRST_RUN, true);
- bundle.putBoolean(SetupWizardApp.EXTRA_SHOW_BUTTON_BAR, true);
- bundle.putBoolean(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
- AccountManager.get(mContext)
- .addAccount(mContext.getString(R.string.cm_account_type), null, null, bundle,
- null, new AccountManagerCallback<Bundle>() {
- @Override
- public void run(AccountManagerFuture<Bundle> future) {
- boolean error = false;
- try {
- Bundle result = future.getResult();
- Intent intent = result
- .getParcelable(AccountManager.KEY_INTENT);
- ActivityOptions options =
- ActivityOptions.makeCustomAnimation(mContext,
- android.R.anim.fade_in,
- android.R.anim.fade_out);
- SetupStats
- .addEvent(SetupStats.Categories.EXTERNAL_PAGE_LOAD,
- SetupStats.Action.EXTERNAL_PAGE_LAUNCH,
- SetupStats.Label.PAGE,
- SetupStats.Label.CYANOGEN_ACCOUNT);
- mFragment.startActivityForResult(intent,
- SetupWizardApp.REQUEST_CODE_SETUP_CYANOGEN,
- options.toBundle());
- } catch (OperationCanceledException e) {
- error = true;
- } catch (IOException e) {
- error = true;
- } catch (AuthenticatorException e) {
- Log.e(TAG, "Error launching cm account", e);
- error = true;
- } finally {
- if (error && getCallbacks().
- isCurrentPage(CyanogenServicesPage.this)) {
- getCallbacks().onNextPage();
- }
- }
- }
- }, null);
- }
-}
diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
index 03a04b6..866371d 100644
--- a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -58,8 +59,9 @@ public class CyanogenSettingsPage extends SetupPage {
public static final String DISABLE_NAV_KEYS = "disable_nav_keys";
public static final String KEY_APPLY_DEFAULT_THEME = "apply_default_theme";
public static final String KEY_BUTTON_BACKLIGHT = "pre_navbar_button_backlight";
+ public static final String KEY_PRIVACY_GUARD = "privacy_guard_default";
- public static final String PRIVACY_POLICY_URI = "https://cyngn.com/oobe-legal?hideHeader=1";
+ public static final String PRIVACY_POLICY_URI = "http://lineageos.org/legal";
public CyanogenSettingsPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
@@ -88,6 +90,11 @@ public class CyanogenSettingsPage extends SetupPage {
return R.string.setup_services;
}
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_features;
+ }
+
private static void writeDisableNavkeysOption(Context context, boolean enabled) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
@@ -126,6 +133,7 @@ public class CyanogenSettingsPage extends SetupPage {
});
handleEnableMetrics();
handleDefaultThemeSetup();
+ handlePrivacyGuard();
}
private void handleEnableMetrics() {
@@ -156,6 +164,15 @@ public class CyanogenSettingsPage extends SetupPage {
}
}
+ private void handlePrivacyGuard() {
+ Bundle mPrivacyData = getData();
+ if (mPrivacyData != null && mPrivacyData.containsKey(KEY_PRIVACY_GUARD)) {
+ CMSettings.Secure.putInt(mContext.getContentResolver(),
+ CMSettings.Secure.PRIVACY_GUARD_DEFAULT,
+ mPrivacyData.getBoolean(KEY_PRIVACY_GUARD) ? 1 : 0);
+ }
+ }
+
private static boolean hideKeyDisabler(Context ctx) {
final CMHardwareManager hardware = CMHardwareManager.getInstance(ctx);
return !hardware.isSupported(CMHardwareManager.FEATURE_KEY_DISABLE);
@@ -179,9 +196,11 @@ public class CyanogenSettingsPage extends SetupPage {
private View mMetricsRow;
private View mDefaultThemeRow;
private View mNavKeysRow;
+ private View mPrivacyGuardRow;
private CheckBox mMetrics;
private CheckBox mDefaultTheme;
private CheckBox mNavKeys;
+ private CheckBox mPrivacyGuard;
private boolean mHideNavKeysRow = false;
private boolean mHideThemeRow = false;
@@ -214,6 +233,15 @@ public class CyanogenSettingsPage extends SetupPage {
}
};
+ private View.OnClickListener mPrivacyGuardClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ boolean checked = !mPrivacyGuard.isChecked();
+ mPrivacyGuard.setChecked(checked);
+ mPage.getData().putBoolean(KEY_PRIVACY_GUARD, checked);
+ }
+ };
+
@Override
protected void initializePage() {
String privacy_policy = getString(R.string.services_privacy_policy);
@@ -222,8 +250,10 @@ public class CyanogenSettingsPage extends SetupPage {
ClickableSpan clickableSpan = new ClickableSpan() {
@Override
public void onClick(View textView) {
- final Intent intent = new Intent(SetupWizardApp.ACTION_VIEW_LEGAL);
- intent.setData(Uri.parse(PRIVACY_POLICY_URI));
+ // At this point of the setup, the device has already been unlocked (if frp
+ // had been enabled), so there should be no issues regarding security
+ final Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse(PRIVACY_POLICY_URI));
try {
getActivity().startActivity(intent);
} catch (Exception e) {
@@ -303,6 +333,12 @@ public class CyanogenSettingsPage extends SetupPage {
isKeyDisablerActive(getActivity());
mNavKeys.setChecked(navKeysDisabled);
}
+
+ mPrivacyGuardRow = mRootView.findViewById(R.id.privacy_guard);
+ mPrivacyGuardRow.setOnClickListener(mPrivacyGuardClickListener);
+ mPrivacyGuard = (CheckBox) mRootView.findViewById(R.id.privacy_guard_checkbox);
+ mPrivacyGuard.setChecked(CMSettings.Secure.getInt(getActivity().getContentResolver(),
+ CMSettings.Secure.PRIVACY_GUARD_DEFAULT, 0) == 1);
}
@Override
diff --git a/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java b/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java
index 7a5922b..f42240f 100644
--- a/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/DateTimePage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -96,6 +97,11 @@ public class DateTimePage extends SetupPage {
return R.string.setup_datetime;
}
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_datetime;
+ }
+
public static class DateTimeFragment extends SetupPageFragment
implements TimePickerDialog.OnTimeSetListener, DatePickerDialog.OnDateSetListener {
diff --git a/src/com/cyanogenmod/setupwizard/setup/FingerprintSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/FingerprintSetupPage.java
index 890a4f6..8d78127 100644
--- a/src/com/cyanogenmod/setupwizard/setup/FingerprintSetupPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/FingerprintSetupPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -68,6 +69,11 @@ public class FingerprintSetupPage extends SetupPage {
}
@Override
+ public int getIconResId() {
+ return R.drawable.ic_fingerprint;
+ }
+
+ @Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (SetupWizardApp.REQUEST_CODE_SETUP_FINGERPRINT == requestCode) {
if (resultCode == Activity.RESULT_OK) {
diff --git a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
index 3cb5a3f..2a7e0e7 100644
--- a/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/FinishPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -40,16 +41,12 @@ public class FinishPage extends SetupPage {
public static final String TAG = "FinishPage";
- private static final int WHAT_EXPLORE_MOD_GUIDE = 1;
private static final String KEY_MESSENGER = "key_messenger";
- private static final String MODGUIDE_PACKAGE_NAME = "com.cyngn.modguide";
private FinishFragment mFinishFragment;
- private final boolean mShowingModGuide;
public FinishPage(Context context, SetupDataCallbacks callbacks) {
super(context, callbacks);
- mShowingModGuide = SetupWizardUtils.canHasModMOD(context);
}
@Override
@@ -78,10 +75,6 @@ public class FinishPage extends SetupPage {
@Override
public void handleMessage(final Message msg) {
- final FinishPage page = mPage.get();
- if ((page != null) && (msg.what == WHAT_EXPLORE_MOD_GUIDE)) {
- page.doExploreModGuide();
- }
}
}
@@ -91,13 +84,13 @@ public class FinishPage extends SetupPage {
}
@Override
- public int getButtonBarBackgroundColorId() {
- return mShowingModGuide ? R.color.mod_button_bar_background : R.color.primary;
+ public int getTitleResId() {
+ return R.string.setup_complete;
}
@Override
- public int getTitleResId() {
- return R.string.setup_complete;
+ public int getIconResId() {
+ return -1;
}
@Override
@@ -106,55 +99,24 @@ public class FinishPage extends SetupPage {
return true;
}
- private void doExploreModGuide() {
- final SetupWizardActivity activity =
- (SetupWizardActivity) mFinishFragment.getActivity();
- final Intent intent =
- activity.getPackageManager().getLaunchIntentForPackage(MODGUIDE_PACKAGE_NAME);
- activity.setFinishIntent(intent);
- getCallbacks().onFinish();
- }
-
@Override
public int getNextButtonTitleResId() {
- return mShowingModGuide ? R.string.done : R.string.start;
+ return R.string.start;
}
public static class FinishFragment extends SetupPageFragment {
- private boolean mShowingModGuide;
-
@Override
protected void initializePage() {
final Activity activity = getActivity();
- if (!mShowingModGuide || (activity == null)) {
+ if (activity == null) {
return;
}
- mRootView.findViewById(R.id.explore_mod_guide)
- .setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- final Messenger messenger = getArguments().getParcelable(KEY_MESSENGER);
- if (messenger == null) {
- return;
- }
- final Message message = Message.obtain();
- message.what = WHAT_EXPLORE_MOD_GUIDE;
- try {
- messenger.send(message);
- } catch (final RemoteException e) {
- Log.e(TAG, "Couldn't send message to start MOD Guide", e);
- }
- }
- });
}
@Override
protected int getLayoutResource() {
- final Context context = getContext();
- mShowingModGuide = (context != null) && SetupWizardUtils.canHasModMOD(context);
- return mShowingModGuide ?
- R.layout.setup_modguide_page : R.layout.setup_finished_page;
+ return R.layout.setup_finished_page;
}
}
diff --git a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
index 436da08..747765e 100644
--- a/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/GmsAccountPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -92,6 +93,11 @@ public class GmsAccountPage extends SetupPage {
}
@Override
+ public int getIconResId() {
+ return -1;
+ }
+
+ @Override
public int getNextButtonTitleResId() {
return R.string.skip;
}
diff --git a/src/com/cyanogenmod/setupwizard/setup/LocalePage.java b/src/com/cyanogenmod/setupwizard/setup/LocalePage.java
new file mode 100644
index 0000000..e9717a5
--- /dev/null
+++ b/src/com/cyanogenmod/setupwizard/setup/LocalePage.java
@@ -0,0 +1,348 @@
+/*
+ * Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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 com.cyanogenmod.setupwizard.setup;
+
+import android.accounts.AccountManager;
+import android.accounts.AccountManagerCallback;
+import android.accounts.AccountManagerFuture;
+import android.app.Activity;
+import android.app.ActivityOptions;
+import android.app.Fragment;
+import android.app.FragmentManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.content.res.Resources;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.os.Handler;
+import android.telephony.SubscriptionInfo;
+import android.telephony.SubscriptionManager;
+import android.telephony.TelephonyManager;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.NumberPicker;
+import android.widget.Toast;
+
+import com.android.internal.telephony.MccTable;
+import com.cyanogenmod.setupwizard.R;
+import com.cyanogenmod.setupwizard.SetupWizardApp;
+import com.cyanogenmod.setupwizard.cmstats.SetupStats;
+import com.cyanogenmod.setupwizard.ui.LocalePicker;
+import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
+import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
+
+import java.util.List;
+import java.util.Locale;
+
+public class LocalePage extends SetupPage {
+
+ public static final String TAG = "LocalePage";
+
+ private LocaleFragment mLocaleFragment;
+
+ public LocalePage(Context context, SetupDataCallbacks callbacks) {
+ super(context, callbacks);
+ }
+
+ @Override
+ public Fragment getFragment(FragmentManager fragmentManager, int action) {
+ mLocaleFragment = (LocaleFragment)fragmentManager.findFragmentByTag(getKey());
+ if (mLocaleFragment == null) {
+ Bundle args = new Bundle();
+ args.putString(Page.KEY_PAGE_ARGUMENT, getKey());
+ args.putInt(Page.KEY_PAGE_ACTION, action);
+ mLocaleFragment = new LocaleFragment();
+ mLocaleFragment.setArguments(args);
+ }
+ return mLocaleFragment;
+ }
+
+ @Override
+ public int getTitleResId() {
+ return R.string.setup_locale;
+ }
+
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_locale;
+ }
+
+ @Override
+ public boolean doNextAction() {
+ if (isLocked()) {
+ confirmCyanogenCredentials(mLocaleFragment);
+ return true;
+ } else {
+ if (mLocaleFragment != null) {
+ mLocaleFragment.sendLocaleStats();
+ }
+ return super.doNextAction();
+ }
+ }
+
+ @Override
+ public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
+ if (requestCode == SetupWizardApp.REQUEST_CODE_UNLOCK) {
+ if (resultCode == Activity.RESULT_OK) {
+ ((SetupWizardApp) mContext.getApplicationContext()).setIsAuthorized(true);
+ getCallbacks().onNextPage();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String getKey() {
+ return TAG;
+ }
+
+ @Override
+ public int getNextButtonTitleResId() {
+ if (isLocked()) {
+ return R.string.setup_unlock;
+ } else {
+ return R.string.next;
+ }
+ }
+
+ private void confirmCyanogenCredentials(final Fragment fragment) {
+ AccountManager accountManager = AccountManager.get(mContext);
+ accountManager.editProperties(SetupWizardApp.ACCOUNT_TYPE_CYANOGEN, null,
+ new AccountManagerCallback<Bundle>() {
+ public void run(AccountManagerFuture<Bundle> f) {
+ try {
+ Bundle b = f.getResult();
+ Intent i = b.getParcelable(AccountManager.KEY_INTENT);
+ i.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
+ i.putExtra(SetupWizardApp.EXTRA_SHOW_BUTTON_BAR, true);
+ i.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
+ i.putExtra(SetupWizardApp.EXTRA_LOGIN_FOR_KILL_SWITCH, true);
+ fragment.startActivityForResult(i,
+ SetupWizardApp.REQUEST_CODE_UNLOCK);
+ } catch (Throwable t) {
+ Log.e(getKey(), "confirmCredentials failed", t);
+ }
+ }
+ }, null);
+ }
+
+ private boolean isLocked() {
+ boolean isAuthorized = ((SetupWizardApp) mContext.getApplicationContext()).isAuthorized();
+ if (SetupWizardUtils.isDeviceLocked()) {
+ return !isAuthorized;
+ }
+ return false;
+ }
+
+ public void simChanged() {
+ if (mLocaleFragment != null) {
+ mLocaleFragment.fetchAndUpdateSimLocale();
+ }
+ }
+
+ public static class LocaleFragment extends SetupPageFragment {
+
+ private ArrayAdapter<com.android.internal.app.LocalePicker.LocaleInfo> mLocaleAdapter;
+ private Locale mInitialLocale;
+ private Locale mCurrentLocale;
+ private int[] mAdapterIndices;
+ private boolean mIgnoreSimLocale;
+ private LocalePicker mLanguagePicker;
+ private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
+ private final Handler mHandler = new Handler();
+ private boolean mPendingLocaleUpdate;
+ private boolean mPaused = true;
+
+ private final Runnable mUpdateLocale = new Runnable() {
+ public void run() {
+ if (mCurrentLocale != null) {
+ mLanguagePicker.setEnabled(false);
+ com.android.internal.app.LocalePicker.updateLocale(mCurrentLocale);
+ }
+ }
+ };
+
+ @Override
+ protected void initializePage() {
+ mLanguagePicker = (LocalePicker) mRootView.findViewById(R.id.locale_list);
+ loadLanguages();
+ }
+
+ private void loadLanguages() {
+ mLocaleAdapter = com.android.internal.app.LocalePicker.constructAdapter(getActivity(),
+ R.layout.locale_picker_item, R.id.locale);
+ mCurrentLocale = mInitialLocale = Locale.getDefault();
+ fetchAndUpdateSimLocale();
+ mAdapterIndices = new int[mLocaleAdapter.getCount()];
+ int currentLocaleIndex = 0;
+ String [] labels = new String[mLocaleAdapter.getCount()];
+ for (int i=0; i<mAdapterIndices.length; i++) {
+ com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo =
+ mLocaleAdapter.getItem(i);
+ Locale localLocale = localLocaleInfo.getLocale();
+ if (localLocale.equals(mCurrentLocale)) {
+ currentLocaleIndex = i;
+ }
+ mAdapterIndices[i] = i;
+ labels[i] = localLocaleInfo.getLabel();
+ }
+ mLanguagePicker.setDisplayedValues(labels);
+ mLanguagePicker.setMaxValue(labels.length - 1);
+ mLanguagePicker.setValue(currentLocaleIndex);
+ mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
+ mLanguagePicker.setOnValueChangedListener(new LocalePicker.OnValueChangeListener() {
+ public void onValueChange(LocalePicker picker, int oldVal, int newVal) {
+ setLocaleFromPicker();
+ }
+ });
+ mLanguagePicker.setOnScrollListener(new LocalePicker.OnScrollListener() {
+ @Override
+ public void onScrollStateChange(LocalePicker view, int scrollState) {
+ if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
+ mIgnoreSimLocale = true;
+ }
+ }
+ });
+ }
+
+ private void setLocaleFromPicker() {
+ mIgnoreSimLocale = true;
+ int i = mAdapterIndices[mLanguagePicker.getValue()];
+ final com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i);
+ onLocaleChanged(localLocaleInfo.getLocale());
+ }
+
+ private void onLocaleChanged(Locale paramLocale) {
+ mLanguagePicker.setEnabled(true);
+ Resources localResources = getActivity().getResources();
+ Configuration localConfiguration1 = localResources.getConfiguration();
+ Configuration localConfiguration2 = new Configuration();
+ localConfiguration2.locale = paramLocale;
+ localResources.updateConfiguration(localConfiguration2, null);
+ localResources.updateConfiguration(localConfiguration1, null);
+ mHandler.removeCallbacks(mUpdateLocale);
+ mCurrentLocale = paramLocale;
+ mHandler.postDelayed(mUpdateLocale, 1000);
+ }
+
+ @Override
+ protected int getLayoutResource() {
+ return R.layout.setup_locale;
+ }
+
+ public void sendLocaleStats() {
+ if (!mCurrentLocale.equals(mInitialLocale)) {
+ SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
+ SetupStats.Action.CHANGE_LOCALE, SetupStats.Label.LOCALE,
+ mCurrentLocale.getDisplayName());
+ }
+ }
+
+ public void fetchAndUpdateSimLocale() {
+ if (mIgnoreSimLocale || isDetached()) {
+ return;
+ }
+ if (mPaused) {
+ mPendingLocaleUpdate = true;
+ return;
+ }
+ if (mFetchUpdateSimLocaleTask != null) {
+ mFetchUpdateSimLocaleTask.cancel(true);
+ }
+ mFetchUpdateSimLocaleTask = new FetchUpdateSimLocaleTask();
+ mFetchUpdateSimLocaleTask.execute();
+ }
+
+ private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
+ @Override
+ protected Locale doInBackground(Void... params) {
+ Locale locale = null;
+ Activity activity = getActivity();
+ if (activity != null) {
+ // If the sim is currently pin locked, return
+ TelephonyManager telephonyManager = (TelephonyManager)
+ activity.getSystemService(Context.TELEPHONY_SERVICE);
+ int state = telephonyManager.getSimState();
+ if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
+ state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
+ return null;
+ }
+
+ final SubscriptionManager subscriptionManager =
+ SubscriptionManager.from(activity);
+ List<SubscriptionInfo> activeSubs =
+ subscriptionManager.getActiveSubscriptionInfoList();
+ if (activeSubs == null || activeSubs.isEmpty()) {
+ return null;
+ }
+
+ // Fetch locale for active sim's MCC
+ int mcc = activeSubs.get(0).getMcc();
+ locale = MccTable.getLocaleFromMcc(activity, mcc, null);
+
+ // If that fails, fall back to preferred languages reported
+ // by the sim
+ if (locale == null) {
+ String localeString = telephonyManager.getLocaleFromDefaultSim();
+ if (localeString != null) {
+ locale = Locale.forLanguageTag(localeString);
+
+ }
+ }
+ }
+ return locale;
+ }
+
+ @Override
+ protected void onPostExecute(Locale simLocale) {
+ if (simLocale != null && !simLocale.equals(mCurrentLocale)) {
+ if (!mIgnoreSimLocale && !isDetached()) {
+ String label = getString(R.string.sim_locale_changed,
+ simLocale.getDisplayName());
+ Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
+ onLocaleChanged(simLocale);
+ mIgnoreSimLocale = true;
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ mPaused = true;
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ mPaused = false;
+ if (mLanguagePicker != null) {
+ mLanguagePicker.setEnabled(true);
+ }
+ if (mPendingLocaleUpdate) {
+ mPendingLocaleUpdate = false;
+ fetchAndUpdateSimLocale();
+ }
+ }
+ }
+
+}
diff --git a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
index 95d5912..f9a66e2 100644
--- a/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/MobileDataPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -75,6 +76,11 @@ public class MobileDataPage extends SetupPage {
return R.string.setup_mobile_data;
}
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_mobile_data;
+ }
+
public static class MobileDataFragment extends SetupPageFragment {
private ViewGroup mPageView;
diff --git a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
index 7ed23dc..5c0b91d 100644
--- a/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/OtherSettingsPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -62,11 +63,12 @@ public class OtherSettingsPage extends SetupPage {
@Override
public int getTitleResId() {
- if (SetupWizardUtils.hasGMS(mContext)) {
- return R.string.setup_other;
- } else {
- return R.string.setup_location;
- }
+ return R.string.setup_location;
+ }
+
+ @Override
+ public int getIconResId() {
+ return R.drawable.ic_location;
}
public static class OtherSettingsFragment extends SetupPageFragment {
diff --git a/src/com/cyanogenmod/setupwizard/setup/Page.java b/src/com/cyanogenmod/setupwizard/setup/Page.java
index 9e48a1b..da27485 100644
--- a/src/com/cyanogenmod/setupwizard/setup/Page.java
+++ b/src/com/cyanogenmod/setupwizard/setup/Page.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -31,6 +32,7 @@ public interface Page {
public String getKey();
public int getTitleResId();
+ public int getIconResId();
public int getButtonBarBackgroundColorId();
public int getPrevButtonTitleResId();
public int getNextButtonTitleResId();
diff --git a/src/com/cyanogenmod/setupwizard/setup/ScreenLockSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/ScreenLockSetupPage.java
index 3c9da33..abbb2de 100644
--- a/src/com/cyanogenmod/setupwizard/setup/ScreenLockSetupPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/ScreenLockSetupPage.java
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
- *
+ * Copyright (C) 2017 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
@@ -23,8 +24,8 @@ import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
+import android.widget.Button;
import android.view.View;
-import android.widget.TextView;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
@@ -67,6 +68,11 @@ public class ScreenLockSetupPage extends SetupPage {
}
@Override
+ public int getIconResId() {
+ return R.drawable.ic_lock_screen;
+ }
+
+ @Override
public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
if (SetupWizardApp.REQUEST_CODE_SETUP_LOCKSCREEN == requestCode) {
if (resultCode == Activity.RESULT_OK || resultCode == Activity.RESULT_FIRST_USER) {
@@ -78,11 +84,11 @@ public class ScreenLockSetupPage extends SetupPage {
public static class LockscreenSetupFragment extends SetupPageFragment {
- private TextView mSetupLockscreen;
+ private Button mSetupLockscreen;
@Override
protected void initializePage() {
- mSetupLockscreen = (TextView) mRootView.findViewById(R.id.setup_lockscreen);
+ mSetupLockscreen = (Button) mRootView.findViewById(R.id.setup_lockscreen);
mSetupLockscreen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
diff --git a/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java b/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java
index 36b4a32..b487f9a 100644
--- a/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/SimCardMissingPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2014 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -62,11 +63,15 @@ public class SimCardMissingPage extends SetupPage {
}
@Override
+ public int getIconResId() {
+ return R.drawable.ic_sim;
+ }
+
+ @Override
public int getNextButtonTitleResId() {
return R.string.skip;
}
-
public static class SimCardMissingFragment extends SetupPageFragment {
@Override
diff --git a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
index 460a0ac..2e63085 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WelcomePage.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -16,39 +16,19 @@
package com.cyanogenmod.setupwizard.setup;
-import android.accounts.AccountManager;
-import android.accounts.AccountManagerCallback;
-import android.accounts.AccountManagerFuture;
import android.app.Activity;
import android.app.ActivityOptions;
import android.app.Fragment;
import android.app.FragmentManager;
import android.content.Context;
import android.content.Intent;
-import android.content.res.Configuration;
import android.content.res.Resources;
-import android.os.AsyncTask;
import android.os.Bundle;
-import android.os.Handler;
-import android.telephony.SubscriptionInfo;
-import android.telephony.SubscriptionManager;
-import android.telephony.TelephonyManager;
-import android.util.Log;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.NumberPicker;
-import android.widget.Toast;
-import com.android.internal.telephony.MccTable;
import com.cyanogenmod.setupwizard.R;
import com.cyanogenmod.setupwizard.SetupWizardApp;
import com.cyanogenmod.setupwizard.cmstats.SetupStats;
-import com.cyanogenmod.setupwizard.ui.LocalePicker;
import com.cyanogenmod.setupwizard.ui.SetupPageFragment;
-import com.cyanogenmod.setupwizard.util.SetupWizardUtils;
-
-import java.util.List;
-import java.util.Locale;
public class WelcomePage extends SetupPage {
@@ -77,20 +57,17 @@ public class WelcomePage extends SetupPage {
@Override
public int getTitleResId() {
- return R.string.setup_welcome;
+ return R.string.os_name;
+ }
+
+ @Override
+ public int getIconResId() {
+ return -1;
}
@Override
public boolean doNextAction() {
- if (isLocked()) {
- confirmCyanogenCredentials(mWelcomeFragment);
- return true;
- } else {
- if (mWelcomeFragment != null) {
- mWelcomeFragment.sendLocaleStats();
- }
- return super.doNextAction();
- }
+ return super.doNextAction();
}
@Override
@@ -129,11 +106,7 @@ public class WelcomePage extends SetupPage {
@Override
public int getNextButtonTitleResId() {
- if (isLocked()) {
- return R.string.setup_unlock;
- } else {
- return R.string.next;
- }
+ return R.string.next;
}
@Override
@@ -141,229 +114,16 @@ public class WelcomePage extends SetupPage {
return R.string.emergency_call;
}
- private void confirmCyanogenCredentials(final Fragment fragment) {
- AccountManager accountManager = AccountManager.get(mContext);
- accountManager.editProperties(SetupWizardApp.ACCOUNT_TYPE_CYANOGEN, null,
- new AccountManagerCallback<Bundle>() {
- public void run(AccountManagerFuture<Bundle> f) {
- try {
- Bundle b = f.getResult();
- Intent i = b.getParcelable(AccountManager.KEY_INTENT);
- i.putExtra(SetupWizardApp.EXTRA_FIRST_RUN, true);
- i.putExtra(SetupWizardApp.EXTRA_SHOW_BUTTON_BAR, true);
- i.putExtra(SetupWizardApp.EXTRA_USE_IMMERSIVE, true);
- i.putExtra(SetupWizardApp.EXTRA_LOGIN_FOR_KILL_SWITCH, true);
- fragment.startActivityForResult(i,
- SetupWizardApp.REQUEST_CODE_UNLOCK);
- } catch (Throwable t) {
- Log.e(getKey(), "confirmCredentials failed", t);
- }
- }
- }, null);
- }
-
- private boolean isLocked() {
- boolean isAuthorized = ((SetupWizardApp) mContext.getApplicationContext()).isAuthorized();
- if (SetupWizardUtils.isDeviceLocked()) {
- return !isAuthorized;
- }
- return false;
- }
-
- public void simChanged() {
- if (mWelcomeFragment != null) {
- mWelcomeFragment.fetchAndUpdateSimLocale();
- }
- }
-
public static class WelcomeFragment extends SetupPageFragment {
- private ArrayAdapter<com.android.internal.app.LocalePicker.LocaleInfo> mLocaleAdapter;
- private Locale mInitialLocale;
- private Locale mCurrentLocale;
- private int[] mAdapterIndices;
- private boolean mIgnoreSimLocale;
- private LocalePicker mLanguagePicker;
- private FetchUpdateSimLocaleTask mFetchUpdateSimLocaleTask;
- private final Handler mHandler = new Handler();
- private boolean mPendingLocaleUpdate;
- private boolean mPaused = true;
-
- private final Runnable mUpdateLocale = new Runnable() {
- public void run() {
- if (mCurrentLocale != null) {
- mLanguagePicker.setEnabled(false);
- com.android.internal.app.LocalePicker.updateLocale(mCurrentLocale);
- }
- }
- };
-
@Override
protected void initializePage() {
- mLanguagePicker = (LocalePicker) mRootView.findViewById(R.id.locale_list);
- loadLanguages();
- final boolean brandedDevice = getResources().getBoolean(
- R.bool.branded_device);
- if (brandedDevice) {
- mRootView.findViewById(R.id.powered_by_logo).setVisibility(View.VISIBLE);
- }
- }
-
- private void loadLanguages() {
- mLocaleAdapter = com.android.internal.app.LocalePicker.constructAdapter(getActivity(), R.layout.locale_picker_item, R.id.locale);
- mCurrentLocale = mInitialLocale = Locale.getDefault();
- fetchAndUpdateSimLocale();
- mAdapterIndices = new int[mLocaleAdapter.getCount()];
- int currentLocaleIndex = 0;
- String [] labels = new String[mLocaleAdapter.getCount()];
- for (int i=0; i<mAdapterIndices.length; i++) {
- com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i);
- Locale localLocale = localLocaleInfo.getLocale();
- if (localLocale.equals(mCurrentLocale)) {
- currentLocaleIndex = i;
- }
- mAdapterIndices[i] = i;
- labels[i] = localLocaleInfo.getLabel();
- }
- mLanguagePicker.setDisplayedValues(labels);
- mLanguagePicker.setMaxValue(labels.length - 1);
- mLanguagePicker.setValue(currentLocaleIndex);
- mLanguagePicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
- mLanguagePicker.setOnValueChangedListener(new LocalePicker.OnValueChangeListener() {
- public void onValueChange(LocalePicker picker, int oldVal, int newVal) {
- setLocaleFromPicker();
- }
- });
- mLanguagePicker.setOnScrollListener(new LocalePicker.OnScrollListener() {
- @Override
- public void onScrollStateChange(LocalePicker view, int scrollState) {
- if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
- mIgnoreSimLocale = true;
- }
- }
- });
- }
-
- private void setLocaleFromPicker() {
- mIgnoreSimLocale = true;
- int i = mAdapterIndices[mLanguagePicker.getValue()];
- final com.android.internal.app.LocalePicker.LocaleInfo localLocaleInfo = mLocaleAdapter.getItem(i);
- onLocaleChanged(localLocaleInfo.getLocale());
- }
-
- private void onLocaleChanged(Locale paramLocale) {
- mLanguagePicker.setEnabled(true);
- Resources localResources = getActivity().getResources();
- Configuration localConfiguration1 = localResources.getConfiguration();
- Configuration localConfiguration2 = new Configuration();
- localConfiguration2.locale = paramLocale;
- localResources.updateConfiguration(localConfiguration2, null);
- localResources.updateConfiguration(localConfiguration1, null);
- mHandler.removeCallbacks(mUpdateLocale);
- mCurrentLocale = paramLocale;
- mHandler.postDelayed(mUpdateLocale, 1000);
}
@Override
protected int getLayoutResource() {
return R.layout.setup_welcome_page;
}
-
- public void sendLocaleStats() {
- if (!mCurrentLocale.equals(mInitialLocale)) {
- SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED,
- SetupStats.Action.CHANGE_LOCALE, SetupStats.Label.LOCALE,
- mCurrentLocale.getDisplayName());
- }
- }
-
- public void fetchAndUpdateSimLocale() {
- if (mIgnoreSimLocale || isDetached()) {
- return;
- }
- if (mPaused) {
- mPendingLocaleUpdate = true;
- return;
- }
- if (mFetchUpdateSimLocaleTask != null) {
- mFetchUpdateSimLocaleTask.cancel(true);
- }
- mFetchUpdateSimLocaleTask = new FetchUpdateSimLocaleTask();
- mFetchUpdateSimLocaleTask.execute();
- }
-
- private class FetchUpdateSimLocaleTask extends AsyncTask<Void, Void, Locale> {
- @Override
- protected Locale doInBackground(Void... params) {
- Locale locale = null;
- Activity activity = getActivity();
- if (activity != null) {
- // If the sim is currently pin locked, return
- TelephonyManager telephonyManager = (TelephonyManager)
- activity.getSystemService(Context.TELEPHONY_SERVICE);
- int state = telephonyManager.getSimState();
- if(state == TelephonyManager.SIM_STATE_PIN_REQUIRED ||
- state == TelephonyManager.SIM_STATE_PUK_REQUIRED) {
- return null;
- }
-
- final SubscriptionManager subscriptionManager =
- SubscriptionManager.from(activity);
- List<SubscriptionInfo> activeSubs =
- subscriptionManager.getActiveSubscriptionInfoList();
- if (activeSubs == null || activeSubs.isEmpty()) {
- return null;
- }
-
- // Fetch locale for active sim's MCC
- int mcc = activeSubs.get(0).getMcc();
- locale = MccTable.getLocaleFromMcc(activity, mcc, null);
-
- // If that fails, fall back to preferred languages reported
- // by the sim
- if (locale == null) {
- String localeString = telephonyManager.getLocaleFromDefaultSim();
- if (localeString != null) {
- locale = Locale.forLanguageTag(localeString);
-
- }
- }
- }
- return locale;
- }
-
- @Override
- protected void onPostExecute(Locale simLocale) {
- if (simLocale != null && !simLocale.equals(mCurrentLocale)) {
- if (!mIgnoreSimLocale && !isDetached()) {
- String label = getString(R.string.sim_locale_changed,
- simLocale.getDisplayName());
- Toast.makeText(getActivity(), label, Toast.LENGTH_SHORT).show();
- onLocaleChanged(simLocale);
- mIgnoreSimLocale = true;
- }
- }
- }
- }
-
- @Override
- public void onPause() {
- super.onPause();
- mPaused = true;
- }
-
- @Override
- public void onResume() {
- super.onResume();
- mPaused = false;
- if (mLanguagePicker != null) {
- mLanguagePicker.setEnabled(true);
- }
- if (mPendingLocaleUpdate) {
- mPendingLocaleUpdate = false;
- fetchAndUpdateSimLocale();
- }
- }
}
}
diff --git a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
index 2d8084a..051cbc3 100644
--- a/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
+++ b/src/com/cyanogenmod/setupwizard/setup/WifiSetupPage.java
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2013 The CyanogenMod Project
+ * Copyright (C) 2017 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.
@@ -146,6 +147,10 @@ public class WifiSetupPage extends SetupPage {
return R.string.loading;
}
+ @Override
+ public int getIconResId() {
+ return -1;
+ }
@Override
public void doLoadAction(FragmentManager fragmentManager, int action) {
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
index b0df440..2ec8e3a 100644
--- a/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
+++ b/src/com/cyanogenmod/setupwizard/ui/SetupPageFragment.java
@@ -23,6 +23,7 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.ImageView;
import android.widget.TextView;
import com.cyanogenmod.setupwizard.R;
@@ -37,6 +38,7 @@ public abstract class SetupPageFragment extends Fragment {
protected Page mPage;
protected View mRootView;
protected TextView mTitleView;
+ protected ImageView mIconView;
protected ViewGroup mHeaderView;
@Override
@@ -52,7 +54,8 @@ public abstract class SetupPageFragment extends Fragment {
Bundle savedInstanceState) {
mRootView = inflater.inflate(getLayoutResource(), container, false);
mTitleView = (TextView) mRootView.findViewById(android.R.id.title);
- mHeaderView = (ViewGroup ) mRootView.findViewById(R.id.header);
+ mHeaderView = (ViewGroup) mRootView.findViewById(R.id.header);
+ mIconView = (ImageView) mRootView.findViewById(R.id.header_icon);
initializePage();
return mRootView;
}
@@ -84,6 +87,13 @@ public abstract class SetupPageFragment extends Fragment {
if (mTitleView != null) {
mTitleView.setText(mPage.getTitleResId());
}
+ if (mIconView != null) {
+ int mResId = mPage.getIconResId();
+ if (mResId != -1) {
+ mIconView.setImageResource(mResId);
+ mIconView.setVisibility(View.VISIBLE);
+ }
+ }
mCallbacks.onPageLoaded(mPage);
getActivity().startPostponedEnterTransition();
}
diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
index cf56631..4782b36 100644
--- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
+++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java
@@ -287,21 +287,11 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks,
null, null, null);
}
final Resources resources = getResources();
- if (mSetupData.isLastPage()) {
- mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
- getDrawable(R.drawable.ic_chevron_right_wht), null);
- mNextButton.setTextColor(resources.getColor(R.color.white));
- mPrevButton.setCompoundDrawablesWithIntrinsicBounds(
- getDrawable(R.drawable.ic_chevron_left_wht), null,
- null, null);
- mPrevButton.setTextColor(resources.getColor(R.color.white));
- } else {
- mButtonBar.setBackgroundResource(R.color.button_bar_background);
- mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
- getDrawable(R.drawable.ic_chevron_right_dark), null);
- mNextButton.setTextColor(resources.getColorStateList(R.color.button_bar_text));
- mPrevButton.setTextColor(resources.getColorStateList(R.color.button_bar_text));
- }
+ mButtonBar.setBackgroundResource(R.color.button_bar_background);
+ mNextButton.setCompoundDrawablesWithIntrinsicBounds(null, null,
+ getDrawable(R.drawable.ic_chevron_right_dark), null);
+ mNextButton.setTextColor(resources.getColorStateList(R.color.button_bar_text));
+ mPrevButton.setTextColor(resources.getColorStateList(R.color.button_bar_text));
}
@Override
diff --git a/src/com/cyanogenmod/setupwizard/ui/WebViewDialogFragment.java b/src/com/cyanogenmod/setupwizard/ui/WebViewDialogFragment.java
deleted file mode 100644
index 46f22ae..0000000
--- a/src/com/cyanogenmod/setupwizard/ui/WebViewDialogFragment.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2013 The CyanogenMod 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.cyanogenmod.setupwizard.ui;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.view.View;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-
-import com.cyanogenmod.setupwizard.R;
-
-public class WebViewDialogFragment extends DialogFragment {
-
- public static String TAG = WebViewDialogFragment.class.getSimpleName();
-
- private View mRootView;
- private WebView mWebView;
- private String mUri;
- private Dialog mDialog;
-
- public static WebViewDialogFragment newInstance() {
- return new WebViewDialogFragment();
- }
-
- public WebViewDialogFragment() {
-
- }
-
- public WebViewDialogFragment setUri(String uri) {
- mUri = uri;
- return this;
- }
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setRetainInstance(true);
- mRootView = getActivity().getLayoutInflater().inflate(R.layout.terms_webview, null, false);
- mWebView = (WebView)mRootView.findViewById(R.id.webview);
- mWebView.setWebViewClient(new WebViewClient() {
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- return false;
- }
- });
- mWebView.getSettings().setJavaScriptEnabled(true);
- mWebView.getSettings().setUseWideViewPort(true);
- mWebView.loadUrl(mUri);
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- if (mDialog == null) {
- mDialog =new AlertDialog.Builder(getActivity())
- .setView(mRootView)
- .setCancelable(false)
- .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialogInterface, int i) {
- dialogInterface.dismiss();
- }
- })
- .create();
- }
- return mDialog;
- }
-}
-
diff --git a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
index 1b6a3ee..34961a9 100644
--- a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
+++ b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java
@@ -50,7 +50,6 @@ public class SetupWizardUtils {
private static final String TAG = SetupWizardUtils.class.getSimpleName();
public static final String GOOGLE_SETUPWIZARD_PACKAGE = "com.google.android.setupwizard";
- private static final String MODMOD_PACKAGE = "com.cyanogen.ambient.core";
private SetupWizardUtils(){}
@@ -203,14 +202,6 @@ public class SetupWizardUtils {
ConnectionResult.SERVICE_MISSING;
}
- /**
- * The assumption here is that if ambient core is present, we have MODs.
- * In the future we will link against the SDK and use the util there.
- */
- public static boolean canHasModMOD(Context context) {
- return isPackageInstalled(context, MODMOD_PACKAGE);
- }
-
public static boolean accountExists(Context context, String accountType) {
return AccountManager.get(context).getAccountsByType(accountType).length > 0;
}