summaryrefslogtreecommitdiff
path: root/src/com/android
diff options
context:
space:
mode:
authorGeorge Lin <giolin@google.com>2022-08-09 21:44:04 +0000
committerGeorge Lin <giolin@google.com>2022-09-08 14:56:21 +0000
commit92b3661ab7b37d3dd01c139609c821ed298534b6 (patch)
treecb4d59feb6050b034cfe6ae854f7afce1bab682e /src/com/android
parentc2414bf4bd1713a6f7d7e10f536c9c7fe4723ebe (diff)
downloadThemePicker-92b3661ab7b37d3dd01c139609c821ed298534b6.tar.gz
Add clock custom fragment
Add clock custom fragment for customizing clock surface. This is just an empty UI and in need to call clock face's API for the content. Design: http://shortn/_7RDNjpWEmS Bug: 241966062 Test: https://screenshot.googleplex.com/AUX4So9hYia6SjD Change-Id: Id3cc910a2b181e88a01dd2f4a4d00eb54de0b10c
Diffstat (limited to 'src/com/android')
-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
4 files changed, 174 insertions, 1 deletions
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();
+ }
+}