Themes: Re-enable applying theme in OOBE

Change-Id: I0b027bff18c3b33fc0a925ee756766ed31740b35
TICKET: OPO-361
This commit is contained in:
d34d 2016-01-25 11:19:15 -08:00 committed by Gerrit Code Review
parent 578df09d02
commit 06aa3eb165
4 changed files with 47 additions and 23 deletions

View File

@ -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">

View File

@ -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 {

View File

@ -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 =

View File

@ -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");