Skip to content

Commit f0dda45

Browse files
committed
No public description
PiperOrigin-RevId: 603079140
1 parent fbe9141 commit f0dda45

File tree

8 files changed

+67
-5
lines changed

8 files changed

+67
-5
lines changed

src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
xmlns:tools="http://schemas.android.com/tools"
2020
package="com.afwsamples.testdpc"
2121
tools:ignore="MissingClass"
22-
android:versionCode="9003"
23-
android:versionName="9.0.3">
22+
android:versionCode="9004"
23+
android:versionName="9.0.4">
2424
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="33"/>
2525

2626
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

src/main/java/com/afwsamples/testdpc/AddAccountActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@
4141
import android.widget.RadioGroup;
4242
import android.widget.Toast;
4343
import androidx.lifecycle.ProcessLifecycleOwner;
44+
import com.afwsamples.testdpc.common.ThemeUtil;
4445
import com.afwsamples.testdpc.common.Util;
4546
import com.google.android.setupcompat.template.FooterBarMixin;
4647
import com.google.android.setupcompat.template.FooterButton;
48+
import com.google.android.setupcompat.util.WizardManagerHelper;
4749
import com.google.android.setupdesign.GlifLayout;
4850
import java.io.IOException;
4951

@@ -75,6 +77,9 @@ protected void onCreate(Bundle savedInstanceState) {
7577
mDevicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
7678
mAdminComponentName = DeviceAdminReceiver.getComponentName(this);
7779

80+
// get default theme string from suw intent extra and set the Theme.
81+
ThemeUtil.setTheme(this, getIntent().getStringExtra(WizardManagerHelper.EXTRA_THEME));
82+
7883
setContentView(R.layout.activity_add_account);
7984
GlifLayout layout = findViewById(R.id.setup_wizard_layout);
8085
FooterBarMixin mixin = layout.getMixin(FooterBarMixin.class);

src/main/java/com/afwsamples/testdpc/FinalizeActivity.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@
2929
import android.widget.ImageView;
3030
import android.widget.TextView;
3131
import com.afwsamples.testdpc.common.LaunchIntentUtil;
32+
import com.afwsamples.testdpc.common.ThemeUtil;
3233
import com.afwsamples.testdpc.common.Util;
3334
import com.afwsamples.testdpc.provision.ProvisioningUtil;
3435
import com.google.android.setupcompat.template.FooterBarMixin;
3536
import com.google.android.setupcompat.template.FooterButton;
37+
import com.google.android.setupcompat.util.WizardManagerHelper;
3638
import com.google.android.setupdesign.GlifLayout;
3739

3840
public class FinalizeActivity extends Activity {
@@ -57,6 +59,9 @@ protected void onCreate(Bundle savedInstanceState) {
5759
return;
5860
}
5961

62+
// get default theme string from suw intent extra and set the Theme.
63+
ThemeUtil.setTheme(this, getIntent().getStringExtra(WizardManagerHelper.EXTRA_THEME));
64+
6065
setContentView(R.layout.finalize_activity);
6166
mSetupWizardLayout = findViewById(R.id.setup_wizard_layout);
6267
FooterBarMixin mixin = mSetupWizardLayout.getMixin(FooterBarMixin.class);

src/main/java/com/afwsamples/testdpc/SetupManagementActivity.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5+
import com.afwsamples.testdpc.common.ThemeUtil;
6+
import com.google.android.setupcompat.util.WizardManagerHelper;
57

68
public class SetupManagementActivity extends Activity {
79

810
@Override
911
protected void onCreate(Bundle savedInstanceState) {
1012
super.onCreate(savedInstanceState);
13+
14+
// get default theme string from suw intent extra and set the Theme.
15+
ThemeUtil.setTheme(this, getIntent().getStringExtra(WizardManagerHelper.EXTRA_THEME));
16+
1117
setContentView(R.layout.activity_main);
1218
if (savedInstanceState == null) {
1319
getFragmentManager()
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.afwsamples.testdpc.common;
2+
3+
import android.content.Context;
4+
import android.os.Build.VERSION_CODES;
5+
import com.afwsamples.testdpc.R;
6+
import com.google.android.setupdesign.util.ThemeHelper;
7+
import com.google.android.setupdesign.util.ThemeResolver;
8+
9+
/** Common utility functions for Theming. */
10+
public final class ThemeUtil {
11+
12+
/**
13+
* Set the correct Theme for the SUW screen
14+
*
15+
* @param default theme string .
16+
*/
17+
public static void setTheme(Context context, String themeName) {
18+
int defaultTheme;
19+
if (Util.SDK_INT < VERSION_CODES.TIRAMISU) {
20+
defaultTheme =
21+
ThemeHelper.isSetupWizardDayNightEnabled(context)
22+
? R.style.SudThemeGlifV3_DayNight
23+
: R.style.SudThemeGlifV3_Light;
24+
} else {
25+
defaultTheme =
26+
ThemeHelper.isSetupWizardDayNightEnabled(context)
27+
? R.style.SudThemeGlifV4_DayNight
28+
: R.style.SudThemeGlifV4_Light;
29+
}
30+
31+
// a. set GlifTheme based on suw intent extra & SUW daynight flag.
32+
ThemeResolver THEME_RESOLVER =
33+
new ThemeResolver.Builder(ThemeResolver.getDefault())
34+
.setDefaultTheme(defaultTheme)
35+
.setUseDayNight(true)
36+
.build();
37+
38+
// If outside suw (themeName=null); the themeResolver will fallback
39+
// to the default theme directly, resolve theme resource based on the day-night flag.
40+
int themeResId =
41+
THEME_RESOLVER.resolve(themeName, !ThemeHelper.isSetupWizardDayNightEnabled(context));
42+
43+
// setTheme for this activity.
44+
context.setTheme(themeResId);
45+
46+
// b. overlay color attrs to dynamic color for GlifTheme.
47+
ThemeHelper.trySetDynamicColor(context);
48+
}
49+
}

src/main/res/layout/activity_add_account.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
android:layout_width="match_parent"
2121
android:layout_height="match_parent"
2222
android:icon="@drawable/ic_enterprise_blue"
23-
android:theme="@style/SudDynamicColorThemeGlifV3.DayNight"
2423
app:sucHeaderText="@string/add_account">
2524

2625
<LinearLayout

src/main/res/layout/finalize_activity.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
android:layout_width="match_parent"
2222
android:layout_height="match_parent"
2323
android:icon="@drawable/ic_enterprise_blue"
24-
android:theme="@style/SudDynamicColorThemeGlifV3.DayNight"
2524
app:sucHeaderText="@string/finish_setup">
2625

2726
<LinearLayout

src/main/res/layout/setup_management_fragment.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
xmlns:android="http://schemas.android.com/apk/res/android"
1919
xmlns:app="http://schemas.android.com/apk/res-auto"
2020
android:id="@+id/setup_wizard_layout"
21-
android:theme="@style/SudDynamicColorThemeGlifV3.DayNight"
2221
android:layout_width="match_parent"
2322
android:layout_height="match_parent"
2423
android:icon="@drawable/ic_enterprise_blue"

0 commit comments

Comments
 (0)