Use system day/night to switch theme instead of from intent extra.
Use value-night to give theme instead of directly from intent extra when Setup day/nNight mode enabled and in Setup flow Before: <vision settings> https://hsv.googleplex.com/4837266235064320 <wifi dialog> https://hsv.googleplex.com/5687053981319168 <lock screen with disabling button> https://hsv.googleplex.com/4843506419892224 <lock screen with enabling button> https://hsv.googleplex.com/5650348922372096 <fingerprint intro> https://hsv.googleplex.com/5133769046491136 <fingerprint touch> https://hsv.googleplex.com/5681937198874624 <fingerprint left touch> https://hsv.googleplex.com/5767441676238848 <squeeze release> https://hsv.googleplex.com/6632476812247040 After: <vision settings> https://hsv.googleplex.com/6213298875793408 <wifi dialog> https://hsv.googleplex.com/6025790804197376 <lock screen with disabling button> https://hsv.googleplex.com/5747461219942400 <lock screen with enabling button> https://hsv.googleplex.com/5766700781797376 <fingerprint intro> https://hsv.googleplex.com/6751334529236992 <fingerprint touch> https://hsv.googleplex.com/5625963293442048 <fingerprint left touch> https://hsv.googleplex.com/4518139360444416 <squeeze release> https://hsv.googleplex.com/5220720579706880 Bug: 169734655 Test: robo test Change-Id: I4aab843e28a932c7b823f36f1d8df1e5b2341f4e
This commit is contained in:
28
res/values-night/themes_suw.xml
Normal file
28
res/values-night/themes_suw.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
Copyright (C) 2020 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.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- SUW related themes -->
|
||||||
|
<resources>
|
||||||
|
<!-- DayNight themes -->
|
||||||
|
<style name="GlifTheme.DayNight" parent="GlifTheme" />
|
||||||
|
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme" />
|
||||||
|
<style name="GlifV3Theme.DayNight" parent="GlifV3Theme" />
|
||||||
|
<style name="GlifV2Theme.DayNight.Transparent" parent="GlifV2Theme.Transparent" />
|
||||||
|
<style name="GlifV3Theme.DayNight.Transparent" parent="GlifV3Theme.Transparent" />
|
||||||
|
<style name="SetupWizardTheme.DayNight.Transparent" parent="SetupWizardTheme.Transparent" />
|
||||||
|
<style name="SuwAlertDialogThemeCompat.DayNight" parent="SuwAlertDialogThemeCompat" />
|
||||||
|
</resources>
|
@@ -211,4 +211,13 @@
|
|||||||
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
<item name="colorAccent">@*android:color/accent_device_default_light</item>
|
||||||
<item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
|
<item name="dialogCornerRadius">@*android:dimen/config_dialogCornerRadius</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- DayNight themes -->
|
||||||
|
<style name="GlifTheme.DayNight" parent="GlifTheme.Light" />
|
||||||
|
<style name="GlifV2Theme.DayNight" parent="GlifV2Theme.Light" />
|
||||||
|
<style name="GlifV3Theme.DayNight" parent="GlifV3Theme.Light" />
|
||||||
|
<style name="GlifV2Theme.DayNight.Transparent" parent="GlifV2Theme.Light.Transparent" />
|
||||||
|
<style name="GlifV3Theme.DayNight.Transparent" parent="GlifV3Theme.Light.Transparent" />
|
||||||
|
<style name="SetupWizardTheme.DayNight.Transparent" parent="SetupWizardTheme.Light.Transparent" />
|
||||||
|
<style name="SuwAlertDialogThemeCompat.DayNight" parent="SuwAlertDialogThemeCompat.Light" />
|
||||||
</resources>
|
</resources>
|
@@ -62,8 +62,8 @@ public class EncryptionInterstitial extends SettingsActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_FIRST_RUN;
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_FIRST_RUN;
|
||||||
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SETUP_FLOW;
|
import static com.google.android.setupcompat.util.WizardManagerHelper.EXTRA_IS_SETUP_FLOW;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.sysprop.SetupWizardProperties;
|
import android.sysprop.SetupWizardProperties;
|
||||||
@@ -39,12 +40,25 @@ public class SetupWizardUtils {
|
|||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTheme(Intent intent) {
|
public static int getTheme(Context context, Intent intent) {
|
||||||
String theme = getThemeString(intent);
|
String theme = getThemeString(intent);
|
||||||
// TODO(yukl): Move to ThemeResolver and add any additional required attributes in
|
// TODO(yukl): Move to ThemeResolver and add any additional required attributes in
|
||||||
// onApplyThemeResource using Theme overlays
|
// onApplyThemeResource using Theme overlays
|
||||||
if (theme != null) {
|
if (theme != null) {
|
||||||
if (WizardManagerHelper.isAnySetupWizard(intent)) {
|
if (WizardManagerHelper.isAnySetupWizard(intent)) {
|
||||||
|
if (ThemeHelper.isSetupWizardDayNightEnabled(context)) {
|
||||||
|
switch (theme) {
|
||||||
|
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF_V3:
|
||||||
|
return R.style.GlifV3Theme_DayNight;
|
||||||
|
case ThemeHelper.THEME_GLIF_V2_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF_V2:
|
||||||
|
return R.style.GlifV2Theme_DayNight;
|
||||||
|
case ThemeHelper.THEME_GLIF_LIGHT:
|
||||||
|
case ThemeHelper.THEME_GLIF:
|
||||||
|
return R.style.GlifTheme_DayNight;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
||||||
return R.style.GlifV3Theme_Light;
|
return R.style.GlifV3Theme_Light;
|
||||||
@@ -59,6 +73,7 @@ public class SetupWizardUtils {
|
|||||||
case ThemeHelper.THEME_GLIF:
|
case ThemeHelper.THEME_GLIF:
|
||||||
return R.style.GlifTheme;
|
return R.style.GlifTheme;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (theme) {
|
switch (theme) {
|
||||||
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
case ThemeHelper.THEME_GLIF_V3_LIGHT:
|
||||||
@@ -76,17 +91,30 @@ public class SetupWizardUtils {
|
|||||||
return R.style.GlifTheme;
|
return R.style.GlifTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getTransparentTheme(Intent intent) {
|
public static int getTransparentTheme(Context context, Intent intent) {
|
||||||
final int suwTheme = getTheme(intent);
|
int transparentTheme;
|
||||||
int transparentTheme = R.style.GlifV2Theme_Light_Transparent;
|
final int suwTheme = getTheme(context, intent);
|
||||||
if (suwTheme == R.style.GlifV3Theme) {
|
if (ThemeHelper.isSetupWizardDayNightEnabled(context)) {
|
||||||
transparentTheme = R.style.GlifV3Theme_Transparent;
|
transparentTheme = R.style.GlifV2Theme_DayNight_Transparent;
|
||||||
|
} else {
|
||||||
|
transparentTheme = R.style.GlifV2Theme_Light_Transparent;
|
||||||
|
}
|
||||||
|
if (suwTheme == R.style.GlifV3Theme_DayNight) {
|
||||||
|
transparentTheme = R.style.GlifV3Theme_DayNight_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifV3Theme_Light) {
|
} else if (suwTheme == R.style.GlifV3Theme_Light) {
|
||||||
transparentTheme = R.style.GlifV3Theme_Light_Transparent;
|
transparentTheme = R.style.GlifV3Theme_Light_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifV2Theme) {
|
} else if (suwTheme == R.style.GlifV2Theme_DayNight) {
|
||||||
transparentTheme = R.style.GlifV2Theme_Transparent;
|
transparentTheme = R.style.GlifV2Theme_DayNight_Transparent;
|
||||||
|
} else if (suwTheme == R.style.GlifV2Theme_Light) {
|
||||||
|
transparentTheme = R.style.GlifV2Theme_Light_Transparent;
|
||||||
|
} else if (suwTheme == R.style.GlifTheme_DayNight) {
|
||||||
|
transparentTheme = R.style.SetupWizardTheme_DayNight_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifTheme_Light) {
|
} else if (suwTheme == R.style.GlifTheme_Light) {
|
||||||
transparentTheme = R.style.SetupWizardTheme_Light_Transparent;
|
transparentTheme = R.style.SetupWizardTheme_Light_Transparent;
|
||||||
|
} else if (suwTheme == R.style.GlifV3Theme) {
|
||||||
|
transparentTheme = R.style.GlifV3Theme_Transparent;
|
||||||
|
} else if (suwTheme == R.style.GlifV2Theme) {
|
||||||
|
transparentTheme = R.style.GlifV2Theme_Transparent;
|
||||||
} else if (suwTheme == R.style.GlifTheme) {
|
} else if (suwTheme == R.style.GlifTheme) {
|
||||||
transparentTheme = R.style.SetupWizardTheme_Transparent;
|
transparentTheme = R.style.SetupWizardTheme_Transparent;
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
package com.android.settings.accessibility;
|
package com.android.settings.accessibility;
|
||||||
|
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
@@ -122,4 +123,11 @@ public class AccessibilitySettingsForSetupWizardActivity extends SettingsActivit
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
|
theme.applyStyle(R.style.SetupWizardPartnerResource, true);
|
||||||
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -203,9 +203,9 @@ public class BiometricEnrollActivity extends InstrumentedActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
theme.applyStyle(R.style.SetupWizardPartnerResource, true);
|
theme.applyStyle(R.style.SetupWizardPartnerResource, true);
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -116,9 +116,9 @@ public abstract class BiometricEnrollBase extends InstrumentedActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
theme.applyStyle(R.style.SetupWizardPartnerResource, true);
|
theme.applyStyle(R.style.SetupWizardPartnerResource, true);
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -62,8 +62,8 @@ public class RedactionInterstitial extends SettingsActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -105,8 +105,8 @@ public class ChooseLockPassword extends SettingsActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IntentBuilder {
|
public static class IntentBuilder {
|
||||||
|
@@ -94,8 +94,8 @@ public class ChooseLockPattern extends SettingsActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class IntentBuilder {
|
public static class IntentBuilder {
|
||||||
|
@@ -64,14 +64,14 @@ public abstract class ConfirmDeviceCredentialBaseActivity extends SettingsActivi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
|
if (UserManager.get(this).isManagedProfile(credentialOwnerUserId)) {
|
||||||
setTheme(SetupWizardUtils.getTheme(getIntent()));
|
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||||
mConfirmCredentialTheme = ConfirmCredentialTheme.WORK;
|
mConfirmCredentialTheme = ConfirmCredentialTheme.WORK;
|
||||||
} else if (getIntent().getBooleanExtra(
|
} else if (getIntent().getBooleanExtra(
|
||||||
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
|
ConfirmDeviceCredentialBaseFragment.DARK_THEME, false)) {
|
||||||
setTheme(R.style.Theme_ConfirmDeviceCredentialsDark);
|
setTheme(R.style.Theme_ConfirmDeviceCredentialsDark);
|
||||||
mConfirmCredentialTheme = ConfirmCredentialTheme.DARK;
|
mConfirmCredentialTheme = ConfirmCredentialTheme.DARK;
|
||||||
} else {
|
} else {
|
||||||
setTheme(SetupWizardUtils.getTheme(getIntent()));
|
setTheme(SetupWizardUtils.getTheme(this, getIntent()));
|
||||||
mConfirmCredentialTheme = ConfirmCredentialTheme.NORMAL;
|
mConfirmCredentialTheme = ConfirmCredentialTheme.NORMAL;
|
||||||
}
|
}
|
||||||
super.onCreate(savedState);
|
super.onCreate(savedState);
|
||||||
|
@@ -31,7 +31,6 @@ import android.os.UserHandle;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
@@ -42,8 +41,6 @@ import com.android.internal.widget.LockPatternUtils;
|
|||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
import com.android.settings.SetupEncryptionInterstitial;
|
import com.android.settings.SetupEncryptionInterstitial;
|
||||||
import com.android.settings.SetupWizardUtils;
|
import com.android.settings.SetupWizardUtils;
|
||||||
import com.android.settings.biometrics.BiometricEnrollActivity;
|
|
||||||
import com.android.settings.biometrics.fingerprint.SetupFingerprintEnrollFindSensor;
|
|
||||||
import com.android.settings.utils.SettingsDividerItemDecoration;
|
import com.android.settings.utils.SettingsDividerItemDecoration;
|
||||||
|
|
||||||
import com.google.android.setupdesign.GlifPreferenceLayout;
|
import com.google.android.setupdesign.GlifPreferenceLayout;
|
||||||
@@ -72,8 +69,8 @@ public class SetupChooseLockGeneric extends ChooseLockGeneric {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -45,6 +45,7 @@ import com.android.wifitrackerlib.NetworkDetailsTracker;
|
|||||||
import com.android.wifitrackerlib.WifiEntry;
|
import com.android.wifitrackerlib.WifiEntry;
|
||||||
|
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
|
|
||||||
import java.time.Clock;
|
import java.time.Clock;
|
||||||
import java.time.ZoneOffset;
|
import java.time.ZoneOffset;
|
||||||
@@ -105,7 +106,7 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
mIntent = getIntent();
|
mIntent = getIntent();
|
||||||
if (WizardManagerHelper.isSetupWizardIntent(mIntent)) {
|
if (WizardManagerHelper.isSetupWizardIntent(mIntent)) {
|
||||||
setTheme(SetupWizardUtils.getTransparentTheme(mIntent));
|
setTheme(SetupWizardUtils.getTransparentTheme(this, mIntent));
|
||||||
}
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
@@ -151,13 +152,16 @@ public class WifiDialogActivity extends ObservableActivity implements WifiDialog
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||||
|
final int targetStyle = ThemeHelper.isSetupWizardDayNightEnabled(this)
|
||||||
|
? R.style.SuwAlertDialogThemeCompat_DayNight :
|
||||||
|
R.style.SuwAlertDialogThemeCompat_Light;
|
||||||
if (mIsWifiTrackerLib) {
|
if (mIsWifiTrackerLib) {
|
||||||
mDialog2 = WifiDialog2.createModal(this, this,
|
mDialog2 = WifiDialog2.createModal(this, this,
|
||||||
mNetworkDetailsTracker.getWifiEntry(),
|
mNetworkDetailsTracker.getWifiEntry(),
|
||||||
WifiConfigUiBase2.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
|
WifiConfigUiBase2.MODE_CONNECT, targetStyle);
|
||||||
} else {
|
} else {
|
||||||
mDialog = WifiDialog.createModal(this, this, mAccessPoint,
|
mDialog = WifiDialog.createModal(this, this, mAccessPoint,
|
||||||
WifiConfigUiBase.MODE_CONNECT, R.style.SuwAlertDialogThemeCompat_Light);
|
WifiConfigUiBase.MODE_CONNECT, targetStyle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (mIsWifiTrackerLib) {
|
if (mIsWifiTrackerLib) {
|
||||||
|
@@ -45,8 +45,8 @@ abstract class WifiDppBaseActivity extends InstrumentedActivity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
|
||||||
resid = SetupWizardUtils.getTheme(getIntent());
|
final int new_resid = SetupWizardUtils.getTheme(this, getIntent());
|
||||||
theme.applyStyle(R.style.SetupWizardPartnerResource, /* force */ true);
|
theme.applyStyle(R.style.SetupWizardPartnerResource, /* force */ true);
|
||||||
super.onApplyThemeResource(theme, resid, first);
|
super.onApplyThemeResource(theme, new_resid, first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,20 +18,42 @@ package com.android.settings;
|
|||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
|
|
||||||
|
import android.content.ContentProvider;
|
||||||
|
import android.content.ContentValues;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.sysprop.SetupWizardProperties;
|
import android.sysprop.SetupWizardProperties;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.test.core.app.ApplicationProvider;
|
||||||
|
|
||||||
|
import com.google.android.setupcompat.partnerconfig.PartnerConfigHelper;
|
||||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||||
import com.google.android.setupdesign.util.ThemeHelper;
|
import com.google.android.setupdesign.util.ThemeHelper;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricTestRunner;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
public class SetupWizardUtilsTest {
|
public class SetupWizardUtilsTest {
|
||||||
|
|
||||||
|
private Context mContext;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
PartnerConfigHelper.resetInstance();
|
||||||
|
mContext = ApplicationProvider.getApplicationContext();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopySetupExtras() {
|
public void testCopySetupExtras() {
|
||||||
Intent fromIntent = new Intent();
|
Intent fromIntent = new Intent();
|
||||||
@@ -66,12 +88,13 @@ public class SetupWizardUtilsTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_withIntentExtra_shouldReturnExtraTheme() {
|
public void testGetTheme_withIntentExtra_shouldReturnTheme() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF);
|
||||||
Intent intent = createSetupWizardIntent();
|
Intent intent = createSetupWizardIntent();
|
||||||
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme);
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV2Theme);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -79,26 +102,109 @@ public class SetupWizardUtilsTest {
|
|||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
Intent intent = createSetupWizardIntent();
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV2Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV2Theme_Light);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_glifV3Light_shouldReturnThemeResource() {
|
public void testGetTheme_whenSuwDayNightEnabledAndWithIntentExtra_shouldReturnDayNightTheme() {
|
||||||
|
FakePartnerContentProvider provider =
|
||||||
|
Robolectric.setupContentProvider(
|
||||||
|
FakePartnerContentProvider.class, "com.google.android.setupwizard.partner");
|
||||||
|
provider.injectFakeDayNightEnabledResult(true);
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
intent.putExtra(WizardManagerHelper.EXTRA_THEME, ThemeHelper.THEME_GLIF_V2);
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV2Theme_DayNight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_glifV3Light_shouldReturnLightTheme() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
||||||
Intent intent = createSetupWizardIntent();
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme_Light);
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
assertThat(SetupWizardUtils.getTransparentTheme(intent))
|
.isEqualTo(R.style.GlifV3Theme_Light);
|
||||||
|
assertThat(SetupWizardUtils.getTransparentTheme(mContext, intent))
|
||||||
.isEqualTo(R.style.GlifV3Theme_Light_Transparent);
|
.isEqualTo(R.style.GlifV3Theme_Light_Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTheme_nonSuw_shouldReturnDayNightTheme() {
|
public void testGetTheme_glifV3_shouldReturnTheme() {
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme);
|
||||||
|
assertThat(SetupWizardUtils.getTransparentTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme_Transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_whenSuwDayNightDisabledAndGlifV2_shouldReturnLightTheme() {
|
||||||
|
FakePartnerContentProvider provider =
|
||||||
|
Robolectric.setupContentProvider(
|
||||||
|
FakePartnerContentProvider.class, "com.google.android.setupwizard.partner");
|
||||||
|
provider.injectFakeDayNightEnabledResult(false);
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV2Theme_Light);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_whenSuwDayNightEnabledAndGlifV2_shouldReturnDayNightTheme() {
|
||||||
|
FakePartnerContentProvider provider =
|
||||||
|
Robolectric.setupContentProvider(
|
||||||
|
FakePartnerContentProvider.class, "com.google.android.setupwizard.partner");
|
||||||
|
provider.injectFakeDayNightEnabledResult(true);
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V2_LIGHT);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV2Theme_DayNight);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_whenSuwDayNightDisabledAndGlifV3_shouldReturnTheme() {
|
||||||
|
FakePartnerContentProvider provider =
|
||||||
|
Robolectric.setupContentProvider(
|
||||||
|
FakePartnerContentProvider.class, "com.google.android.setupwizard.partner");
|
||||||
|
provider.injectFakeDayNightEnabledResult(false);
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme);
|
||||||
|
assertThat(SetupWizardUtils.getTransparentTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme_Transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_whenSuwDayNightEnabledAndGlifV3_shouldReturnDayNightTheme() {
|
||||||
|
FakePartnerContentProvider provider =
|
||||||
|
Robolectric.setupContentProvider(
|
||||||
|
FakePartnerContentProvider.class, "com.google.android.setupwizard.partner");
|
||||||
|
provider.injectFakeDayNightEnabledResult(true);
|
||||||
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3);
|
||||||
|
Intent intent = createSetupWizardIntent();
|
||||||
|
|
||||||
|
assertThat(SetupWizardUtils.getTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme_DayNight);
|
||||||
|
assertThat(SetupWizardUtils.getTransparentTheme(mContext, intent))
|
||||||
|
.isEqualTo(R.style.GlifV3Theme_DayNight_Transparent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetTheme_nonSuw_shouldReturnTheme() {
|
||||||
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
SetupWizardProperties.theme(ThemeHelper.THEME_GLIF_V3_LIGHT);
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
|
||||||
assertThat(SetupWizardUtils.getTheme(intent)).isEqualTo(R.style.GlifV3Theme);
|
assertThat(SetupWizardUtils.getTheme(mContext, intent)).isEqualTo(R.style.GlifV3Theme);
|
||||||
assertThat(SetupWizardUtils.getTransparentTheme(intent))
|
assertThat(SetupWizardUtils.getTransparentTheme(mContext, intent))
|
||||||
.isEqualTo(R.style.GlifV3Theme_Transparent);
|
.isEqualTo(R.style.GlifV3Theme_Transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,4 +213,65 @@ public class SetupWizardUtilsTest {
|
|||||||
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
|
.putExtra(WizardManagerHelper.EXTRA_IS_SETUP_FLOW, true)
|
||||||
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
|
.putExtra(WizardManagerHelper.EXTRA_IS_FIRST_RUN, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final class FakePartnerContentProvider extends ContentProvider {
|
||||||
|
|
||||||
|
private final Bundle mFakeProviderDayNightEnabledResultBundle = new Bundle();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreate() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Cursor query(
|
||||||
|
@NonNull Uri uri,
|
||||||
|
@Nullable String[] projection,
|
||||||
|
@Nullable String selection,
|
||||||
|
@Nullable String[] selectionArgs,
|
||||||
|
@Nullable String sortOrder) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public String getType(@NonNull Uri uri) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Uri insert(@NonNull Uri uri, @Nullable ContentValues values) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(
|
||||||
|
@NonNull Uri uri, @Nullable String selection, @Nullable String[] selectionArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(
|
||||||
|
@NonNull Uri uri,
|
||||||
|
@Nullable ContentValues values,
|
||||||
|
@Nullable String selection,
|
||||||
|
@Nullable String[] selectionArgs) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Bundle call(String method, String arg, Bundle extras) {
|
||||||
|
if (TextUtils.equals(method, "isSuwDayNightEnabled")) {
|
||||||
|
return mFakeProviderDayNightEnabledResultBundle;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FakePartnerContentProvider injectFakeDayNightEnabledResult(boolean dayNightEnabled) {
|
||||||
|
mFakeProviderDayNightEnabledResultBundle.putBoolean(
|
||||||
|
"isSuwDayNightEnabled", dayNightEnabled);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user