Merge "Replace "Hub" naming with "Customization"" into sc-dev
diff --git a/res/layout/mode_section_view.xml b/res/layout/dark_mode_section_view.xml
similarity index 93%
rename from res/layout/mode_section_view.xml
rename to res/layout/dark_mode_section_view.xml
index 12e0c04..d63f07a 100644
--- a/res/layout/mode_section_view.xml
+++ b/res/layout/dark_mode_section_view.xml
@@ -14,7 +14,7 @@
      See the License for the specific language governing permissions and
      limitations under the License.
 -->
-<com.android.customization.picker.mode.ModeSectionView
+<com.android.customization.picker.mode.DarkModeSectionView
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
@@ -41,4 +41,4 @@
         android:focusable="false"
         style="@style/Switch.SettingsLib" />
 
-</com.android.customization.picker.mode.ModeSectionView>
+</com.android.customization.picker.mode.DarkModeSectionView>
diff --git a/src/com/android/customization/model/CustomizationManager.java b/src/com/android/customization/model/CustomizationManager.java
index efc4c74..104cc83 100644
--- a/src/com/android/customization/model/CustomizationManager.java
+++ b/src/com/android/customization/model/CustomizationManager.java
@@ -28,20 +28,6 @@
 public interface CustomizationManager<T extends CustomizationOption> {
 
     /**
-     * Create a new {@link CustomizationSection} corresponding to this Manager
-     */
-    default CustomizationSection<T> createSection() {
-        return null;
-    }
-
-    /**
-     * @return the id in the navigation menu for the section this Manager manages.
-     */
-    default int getNavId() {
-        return 0;
-    };
-
-    /**
      * Callback for applying a customization option.
      */
     interface Callback {
diff --git a/src/com/android/customization/model/CustomizationSection.java b/src/com/android/customization/model/CustomizationSection.java
deleted file mode 100644
index da1b4f8..0000000
--- a/src/com/android/customization/model/CustomizationSection.java
+++ /dev/null
@@ -1,52 +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 androidx.annotation.IdRes;
-import androidx.fragment.app.Fragment;
-
-/**
- * Represents a section of the Picker (eg "ThemeBundle", "Clock", etc).
- * There should be a concrete subclass per available section, providing the corresponding
- * Fragment to be displayed when switching to each section.
- * @param <T> CustomizationOption that this section represents.
- */
-public abstract class CustomizationSection<T extends CustomizationOption> {
-
-    /**
-     * IdRes used to identify this section in the BottomNavigationView menu.
-     */
-    @IdRes
-    public final int id;
-    protected final CustomizationManager<T> mCustomizationManager;
-
-    public CustomizationSection(@IdRes int id, CustomizationManager<T> manager) {
-        this.id = id;
-        mCustomizationManager = manager;
-    }
-
-    /**
-     * @return the Fragment corresponding to this section.
-     */
-    public abstract Fragment getFragment(Context c);
-
-    public CustomizationManager<T> getCustomizationManager() {
-        return mCustomizationManager;
-    }
-
-}
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index c1ec729..da1139e 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -43,7 +43,7 @@
     private final ThemesUserEventLogger mEventLogger;
 
     /** Returns the {@link GridOptionsManager} instance. */
-    public static GridOptionsManager get(Context context) {
+    public static GridOptionsManager getInstance(Context context) {
         if (sGridOptionsManager == null) {
             Context appContext = context.getApplicationContext();
             CustomizationInjector injector = (CustomizationInjector) InjectorProvider.getInjector();
diff --git a/src/com/android/customization/model/grid/GridSectionController.java b/src/com/android/customization/model/grid/GridSectionController.java
index a570565..5470d77 100644
--- a/src/com/android/customization/model/grid/GridSectionController.java
+++ b/src/com/android/customization/model/grid/GridSectionController.java
@@ -27,22 +27,22 @@
 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 com.android.wallpaper.model.CustomizationSectionController;
 
 import java.util.List;
 
-/** A {@link HubSectionController} for app grid. */
-public class GridSectionController implements HubSectionController<GridSectionView> {
+/** A {@link CustomizationSectionController} for app grid. */
+public class GridSectionController implements CustomizationSectionController<GridSectionView> {
 
     private static final String TAG = "GridSectionController";
 
     private final GridOptionsManager mGridOptionsManager;
-    private final HubSectionNavigationController mHubSectionNavigationController;
+    private final CustomizationSectionNavigationController mSectionNavigationController;
 
     public GridSectionController(GridOptionsManager gridOptionsManager,
-            HubSectionNavigationController hubSectionNavigationController) {
+            CustomizationSectionNavigationController sectionNavigationController) {
         mGridOptionsManager = gridOptionsManager;
-        mHubSectionNavigationController = hubSectionNavigationController;
+        mSectionNavigationController = sectionNavigationController;
     }
 
     @Override
@@ -74,7 +74,7 @@
             }
         }, /* reload= */ true);
 
-        gridSectionView.setOnClickListener(v -> mHubSectionNavigationController.navigateTo(
+        gridSectionView.setOnClickListener(v -> mSectionNavigationController.navigateTo(
                 GridFragment.newInstance(context.getString(R.string.grid_title))));
 
         return gridSectionView;
diff --git a/src/com/android/customization/model/mode/BatterySaverStateReceiver.java b/src/com/android/customization/model/mode/BatterySaverStateReceiver.java
deleted file mode 100644
index 803f722..0000000
--- a/src/com/android/customization/model/mode/BatterySaverStateReceiver.java
+++ /dev/null
@@ -1,47 +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.mode;
-
-import static android.os.PowerManager.ACTION_POWER_SAVE_MODE_CHANGED;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.os.PowerManager;
-import android.text.TextUtils;
-
-import com.android.wallpaper.model.HubSectionController.HubSectionBatterySaverListener;
-
-/**
- * Broadcast receiver for getting battery saver state and callback to
- * {@link HubSectionBatterySaverListener}
- */
-public class BatterySaverStateReceiver extends BroadcastReceiver {
-
-    private final HubSectionBatterySaverListener mHubSectionBatterySaverListener;
-
-    public BatterySaverStateReceiver(HubSectionBatterySaverListener batterySaverController) {
-        mHubSectionBatterySaverListener = batterySaverController;
-    }
-
-    @Override
-    public void onReceive(Context context, Intent intent) {
-        if (TextUtils.equals(intent.getAction(), ACTION_POWER_SAVE_MODE_CHANGED)) {
-            PowerManager pm = context.getSystemService(PowerManager.class);
-            mHubSectionBatterySaverListener.onBatterySaverStateChanged(pm.isPowerSaveMode());
-        }
-    }
-}
diff --git a/src/com/android/customization/model/mode/ModeSection.java b/src/com/android/customization/model/mode/DarkModeSectionController.java
similarity index 66%
rename from src/com/android/customization/model/mode/ModeSection.java
rename to src/com/android/customization/model/mode/DarkModeSectionController.java
index 9096e07..de63983 100644
--- a/src/com/android/customization/model/mode/ModeSection.java
+++ b/src/com/android/customization/model/mode/DarkModeSectionController.java
@@ -21,9 +21,12 @@
 import static android.os.PowerManager.ACTION_POWER_SAVE_MODE_CHANGED;
 
 import android.app.UiModeManager;
+import android.content.BroadcastReceiver;
 import android.content.Context;
+import android.content.Intent;
 import android.content.IntentFilter;
 import android.os.PowerManager;
+import android.text.TextUtils;
 import android.view.LayoutInflater;
 import android.widget.Switch;
 import android.widget.Toast;
@@ -34,32 +37,31 @@
 import androidx.lifecycle.LifecycleObserver;
 import androidx.lifecycle.OnLifecycleEvent;
 
-import com.android.customization.picker.mode.ModeSectionView;
+import com.android.customization.picker.mode.DarkModeSectionView;
 import com.android.wallpaper.R;
-import com.android.wallpaper.model.HubSectionController;
-import com.android.wallpaper.model.HubSectionController.HubSectionBatterySaverListener;
+import com.android.wallpaper.model.CustomizationSectionController;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-/**
- * Section for dark theme toggle that controls if this section will be shown visually
- */
-public class ModeSection implements HubSectionController<ModeSectionView>, LifecycleObserver,
-        HubSectionBatterySaverListener {
+/** Section for dark theme toggle that controls if this section will be shown visually. */
+public class DarkModeSectionController implements
+        CustomizationSectionController<DarkModeSectionView>, LifecycleObserver {
+
+    private static final ExecutorService sExecutorService = Executors.newSingleThreadExecutor();
 
     private final Lifecycle mLifecycle;
-    private final BatterySaverStateReceiver mBatterySaverStateReceiver;
-
-    private static ExecutorService sExecutorService = Executors.newSingleThreadExecutor();
+    private final PowerManager mPowerManager;
+    private final BatterySaverStateReceiver mBatterySaverStateReceiver =
+            new BatterySaverStateReceiver();
 
     private Context mContext;
-    private ModeSectionView mModeSectionView;
+    private DarkModeSectionView mDarkModeSectionView;
 
-    public ModeSection(Context context, Lifecycle lifecycle) {
+    public DarkModeSectionController(Context context, Lifecycle lifecycle) {
         mContext = context;
         mLifecycle = lifecycle;
-        mBatterySaverStateReceiver = new BatterySaverStateReceiver(this);
+        mPowerManager = context.getSystemService(PowerManager.class);
         mLifecycle.addObserver(this);
     }
 
@@ -101,20 +103,20 @@
     }
 
     @Override
-    public ModeSectionView createView(Context context) {
-        mModeSectionView = (ModeSectionView) LayoutInflater.from(
-                context).inflate(R.layout.mode_section_view, /* root= */ null);
-        mModeSectionView.setViewListener(this::onViewActivated);
+    public DarkModeSectionView createView(Context context) {
+        mDarkModeSectionView = (DarkModeSectionView) LayoutInflater.from(
+                context).inflate(R.layout.dark_mode_section_view, /* root= */ null);
+        mDarkModeSectionView.setViewListener(this::onViewActivated);
         PowerManager pm = context.getSystemService(PowerManager.class);
-        mModeSectionView.setEnabled(!pm.isPowerSaveMode());
-        return mModeSectionView;
+        mDarkModeSectionView.setEnabled(!pm.isPowerSaveMode());
+        return mDarkModeSectionView;
     }
 
     private void onViewActivated(Context context, boolean viewActivated) {
         if (context == null) {
             return;
         }
-        Switch switchView = mModeSectionView.findViewById(R.id.dark_mode_toggle);
+        Switch switchView = mDarkModeSectionView.findViewById(R.id.dark_mode_toggle);
         if (!switchView.isEnabled()) {
             Toast disableToast = Toast.makeText(mContext,
                     mContext.getString(R.string.mode_disabled_msg), Toast.LENGTH_SHORT);
@@ -125,8 +127,13 @@
         uiModeManager.setNightModeActivated(viewActivated);
     }
 
-    @Override
-    public void onBatterySaverStateChanged(boolean isEnabled) {
-        mModeSectionView.setEnabled(!isEnabled);
+    private class BatterySaverStateReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (TextUtils.equals(intent.getAction(), ACTION_POWER_SAVE_MODE_CHANGED)
+                    && mDarkModeSectionView != null) {
+                mDarkModeSectionView.setEnabled(!mPowerManager.isPowerSaveMode());
+            }
+        }
     }
 }
diff --git a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
index 32fbfa8..9ec5c2c 100644
--- a/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
+++ b/src/com/android/customization/model/themedicon/ThemedIconSectionController.java
@@ -22,14 +22,15 @@
 
 import com.android.customization.picker.themedicon.ThemedIconSectionView;
 import com.android.wallpaper.R;
-import com.android.wallpaper.model.HubSectionController;
+import com.android.wallpaper.model.CustomizationSectionController;
 import com.android.wallpaper.model.WorkspaceViewModel;
 
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 
-/** The {@link HubSectionController} for themed icon section. */
-public class ThemedIconSectionController implements HubSectionController<ThemedIconSectionView> {
+/** The {@link CustomizationSectionController} for themed icon section. */
+public class ThemedIconSectionController implements
+        CustomizationSectionController<ThemedIconSectionView> {
 
     private final ThemedIconSwitchProvider mThemedIconOptionsProvider;
     private final WorkspaceViewModel mWorkspaceViewModel;
diff --git a/src/com/android/customization/module/CustomizationInjector.java b/src/com/android/customization/module/CustomizationInjector.java
index 722ebb3..85853de 100644
--- a/src/com/android/customization/module/CustomizationInjector.java
+++ b/src/com/android/customization/module/CustomizationInjector.java
@@ -16,11 +16,9 @@
 package com.android.customization.module;
 
 import android.content.Context;
-import android.content.Intent;
 
 import androidx.fragment.app.FragmentActivity;
 
-import com.android.customization.model.CustomizationManager;
 import com.android.customization.model.theme.OverlayManagerCompat;
 import com.android.customization.model.theme.ThemeBundleProvider;
 import com.android.customization.model.theme.ThemeManager;
@@ -32,31 +30,4 @@
 
     ThemeManager getThemeManager(ThemeBundleProvider provider, FragmentActivity activity,
             OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger logger);
-
-    /**
-     * Obtain an extra CustomizationManager to add to the bottom nav
-     */
-    default CustomizationManager<?> getExtraManager(FragmentActivity activity,
-            OverlayManagerCompat overlayManagerCompat, ThemesUserEventLogger eventLogger) {
-        return null;
-    }
-
-    /**
-     * Obtain an extra Customization intent to start Activity if any.
-     *
-     * @param context The {@link Context} of the application
-     * @return intent The {@link Intent} to start Activity
-     */
-    default Intent getCustomizeExtIntent(Context context) {
-        return null;
-    }
-
-    /**
-     * Check if the system supporting customization extension.
-     *
-     * @return {@code true} if the system supports customization extension, {@code false} otherwise.
-     */
-    default boolean supportsCustomizationExtended(Context context) {
-        return false;
-    }
 }
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/DefaultCustomizationInjector.java
index 5b5c11e..24dfb58 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/DefaultCustomizationInjector.java
@@ -31,8 +31,8 @@
 import com.android.wallpaper.model.CategoryProvider;
 import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.BaseWallpaperInjector;
+import com.android.wallpaper.module.CustomizationSections;
 import com.android.wallpaper.module.DefaultCategoryProvider;
-import com.android.wallpaper.module.HubSections;
 import com.android.wallpaper.module.LoggingOptInStatusProvider;
 import com.android.wallpaper.module.WallpaperPreferences;
 import com.android.wallpaper.module.WallpaperRotationRefresher;
@@ -47,7 +47,7 @@
     private WallpaperRotationRefresher mWallpaperRotationRefresher;
     private PerformanceMonitor mPerformanceMonitor;
     private WallpaperPreferences mPrefs;
-    private HubSections mHubSections;
+    private CustomizationSections mCustomizationSections;
 
     @Override
     public synchronized WallpaperPreferences getPreferences(Context context) {
@@ -142,10 +142,10 @@
     }
 
     @Override
-    public HubSections getHubSections() {
-        if (mHubSections == null) {
-            mHubSections = new DefaultCustomizationSections();
+    public CustomizationSections getCustomizationSections() {
+        if (mCustomizationSections == null) {
+            mCustomizationSections = new DefaultCustomizationSections();
         }
-        return mHubSections;
+        return mCustomizationSections;
     }
 }
diff --git a/src/com/android/customization/module/DefaultCustomizationSections.java b/src/com/android/customization/module/DefaultCustomizationSections.java
index d35d198..db9218f 100644
--- a/src/com/android/customization/module/DefaultCustomizationSections.java
+++ b/src/com/android/customization/module/DefaultCustomizationSections.java
@@ -8,42 +8,44 @@
 
 import com.android.customization.model.grid.GridOptionsManager;
 import com.android.customization.model.grid.GridSectionController;
-import com.android.customization.model.mode.ModeSection;
+import com.android.customization.model.mode.DarkModeSectionController;
 import com.android.customization.model.themedicon.ThemedIconSectionController;
 import com.android.customization.model.themedicon.ThemedIconSwitchProvider;
 import com.android.customization.model.themedicon.ThemedIconUtils;
 import com.android.wallpaper.R;
-import com.android.wallpaper.model.HubSectionController;
+import com.android.wallpaper.model.CustomizationSectionController;
+import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController;
 import com.android.wallpaper.model.PermissionRequester;
 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.HubSections;
+import com.android.wallpaper.module.CustomizationSections;
 
 import java.util.ArrayList;
 import java.util.List;
 
-/** {@link HubSections} for the customization picker. */
-public final class DefaultCustomizationSections implements HubSections {
+/** {@link CustomizationSections} for the customization picker. */
+public final class DefaultCustomizationSections implements CustomizationSections {
 
     @Override
-    public List<HubSectionController<?>> getAllSectionControllers(Activity activity,
+    public List<CustomizationSectionController<?>> getAllSectionControllers(Activity activity,
             LifecycleOwner lifecycleOwner, WallpaperColorsViewModel wallpaperColorsViewModel,
             WorkspaceViewModel workspaceViewModel, PermissionRequester permissionRequester,
             WallpaperPreviewNavigator wallpaperPreviewNavigator,
-            HubSectionController.HubSectionNavigationController hubSectionNavigationController,
+            CustomizationSectionNavigationController sectionNavigationController,
             @Nullable Bundle savedInstanceState) {
-        List<HubSectionController<?>> sectionControllers = new ArrayList<>();
+        List<CustomizationSectionController<?>> sectionControllers = new ArrayList<>();
 
         // Wallpaper section.
         sectionControllers.add(new WallpaperSectionController(
                 activity, lifecycleOwner, permissionRequester, wallpaperColorsViewModel,
-                workspaceViewModel, hubSectionNavigationController, wallpaperPreviewNavigator,
+                workspaceViewModel, sectionNavigationController, wallpaperPreviewNavigator,
                 savedInstanceState));
 
         // Dark/Light theme section.
-        sectionControllers.add(new ModeSection(activity, lifecycleOwner.getLifecycle()));
+        sectionControllers.add(new DarkModeSectionController(activity,
+                lifecycleOwner.getLifecycle()));
 
         // Themed app icon section.
         sectionControllers.add(new ThemedIconSectionController(
@@ -53,7 +55,7 @@
 
         // App grid section.
         sectionControllers.add(new GridSectionController(
-                GridOptionsManager.get(activity), hubSectionNavigationController));
+                GridOptionsManager.getInstance(activity), sectionNavigationController));
 
         return sectionControllers;
     }
diff --git a/src/com/android/customization/picker/grid/GridFragment.java b/src/com/android/customization/picker/grid/GridFragment.java
index 18fb5a7..45cc18d 100644
--- a/src/com/android/customization/picker/grid/GridFragment.java
+++ b/src/com/android/customization/picker/grid/GridFragment.java
@@ -134,7 +134,7 @@
         // Clear memory cache whenever grid fragment view is being loaded.
         Glide.get(getContext()).clearMemory();
 
-        mGridManager = GridOptionsManager.get(getContext());
+        mGridManager = GridOptionsManager.getInstance(getContext());
         mEventLogger = (ThemesUserEventLogger) InjectorProvider.getInjector()
                 .getUserEventLogger(getContext());
         setUpOptions(savedInstanceState);
diff --git a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
index fc724db..f4b0219 100644
--- a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
+++ b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
@@ -89,7 +89,7 @@
         SurfaceView wallpaperSurface = view.findViewById(R.id.wallpaper_preview_surface);
         mWallpaperPreviewer = new WallpaperPreviewer(
                 getLifecycle(), getActivity(), wallpaperPreviewImage, wallpaperSurface);
-        mGridOptionPreviewer = new GridOptionPreviewer(GridOptionsManager.get(getContext()),
+        mGridOptionPreviewer = new GridOptionPreviewer(GridOptionsManager.getInstance(getContext()),
                 view.findViewById(R.id.grid_preview_container));
         return view;
     }
diff --git a/src/com/android/customization/picker/mode/ModeSectionView.java b/src/com/android/customization/picker/mode/DarkModeSectionView.java
similarity index 91%
rename from src/com/android/customization/picker/mode/ModeSectionView.java
rename to src/com/android/customization/picker/mode/DarkModeSectionView.java
index 37e90a5..64b4622 100644
--- a/src/com/android/customization/picker/mode/ModeSectionView.java
+++ b/src/com/android/customization/picker/mode/DarkModeSectionView.java
@@ -25,14 +25,12 @@
 import com.android.wallpaper.R;
 import com.android.wallpaper.picker.SectionView;
 
-/**
- * The view of section in the Customization Hub fragment.
- */
-public final class ModeSectionView extends SectionView {
+/** The view of section in the customization picker fragment. */
+public final class DarkModeSectionView extends SectionView {
 
     private boolean mIsDarkModeActivated;
 
-    public ModeSectionView(Context context, @Nullable AttributeSet attrs) {
+    public DarkModeSectionView(Context context, @Nullable AttributeSet attrs) {
         super(context, attrs);
         setTitle(context.getString(R.string.mode_title));
         mIsDarkModeActivated = (context.getResources().getConfiguration().uiMode