[2/n] Move new picker logic to AOSP
- Wallpaper section
Bug: 190354625
Test: Build and run the app
Change-Id: I2ac6e82abdd2b114d3da5688ff8ecf561032d05f
diff --git a/res/drawable/ic_nav_wallpaper.xml b/res/drawable/ic_nav_wallpaper.xml
deleted file mode 100644
index c935666..0000000
--- a/res/drawable/ic_nav_wallpaper.xml
+++ /dev/null
@@ -1,25 +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.
--->
-<!-- Represents the wallpaper icon (a "landscape" shape in a box) -->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M9,12.71l2.14,2.58l3,-3.87L18,16.57H6L9,12.71zM5,5h6V3H5C3.9,3 3,3.9 3,5v6h2V5zM19,19h-6v2h6c1.1,0 2,-0.9 2,-2v-6h-2V19zM5,19v-6H3v6c0,1.1 0.9,2 2,2h6v-2H5zM19,5v6h2V5c0,-1.1 -0.9,-2 -2,-2h-6v2H19zM16,9c0.55,0 1,-0.45 1,-1s-0.45,-1 -1,-1c-0.55,0 -1,0.45 -1,1S15.45,9 16,9z"/>
-</vector>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 51ff6f1..193d6c3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -120,12 +120,4 @@
<dimen name="theme_info_app_preview_icon_margin">2dp</dimen>
<dimen name="theme_info_app_preview_icon_elevation">2dp</dimen>
<dimen name="theme_info_text_size">28sp</dimen>
-
- <!-- Common dimensions for option sections -->
- <dimen name="section_container_vertical_margin">24dp</dimen>
- <dimen name="section_horizontal_padding">24dp</dimen>
- <dimen name="section_vertical_padding">24dp</dimen>
- <dimen name="section_top_padding">16dp</dimen>
- <dimen name="section_bottom_padding">16dp</dimen>
-
</resources>
diff --git a/src/com/android/customization/model/HubSectionController.java b/src/com/android/customization/model/HubSectionController.java
deleted file mode 100644
index 765e520..0000000
--- a/src/com/android/customization/model/HubSectionController.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2021 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.model;
-
-import android.content.Context;
-import android.os.Bundle;
-
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-
-import com.android.customization.picker.SectionView;
-
-/**
- * The interface for the behavior of section in the Customization hub.
- *
- * @param <T> the {@link SectionView} to create for the section
- */
-public interface HubSectionController<T extends SectionView> {
-
- /** Interface for Customization hub section navigation. */
- interface HubSectionNavigationController {
- /** Navigates to the given {@code fragment}. */
- void navigateTo(Fragment fragment);
- }
-
- /** Interface for Customization hub section's dark mode responding to battery saver. */
- interface HubSectionBatterySaverListener {
- /** Callback when battery saver's state changed with given {@code isEnabled}. */
- void onBatterySaverStateChanged(boolean isEnabled);
- }
-
- /** Returns {@code true} if the Customization hub section is available. */
- boolean isAvailable(@Nullable Context context);
-
- /**
- * Returns a newly created {@link SectionView} for the section.
- *
- * @param context the {@link Context} to inflate view
- */
- T createView(Context context);
-
- /** Saves the view state for configuration changes. */
- default void onSaveInstanceState(Bundle savedInstanceState) {}
-
- /** Releases the controller. */
- default void release() {}
-}
diff --git a/src/com/android/customization/model/grid/GridSectionController.java b/src/com/android/customization/model/grid/GridSectionController.java
index a84e878..a570565 100644
--- a/src/com/android/customization/model/grid/GridSectionController.java
+++ b/src/com/android/customization/model/grid/GridSectionController.java
@@ -24,10 +24,10 @@
import androidx.annotation.Nullable;
import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
-import com.android.customization.model.HubSectionController;
import com.android.customization.picker.grid.GridFragment;
import com.android.customization.picker.grid.GridSectionView;
import com.android.wallpaper.R;
+import com.android.wallpaper.model.HubSectionController;
import java.util.List;
diff --git a/src/com/android/customization/model/mode/BatterySaverStateReceiver.java b/src/com/android/customization/model/mode/BatterySaverStateReceiver.java
index f3a9c05..803f722 100644
--- a/src/com/android/customization/model/mode/BatterySaverStateReceiver.java
+++ b/src/com/android/customization/model/mode/BatterySaverStateReceiver.java
@@ -23,7 +23,7 @@
import android.os.PowerManager;
import android.text.TextUtils;
-import com.android.customization.model.HubSectionController.HubSectionBatterySaverListener;
+import com.android.wallpaper.model.HubSectionController.HubSectionBatterySaverListener;
/**
* Broadcast receiver for getting battery saver state and callback to
diff --git a/src/com/android/customization/model/mode/ModeSection.java b/src/com/android/customization/model/mode/ModeSection.java
index 9dd4b65..493774d 100644
--- a/src/com/android/customization/model/mode/ModeSection.java
+++ b/src/com/android/customization/model/mode/ModeSection.java
@@ -34,10 +34,10 @@
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;
-import com.android.customization.model.HubSectionController;
-import com.android.customization.model.HubSectionController.HubSectionBatterySaverListener;
import com.android.customization.picker.mode.ModeSectionView;
import com.android.wallpaper.R;
+import com.android.wallpaper.model.HubSectionController;
+import com.android.wallpaper.model.HubSectionController.HubSectionBatterySaverListener;
/**
* Section for dark theme toggle that controls if this section will be shown visually
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
index 7b2d06a..20f3746 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
@@ -20,20 +20,21 @@
import androidx.annotation.Nullable;
-import com.android.customization.model.HubSectionController;
import com.android.customization.picker.themedicon.ThemedIconSectionView;
import com.android.wallpaper.R;
+import com.android.wallpaper.model.HubSectionController;
+import com.android.wallpaper.model.WorkspaceViewModel;
/** The {@link HubSectionController} for themed icon section. */
public class ThemedIconSectionController implements HubSectionController<ThemedIconSectionView> {
private final ThemedIconSwitchProvider mThemedIconOptionsProvider;
- private final ThemedIconViewModel mThemedIconViewModel;
+ private final WorkspaceViewModel mWorkspaceViewModel;
public ThemedIconSectionController(ThemedIconSwitchProvider themedIconOptionsProvider,
- ThemedIconViewModel themedIconViewModel) {
+ WorkspaceViewModel workspaceViewModel) {
mThemedIconOptionsProvider = themedIconOptionsProvider;
- mThemedIconViewModel = themedIconViewModel;
+ mWorkspaceViewModel = workspaceViewModel;
}
@Override
@@ -57,6 +58,6 @@
return;
}
mThemedIconOptionsProvider.setThemedIconEnabled(viewActivated);
- mThemedIconViewModel.getThemedIconEnabled().setValue(viewActivated);
+ mWorkspaceViewModel.getUpdateWorkspace().setValue(viewActivated);
}
}
diff --git a/src/com/android/customization/model/themedicon/ThemedIconViewModel.kt b/src/com/android/customization/model/themedicon/ThemedIconViewModel.kt
deleted file mode 100644
index f8906ff..0000000
--- a/src/com/android/customization/model/themedicon/ThemedIconViewModel.kt
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2021 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.model.themedicon
-
-import androidx.lifecycle.MutableLiveData
-import androidx.lifecycle.ViewModel
-
-/**
- * ViewModel class to keep track of themed icon
- */
-class ThemedIconViewModel : ViewModel() {
-
- /**
- * Flag for the themed icon enabled or not
- */
- val themedIconEnabled: MutableLiveData<Boolean> by lazy {
- MutableLiveData<Boolean>()
- }
-}
diff --git a/src/com/android/customization/picker/SectionView.java b/src/com/android/customization/picker/SectionView.java
deleted file mode 100644
index c1fd21a..0000000
--- a/src/com/android/customization/picker/SectionView.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2021 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.Context;
-import android.util.AttributeSet;
-import android.widget.LinearLayout;
-
-import androidx.annotation.Nullable;
-
-/**
- * The SectionView base for views hosting in the {@link
- * com.android.customization.picker.hub.HubFragment}.
- */
-public abstract class SectionView extends LinearLayout {
-
- /** The callback for the section view updates. */
- public interface SectionViewListener {
- void onViewActivated(@Nullable Context context, boolean viewActivated);
- }
-
- protected SectionViewListener mSectionViewListener;
- private String mTitle;
-
- public SectionView(Context context, @Nullable AttributeSet attrs) {
- super(context, attrs);
- }
-
- public void setTitle(String title) {
- mTitle = title;
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- /** Sets the listener to the {@code SectionView} instance for reacting the view changes. */
- public void setViewListener(SectionViewListener sectionViewListener) {
- mSectionViewListener = sectionViewListener;
- }
-}
diff --git a/src/com/android/customization/picker/grid/GridSectionView.java b/src/com/android/customization/picker/grid/GridSectionView.java
index 12f7274..58468e1 100644
--- a/src/com/android/customization/picker/grid/GridSectionView.java
+++ b/src/com/android/customization/picker/grid/GridSectionView.java
@@ -20,7 +20,7 @@
import androidx.annotation.Nullable;
-import com.android.customization.picker.SectionView;
+import com.android.wallpaper.picker.SectionView;
/** The {@link SectionView} for app grid. */
public final class GridSectionView extends SectionView {
diff --git a/src/com/android/customization/picker/mode/ModeSectionView.java b/src/com/android/customization/picker/mode/ModeSectionView.java
index 353579a..090dce1 100644
--- a/src/com/android/customization/picker/mode/ModeSectionView.java
+++ b/src/com/android/customization/picker/mode/ModeSectionView.java
@@ -22,8 +22,8 @@
import androidx.annotation.Nullable;
-import com.android.customization.picker.SectionView;
import com.android.wallpaper.R;
+import com.android.wallpaper.picker.SectionView;
/**
* The view of section in the Customization Hub fragment.
diff --git a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
index 1280106..3e03a41 100644
--- a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
+++ b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java
@@ -21,8 +21,8 @@
import androidx.annotation.Nullable;
-import com.android.customization.picker.SectionView;
import com.android.wallpaper.R;
+import com.android.wallpaper.picker.SectionView;
/**
* The {@link SectionView} for themed icon section view