diff options
author | Chihhang Chuang <chihhangchuang@google.com> | 2021-06-09 13:55:28 +0800 |
---|---|---|
committer | Chihhang Chuang <chihhangchuang@google.com> | 2021-06-09 15:51:15 +0800 |
commit | c395e58f4c8d0028a941d5e08f3dd1d2b3b00a23 (patch) | |
tree | 3bce74f11a8a496c8d92e6a9a4e7d88f26ad7892 /src | |
parent | c21a3ffb6726945e8d56845eb326a1c835529fc9 (diff) | |
download | ThemePicker-c395e58f4c8d0028a941d5e08f3dd1d2b3b00a23.tar.gz |
[2/n] Move new picker logic to AOSP
- Wallpaper section
Bug: 190354625
Test: Build and run the app
Change-Id: I2ac6e82abdd2b114d3da5688ff8ecf561032d05f
Diffstat (limited to 'src')
10 files changed, 13 insertions, 158 deletions
diff --git a/src/com/android/customization/model/HubSectionController.java b/src/com/android/customization/model/HubSectionController.java deleted file mode 100644 index 765e520a..00000000 --- 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 a84e878f..a570565c 100644 --- a/src/com/android/customization/model/grid/GridSectionController.java +++ b/src/com/android/customization/model/grid/GridSectionController.java @@ -24,10 +24,10 @@ import android.widget.TextView; 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 f3a9c05b..803f7222 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.content.Intent; 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 9dd4b65e..493774d4 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.Lifecycle; 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 7b2d06ad..20f3746e 100644 --- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java +++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java @@ -20,20 +20,21 @@ import android.view.LayoutInflater; 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 @@ public class ThemedIconSectionController implements HubSectionController<ThemedI 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 f8906ff7..00000000 --- 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 c1fd21ac..00000000 --- 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 12f72747..58468e10 100644 --- a/src/com/android/customization/picker/grid/GridSectionView.java +++ b/src/com/android/customization/picker/grid/GridSectionView.java @@ -20,7 +20,7 @@ import android.util.AttributeSet; 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 353579a9..090dce17 100644 --- a/src/com/android/customization/picker/mode/ModeSectionView.java +++ b/src/com/android/customization/picker/mode/ModeSectionView.java @@ -22,8 +22,8 @@ import android.widget.Switch; 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 12801065..3e03a41c 100644 --- a/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java +++ b/src/com/android/customization/picker/themedicon/ThemedIconSectionView.java @@ -21,8 +21,8 @@ import android.widget.Switch; 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 |