diff options
author | d34d <clark@cyngn.com> | 2016-01-25 11:19:15 -0800 |
---|---|---|
committer | Gerrit Code Review <gerrit@cyanogenmod.org> | 2016-01-28 08:04:18 -0800 |
commit | 06aa3eb165a5fd24472adb80c89add8632fa6b31 (patch) | |
tree | d103a38a35f4a12f887bf28efaec43e5e158fabd | |
parent | 578df09d02a967e9fbf39eb51ef510445872a099 (diff) | |
download | packages_apps_SetupWizard-06aa3eb165a5fd24472adb80c89add8632fa6b31.zip packages_apps_SetupWizard-06aa3eb165a5fd24472adb80c89add8632fa6b31.tar.gz packages_apps_SetupWizard-06aa3eb165a5fd24472adb80c89add8632fa6b31.tar.bz2 |
Themes: Re-enable applying theme in OOBE
Change-Id: I0b027bff18c3b33fc0a925ee756766ed31740b35
TICKET: OPO-361
-rw-r--r-- | AndroidManifest.xml | 2 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java | 25 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java | 21 | ||||
-rw-r--r-- | src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java | 22 |
4 files changed, 47 insertions, 23 deletions
diff --git a/AndroidManifest.xml b/AndroidManifest.xml index ce37eb3..cd4aa14 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -78,7 +78,7 @@ android:label="@string/product_name" android:launchMode="singleInstance" android:excludeFromRecents="true" - android:configChanges="mcc|mnc" + android:configChanges="mcc|mnc|themeChange" android:immersive="true" android:windowSoftInputMode="stateAlwaysHidden"> diff --git a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java index 6184055..de0b284 100644 --- a/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java +++ b/src/com/cyanogenmod/setupwizard/setup/CyanogenSettingsPage.java @@ -24,14 +24,13 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -/*import android.content.pm.ThemeUtils; +import android.content.pm.ThemeUtils; import android.content.res.ThemeConfig; -import android.content.res.ThemeManager;*/ +import android.content.res.ThemeManager; import android.net.Uri; import android.os.Bundle; import android.os.RemoteException; import android.preference.PreferenceManager; -import android.provider.Settings; import android.text.Spannable; import android.text.SpannableString; import android.text.SpannableStringBuilder; @@ -178,9 +177,10 @@ public class CyanogenSettingsPage extends SetupPage { } private void handleDefaultThemeSetup() { - /*Bundle privacyData = getData(); - if (!ThemeUtils.getDefaultThemePackageName(mContext).equals(ThemeConfig.SYSTEM_DEFAULT) && - privacyData != null && privacyData.getBoolean(KEY_APPLY_DEFAULT_THEME)) { + Bundle privacyData = getData(); + if (!SetupWizardUtils.getDefaultThemePackageName(mContext).equals( + ThemeConfig.SYSTEM_DEFAULT) && privacyData != null && + privacyData.getBoolean(KEY_APPLY_DEFAULT_THEME)) { SetupStats.addEvent(SetupStats.Categories.SETTING_CHANGED, SetupStats.Action.APPLY_CUSTOM_THEME, SetupStats.Label.CHECKED, @@ -189,9 +189,9 @@ public class CyanogenSettingsPage extends SetupPage { final ThemeManager tm = (ThemeManager) mContext.getSystemService(Context.THEME_SERVICE); tm.applyDefaultTheme(); - } else { */ + } else { getCallbacks().finishSetup(); - //} + } } private static boolean hideKeyDisabler(Context ctx) { @@ -221,9 +221,10 @@ public class CyanogenSettingsPage extends SetupPage { SetupWizardUtils.isSimMissing(context)); } - /*private static boolean hideThemeSwitch(Context context) { - return ThemeUtils.getDefaultThemePackageName(context).equals(ThemeConfig.SYSTEM_DEFAULT); - }*/ + private static boolean hideThemeSwitch(Context context) { + return SetupWizardUtils.getDefaultThemePackageName(context) + .equals(ThemeConfig.SYSTEM_DEFAULT); + } public static class CyanogenSettingsFragment extends SetupPageFragment { @@ -333,7 +334,7 @@ public class CyanogenSettingsPage extends SetupPage { mMetrics = (CheckBox) mRootView.findViewById(R.id.enable_metrics_checkbox); mDefaultThemeRow = mRootView.findViewById(R.id.theme); - mHideThemeRow = true; // hideThemeSwitch(getActivity()); + mHideThemeRow = hideThemeSwitch(getActivity()); if (mHideThemeRow) { mDefaultThemeRow.setVisibility(View.GONE); } else { diff --git a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java index 81121fa..37eadbb 100644 --- a/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java +++ b/src/com/cyanogenmod/setupwizard/ui/SetupWizardActivity.java @@ -23,7 +23,7 @@ import android.content.Context; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Resources; -/*import android.content.res.ThemeManager;*/ +import android.content.res.ThemeManager; import android.graphics.Bitmap; import android.graphics.Point; import android.os.AsyncTask; @@ -52,7 +52,8 @@ import com.cyanogenmod.setupwizard.util.SetupWizardUtils; import java.util.ArrayList; -public class SetupWizardActivity extends Activity implements SetupDataCallbacks { +public class SetupWizardActivity extends Activity implements SetupDataCallbacks, + ThemeManager.ThemeChangeListener { private static final String TAG = SetupWizardActivity.class.getSimpleName(); @@ -305,12 +306,12 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks mFinishingProgressBar.setVisibility(View.VISIBLE); mFinishingProgressBar.setIndeterminate(true); mFinishingProgressBar.startAnimation(fadeIn); - /*final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE); - tm.addClient(this);*/ + final ThemeManager tm = (ThemeManager) getSystemService(Context.THEME_SERVICE); + tm.addClient(this); mSetupData.finishPages(); } - /*@Override + @Override public void onFinish(boolean isSuccess) { if (isResumed()) { mHandler.post(new Runnable() { @@ -320,15 +321,15 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks } }); } - }*/ + } - /*@Override + @Override public void onProgress(int progress) { if (progress > 0) { mFinishingProgressBar.setIndeterminate(false); mFinishingProgressBar.setProgress(progress); } - }*/ + } @Override public void finishSetup() { @@ -421,9 +422,9 @@ public class SetupWizardActivity extends Activity implements SetupDataCallbacks if (mEnableAccessibilityController != null) { mEnableAccessibilityController.onDestroy(); } - /*final ThemeManager tm = + final ThemeManager tm = (ThemeManager) SetupWizardActivity.this.getSystemService(THEME_SERVICE); - tm.removeClient(SetupWizardActivity.this);*/ + tm.removeClient(SetupWizardActivity.this); SetupStats.sendEvents(SetupWizardActivity.this); SetupWizardUtils.disableGMSSetupWizard(SetupWizardActivity.this); final WallpaperManager wallpaperManager = diff --git a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java index 67671d3..e72080f 100644 --- a/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java +++ b/src/com/cyanogenmod/setupwizard/util/SetupWizardUtils.java @@ -35,6 +35,7 @@ import android.service.persistentdata.PersistentDataBlockManager; import android.telephony.ServiceState; import android.telephony.SubscriptionManager; import android.telephony.TelephonyManager; +import android.text.TextUtils; import android.util.Log; /*import com.android.internal.os.IKillSwitchService;*/ @@ -42,6 +43,9 @@ import com.cyanogenmod.setupwizard.SetupWizardApp; import com.google.android.gms.common.ConnectionResult; import com.google.android.gms.common.GooglePlayServicesUtil; +import cyanogenmod.providers.CMSettings; + +import static android.content.res.ThemeConfig.SYSTEM_DEFAULT; public class SetupWizardUtils { @@ -293,6 +297,24 @@ public class SetupWizardUtils { return fingerprintManager.isHardwareDetected(); } + public static String getDefaultThemePackageName(Context context) { + final String defaultThemePkg = CMSettings.Secure.getString(context.getContentResolver(), + CMSettings.Secure.DEFAULT_THEME_PACKAGE); + if (!TextUtils.isEmpty(defaultThemePkg)) { + PackageManager pm = context.getPackageManager(); + try { + if (pm.getPackageInfo(defaultThemePkg, 0) != null) { + return defaultThemePkg; + } + } catch (PackageManager.NameNotFoundException e) { + // doesn't exist so system will be default + Log.w(TAG, "Default theme " + defaultThemePkg + " not found"); + } + } + + return SYSTEM_DEFAULT; + } + public static final ComponentName mTvwifisettingsActivity = new ComponentName("com.android.tv.settings", "com.android.tv.settings.connectivity.setup.WifiSetupActivity"); |