ParanoidThemePicker: update to udc qpr1
Edits: Start using Hilt!! Remove WallpaperColorThemePreview and related classes Deprecated non-revamped UI fns Change-Id: I37fbc45f63fb629403861c51836641c991f7a6b4
This commit is contained in:
parent
79dda714ec
commit
0df9457e75
25
Android.bp
25
Android.bp
|
@ -60,22 +60,6 @@ genrule {
|
|||
+ "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR"
|
||||
}
|
||||
|
||||
android_library {
|
||||
name: "ParanoidThemePicker-core",
|
||||
|
||||
defaults: ["ThemePicker_defaults"],
|
||||
|
||||
optimize: {
|
||||
enabled: false,
|
||||
},
|
||||
|
||||
resource_dirs: ["res", "res_override"],
|
||||
|
||||
resource_zips: [":WallpaperPicker2_res", ":ThemePicker_res"],
|
||||
|
||||
kotlincflags: ["-Xjvm-default=enable"],
|
||||
}
|
||||
|
||||
//
|
||||
// Build app code.
|
||||
//
|
||||
|
@ -83,7 +67,14 @@ android_app {
|
|||
name: "ParanoidThemePicker",
|
||||
|
||||
static_libs: [
|
||||
"ParanoidThemePicker-core",
|
||||
"guava",
|
||||
"hilt_android",
|
||||
"monet",
|
||||
"renderscript_toolkit",
|
||||
"wallpaper-common-deps",
|
||||
"SettingsLibSettingsTheme",
|
||||
"SystemUI-statsd",
|
||||
"styleprotoslite",
|
||||
],
|
||||
|
||||
srcs: [
|
||||
|
|
|
@ -8,7 +8,6 @@ import androidx.fragment.app.FragmentActivity;
|
|||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.android.customization.model.color.ColorSectionController;
|
||||
import com.android.customization.model.grid.GridOptionsManager;
|
||||
import com.android.customization.model.grid.GridSectionController;
|
||||
import com.android.customization.model.mode.DarkModeSectionController;
|
||||
|
@ -20,6 +19,7 @@ import com.android.customization.model.themedicon.domain.interactor.ThemedIconIn
|
|||
import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer;
|
||||
import com.android.customization.picker.clock.ui.view.ClockViewFactory;
|
||||
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel;
|
||||
import com.android.customization.picker.color.domain.interactor.ColorPickerInteractor;
|
||||
import com.android.customization.picker.color.ui.section.ColorSectionController2;
|
||||
import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel;
|
||||
import com.android.customization.picker.notifications.ui.section.NotificationSectionController;
|
||||
|
@ -36,7 +36,6 @@ import com.android.wallpaper.model.CustomizationSectionController.CustomizationS
|
|||
import com.android.wallpaper.model.PermissionRequester;
|
||||
import com.android.wallpaper.model.WallpaperColorsViewModel;
|
||||
import com.android.wallpaper.model.WallpaperPreviewNavigator;
|
||||
import com.android.wallpaper.model.WallpaperSectionController;
|
||||
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
|
||||
import com.android.wallpaper.module.CustomizationSections;
|
||||
import com.android.wallpaper.picker.customization.domain.interactor.WallpaperInteractor;
|
||||
|
@ -67,6 +66,7 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
private final DarkModeSnapshotRestorer mDarkModeSnapshotRestorer;
|
||||
private final ThemedIconSnapshotRestorer mThemedIconSnapshotRestorer;
|
||||
private final ThemedIconInteractor mThemedIconInteractor;
|
||||
private final ColorPickerInteractor mColorPickerInteractor;
|
||||
|
||||
public AospaCustomizationSections(
|
||||
ColorPickerViewModel.Factory colorPickerViewModelFactory,
|
||||
|
@ -79,7 +79,8 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
ClockViewFactory clockViewFactory,
|
||||
DarkModeSnapshotRestorer darkModeSnapshotRestorer,
|
||||
ThemedIconSnapshotRestorer themedIconSnapshotRestorer,
|
||||
ThemedIconInteractor themedIconInteractor) {
|
||||
ThemedIconInteractor themedIconInteractor,
|
||||
ColorPickerInteractor colorPickerInteractor) {
|
||||
mColorPickerViewModelFactory = colorPickerViewModelFactory;
|
||||
mKeyguardQuickAffordancePickerInteractor = keyguardQuickAffordancePickerInteractor;
|
||||
mKeyguardQuickAffordancePickerViewModelFactory =
|
||||
|
@ -91,10 +92,11 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
mDarkModeSnapshotRestorer = darkModeSnapshotRestorer;
|
||||
mThemedIconSnapshotRestorer = themedIconSnapshotRestorer;
|
||||
mThemedIconInteractor = themedIconInteractor;
|
||||
mColorPickerInteractor = colorPickerInteractor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomizationSectionController<?>> getRevampedUISectionControllersForScreen(
|
||||
public List<CustomizationSectionController<?>> getSectionControllersForScreen(
|
||||
Screen screen,
|
||||
FragmentActivity activity,
|
||||
LifecycleOwner lifecycleOwner,
|
||||
|
@ -127,8 +129,10 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
sectionNavigationController,
|
||||
wallpaperInteractor,
|
||||
mThemedIconInteractor,
|
||||
mColorPickerInteractor,
|
||||
wallpaperManager,
|
||||
isTwoPaneAndSmallWidth)
|
||||
isTwoPaneAndSmallWidth,
|
||||
customizationPickerViewModel)
|
||||
: new PreviewWithThemeSectionController(
|
||||
activity,
|
||||
lifecycleOwner,
|
||||
|
@ -139,8 +143,10 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
wallpaperPreviewNavigator,
|
||||
wallpaperInteractor,
|
||||
mThemedIconInteractor,
|
||||
mColorPickerInteractor,
|
||||
wallpaperManager,
|
||||
isTwoPaneAndSmallWidth));
|
||||
isTwoPaneAndSmallWidth,
|
||||
customizationPickerViewModel));
|
||||
|
||||
sectionControllers.add(
|
||||
new ConnectedSectionController(
|
||||
|
@ -220,65 +226,4 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
|
||||
return sectionControllers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomizationSectionController<?>> getAllSectionControllers(
|
||||
FragmentActivity activity,
|
||||
LifecycleOwner lifecycleOwner,
|
||||
WallpaperColorsViewModel wallpaperColorsViewModel,
|
||||
PermissionRequester permissionRequester,
|
||||
WallpaperPreviewNavigator wallpaperPreviewNavigator,
|
||||
CustomizationSectionNavigationController sectionNavigationController,
|
||||
@Nullable Bundle savedInstanceState,
|
||||
DisplayUtils displayUtils) {
|
||||
List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
|
||||
|
||||
// Wallpaper section.
|
||||
sectionControllers.add(
|
||||
new WallpaperSectionController(
|
||||
activity,
|
||||
lifecycleOwner,
|
||||
permissionRequester,
|
||||
wallpaperColorsViewModel,
|
||||
mThemedIconInteractor.isActivatedAsLiveData(),
|
||||
sectionNavigationController,
|
||||
wallpaperPreviewNavigator,
|
||||
savedInstanceState,
|
||||
displayUtils));
|
||||
|
||||
// Theme color section.
|
||||
sectionControllers.add(new ColorSectionController(
|
||||
activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState));
|
||||
|
||||
// Dark/Light theme section.
|
||||
sectionControllers.add(new DarkModeSectionController(
|
||||
activity,
|
||||
lifecycleOwner.getLifecycle(),
|
||||
mDarkModeSnapshotRestorer));
|
||||
|
||||
// Themed app icon section.
|
||||
sectionControllers.add(new ThemedIconSectionController(
|
||||
ThemedIconSwitchProvider.getInstance(activity),
|
||||
mThemedIconInteractor,
|
||||
savedInstanceState,
|
||||
mThemedIconSnapshotRestorer));
|
||||
|
||||
// App grid section.
|
||||
sectionControllers.add(
|
||||
new GridSectionController(
|
||||
GridOptionsManager.getInstance(activity),
|
||||
sectionNavigationController,
|
||||
lifecycleOwner,
|
||||
/* isRevampedUiEnabled= */ false));
|
||||
|
||||
// Icon pack selection section.
|
||||
sectionControllers.add(new IconPackSectionController(
|
||||
IconPackManager.getInstance(activity, new OverlayManagerCompat(activity)), sectionNavigationController));
|
||||
|
||||
// Font selection section.
|
||||
sectionControllers.add(new FontSectionController(
|
||||
FontManager.getInstance(activity, new OverlayManagerCompat(activity)), sectionNavigationController));
|
||||
|
||||
return sectionControllers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,13 @@ import androidx.activity.ComponentActivity
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
|
||||
import com.android.wallpaper.model.WallpaperInfo
|
||||
import com.android.wallpaper.dispatchers.BackgroundDispatcher
|
||||
import com.android.wallpaper.dispatchers.MainDispatcher
|
||||
import com.android.wallpaper.module.CustomizationSections
|
||||
import com.android.wallpaper.picker.MonetPreviewFragment
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
import kotlinx.coroutines.CoroutineDispatcher
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
|
||||
import com.android.customization.picker.clock.ui.view.ClockViewFactory
|
||||
import com.android.customization.picker.clock.ui.viewmodel.ClockCarouselViewModel
|
||||
|
@ -21,26 +25,26 @@ import com.android.customization.model.themedicon.domain.interactor.ThemedIconIn
|
|||
import com.android.customization.model.themedicon.domain.interactor.ThemedIconSnapshotRestorer
|
||||
import com.android.customization.module.ThemePickerInjector
|
||||
|
||||
public class AospaThemePickerInjector : ThemePickerInjector() {
|
||||
@Singleton
|
||||
open class AospaThemePickerInjector @Inject constructor(
|
||||
@MainDispatcher mainScope: CoroutineScope,
|
||||
@MainDispatcher mainDispatcher: CoroutineDispatcher,
|
||||
@BackgroundDispatcher bgDispatcher: CoroutineDispatcher,
|
||||
) : ThemePickerInjector(
|
||||
mainScope,
|
||||
mainDispatcher,
|
||||
bgDispatcher,
|
||||
) {
|
||||
|
||||
private var customizationSections: CustomizationSections? = null
|
||||
|
||||
override fun getPreviewFragment(
|
||||
context: Context,
|
||||
wallpaperInfo: WallpaperInfo,
|
||||
mode: Int,
|
||||
viewAsHome: Boolean,
|
||||
viewFullScreen: Boolean,
|
||||
testingModeEnabled: Boolean): Fragment {
|
||||
return MonetPreviewFragment.newInstance(wallpaperInfo, mode, viewAsHome, viewFullScreen, testingModeEnabled);
|
||||
}
|
||||
|
||||
override fun getCustomizationSections(activity: ComponentActivity): CustomizationSections {
|
||||
val wallpaperColorsViewModel = getWallpaperColorsViewModel()
|
||||
return customizationSections
|
||||
?: AospaCustomizationSections(
|
||||
getColorPickerViewModelFactory(
|
||||
context = activity,
|
||||
wallpaperColorsViewModel = getWallpaperColorsViewModel(),
|
||||
wallpaperColorsViewModel = wallpaperColorsViewModel,
|
||||
),
|
||||
getKeyguardQuickAffordancePickerInteractor(activity),
|
||||
getKeyguardQuickAffordancePickerViewModelFactory(activity),
|
||||
|
@ -53,6 +57,7 @@ public class AospaThemePickerInjector : ThemePickerInjector() {
|
|||
getDarkModeSnapshotRestorer(activity),
|
||||
getThemedIconSnapshotRestorer(activity),
|
||||
getThemedIconInteractor(),
|
||||
getColorPickerInteractor(activity, wallpaperColorsViewModel),
|
||||
)
|
||||
.also { customizationSections = it }
|
||||
}
|
||||
|
|
|
@ -1,17 +1,21 @@
|
|||
package co.aospa.android.customization.picker
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import com.android.wallpaper.module.InjectorProvider;
|
||||
|
||||
import co.aospa.android.customization.module.AospaThemePickerInjector;
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import javax.inject.Inject
|
||||
|
||||
public class AospaCustomizationPickerApplication : Application() {
|
||||
@HiltAndroidApp(Application::class)
|
||||
class AospaCustomizationPickerApplication : Hilt_AospaCustomizationPickerApplication() {
|
||||
|
||||
@Inject
|
||||
lateinit var injector: AospaThemePickerInjector
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
InjectorProvider.setInjector(AospaThemePickerInjector());
|
||||
InjectorProvider.setInjector(injector);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 2023 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.
|
||||
*/
|
||||
package com.android.wallpaper.module
|
||||
|
||||
import android.content.Context
|
||||
import com.android.customization.module.CustomizationInjector
|
||||
import com.android.customization.module.DefaultCustomizationPreferences
|
||||
import co.aospa.android.customization.module.AospaThemePickerInjector
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Module
|
||||
@InstallIn(SingletonComponent::class)
|
||||
abstract class AppModule {
|
||||
@Binds @Singleton abstract fun bindInjector(impl: AospaThemePickerInjector): CustomizationInjector
|
||||
|
||||
companion object {
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideWallpaperPreferences(
|
||||
@ApplicationContext context: Context
|
||||
): WallpaperPreferences {
|
||||
return DefaultCustomizationPreferences(context)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package com.android.wallpaper.picker;
|
||||
|
||||
import android.app.WallpaperColors;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.android.wallpaper.R;
|
||||
import com.android.wallpaper.util.PreviewUtils;
|
||||
import com.android.wallpaper.widget.LockScreenPreviewer;
|
||||
|
||||
import com.google.android.material.resources.MaterialAttributes;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import com.android.customization.model.color.WallpaperColorResources;
|
||||
|
||||
public class ImageWallpaperColorThemePreviewFragment extends ImagePreviewFragment implements WallpaperColorThemePreview {
|
||||
private boolean mIgnoreInitialColorChange;
|
||||
private boolean mThemedIconSupported;
|
||||
private WallpaperColors mWallpaperColors;
|
||||
|
||||
@Override
|
||||
public WorkspaceSurfaceHolderCallback createWorkspaceSurfaceCallback(SurfaceView surfaceView) {
|
||||
return new WorkspaceSurfaceHolderCallback(
|
||||
surfaceView,
|
||||
new PreviewUtils(
|
||||
getContext(), getString(R.string.grid_control_metadata_name)),
|
||||
shouldApplyWallpaperColors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mThemedIconSupported = determineThemedIconsSupport(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Bundle bundle2 = getArguments();
|
||||
if (bundle2 != null && bundle2.getInt("preview_mode") == 0) {
|
||||
mIgnoreInitialColorChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWallpaperColorsChanged(WallpaperColors wallpaperColors) {
|
||||
if (mIgnoreInitialColorChange || wallpaperColors == null) {
|
||||
updateWorkspacePreview(mWorkspaceSurface, mWorkspaceSurfaceCallback, null);
|
||||
} else if (!wallpaperColors.equals(mWallpaperColors) && shouldApplyWallpaperColors()) {
|
||||
mWallpaperColors = wallpaperColors;
|
||||
Context context = getContext();
|
||||
new WallpaperColorResources(wallpaperColors).apply(context);
|
||||
updateSystemBarColor(context);
|
||||
getView().setBackgroundColor(MaterialAttributes.resolveOrThrow(context, android.R.attr.colorPrimary, "android.R.attr.colorPrimary is not set in the current theme"));
|
||||
LayoutInflater from = LayoutInflater.from(context);
|
||||
ViewGroup viewGroup = (ViewGroup) getView().findViewById(R.id.section_header_container);
|
||||
viewGroup.removeAllViews();
|
||||
setUpToolbar(from.inflate(R.layout.section_header, viewGroup), true);
|
||||
mFullScreenAnimation.ensureToolbarIsCorrectlyLocated();
|
||||
mFullScreenAnimation.ensureToolbarIsCorrectlyColored();
|
||||
ViewGroup viewGroup2 = (ViewGroup) getView().findViewById(R.id.fullscreen_buttons_container);
|
||||
viewGroup2.removeAllViews();
|
||||
setFullScreenActions(from.inflate(R.layout.fullscreen_buttons, viewGroup2));
|
||||
((PreviewFragment) this).mBottomActionBar.setColor(from.getContext());
|
||||
updateWorkspacePreview(mWorkspaceSurface, mWorkspaceSurfaceCallback, wallpaperColors);
|
||||
ViewGroup viewGroup3 = (ViewGroup) getView().findViewById(R.id.separated_tabs_container);
|
||||
viewGroup3.removeAllViews();
|
||||
setUpTabs((TabLayout) from.inflate(R.layout.separated_tabs, viewGroup3).findViewById(R.id.separated_tabs));
|
||||
mLockScreenPreviewer.release();
|
||||
mLockPreviewContainer.removeAllViews();
|
||||
LockScreenPreviewer lockScreenPreviewer = new LockScreenPreviewer(getLifecycle(), context, mLockPreviewContainer);
|
||||
mLockScreenPreviewer = lockScreenPreviewer;
|
||||
lockScreenPreviewer.setDateViewVisibility(!mFullScreenAnimation.isFullScreen());
|
||||
}
|
||||
mIgnoreInitialColorChange = false;
|
||||
super.onWallpaperColorsChanged(wallpaperColors);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUpdateWorkspaceColors() {
|
||||
return mThemedIconSupported;
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
package com.android.wallpaper.picker;
|
||||
|
||||
import android.app.WallpaperColors;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import com.android.wallpaper.R;
|
||||
import com.android.wallpaper.widget.LockScreenPreviewer;
|
||||
import com.android.wallpaper.util.PreviewUtils;
|
||||
|
||||
import com.google.android.material.resources.MaterialAttributes;
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
import com.android.customization.model.color.WallpaperColorResources;
|
||||
|
||||
public class LiveWallpaperColorThemePreviewFragment extends LivePreviewFragment implements WallpaperColorThemePreview {
|
||||
private boolean mIgnoreInitialColorChange;
|
||||
private boolean mThemedIconSupported;
|
||||
private WallpaperColors mWallpaperColors;
|
||||
|
||||
@Override
|
||||
public WorkspaceSurfaceHolderCallback createWorkspaceSurfaceCallback(SurfaceView surfaceView) {
|
||||
return new WorkspaceSurfaceHolderCallback(
|
||||
surfaceView,
|
||||
new PreviewUtils(
|
||||
getContext(), getString(R.string.grid_control_metadata_name)),
|
||||
shouldApplyWallpaperColors());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
mThemedIconSupported = determineThemedIconsSupport(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
Bundle bundle2 = getArguments();
|
||||
if (bundle2 != null && bundle2.getInt("preview_mode") == 0) {
|
||||
mIgnoreInitialColorChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWallpaperColorsChanged(WallpaperColors wallpaperColors, int i) {
|
||||
if (mIgnoreInitialColorChange || wallpaperColors == null) {
|
||||
updateWorkspacePreview(mWorkspaceSurface, mWorkspaceSurfaceCallback, null);
|
||||
} else if (!wallpaperColors.equals(mWallpaperColors) && shouldApplyWallpaperColors()) {
|
||||
mWallpaperColors = wallpaperColors;
|
||||
Context context = getContext();
|
||||
new WallpaperColorResources(wallpaperColors).apply(context);
|
||||
updateSystemBarColor(context);
|
||||
getView().setBackgroundColor(MaterialAttributes.resolveOrThrow(context, android.R.attr.colorPrimary, "android.R.attr.colorPrimary is not set in the current theme"));
|
||||
LayoutInflater from = LayoutInflater.from(context);
|
||||
ViewGroup viewGroup = (ViewGroup) getView().findViewById(R.id.section_header_container);
|
||||
viewGroup.removeAllViews();
|
||||
setUpToolbar(from.inflate(R.layout.section_header, viewGroup), true);
|
||||
mFullScreenAnimation.ensureToolbarIsCorrectlyLocated();
|
||||
mFullScreenAnimation.ensureToolbarIsCorrectlyColored();
|
||||
ViewGroup viewGroup2 = (ViewGroup) getView().findViewById(R.id.fullscreen_buttons_container);
|
||||
viewGroup2.removeAllViews();
|
||||
setFullScreenActions(from.inflate(R.layout.fullscreen_buttons, viewGroup2));
|
||||
((PreviewFragment) this).mBottomActionBar.setColor(from.getContext());
|
||||
updateWorkspacePreview(mWorkspaceSurface, mWorkspaceSurfaceCallback, wallpaperColors);
|
||||
ViewGroup viewGroup3 = (ViewGroup) getView().findViewById(R.id.separated_tabs_container);
|
||||
viewGroup3.removeAllViews();
|
||||
setUpTabs((TabLayout) from.inflate(R.layout.separated_tabs, viewGroup3).findViewById(R.id.separated_tabs));
|
||||
mLockScreenPreviewer.release();
|
||||
mLockPreviewContainer.removeAllViews();
|
||||
LockScreenPreviewer lockScreenPreviewer = new LockScreenPreviewer(getLifecycle(), context, mLockPreviewContainer);
|
||||
mLockScreenPreviewer = lockScreenPreviewer;
|
||||
lockScreenPreviewer.setDateViewVisibility(!mFullScreenAnimation.isFullScreen());
|
||||
}
|
||||
mIgnoreInitialColorChange = false;
|
||||
super.onWallpaperColorsChanged(wallpaperColors, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUpdateWorkspaceColors() {
|
||||
return mThemedIconSupported;
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2017 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.
|
||||
*/
|
||||
package com.android.wallpaper.picker;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.wallpaper.model.LiveWallpaperInfo;
|
||||
import com.android.wallpaper.model.WallpaperInfo;
|
||||
|
||||
public abstract class MonetPreviewFragment extends PreviewFragment {
|
||||
|
||||
public static PreviewFragment newInstance(WallpaperInfo wallpaperInfo, @PreviewMode int mode,
|
||||
boolean viewAsHome, boolean viewFullScreen, boolean testingModeEnabled) {
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable(ARG_WALLPAPER, wallpaperInfo);
|
||||
args.putInt(ARG_PREVIEW_MODE, mode);
|
||||
args.putBoolean(ARG_VIEW_AS_HOME, viewAsHome);
|
||||
args.putBoolean(ARG_FULL_SCREEN, viewFullScreen);
|
||||
args.putBoolean(ARG_TESTING_MODE_ENABLED, testingModeEnabled);
|
||||
|
||||
PreviewFragment fragment = wallpaperInfo instanceof LiveWallpaperInfo
|
||||
? new LiveWallpaperColorThemePreviewFragment() : new ImageWallpaperColorThemePreviewFragment();
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
package com.android.wallpaper.picker;
|
||||
|
||||
import android.app.WallpaperColors;
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentActivity;
|
||||
|
||||
import com.android.customization.model.theme.OverlayManagerCompat;
|
||||
import com.android.customization.model.themedicon.ThemedIconSwitchProvider;
|
||||
|
||||
import com.google.android.material.resources.MaterialAttributes;
|
||||
|
||||
import com.android.customization.model.color.ColorUtils;
|
||||
|
||||
public interface WallpaperColorThemePreview {
|
||||
|
||||
default boolean determineThemedIconsSupport(Context context) {
|
||||
ThemedIconSwitchProvider instance = ThemedIconSwitchProvider.getInstance(context);
|
||||
return instance.isThemedIconAvailable() && instance.isThemedIconEnabled();
|
||||
}
|
||||
|
||||
default boolean shouldApplyWallpaperColors() {
|
||||
FragmentActivity activity = ((Fragment) this).getActivity();
|
||||
if (activity == null || activity.isFinishing()) {
|
||||
Log.w("WallpaperColorThemePreview", "shouldApplyWallpaperColors: activity is null or finishing");
|
||||
return false;
|
||||
} else if (!ColorUtils.isMonetEnabled(activity)) {
|
||||
Log.w("WallpaperColorThemePreview", "Monet is not enabled");
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean shouldUpdateWorkspaceColors();
|
||||
|
||||
default void updateSystemBarColor(Context context) {
|
||||
int resolveOrThrow = MaterialAttributes.resolveOrThrow(context, android.R.attr.colorPrimary, "android.R.attr.colorPrimary is not set in the current theme");
|
||||
Window window = ((Fragment) this).getActivity().getWindow();
|
||||
window.setStatusBarColor(resolveOrThrow);
|
||||
window.setNavigationBarColor(resolveOrThrow);
|
||||
}
|
||||
|
||||
default void updateWorkspacePreview(SurfaceView surfaceView, WorkspaceSurfaceHolderCallback workspaceSurfaceHolderCallback, WallpaperColors wallpaperColors) {
|
||||
if (shouldUpdateWorkspaceColors()) {
|
||||
int visibility = surfaceView.getVisibility();
|
||||
surfaceView.setVisibility(View.GONE);
|
||||
if (workspaceSurfaceHolderCallback != null) {
|
||||
workspaceSurfaceHolderCallback.cleanUp();
|
||||
workspaceSurfaceHolderCallback.setWallpaperColors(wallpaperColors);
|
||||
surfaceView.setUseAlpha();
|
||||
surfaceView.setAlpha(0.0f);
|
||||
workspaceSurfaceHolderCallback.setListener(new WorkspaceSurfaceHolderCallback.WorkspaceRenderListener() {
|
||||
@Override
|
||||
public void onWorkspaceRendered() {
|
||||
surfaceView.setTop(-1);
|
||||
surfaceView.animate().alpha(1.0f).setDuration(300).start();
|
||||
}
|
||||
});
|
||||
}
|
||||
surfaceView.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue