Loading res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -141,4 +141,8 @@ <!-- Generic label for canceling the current action [CHAR_LIMIT=20] --> <string name="cancel">Cancel</string> <!-- Label for a dialog which asks the user the destination (home screen, lock screen, both) where to set the theme's bundled image as wallpaper. [CHAR LIMIT=50] --> <string name="set_theme_wallpaper_dialog_message">Set style wallpaper</string> </resources> res/values/styles.xml +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ <item name="android:navigationBarDividerColor">@color/system_navigation_bar_divider</item> <item name="selectableItemBackground">?android:attr/selectableItemBackground</item> <item name="dialogPreferredPadding">24dp</item> <item name="colorControlHighlight">@color/ripple_material_dark</item> </style> <style name="CustomizationTheme.NoActionBar"> <item name="android:windowActionBar">false</item> Loading src/com/android/customization/model/theme/ThemeManager.java +42 −15 Original line number Diff line number Diff line Loading @@ -26,20 +26,22 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE; import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.app.Activity; import android.graphics.Point; import android.os.UserHandle; import android.provider.Settings; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; import com.android.customization.model.CustomizationManager; import com.android.customization.model.ResourceConstants; import com.android.customization.model.theme.custom.CustomTheme; import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.module.WallpaperPersister; import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback; import com.android.wallpaper.module.WallpaperSetter; import com.android.wallpaper.picker.SetWallpaperDialogFragment.Listener; import com.android.wallpaper.util.WallpaperCropUtils; import java.util.HashSet; Loading @@ -64,11 +66,11 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { private final OverlayManagerCompat mOverlayManagerCompat; private final WallpaperSetter mWallpaperSetter; private final Activity mActivity; private final FragmentActivity mActivity; private Map<String, String> mCurrentOverlays; public ThemeManager(ThemeBundleProvider provider, Activity activity, public ThemeManager(ThemeBundleProvider provider, FragmentActivity activity, WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat) { mProvider = provider; mActivity = activity; Loading @@ -85,23 +87,48 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { public void apply(ThemeBundle theme, Callback callback) { // Set wallpaper if (theme.shouldUseThemeWallpaper()) { applyWallpaper(theme, new SetWallpaperCallback() { mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(), R.string.set_theme_wallpaper_dialog_message, new Listener() { @Override public void onSuccess() { applyOverlays(theme, callback); public void onSetHomeScreen() { applyWallpaper(theme, WallpaperPersister.DEST_HOME_SCREEN, createSetWallpaperCallback(theme, callback)); } @Override public void onError(@Nullable Throwable throwable) { callback.onError(throwable); public void onSetLockScreen() { applyWallpaper(theme, WallpaperPersister.DEST_LOCK_SCREEN, createSetWallpaperCallback(theme, callback)); } @Override public void onSetBoth() { applyWallpaper(theme, WallpaperPersister.DEST_BOTH, createSetWallpaperCallback(theme, callback)); } }); } else { applyOverlays(theme, callback); } } private void applyWallpaper(ThemeBundle theme, SetWallpaperCallback callback) { private SetWallpaperCallback createSetWallpaperCallback(ThemeBundle theme, Callback callback) { return new SetWallpaperCallback() { @Override public void onSuccess() { applyOverlays(theme, callback); } @Override public void onError(@Nullable Throwable throwable) { callback.onError(throwable); } }; } private void applyWallpaper(ThemeBundle theme, int destination, SetWallpaperCallback callback) { Point defaultCropSurfaceSize = WallpaperCropUtils.getDefaultCropSurfaceSize( mActivity.getResources(), mActivity.getWindowManager().getDefaultDisplay()); Loading @@ -116,7 +143,7 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { mWallpaperSetter.setCurrentWallpaper(mActivity, theme.getWallpaperInfo(), wallpaperAsset, WallpaperPersister.DEST_BOTH, destination, scale, null, callback); }); } Loading src/com/android/customization/picker/theme/ThemeFragment.java +20 −17 Original line number Diff line number Diff line Loading @@ -112,6 +112,17 @@ public class ThemeFragment extends ToolbarFragment { mPreviewPager = view.findViewById(R.id.theme_preview_pager); mOptionsContainer = view.findViewById(R.id.options_container); view.findViewById(R.id.apply_button).setOnClickListener(v -> { applyTheme(); }); mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper); mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged); setUpOptions(savedInstanceState); return view; } private void applyTheme() { mThemeManager.apply(mSelectedTheme, new Callback() { @Override public void onSuccess() { Loading @@ -128,14 +139,6 @@ public class ThemeFragment extends ToolbarFragment { Toast.LENGTH_LONG).show(); } }); }); mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper); mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged); setUpOptions(savedInstanceState); return view; } @Override Loading Loading
res/values/strings.xml +4 −0 Original line number Diff line number Diff line Loading @@ -141,4 +141,8 @@ <!-- Generic label for canceling the current action [CHAR_LIMIT=20] --> <string name="cancel">Cancel</string> <!-- Label for a dialog which asks the user the destination (home screen, lock screen, both) where to set the theme's bundled image as wallpaper. [CHAR LIMIT=50] --> <string name="set_theme_wallpaper_dialog_message">Set style wallpaper</string> </resources>
res/values/styles.xml +2 −0 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ <item name="android:navigationBarDividerColor">@color/system_navigation_bar_divider</item> <item name="selectableItemBackground">?android:attr/selectableItemBackground</item> <item name="dialogPreferredPadding">24dp</item> <item name="colorControlHighlight">@color/ripple_material_dark</item> </style> <style name="CustomizationTheme.NoActionBar"> <item name="android:windowActionBar">false</item> Loading
src/com/android/customization/model/theme/ThemeManager.java +42 −15 Original line number Diff line number Diff line Loading @@ -26,20 +26,22 @@ import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY import static com.android.customization.model.ResourceConstants.SETTINGS_PACKAGE; import static com.android.customization.model.ResourceConstants.SYSUI_PACKAGE; import android.app.Activity; import android.graphics.Point; import android.os.UserHandle; import android.provider.Settings; import androidx.annotation.Nullable; import androidx.fragment.app.FragmentActivity; import com.android.customization.model.CustomizationManager; import com.android.customization.model.ResourceConstants; import com.android.customization.model.theme.custom.CustomTheme; import com.android.wallpaper.R; import com.android.wallpaper.asset.Asset; import com.android.wallpaper.module.WallpaperPersister; import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback; import com.android.wallpaper.module.WallpaperSetter; import com.android.wallpaper.picker.SetWallpaperDialogFragment.Listener; import com.android.wallpaper.util.WallpaperCropUtils; import java.util.HashSet; Loading @@ -64,11 +66,11 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { private final OverlayManagerCompat mOverlayManagerCompat; private final WallpaperSetter mWallpaperSetter; private final Activity mActivity; private final FragmentActivity mActivity; private Map<String, String> mCurrentOverlays; public ThemeManager(ThemeBundleProvider provider, Activity activity, public ThemeManager(ThemeBundleProvider provider, FragmentActivity activity, WallpaperSetter wallpaperSetter, OverlayManagerCompat overlayManagerCompat) { mProvider = provider; mActivity = activity; Loading @@ -85,23 +87,48 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { public void apply(ThemeBundle theme, Callback callback) { // Set wallpaper if (theme.shouldUseThemeWallpaper()) { applyWallpaper(theme, new SetWallpaperCallback() { mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(), R.string.set_theme_wallpaper_dialog_message, new Listener() { @Override public void onSuccess() { applyOverlays(theme, callback); public void onSetHomeScreen() { applyWallpaper(theme, WallpaperPersister.DEST_HOME_SCREEN, createSetWallpaperCallback(theme, callback)); } @Override public void onError(@Nullable Throwable throwable) { callback.onError(throwable); public void onSetLockScreen() { applyWallpaper(theme, WallpaperPersister.DEST_LOCK_SCREEN, createSetWallpaperCallback(theme, callback)); } @Override public void onSetBoth() { applyWallpaper(theme, WallpaperPersister.DEST_BOTH, createSetWallpaperCallback(theme, callback)); } }); } else { applyOverlays(theme, callback); } } private void applyWallpaper(ThemeBundle theme, SetWallpaperCallback callback) { private SetWallpaperCallback createSetWallpaperCallback(ThemeBundle theme, Callback callback) { return new SetWallpaperCallback() { @Override public void onSuccess() { applyOverlays(theme, callback); } @Override public void onError(@Nullable Throwable throwable) { callback.onError(throwable); } }; } private void applyWallpaper(ThemeBundle theme, int destination, SetWallpaperCallback callback) { Point defaultCropSurfaceSize = WallpaperCropUtils.getDefaultCropSurfaceSize( mActivity.getResources(), mActivity.getWindowManager().getDefaultDisplay()); Loading @@ -116,7 +143,7 @@ public class ThemeManager implements CustomizationManager<ThemeBundle> { mWallpaperSetter.setCurrentWallpaper(mActivity, theme.getWallpaperInfo(), wallpaperAsset, WallpaperPersister.DEST_BOTH, destination, scale, null, callback); }); } Loading
src/com/android/customization/picker/theme/ThemeFragment.java +20 −17 Original line number Diff line number Diff line Loading @@ -112,6 +112,17 @@ public class ThemeFragment extends ToolbarFragment { mPreviewPager = view.findViewById(R.id.theme_preview_pager); mOptionsContainer = view.findViewById(R.id.options_container); view.findViewById(R.id.apply_button).setOnClickListener(v -> { applyTheme(); }); mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper); mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged); setUpOptions(savedInstanceState); return view; } private void applyTheme() { mThemeManager.apply(mSelectedTheme, new Callback() { @Override public void onSuccess() { Loading @@ -128,14 +139,6 @@ public class ThemeFragment extends ToolbarFragment { Toast.LENGTH_LONG).show(); } }); }); mUseMyWallpaperButton = view.findViewById(R.id.use_my_wallpaper); mUseMyWallpaperButton.setOnCheckedChangeListener(this::onUseMyWallpaperCheckChanged); setUpOptions(savedInstanceState); return view; } @Override Loading