From cbd37647a79d9ee5664c333dd9fc086bb9a4b537 Mon Sep 17 00:00:00 2001 From: Anay Wadhera Date: Sat, 16 Apr 2022 18:52:45 -0700 Subject: [PATCH] google_pixel: ThemePickergoogle: Initial build files Change-Id: I5ba86c57983ff709a03de35736f73dbc83187dd3 --- ThemePickerGoogle/Android.bp | 87 ++++++++++++++ ThemePickerGoogle/AndroidManifest.xml | 40 +++++++ ThemePickerGoogle/res/values/strings.xml | 21 ++++ .../module/GoogleCustomizationInjector.kt | 5 + .../GoogleCustomizationPickerApplication.kt | 17 +++ .../com/android/wallpaper/config/Flags.kt | 18 +++ .../wallpaper/module/WallpapersInjector.java | 112 ++++++++++++++++++ 7 files changed, 300 insertions(+) create mode 100644 ThemePickerGoogle/Android.bp create mode 100644 ThemePickerGoogle/AndroidManifest.xml create mode 100644 ThemePickerGoogle/res/values/strings.xml create mode 100644 ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt create mode 100644 ThemePickerGoogle/src/com/google/android/customization/picker/GoogleCustomizationPickerApplication.kt create mode 100644 ThemePickerGoogle/src_override/com/android/wallpaper/config/Flags.kt create mode 100644 ThemePickerGoogle/src_override/com/android/wallpaper/module/WallpapersInjector.java diff --git a/ThemePickerGoogle/Android.bp b/ThemePickerGoogle/Android.bp new file mode 100644 index 0000000..8e7aad9 --- /dev/null +++ b/ThemePickerGoogle/Android.bp @@ -0,0 +1,87 @@ +// +// Copyright (C) 2022 StatiXOS +// +// 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 { + default_applicable_licenses: ["Android-Apache-2.0"], +} + +filegroup { + name: "ThemePickerGoogle_srcs", + srcs: [ + "src/**/*.java", + "src/**/*.kt", + ], +} + +filegroup { + name: "ThemePickerGoogle_Manifest", + srcs: [ + "AndroidManifest.xml", + ], +} + +genrule { + name: "ThemePickerGoogle_res", + tools: ["soong_zip"], + srcs: [ + "res/**/*" + ], + out: ["ThemePickerGoogle_res.zip"], + cmd: "INPUTS=($(in)) && " + + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && " + + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR" +} + +// +// Build app code. +// +android_app { + name: "ThemePickerGoogle", + + static_libs: [ + "wallpaper-common-deps", + "SettingsLibSettingsTheme", + "SystemUI-statsd", + "styleprotoslite", + ], + + srcs: [ + ":WallpaperPicker2_srcs", + ":ThemePicker_srcs", + ":ThemePickerGoogle_srcs", + "src_override/**/*.java", + "src_override/**/*.kt", + ], + + use_embedded_native_libs: true, + + resource_zips: [":WallpaperPicker2_res", ":ThemePicker_res", ":ThemePickerGoogle_res"], + + optimize: { + enabled: false, + }, + kotlincflags: ["-Xjvm-default=enable"], + certificate: "platform", + + privileged: true, + system_ext_specific: true, + platform_apis: true, + manifest: "AndroidManifest.xml", + additional_manifests: [":WallpaperPicker2_Manifest", ":ThemePicker_Manifest"], + + overrides: ["ThemePicker", "WallpaperPicker2", "WallpaperPicker"], +} diff --git a/ThemePickerGoogle/AndroidManifest.xml b/ThemePickerGoogle/AndroidManifest.xml new file mode 100644 index 0000000..8f00c0f --- /dev/null +++ b/ThemePickerGoogle/AndroidManifest.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + diff --git a/ThemePickerGoogle/res/values/strings.xml b/ThemePickerGoogle/res/values/strings.xml new file mode 100644 index 0000000..2344e87 --- /dev/null +++ b/ThemePickerGoogle/res/values/strings.xml @@ -0,0 +1,21 @@ + + + + + Custom Themes & Styles + + diff --git a/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt new file mode 100644 index 0000000..4c4f111 --- /dev/null +++ b/ThemePickerGoogle/src/com/google/android/customization/module/GoogleCustomizationInjector.kt @@ -0,0 +1,5 @@ +package com.google.android.customization.module + +import com.android.customization.module.DefaultCustomizationInjector + +public class GoogleCustomizationInjector : DefaultCustomizationInjector() diff --git a/ThemePickerGoogle/src/com/google/android/customization/picker/GoogleCustomizationPickerApplication.kt b/ThemePickerGoogle/src/com/google/android/customization/picker/GoogleCustomizationPickerApplication.kt new file mode 100644 index 0000000..bcd9990 --- /dev/null +++ b/ThemePickerGoogle/src/com/google/android/customization/picker/GoogleCustomizationPickerApplication.kt @@ -0,0 +1,17 @@ +package com.google.android.customization.picker + +import android.app.Application; + +import com.android.wallpaper.module.InjectorProvider; + +import com.google.android.customization.module.GoogleCustomizationInjector; + +public class GoogleCustomizationPickerApplication : Application() { + + override fun onCreate() { + super.onCreate() + + InjectorProvider.setInjector(GoogleCustomizationInjector()); + } + +} diff --git a/ThemePickerGoogle/src_override/com/android/wallpaper/config/Flags.kt b/ThemePickerGoogle/src_override/com/android/wallpaper/config/Flags.kt new file mode 100644 index 0000000..40d83ce --- /dev/null +++ b/ThemePickerGoogle/src_override/com/android/wallpaper/config/Flags.kt @@ -0,0 +1,18 @@ +/* + * 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.config + +internal class Flags : BaseFlags() diff --git a/ThemePickerGoogle/src_override/com/android/wallpaper/module/WallpapersInjector.java b/ThemePickerGoogle/src_override/com/android/wallpaper/module/WallpapersInjector.java new file mode 100644 index 0000000..f8a4182 --- /dev/null +++ b/ThemePickerGoogle/src_override/com/android/wallpaper/module/WallpapersInjector.java @@ -0,0 +1,112 @@ +/* + * 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.ImagePreviewFragment; +import com.android.wallpaper.picker.TopLevelPickerActivity; + +/** + * 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, TopLevelPickerActivity.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; + } +}