summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/layout/fragment_clock_custom_picker.xml55
-rw-r--r--src/com/android/customization/model/clock/ClockSectionController.java6
-rw-r--r--src/com/android/customization/model/clock/custom/ClockCustomManager.java43
-rw-r--r--src/com/android/customization/model/clock/custom/ClockOption.java50
-rw-r--r--src/com/android/customization/picker/clock/ClockCustomFragment.java76
5 files changed, 229 insertions, 1 deletions
diff --git a/res/layout/fragment_clock_custom_picker.xml b/res/layout/fragment_clock_custom_picker.xml
new file mode 100644
index 00000000..f1bd12b3
--- /dev/null
+++ b/res/layout/fragment_clock_custom_picker.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ Copyright (C) 2022 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.
+-->
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingBottom="108dp">
+
+ <FrameLayout
+ android:id="@+id/section_header_container"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ app:layout_constraintBottom_toTopOf="@+id/preview_card_container"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent">
+
+ <include layout="@layout/section_header" />
+ </FrameLayout>
+
+ <FrameLayout
+ android:id="@+id/preview_card_container"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ app:layout_constrainedHeight="true"
+ app:layout_constraintBottom_toTopOf="@+id/clock_preview_card_list"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/section_header_container"
+ android:paddingBottom="@dimen/preview_page_bottom_margin"
+ android:paddingTop="@dimen/preview_page_top_margin"
+ android:clipToPadding="false" />
+
+ <androidx.recyclerview.widget.RecyclerView
+ android:id="@+id/clock_preview_card_list"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/options_container_height"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toBottomOf="@+id/preview_card_container"
+ android:paddingHorizontal="@dimen/grid_options_container_horizontal_margin"
+ android:scrollbars="horizontal"
+ android:clipToPadding="false" />
+</androidx.constraintlayout.widget.ConstraintLayout> \ No newline at end of file
diff --git a/src/com/android/customization/model/clock/ClockSectionController.java b/src/com/android/customization/model/clock/ClockSectionController.java
index cb8b9c8a..8f98b884 100644
--- a/src/com/android/customization/model/clock/ClockSectionController.java
+++ b/src/com/android/customization/model/clock/ClockSectionController.java
@@ -20,6 +20,7 @@ import android.view.LayoutInflater;
import androidx.annotation.Nullable;
+import com.android.customization.picker.clock.ClockCustomFragment;
import com.android.customization.picker.clock.ClockSectionView;
import com.android.wallpaper.R;
import com.android.wallpaper.config.Flags;
@@ -41,7 +42,10 @@ public class ClockSectionController implements CustomizationSectionController<Cl
@Override
public ClockSectionView createView(Context context) {
- return (ClockSectionView) LayoutInflater.from(context).inflate(R.layout.clock_section_view,
+ ClockSectionView view = (ClockSectionView) LayoutInflater.from(context).inflate(
+ R.layout.clock_section_view,
null);
+ view.setOnClickListener(v -> mNavigationController.navigateTo(new ClockCustomFragment()));
+ return view;
}
}
diff --git a/src/com/android/customization/model/clock/custom/ClockCustomManager.java b/src/com/android/customization/model/clock/custom/ClockCustomManager.java
new file mode 100644
index 00000000..0815a3ea
--- /dev/null
+++ b/src/com/android/customization/model/clock/custom/ClockCustomManager.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2022 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.clock.custom;
+
+import com.android.customization.model.CustomizationManager;
+
+import com.google.common.collect.Lists;
+
+/**
+ * {@link CustomizationManager} for clock faces.
+ */
+public class ClockCustomManager implements CustomizationManager<ClockOption> {
+ @Override
+ public boolean isAvailable() {
+ return true;
+ }
+
+ @Override
+ public void apply(ClockOption option, Callback callback) {
+ // TODO(/b241966062) execute applying the clock when user selects a clock
+ }
+
+ @Override
+ public void fetchOptions(OptionsFetchedListener<ClockOption> callback, boolean reload) {
+ // TODO(/b241966062) fetch the real clock metadata from the ClockRegistry
+ callback.onOptionsLoaded(
+ Lists.newArrayList(new ClockOption(), new ClockOption(), new ClockOption(),
+ new ClockOption(), new ClockOption()));
+ }
+}
diff --git a/src/com/android/customization/model/clock/custom/ClockOption.java b/src/com/android/customization/model/clock/custom/ClockOption.java
new file mode 100644
index 00000000..5a9f051a
--- /dev/null
+++ b/src/com/android/customization/model/clock/custom/ClockOption.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2022 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.clock.custom;
+
+import android.view.View;
+
+import com.android.customization.model.CustomizationManager;
+import com.android.customization.model.CustomizationOption;
+import com.android.wallpaper.R;
+
+/**
+ * {@link CustomizationOption} for a clock face.
+ */
+public class ClockOption implements CustomizationOption<ClockOption> {
+
+ @Override
+ public String getTitle() {
+ // TODO(/b241966062) use the title from the clock metadata
+ return "title";
+ }
+
+ @Override
+ public void bindThumbnailTile(View view) {
+ // TODO(/b241966062) bind the thumbnail
+ }
+
+ @Override
+ public boolean isActive(CustomizationManager<ClockOption> manager) {
+ return false;
+ }
+
+
+ @Override
+ public int getLayoutResId() {
+ return R.layout.clock_option;
+ }
+}
diff --git a/src/com/android/customization/picker/clock/ClockCustomFragment.java b/src/com/android/customization/picker/clock/ClockCustomFragment.java
new file mode 100644
index 00000000..56860fea
--- /dev/null
+++ b/src/com/android/customization/picker/clock/ClockCustomFragment.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2022 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 static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.customization.model.clock.custom.ClockCustomManager;
+import com.android.customization.model.clock.custom.ClockOption;
+import com.android.customization.widget.OptionSelectorController;
+import com.android.wallpaper.R;
+import com.android.wallpaper.picker.AppbarFragment;
+import com.android.wallpaper.widget.BottomActionBar;
+
+import com.google.common.collect.Lists;
+
+/**
+ * Fragment that contains the main UI for selecting and applying a custom clock.
+ */
+public class ClockCustomFragment extends AppbarFragment {
+
+ OptionSelectorController<ClockOption> mClockSelectorController;
+
+ @Nullable
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
+ @Nullable Bundle savedInstanceState) {
+ View view = inflater.inflate(R.layout.fragment_clock_custom_picker, container, false);
+
+ setUpToolbar(view);
+
+ RecyclerView clockPreviewCardList = view.requireViewById(R.id.clock_preview_card_list);
+
+ mClockSelectorController = new OptionSelectorController<>(clockPreviewCardList,
+ Lists.newArrayList(new ClockOption(), new ClockOption(), new ClockOption(),
+ new ClockOption(), new ClockOption()), false,
+ OptionSelectorController.CheckmarkStyle.CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED);
+ mClockSelectorController.initOptions(new ClockCustomManager());
+
+ return view;
+ }
+
+ @Override
+ public CharSequence getDefaultTitle() {
+ return getString(R.string.clock_title);
+ }
+
+ @Override
+ protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
+ super.onBottomActionBarReady(bottomActionBar);
+ bottomActionBar.showActionsOnly(INFORMATION, APPLY);
+ bottomActionBar.show();
+ }
+}