From d2ece574d224dc84c0fd4643af1f258df2121228 Mon Sep 17 00:00:00 2001 From: Chihhang Chuang Date: Thu, 17 Jun 2021 22:40:26 +0800 Subject: Fix ThemePicker build and exclude unused features - Exclude Theme and Clock from builds since they are unused, should add them back when the features are needed. Screenshot: https://screenshot.googleplex.com/AeLSMUFq5EdndWr.png Bug: 190354625 Test: m ThemePicker Change-Id: I0219fa5b27354fc7afdcb5526e1b8e8e3d29b755 --- Android.bp | 17 +++++ AndroidManifest.xml | 5 +- res/layout/theme_info_view.xml | 4 +- .../picker/ClockFacePickerActivity.java | 83 --------------------- .../picker/ViewOnlyFullPreviewActivity.java | 10 --- .../picker/clock/ClockFacePickerActivity.java | 82 +++++++++++++++++++++ .../customization/picker/theme/ThemeFragment.java | 1 - .../picker/theme/ThemeFullPreviewFragment.java | 1 - .../customization/picker/theme/ThemeInfoView.java | 84 ++++++++++++++++++++++ .../customization/widget/ThemeInfoView.java | 84 ---------------------- 10 files changed, 186 insertions(+), 185 deletions(-) delete mode 100644 src/com/android/customization/picker/ClockFacePickerActivity.java create mode 100644 src/com/android/customization/picker/clock/ClockFacePickerActivity.java create mode 100644 src/com/android/customization/picker/theme/ThemeInfoView.java delete mode 100644 src/com/android/customization/widget/ThemeInfoView.java diff --git a/Android.bp b/Android.bp index 8f02388a..57d30ce5 100644 --- a/Android.bp +++ b/Android.bp @@ -24,6 +24,22 @@ filegroup { srcs: [ "src/**/*.java", "src/**/*.kt", + // Min requirement for CustomizationInjector and StatsLogUserEventLogger to build without Clock and Theme feature. + "src/com/android/customization/model/clock/BaseClockManager.java", + "src/com/android/customization/model/clock/Clockface.java", + "src/com/android/customization/model/clock/ClockManager.java", + "src/com/android/customization/model/clock/ClockProvider.java", + "src/com/android/customization/model/theme/OverlayManagerCompat.java", + "src/com/android/customization/model/theme/ThemeBundleProvider.java", + "src/com/android/customization/model/theme/ThemeManager.java", + "src/com/android/customization/model/theme/ThemeBundle.java", + "src/com/android/customization/model/theme/custom/CustomTheme.java", + ], + exclude_srcs: [ + "src/com/android/customization/model/clock/**/*.java", + "src/com/android/customization/model/theme/**/*.java", + "src/com/android/customization/picker/clock/**/*.java", + "src/com/android/customization/picker/theme/**/*.java", ], } @@ -80,5 +96,6 @@ android_app { system_ext_specific: true, platform_apis: true, manifest: "AndroidManifest.xml", + additional_manifests: [":WallpaperPicker2_Manifest"], overrides: ["WallpaperPicker2"], } diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 4f624296..bae1cb37 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -48,6 +48,7 @@ android:name="com.android.customization.picker.CustomizationPickerApplication" android:theme="@style/CustomizationTheme"> - - diff --git a/res/layout/theme_info_view.xml b/res/layout/theme_info_view.xml index 83422ed9..085a35e3 100644 --- a/res/layout/theme_info_view.xml +++ b/res/layout/theme_info_view.xml @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. --> - - \ No newline at end of file + \ No newline at end of file diff --git a/src/com/android/customization/picker/ClockFacePickerActivity.java b/src/com/android/customization/picker/ClockFacePickerActivity.java deleted file mode 100644 index 5065aef4..00000000 --- a/src/com/android/customization/picker/ClockFacePickerActivity.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (C) 2019 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.customization.picker; - -import android.content.Intent; -import android.os.Bundle; -import androidx.fragment.app.FragmentActivity; -import androidx.fragment.app.FragmentManager; -import androidx.fragment.app.FragmentTransaction; -import com.android.customization.model.clock.BaseClockManager; -import com.android.customization.model.clock.Clockface; -import com.android.customization.model.clock.ContentProviderClockProvider; -import com.android.customization.picker.clock.ClockFragment; -import com.android.customization.picker.clock.ClockFragment.ClockFragmentHost; -import com.android.wallpaper.R; - -/** - * Activity allowing for the clock face picker to be linked to from other setup flows. - * - * This should be used with startActivityForResult. The resulting intent contains an extra - * "clock_face_name" with the id of the picked clock face. - */ -public class ClockFacePickerActivity extends FragmentActivity implements ClockFragmentHost { - - private static final String EXTRA_CLOCK_FACE_NAME = "clock_face_name"; - - private BaseClockManager mClockManager; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_clock_face_picker); - - // Creating a class that overrides {@link ClockManager#apply} to return the clock id to the - // calling activity instead of putting the value into settings. - // - mClockManager = new BaseClockManager( - new ContentProviderClockProvider(ClockFacePickerActivity.this)) { - - @Override - protected void handleApply(Clockface option, Callback callback) { - Intent result = new Intent(); - result.putExtra(EXTRA_CLOCK_FACE_NAME, option.getId()); - setResult(RESULT_OK, result); - callback.onSuccess(); - finish(); - } - - @Override - protected String lookUpCurrentClock() { - return getIntent().getStringExtra(EXTRA_CLOCK_FACE_NAME); - } - }; - if (!mClockManager.isAvailable()) { - finish(); - } else { - final FragmentManager fm = getSupportFragmentManager(); - final FragmentTransaction fragmentTransaction = fm.beginTransaction(); - final ClockFragment clockFragment = ClockFragment.newInstance( - getString(R.string.clock_title)); - fragmentTransaction.replace(R.id.fragment_container, clockFragment); - fragmentTransaction.commitNow(); - } - } - - @Override - public BaseClockManager getClockManager() { - return mClockManager; - } -} diff --git a/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java b/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java index 91c310c2..44c6835b 100644 --- a/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java +++ b/src/com/android/customization/picker/ViewOnlyFullPreviewActivity.java @@ -15,8 +15,6 @@ */ package com.android.customization.picker; -import static com.android.customization.picker.theme.ThemeFullPreviewFragment.EXTRA_THEME_OPTION_TITLE; - import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -28,7 +26,6 @@ import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import com.android.customization.picker.grid.GridFullPreviewFragment; -import com.android.customization.picker.theme.ThemeFullPreviewFragment; import com.android.wallpaper.R; import com.android.wallpaper.picker.AppbarFragment.AppbarFragmentHost; import com.android.wallpaper.widget.BottomActionBar; @@ -81,13 +78,6 @@ public class ViewOnlyFullPreviewActivity extends FragmentActivity implements App if (section == SECTION_GRID) { showFragment(GridFullPreviewFragment.newInstance( getString(R.string.grid_title), bundle)); - } else if (section == SECTION_STYLE) { - final String themeTitle = bundle.getString(EXTRA_THEME_OPTION_TITLE); - showFragment(ThemeFullPreviewFragment.newInstance( - TextUtils.isEmpty(themeTitle) - ? getString(R.string.theme_title) - : themeTitle, - bundle)); } } diff --git a/src/com/android/customization/picker/clock/ClockFacePickerActivity.java b/src/com/android/customization/picker/clock/ClockFacePickerActivity.java new file mode 100644 index 00000000..5e512341 --- /dev/null +++ b/src/com/android/customization/picker/clock/ClockFacePickerActivity.java @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2019 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.customization.picker.clock; + +import android.content.Intent; +import android.os.Bundle; +import androidx.fragment.app.FragmentActivity; +import androidx.fragment.app.FragmentManager; +import androidx.fragment.app.FragmentTransaction; +import com.android.customization.model.clock.BaseClockManager; +import com.android.customization.model.clock.Clockface; +import com.android.customization.model.clock.ContentProviderClockProvider; +import com.android.customization.picker.clock.ClockFragment.ClockFragmentHost; +import com.android.wallpaper.R; + +/** + * Activity allowing for the clock face picker to be linked to from other setup flows. + * + * This should be used with startActivityForResult. The resulting intent contains an extra + * "clock_face_name" with the id of the picked clock face. + */ +public class ClockFacePickerActivity extends FragmentActivity implements ClockFragmentHost { + + private static final String EXTRA_CLOCK_FACE_NAME = "clock_face_name"; + + private BaseClockManager mClockManager; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_clock_face_picker); + + // Creating a class that overrides {@link ClockManager#apply} to return the clock id to the + // calling activity instead of putting the value into settings. + // + mClockManager = new BaseClockManager( + new ContentProviderClockProvider(ClockFacePickerActivity.this)) { + + @Override + protected void handleApply(Clockface option, Callback callback) { + Intent result = new Intent(); + result.putExtra(EXTRA_CLOCK_FACE_NAME, option.getId()); + setResult(RESULT_OK, result); + callback.onSuccess(); + finish(); + } + + @Override + protected String lookUpCurrentClock() { + return getIntent().getStringExtra(EXTRA_CLOCK_FACE_NAME); + } + }; + if (!mClockManager.isAvailable()) { + finish(); + } else { + final FragmentManager fm = getSupportFragmentManager(); + final FragmentTransaction fragmentTransaction = fm.beginTransaction(); + final ClockFragment clockFragment = ClockFragment.newInstance( + getString(R.string.clock_title)); + fragmentTransaction.replace(R.id.fragment_container, clockFragment); + fragmentTransaction.commitNow(); + } + } + + @Override + public BaseClockManager getClockManager() { + return mClockManager; + } +} diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java index 5ff5ef82..965a2ad9 100644 --- a/src/com/android/customization/picker/theme/ThemeFragment.java +++ b/src/com/android/customization/picker/theme/ThemeFragment.java @@ -51,7 +51,6 @@ import com.android.customization.module.ThemesUserEventLogger; import com.android.customization.picker.ViewOnlyFullPreviewActivity; import com.android.customization.picker.WallpaperPreviewer; import com.android.customization.widget.OptionSelectorController; -import com.android.customization.widget.ThemeInfoView; import com.android.wallpaper.R; import com.android.wallpaper.model.WallpaperInfo; import com.android.wallpaper.module.CurrentWallpaperInfoFactory; diff --git a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java index 77325e7c..5ea84ce8 100644 --- a/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java +++ b/src/com/android/customization/picker/theme/ThemeFullPreviewFragment.java @@ -37,7 +37,6 @@ import com.android.customization.model.theme.ThemeBundle; import com.android.customization.model.theme.ThemeBundleProvider; import com.android.customization.module.CustomizationInjector; import com.android.customization.picker.WallpaperPreviewer; -import com.android.customization.widget.ThemeInfoView; import com.android.wallpaper.R; import com.android.wallpaper.model.WallpaperInfo; import com.android.wallpaper.module.InjectorProvider; diff --git a/src/com/android/customization/picker/theme/ThemeInfoView.java b/src/com/android/customization/picker/theme/ThemeInfoView.java new file mode 100644 index 00000000..e929c4d2 --- /dev/null +++ b/src/com/android/customization/picker/theme/ThemeInfoView.java @@ -0,0 +1,84 @@ +/* + * Copyright (C) 2020 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.customization.picker.theme; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.util.AttributeSet; +import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.android.customization.model.theme.ThemeBundle; +import com.android.wallpaper.R; + +/** A view for displaying style info. */ +public class ThemeInfoView extends LinearLayout { + private static final int WIFI_ICON_PREVIEW_INDEX = 0; + private static final int SHAPE_PREVIEW_INDEX = 0; + + private TextView mTitle; + private TextView mFontPreviewTextView; + private ImageView mIconPreviewImageView; + private ImageView mAppPreviewImageView; + private ImageView mShapePreviewImageView; + + public ThemeInfoView(Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onFinishInflate() { + super.onFinishInflate(); + mTitle = findViewById(R.id.style_info_title); + mFontPreviewTextView = findViewById(R.id.font_preview); + mIconPreviewImageView = findViewById(R.id.qs_preview_icon); + mAppPreviewImageView = findViewById(R.id.app_preview_icon); + mShapePreviewImageView = findViewById(R.id.shape_preview_icon); + } + + /** Populates theme info. */ + public void populateThemeInfo(@NonNull ThemeBundle selectedTheme) { + ThemeBundle.PreviewInfo previewInfo = selectedTheme.getPreviewInfo(); + + if (previewInfo != null) { + mTitle.setText(getContext().getString(R.string.style_info_description)); + if (previewInfo.headlineFontFamily != null) { + mTitle.setTypeface(previewInfo.headlineFontFamily); + mFontPreviewTextView.setTypeface(previewInfo.headlineFontFamily); + } + + if (previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX) != null) { + mIconPreviewImageView.setImageDrawable( + previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX)); + } + + if (previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX) != null) { + mAppPreviewImageView.setBackground( + previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX).getDrawableCopy()); + } + + if (previewInfo.shapeDrawable != null) { + mShapePreviewImageView.setImageDrawable(previewInfo.shapeDrawable); + mShapePreviewImageView.setImageTintList( + ColorStateList.valueOf(previewInfo.resolveAccentColor(getResources()))); + } + } + } +} diff --git a/src/com/android/customization/widget/ThemeInfoView.java b/src/com/android/customization/widget/ThemeInfoView.java deleted file mode 100644 index 9eb0320b..00000000 --- a/src/com/android/customization/widget/ThemeInfoView.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (C) 2020 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.customization.widget; - -import android.content.Context; -import android.content.res.ColorStateList; -import android.util.AttributeSet; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.TextView; - -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; - -import com.android.customization.model.theme.ThemeBundle; -import com.android.wallpaper.R; - -/** A view for displaying style info. */ -public class ThemeInfoView extends LinearLayout { - private static final int WIFI_ICON_PREVIEW_INDEX = 0; - private static final int SHAPE_PREVIEW_INDEX = 0; - - private TextView mTitle; - private TextView mFontPreviewTextView; - private ImageView mIconPreviewImageView; - private ImageView mAppPreviewImageView; - private ImageView mShapePreviewImageView; - - public ThemeInfoView(Context context, @Nullable AttributeSet attrs) { - super(context, attrs); - } - - @Override - protected void onFinishInflate() { - super.onFinishInflate(); - mTitle = findViewById(R.id.style_info_title); - mFontPreviewTextView = findViewById(R.id.font_preview); - mIconPreviewImageView = findViewById(R.id.qs_preview_icon); - mAppPreviewImageView = findViewById(R.id.app_preview_icon); - mShapePreviewImageView = findViewById(R.id.shape_preview_icon); - } - - /** Populates theme info. */ - public void populateThemeInfo(@NonNull ThemeBundle selectedTheme) { - ThemeBundle.PreviewInfo previewInfo = selectedTheme.getPreviewInfo(); - - if (previewInfo != null) { - mTitle.setText(getContext().getString(R.string.style_info_description)); - if (previewInfo.headlineFontFamily != null) { - mTitle.setTypeface(previewInfo.headlineFontFamily); - mFontPreviewTextView.setTypeface(previewInfo.headlineFontFamily); - } - - if (previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX) != null) { - mIconPreviewImageView.setImageDrawable( - previewInfo.icons.get(WIFI_ICON_PREVIEW_INDEX)); - } - - if (previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX) != null) { - mAppPreviewImageView.setBackground( - previewInfo.shapeAppIcons.get(SHAPE_PREVIEW_INDEX).getDrawableCopy()); - } - - if (previewInfo.shapeDrawable != null) { - mShapePreviewImageView.setImageDrawable(previewInfo.shapeDrawable); - mShapePreviewImageView.setImageTintList( - ColorStateList.valueOf(previewInfo.resolveAccentColor(getResources()))); - } - } - } -} -- cgit v1.2.3