summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/SystemUI/res-keyguard/drawable-xxxhdpi/ssos_thumbnail.pngbin0 -> 7123 bytes
-rw-r--r--packages/SystemUI/res-keyguard/layout/digital_clock_ssos.xml86
-rw-r--r--packages/SystemUI/res-keyguard/layout/digital_clock_ssos_preview.xml86
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java1
-rw-r--r--packages/SystemUI/src/com/android/keyguard/clock/ShapeShiftClockController.java206
5 files changed, 379 insertions, 0 deletions
diff --git a/packages/SystemUI/res-keyguard/drawable-xxxhdpi/ssos_thumbnail.png b/packages/SystemUI/res-keyguard/drawable-xxxhdpi/ssos_thumbnail.png
new file mode 100644
index 000000000000..75441ea8c1ae
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/drawable-xxxhdpi/ssos_thumbnail.png
Binary files differ
diff --git a/packages/SystemUI/res-keyguard/layout/digital_clock_ssos.xml b/packages/SystemUI/res-keyguard/layout/digital_clock_ssos.xml
new file mode 100644
index 000000000000..23fca1c9c037
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/layout/digital_clock_ssos.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 ShapeShiftOS
+ 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.
+-->
+
+<com.android.keyguard.clock.ClockLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal|top">
+
+ <LinearLayout
+ android:id="@+id/clock_view"
+ android:layout_width="match_parent"
+ android:paddingLeft="20dp"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:orientation="vertical">
+
+ <TextClock
+ android:id="@+id/clock_day"
+ android:layout_width="match_parent"
+ android:textSize="44.5sp"
+ android:ellipsize="none"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:format12Hour="EEEE"
+ android:format24Hour="EEEE"
+ android:textColor="?android:textColorPrimary" />
+
+ <LinearLayout
+ android:id="@+id/clock"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="-4dp"
+ android:layout_gravity="left"
+ android:orientation="horizontal">
+
+ <TextClock
+ android:id="@+id/time_clock_accented"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"
+ android:ellipsize="none"
+ android:format12Hour="h"
+ android:format24Hour="kk"
+ android:textColor="?android:attr/colorAccent"
+ android:textSize="45.5sp" />
+
+ <TextClock
+ android:id="@+id/time_clock"
+ android:textSize="45.5sp"
+ android:layout_width="wrap_content"
+ android:ellipsize="none"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center|bottom"
+ android:format12Hour=":mm"
+ android:format24Hour=":mm"
+ android:textColor="?android:textColorPrimary"/>
+
+ </LinearLayout>
+
+ <TextClock
+ android:id="@+id/timedate"
+ android:layout_width="wrap_content"
+ android:textSize="15sp"
+ android:layout_height="wrap_content"
+ android:ellipsize="none"
+ android:layout_gravity="left|bottom"
+ android:format12Hour=" MMMM dd"
+ android:format24Hour=" MMMM dd"
+ android:paddingBottom="@dimen/title_clock_padding"
+ android:textColor="?android:textColorPrimary" />
+
+ </LinearLayout>
+
+</com.android.keyguard.clock.ClockLayout>
diff --git a/packages/SystemUI/res-keyguard/layout/digital_clock_ssos_preview.xml b/packages/SystemUI/res-keyguard/layout/digital_clock_ssos_preview.xml
new file mode 100644
index 000000000000..57f2c78e4f3a
--- /dev/null
+++ b/packages/SystemUI/res-keyguard/layout/digital_clock_ssos_preview.xml
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2021 ShapeShiftOS
+ 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.
+-->
+
+<RelativeLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center">
+
+ <LinearLayout
+ android:id="@+id/clock_view"
+ android:layout_width="fill_parent"
+ android:paddingLeft="20dp"
+ android:layout_height="wrap_content"
+ android:layout_centerInParent="true"
+ android:orientation="vertical">
+
+ <TextClock
+ android:id="@+id/clock_day"
+ android:layout_width="match_parent"
+ android:textSize="44.5sp"
+ android:ellipsize="none"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center_horizontal"
+ android:format12Hour="EEEE"
+ android:format24Hour="EEEE"
+ android:textColor="?android:textColorPrimary" />
+
+ <LinearLayout
+ android:id="@+id/clock"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="-4dp"
+ android:layout_gravity="left"
+ android:orientation="horizontal">
+
+ <TextClock
+ android:id="@+id/time_clock_accented"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_gravity="center_horizontal"
+ android:ellipsize="none"
+ android:format24Hour="kk"
+ android:format12Hour="h"
+ android:textColor="?android:attr/colorAccent"
+ android:textSize="45.5sp" />
+
+ <TextClock
+ android:id="@+id/time_clock"
+ android:textSize="45.5sp"
+ android:layout_width="wrap_content"
+ android:ellipsize="none"
+ android:layout_height="wrap_content"
+ android:layout_gravity="center|bottom"
+ android:format24Hour=":mm"
+ android:format12Hour=":mm"
+ android:textColor="?android:textColorPrimary"/>
+
+ </LinearLayout>
+
+ <TextClock
+ android:id="@+id/timedate"
+ android:layout_width="wrap_content"
+ android:textSize="15sp"
+ android:layout_height="wrap_content"
+ android:ellipsize="none"
+ android:layout_gravity="left|bottom"
+ android:format24Hour=" MMMM dd"
+ android:format12Hour=" MMMM dd"
+ android:paddingBottom="@dimen/title_clock_padding"
+ android:textColor="?android:textColorPrimary" />
+
+ </LinearLayout>
+
+</RelativeLayout>
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
index fd5c99e75a1f..7c23bb6385b0 100644
--- a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java
@@ -151,6 +151,7 @@ public final class ClockManager {
addBuiltinClock(() -> new DefaultClockController(res, layoutInflater, colorExtractor));
addBuiltinClock(() -> new TypeClockController(res, layoutInflater, colorExtractor));
+ addBuiltinClock(() -> new ShapeShiftClockController(res, layoutInflater, colorExtractor));
// Store the size of the display for generation of clock preview.
DisplayMetrics dm = res.getDisplayMetrics();
diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ShapeShiftClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/ShapeShiftClockController.java
new file mode 100644
index 000000000000..6a9c81f74475
--- /dev/null
+++ b/packages/SystemUI/src/com/android/keyguard/clock/ShapeShiftClockController.java
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ * Copyright (C) 2020 ProjectFluid
+ * Copyright (C) 2021 ShapeShiftOS
+ * 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.keyguard.clock;
+
+import android.app.WallpaperManager;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Color;
+import android.graphics.Paint.Style;
+import android.text.Html;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.TextClock;
+
+import com.android.systemui.R;
+import com.android.systemui.plugins.ClockPlugin;
+import com.android.systemui.colorextraction.SysuiColorExtractor;
+import com.android.internal.colorextraction.ColorExtractor;
+
+import java.util.TimeZone;
+
+import static com.android.systemui.statusbar.phone
+ .KeyguardClockPositionAlgorithm.CLOCK_USE_DEFAULT_Y;
+
+/**
+ * Plugin for the default clock face used only to provide a preview.
+ */
+public class ShapeShiftClockController implements ClockPlugin {
+
+ /**
+ * Resources used to get title and thumbnail.
+ */
+ private final Resources mResources;
+
+ /**
+ * LayoutInflater used to inflate custom clock views.
+ */
+ private final LayoutInflater mLayoutInflater;
+
+ /**
+ * Renders preview from clock view.
+ */
+ private final ViewPreviewer mRenderer = new ViewPreviewer();
+
+ /**
+ * Extracts accent color from wallpaper.
+ */
+ private final SysuiColorExtractor mColorExtractor;
+
+
+ /**
+ * Root view of clock.
+ */
+ private ClockLayout mView;
+
+ /**
+ * Text clock in preview view hierarchy.
+ */
+ private TextClock mTimeClock;
+ private TextClock mDay;
+ private TextClock mDate;
+ private TextClock mTimeClockAccented;
+
+ /**
+ * Create a DefaultClockController instance.
+ *
+ * @param res Resources contains title and thumbnail.
+ * @param inflater Inflater used to inflate custom clock views.
+ * @param colorExtractor Extracts accent color from wallpaper.
+ */
+ public ShapeShiftClockController(Resources res, LayoutInflater inflater,
+ SysuiColorExtractor colorExtractor) {
+ mResources = res;
+ mLayoutInflater = inflater;
+ mColorExtractor = colorExtractor;
+ }
+
+ private void createViews() {
+ mView = (ClockLayout) mLayoutInflater
+ .inflate(R.layout.digital_clock_ssos, null);
+ setViews(mView);
+ }
+
+ private void setViews(View view) {
+ mTimeClock = view.findViewById(R.id.time_clock);
+ mTimeClockAccented = view.findViewById(R.id.time_clock_accented);
+ mDay = view.findViewById(R.id.clock_day);
+ mDate = view.findViewById(R.id.timedate);
+ }
+
+ @Override
+ public void onDestroyView() {
+ mView = null;
+ mTimeClock = null;
+ mDay = null;
+ mDate = null;
+ mTimeClockAccented = null;
+ }
+
+ @Override
+ public String getName() {
+ return "ssos";
+ }
+
+ @Override
+ public String getTitle() {
+ return "OxygenOS";
+ }
+
+ @Override
+ public Bitmap getThumbnail() {
+ return BitmapFactory.decodeResource(mResources, R.drawable.ssos_thumbnail);
+ }
+
+ @Override
+ public Bitmap getPreview(int width, int height) {
+
+ View previewView = mLayoutInflater.inflate(R.layout.digital_clock_ssos_preview, null);
+
+ setViews(previewView);
+
+ ColorExtractor.GradientColors colors = mColorExtractor.getColors(
+ WallpaperManager.FLAG_LOCK);
+
+ setColorPalette(colors.supportsDarkText(), colors.getColorPalette());
+ onTimeTick();
+
+ return mRenderer.createPreview(previewView, width, height);
+ }
+
+ @Override
+ public View getView() {
+ if (mView == null) {
+ createViews();
+ }
+ return mView;
+ }
+
+ @Override
+ public View getBigClockView() {
+ return null;
+ }
+
+ @Override
+ public int getPreferredY(int totalHeight) {
+ return CLOCK_USE_DEFAULT_Y;
+ }
+
+ @Override
+ public void setStyle(Style style) {}
+
+ @Override
+ public void setTextColor(int color) {
+ mTimeClock.setTextColor(color);
+ mDay.setTextColor(color);
+ mDate.setTextColor(color);
+ }
+
+ @Override
+ public void setColorPalette(boolean supportsDarkText, int[] colorPalette) {
+ if (colorPalette == null || colorPalette.length == 0) {
+ return;
+ }
+ final int accentColor = colorPalette[Math.max(0, colorPalette.length - 5)];
+ mTimeClockAccented.setTextColor(accentColor);
+ }
+
+ @Override
+ public void onTimeTick() {
+ if (mView != null)
+ mView.onTimeChanged();
+ mTimeClock.refreshTime();
+ mTimeClockAccented.refreshTime();
+ mDay.refreshTime();
+ mDate.refreshTime();
+ }
+
+ @Override
+ public void setDarkAmount(float darkAmount) {
+ if (mView != null)
+ mView.setDarkAmount(darkAmount);
+ }
+
+ @Override
+ public void onTimeZoneChanged(TimeZone timeZone) {}
+
+ @Override
+ public boolean shouldShowStatusArea() {
+ return false;
+ }
+}