Fix theme resolution in account preferences
BUG: 13341461 Change-Id: Idb42ad4026d63900b62f911782e07092216d906e
This commit is contained in:
@@ -71,7 +71,10 @@
|
|||||||
<item name="android:colorAccent">@color/quantum_orange_A200</item>
|
<item name="android:colorAccent">@color/quantum_orange_A200</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="Theme.Settings" parent="@android:style/Theme.Quantum.Light.DarkActionBar">
|
<!-- Theme with no local references, used by AccountPreferenceBase. -->
|
||||||
|
<style name="Theme.SettingsBase" parent="@android:style/Theme.Quantum.Light.DarkActionBar" />
|
||||||
|
|
||||||
|
<style name="Theme.Settings" parent="Theme.SettingsBase">
|
||||||
<item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
|
<item name="@*android:preferenceHeaderPanelStyle">@style/PreferenceHeaderPanelSinglePane</item>
|
||||||
<item name="@*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
|
<item name="@*android:preferencePanelStyle">@style/PreferencePanelSinglePane</item>
|
||||||
<item name="@*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
|
<item name="@*android:preferenceListStyle">@style/PreferenceHeaderListSinglePane</item>
|
||||||
|
@@ -22,6 +22,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.android.settings.SettingsPreferenceFragment;
|
import com.android.settings.SettingsPreferenceFragment;
|
||||||
|
|
||||||
import com.google.android.collect.Maps;
|
import com.google.android.collect.Maps;
|
||||||
|
|
||||||
import android.accounts.Account;
|
import android.accounts.Account;
|
||||||
@@ -35,12 +36,14 @@ import android.content.SyncAdapterType;
|
|||||||
import android.content.SyncStatusObserver;
|
import android.content.SyncStatusObserver;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.content.res.Resources.Theme;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.text.format.DateFormat;
|
import android.text.format.DateFormat;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.ContextThemeWrapper;
|
||||||
|
|
||||||
class AccountPreferenceBase extends SettingsPreferenceFragment
|
class AccountPreferenceBase extends SettingsPreferenceFragment
|
||||||
implements OnAccountsUpdateListener {
|
implements OnAccountsUpdateListener {
|
||||||
@@ -147,8 +150,19 @@ class AccountPreferenceBase extends SettingsPreferenceFragment
|
|||||||
try {
|
try {
|
||||||
desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
|
desc = mAuthenticatorHelper.getAccountTypeDescription(accountType);
|
||||||
if (desc != null && desc.accountPreferencesId != 0) {
|
if (desc != null && desc.accountPreferencesId != 0) {
|
||||||
Context authContext = getActivity().createPackageContext(desc.packageName, 0);
|
// Load the context of the target package, then apply the
|
||||||
prefs = getPreferenceManager().inflateFromResource(authContext,
|
// base Settings theme (no references to local resources)
|
||||||
|
// and create a context theme wrapper so that we get the
|
||||||
|
// correct text colors. Control colors will still be wrong,
|
||||||
|
// but there's not much we can do about it since we can't
|
||||||
|
// reference local color resources.
|
||||||
|
final Context targetCtx = getActivity().createPackageContext(
|
||||||
|
desc.packageName, 0);
|
||||||
|
final Theme baseTheme = getResources().newTheme();
|
||||||
|
baseTheme.applyStyle(com.android.settings.R.style.Theme_SettingsBase, true);
|
||||||
|
final Context themedCtx = new ContextThemeWrapper(targetCtx, 0);
|
||||||
|
themedCtx.getTheme().setTo(baseTheme);
|
||||||
|
prefs = getPreferenceManager().inflateFromResource(themedCtx,
|
||||||
desc.accountPreferencesId, parent);
|
desc.accountPreferencesId, parent);
|
||||||
}
|
}
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
Reference in New Issue
Block a user