ParanoidThemePicker: update injections to qpr2
Change-Id: I526ecf69fa6841932095f20b0fdec107920f9ccc
This commit is contained in:
parent
79a355bd49
commit
ddcab8ac1f
11
Android.bp
11
Android.bp
|
@ -51,16 +51,7 @@ genrule {
|
|||
android_library {
|
||||
name: "ParanoidThemePicker-core",
|
||||
|
||||
static_libs: [
|
||||
"guava",
|
||||
"monet",
|
||||
"renderscript_toolkit",
|
||||
"wallpaper-common-deps",
|
||||
"SettingsLibSettingsTheme",
|
||||
"SystemUIFlagsLib",
|
||||
"SystemUI-statsd",
|
||||
"styleprotoslite",
|
||||
],
|
||||
defaults: ["ThemePicker_defaults"],
|
||||
|
||||
optimize: {
|
||||
enabled: false,
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package co.aospa.android.customization.module;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
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;
|
||||
|
@ -13,6 +14,9 @@ import com.android.customization.model.mode.DarkModeSectionController;
|
|||
import com.android.customization.model.theme.OverlayManagerCompat;
|
||||
import com.android.customization.model.themedicon.ThemedIconSectionController;
|
||||
import com.android.customization.model.themedicon.ThemedIconSwitchProvider;
|
||||
import com.android.customization.picker.quickaffordance.domain.interactor.KeyguardQuickAffordancePickerInteractor;
|
||||
import com.android.customization.picker.quickaffordance.ui.section.KeyguardQuickAffordanceSectionController;
|
||||
import com.android.customization.picker.quickaffordance.ui.viewmodel.KeyguardQuickAffordancePickerViewModel;
|
||||
import com.android.wallpaper.model.CustomizationSectionController;
|
||||
import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController;
|
||||
import com.android.wallpaper.model.PermissionRequester;
|
||||
|
@ -20,7 +24,10 @@ import com.android.wallpaper.model.WallpaperColorsViewModel;
|
|||
import com.android.wallpaper.model.WallpaperPreviewNavigator;
|
||||
import com.android.wallpaper.model.WallpaperSectionController;
|
||||
import com.android.wallpaper.model.WorkspaceViewModel;
|
||||
import com.android.wallpaper.module.CurrentWallpaperInfoFactory;
|
||||
import com.android.wallpaper.module.CustomizationSections;
|
||||
import com.android.wallpaper.picker.customization.ui.section.ScreenPreviewSectionController;
|
||||
import com.android.wallpaper.util.DisplayUtils;
|
||||
|
||||
import co.aospa.android.customization.model.font.FontManager;
|
||||
import co.aospa.android.customization.model.font.FontSectionController;
|
||||
|
@ -33,25 +40,106 @@ import java.util.List;
|
|||
/** {@link CustomizationSections} for the customization picker. */
|
||||
public final class AospaCustomizationSections implements CustomizationSections {
|
||||
|
||||
private final KeyguardQuickAffordancePickerInteractor mKeyguardQuickAffordancePickerInteractor;
|
||||
private final KeyguardQuickAffordancePickerViewModel.Factory
|
||||
mKeyguardQuickAffordancePickerViewModelFactory;
|
||||
|
||||
public AospaCustomizationSections(
|
||||
KeyguardQuickAffordancePickerInteractor keyguardQuickAffordancePickerInteractor,
|
||||
KeyguardQuickAffordancePickerViewModel.Factory
|
||||
keyguardQuickAffordancePickerViewModelFactory) {
|
||||
mKeyguardQuickAffordancePickerInteractor = keyguardQuickAffordancePickerInteractor;
|
||||
mKeyguardQuickAffordancePickerViewModelFactory =
|
||||
keyguardQuickAffordancePickerViewModelFactory;
|
||||
}
|
||||
@Override
|
||||
public List<CustomizationSectionController<?>> getAllSectionControllers(Activity activity,
|
||||
LifecycleOwner lifecycleOwner, WallpaperColorsViewModel wallpaperColorsViewModel,
|
||||
WorkspaceViewModel workspaceViewModel, PermissionRequester permissionRequester,
|
||||
public List<CustomizationSectionController<?>> getSectionControllersForScreen(
|
||||
Screen screen,
|
||||
FragmentActivity activity,
|
||||
LifecycleOwner lifecycleOwner,
|
||||
WallpaperColorsViewModel wallpaperColorsViewModel,
|
||||
WorkspaceViewModel workspaceViewModel,
|
||||
PermissionRequester permissionRequester,
|
||||
WallpaperPreviewNavigator wallpaperPreviewNavigator,
|
||||
CustomizationSectionNavigationController sectionNavigationController,
|
||||
@Nullable Bundle savedInstanceState) {
|
||||
@Nullable Bundle savedInstanceState,
|
||||
CurrentWallpaperInfoFactory wallpaperInfoFactory,
|
||||
DisplayUtils displayUtils) {
|
||||
List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
|
||||
// Wallpaper section.
|
||||
sectionControllers.add(
|
||||
new ScreenPreviewSectionController(
|
||||
activity,
|
||||
lifecycleOwner,
|
||||
screen,
|
||||
wallpaperInfoFactory,
|
||||
wallpaperColorsViewModel,
|
||||
displayUtils));
|
||||
|
||||
// Theme color section.
|
||||
sectionControllers.add(new ColorSectionController(
|
||||
activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState));
|
||||
|
||||
switch (screen) {
|
||||
case LOCK_SCREEN:
|
||||
// Lock screen quick affordances section.
|
||||
sectionControllers.add(
|
||||
new KeyguardQuickAffordanceSectionController(
|
||||
sectionNavigationController,
|
||||
mKeyguardQuickAffordancePickerInteractor,
|
||||
new ViewModelProvider(
|
||||
activity,
|
||||
mKeyguardQuickAffordancePickerViewModelFactory)
|
||||
.get(KeyguardQuickAffordancePickerViewModel.class),
|
||||
lifecycleOwner));
|
||||
break;
|
||||
case HOME_SCREEN:
|
||||
// Dark/Light theme section.
|
||||
sectionControllers.add(new DarkModeSectionController(activity,
|
||||
lifecycleOwner.getLifecycle()));
|
||||
// Themed app icon section.
|
||||
sectionControllers.add(new ThemedIconSectionController(
|
||||
ThemedIconSwitchProvider.getInstance(activity), workspaceViewModel,
|
||||
savedInstanceState));
|
||||
// App grid section.
|
||||
sectionControllers.add(new GridSectionController(
|
||||
GridOptionsManager.getInstance(activity), sectionNavigationController));
|
||||
break;
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CustomizationSectionController<?>> getAllSectionControllers(
|
||||
FragmentActivity activity,
|
||||
LifecycleOwner lifecycleOwner,
|
||||
WallpaperColorsViewModel wallpaperColorsViewModel,
|
||||
WorkspaceViewModel workspaceViewModel,
|
||||
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,
|
||||
workspaceViewModel, sectionNavigationController, wallpaperPreviewNavigator,
|
||||
savedInstanceState));
|
||||
savedInstanceState, displayUtils));
|
||||
|
||||
// Color section
|
||||
sectionControllers.add(
|
||||
new ColorSectionController(activity, wallpaperColorsViewModel, lifecycleOwner,
|
||||
savedInstanceState));
|
||||
// Theme color section.
|
||||
sectionControllers.add(new ColorSectionController(
|
||||
activity, wallpaperColorsViewModel, lifecycleOwner, savedInstanceState));
|
||||
|
||||
// Dark/Light theme section.
|
||||
sectionControllers.add(new DarkModeSectionController(activity,
|
||||
|
@ -66,6 +154,17 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
sectionControllers.add(new GridSectionController(
|
||||
GridOptionsManager.getInstance(activity), sectionNavigationController));
|
||||
|
||||
// Lock screen quick affordances section.
|
||||
sectionControllers.add(
|
||||
new KeyguardQuickAffordanceSectionController(
|
||||
sectionNavigationController,
|
||||
mKeyguardQuickAffordancePickerInteractor,
|
||||
new ViewModelProvider(
|
||||
activity,
|
||||
mKeyguardQuickAffordancePickerViewModelFactory)
|
||||
.get(KeyguardQuickAffordancePickerViewModel.class),
|
||||
lifecycleOwner));
|
||||
|
||||
// Icon pack selection section.
|
||||
sectionControllers.add(new IconPackSectionController(
|
||||
IconPackManager.getInstance(activity, new OverlayManagerCompat(activity)), sectionNavigationController));
|
||||
|
@ -73,6 +172,7 @@ public final class AospaCustomizationSections implements CustomizationSections {
|
|||
// Font selection section.
|
||||
sectionControllers.add(new FontSectionController(
|
||||
FontManager.getInstance(activity, new OverlayManagerCompat(activity)), sectionNavigationController));
|
||||
|
||||
return sectionControllers;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package co.aospa.android.customization.module
|
||||
|
||||
import android.app.Activity
|
||||
|
||||
import android.content.Context
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
|
@ -8,9 +10,9 @@ import com.android.wallpaper.model.WallpaperInfo
|
|||
import com.android.wallpaper.module.CustomizationSections
|
||||
import com.android.wallpaper.picker.MonetPreviewFragment
|
||||
|
||||
import com.android.customization.module.DefaultCustomizationInjector
|
||||
import com.android.customization.module.ThemePickerInjector
|
||||
|
||||
public class AospaCustomizationInjector : DefaultCustomizationInjector() {
|
||||
public class AospaThemePickerInjector : ThemePickerInjector() {
|
||||
|
||||
private var customizationSections: CustomizationSections? = null
|
||||
|
||||
|
@ -24,10 +26,12 @@ public class AospaCustomizationInjector : DefaultCustomizationInjector() {
|
|||
return MonetPreviewFragment.newInstance(wallpaperInfo, mode, viewAsHome, viewFullScreen, testingModeEnabled);
|
||||
}
|
||||
|
||||
override fun getCustomizationSections(): CustomizationSections {
|
||||
if (customizationSections == null) {
|
||||
customizationSections = AospaCustomizationSections()
|
||||
}
|
||||
return customizationSections!!
|
||||
override fun getCustomizationSections(activity: Activity): CustomizationSections {
|
||||
return customizationSections
|
||||
?: AospaCustomizationSections(
|
||||
getKeyguardQuickAffordancePickerInteractor(activity),
|
||||
getKeyguardQuickAffordancePickerViewModelFactory(activity)
|
||||
)
|
||||
.also { customizationSections = it }
|
||||
}
|
||||
}
|
|
@ -4,14 +4,14 @@ import android.app.Application;
|
|||
|
||||
import com.android.wallpaper.module.InjectorProvider;
|
||||
|
||||
import co.aospa.android.customization.module.AospaCustomizationInjector;
|
||||
import co.aospa.android.customization.module.AospaThemePickerInjector;
|
||||
|
||||
public class AospaCustomizationPickerApplication : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
|
||||
InjectorProvider.setInjector(AospaCustomizationInjector());
|
||||
InjectorProvider.setInjector(AospaThemePickerInjector());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2018 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 android.content.Intent;
|
||||
import android.net.Uri;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.android.wallpaper.model.CategoryProvider;
|
||||
import com.android.wallpaper.model.WallpaperInfo;
|
||||
import com.android.wallpaper.monitor.PerformanceMonitor;
|
||||
import com.android.wallpaper.picker.CustomizationPickerActivity;
|
||||
import com.android.wallpaper.picker.ImagePreviewFragment;
|
||||
|
||||
/**
|
||||
* A concrete, real implementation of the dependency provider.
|
||||
*/
|
||||
public class WallpapersInjector extends BaseWallpaperInjector {
|
||||
private CategoryProvider mCategoryProvider;
|
||||
private UserEventLogger mUserEventLogger;
|
||||
private WallpaperRotationRefresher mWallpaperRotationRefresher;
|
||||
private PerformanceMonitor mPerformanceMonitor;
|
||||
|
||||
@Override
|
||||
public synchronized CategoryProvider getCategoryProvider(Context context) {
|
||||
if (mCategoryProvider == null) {
|
||||
mCategoryProvider = new DefaultCategoryProvider(context.getApplicationContext());
|
||||
}
|
||||
return mCategoryProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized UserEventLogger getUserEventLogger(Context context) {
|
||||
if (mUserEventLogger == null) {
|
||||
mUserEventLogger = new NoOpUserEventLogger();
|
||||
}
|
||||
return mUserEventLogger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized WallpaperRotationRefresher getWallpaperRotationRefresher() {
|
||||
if (mWallpaperRotationRefresher == null) {
|
||||
mWallpaperRotationRefresher = new WallpaperRotationRefresher() {
|
||||
@Override
|
||||
public void refreshWallpaper(Context context, Listener listener) {
|
||||
// Not implemented
|
||||
listener.onError();
|
||||
}
|
||||
};
|
||||
}
|
||||
return mWallpaperRotationRefresher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getPreviewFragment(
|
||||
Context context,
|
||||
WallpaperInfo wallpaperInfo,
|
||||
int mode,
|
||||
boolean viewAsHome,
|
||||
boolean viewFullScreen,
|
||||
boolean testingModeEnabled) {
|
||||
return ImagePreviewFragment.newInstance(wallpaperInfo, mode, viewAsHome, viewFullScreen,
|
||||
testingModeEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getDeepLinkRedirectIntent(Context context, Uri uri) {
|
||||
Intent intent = new Intent();
|
||||
intent.setClass(context, CustomizationPickerActivity.class);
|
||||
intent.setData(uri);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||
return intent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized PerformanceMonitor getPerformanceMonitor() {
|
||||
if (mPerformanceMonitor == null) {
|
||||
mPerformanceMonitor = new PerformanceMonitor() {
|
||||
@Override
|
||||
public void recordFullResPreviewLoadedMemorySnapshot() {
|
||||
// No Op
|
||||
}
|
||||
};
|
||||
}
|
||||
return mPerformanceMonitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized LoggingOptInStatusProvider getLoggingOptInStatusProvider(Context context) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDownloadableIntentAction() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ 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;
|
||||
|
@ -23,7 +24,11 @@ public class ImageWallpaperColorThemePreviewFragment extends ImagePreviewFragmen
|
|||
|
||||
@Override
|
||||
public WorkspaceSurfaceHolderCallback createWorkspaceSurfaceCallback(SurfaceView surfaceView) {
|
||||
return new WorkspaceSurfaceHolderCallback(surfaceView, getContext(), mThemedIconSupported);
|
||||
return new WorkspaceSurfaceHolderCallback(
|
||||
surfaceView,
|
||||
new PreviewUtils(
|
||||
getContext(), getString(R.string.grid_control_metadata_name)),
|
||||
shouldApplyWallpaperColors());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,6 +10,7 @@ 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;
|
||||
|
@ -23,7 +24,11 @@ public class LiveWallpaperColorThemePreviewFragment extends LivePreviewFragment
|
|||
|
||||
@Override
|
||||
public WorkspaceSurfaceHolderCallback createWorkspaceSurfaceCallback(SurfaceView surfaceView) {
|
||||
return new WorkspaceSurfaceHolderCallback(surfaceView, getContext(), mThemedIconSupported);
|
||||
return new WorkspaceSurfaceHolderCallback(
|
||||
surfaceView,
|
||||
new PreviewUtils(
|
||||
getContext(), getString(R.string.grid_control_metadata_name)),
|
||||
shouldApplyWallpaperColors());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue