diff options
author | gnumdk <gnumdk@gmail.com> | 2020-06-03 14:07:19 +0000 |
---|---|---|
committer | Sam Mortimer <sam@mortimer.me.uk> | 2020-06-17 00:53:44 +0200 |
commit | 257a6821cbc2802265b20c3631fdae5505cd983a (patch) | |
tree | 831858865d40ecd42f13d0440e6a02e23d66a2fd | |
parent | f730abf925a48c48953eb7177af7f06cd7c76a09 (diff) | |
download | frameworks_base-257a6821cbc2802265b20c3631fdae5505cd983a.tar.gz frameworks_base-257a6821cbc2802265b20c3631fdae5505cd983a.tar.bz2 frameworks_base-257a6821cbc2802265b20c3631fdae5505cd983a.zip |
Add a LineageOS clock
Here a custom clock for ClockPlugin showing LineageOS logo
https://i.ibb.co/4N8gZrT/clock.png
Change-Id: I7e29eba21357ab740dae20a738ef34c18f1a594e
-rw-r--r-- | packages/SystemUI/res-keyguard/drawable-xxxhdpi/lineage_thumbnail.png | bin | 0 -> 72830 bytes | |||
-rw-r--r-- | packages/SystemUI/res-keyguard/drawable/lineage_logo.xml | 26 | ||||
-rw-r--r-- | packages/SystemUI/res-keyguard/layout/lineage_clock.xml | 38 | ||||
-rw-r--r-- | packages/SystemUI/res/values/cm_strings.xml | 3 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java | 1 | ||||
-rw-r--r-- | packages/SystemUI/src/com/android/keyguard/clock/LineageClockController.java | 163 |
6 files changed, 231 insertions, 0 deletions
diff --git a/packages/SystemUI/res-keyguard/drawable-xxxhdpi/lineage_thumbnail.png b/packages/SystemUI/res-keyguard/drawable-xxxhdpi/lineage_thumbnail.png Binary files differnew file mode 100644 index 00000000000..246039c3502 --- /dev/null +++ b/packages/SystemUI/res-keyguard/drawable-xxxhdpi/lineage_thumbnail.png diff --git a/packages/SystemUI/res-keyguard/drawable/lineage_logo.xml b/packages/SystemUI/res-keyguard/drawable/lineage_logo.xml new file mode 100644 index 00000000000..08747ea76f7 --- /dev/null +++ b/packages/SystemUI/res-keyguard/drawable/lineage_logo.xml @@ -0,0 +1,26 @@ +<vector xmlns:android="http://schemas.android.com/apk/res/android" + android:width="220dp" + android:height="92.63152dp" + android:viewportWidth="220" + android:viewportHeight="92.63152"> + <path + android:pathData="M110.007,45.988m-39.256,0a39.256,39.256 0,1 1,78.513 0a39.256,39.256 0,1 1,-78.513 0" + android:strokeAlpha="1" + android:strokeWidth="6" + android:strokeColor="#FFFFFF"/> + <path + android:pathData="M22.771,67.798m-17.447,0a17.447,17.447 0,1 1,34.895 0a17.447,17.447 0,1 1,-34.895 0" + android:strokeAlpha="1" + android:strokeWidth="6" + android:strokeColor="#FFFFFF"/> + <path + android:pathData="M197.244,67.798m-17.447,0a17.447,17.447 0,1 1,34.895 0a17.447,17.447 0,1 1,-34.895 0" + android:strokeAlpha="1" + android:strokeWidth="6" + android:strokeColor="#FFFFFF"/> + <path + android:pathData="m36.947,59.619c12.704,-5.109 22.627,-8.178 35.985,-10.577M183.068,59.619c-12.704,-5.109 -22.627,-8.178 -35.985,-10.577" + android:strokeAlpha="1" + android:strokeWidth="6" + android:strokeColor="#FFFFFF"/> +</vector> diff --git a/packages/SystemUI/res-keyguard/layout/lineage_clock.xml b/packages/SystemUI/res-keyguard/layout/lineage_clock.xml new file mode 100644 index 00000000000..d355508236f --- /dev/null +++ b/packages/SystemUI/res-keyguard/layout/lineage_clock.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2020 The LineageOS 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. + --> +<com.android.keyguard.clock.ClockLayout + xmlns:android="http://schemas.android.com/apk/res/android" + android:layout_alignParentTop="true" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:paddingBottom="10dp"> + <TextClock + android:id="@+id/clock" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:gravity="center" + android:elegantTextHeight="false" + android:letterSpacing="0.1" + android:textSize="26dp" + android:textStyle="bold" /> + <ImageView + android:gravity="center" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:src="@drawable/lineage_logo" /> +</com.android.keyguard.clock.ClockLayout> + diff --git a/packages/SystemUI/res/values/cm_strings.xml b/packages/SystemUI/res/values/cm_strings.xml index 15597ffc90d..5192048d6a6 100644 --- a/packages/SystemUI/res/values/cm_strings.xml +++ b/packages/SystemUI/res/values/cm_strings.xml @@ -128,4 +128,7 @@ <!-- Notify use that they are in Lock-to-app (for devices without navbar)--> <string name="screen_pinning_toast_no_navbar">To unpin this screen, touch & hold Back button</string> + + <!-- Lineage clock --> + <string name="clock_title_lineage" translatable="false">LineageOS</string> </resources> diff --git a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java index 5668c5f9183..3db1fff1028 100644 --- a/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java +++ b/packages/SystemUI/src/com/android/keyguard/clock/ClockManager.java @@ -150,6 +150,7 @@ public final class ClockManager { addBuiltinClock(() -> new DefaultClockController(res, layoutInflater, colorExtractor)); addBuiltinClock(() -> new BubbleClockController(res, layoutInflater, colorExtractor)); addBuiltinClock(() -> new AnalogClockController(res, layoutInflater, colorExtractor)); + addBuiltinClock(() -> new LineageClockController(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/LineageClockController.java b/packages/SystemUI/src/com/android/keyguard/clock/LineageClockController.java new file mode 100644 index 00000000000..53886915855 --- /dev/null +++ b/packages/SystemUI/src/com/android/keyguard/clock/LineageClockController.java @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2020 The LineageOS 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.keyguard.clock; + +import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import android.graphics.Paint.Style; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.TextClock; + +import com.android.systemui.R; +import com.android.systemui.colorextraction.SysuiColorExtractor; +import com.android.systemui.plugins.ClockPlugin; + +import java.util.TimeZone; + +/** + * Plugin for the default clock face used only to provide a preview. + */ +public class LineageClockController 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(); + + /** + * Root view of clock. + */ + private ClockLayout mView; + + /** + * Text clock in preview view hierarchy. + */ + private TextClock mClock; + + /** + * 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 LineageClockController(Resources res, LayoutInflater inflater, + SysuiColorExtractor colorExtractor) { + mResources = res; + mLayoutInflater = inflater; + } + + private void createViews() { + mView = (ClockLayout) mLayoutInflater + .inflate(R.layout.lineage_clock, null); + mClock = (TextClock) mView.findViewById(R.id.clock); + mClock.setFormat12Hour("hh\nmm"); + mClock.setFormat24Hour("kk\nmm"); + } + + @Override + public void onDestroyView() { + mView = null; + mClock = null; + } + + @Override + public String getName() { + return "lineageos"; + } + + @Override + public String getTitle() { + return mResources.getString(R.string.clock_title_lineage); + } + + @Override + public int getPreferredY(int totalHeight) { + return totalHeight / 3; + } + + @Override + public Bitmap getThumbnail() { + return BitmapFactory.decodeResource(mResources, R.drawable.lineage_thumbnail); + } + + @Override + public Bitmap getPreview(int width, int height) { + + View previewView = getView(); + TextClock clock = previewView.findViewById(R.id.clock); + clock.setFormat12Hour("hh\nmm"); + clock.setFormat24Hour("kk\nmm"); + 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 void setStyle(Style style) {} + + @Override + public void setTextColor(int color) { + mClock.setTextColor(color); + } + + @Override + public void setColorPalette(boolean supportsDarkText, int[] colorPalette) {} + + @Override + public void onTimeTick() { + mView.onTimeChanged(); + mClock.refresh(); + } + + @Override + public void setDarkAmount(float darkAmount) { + mView.setDarkAmount(darkAmount); + } + + @Override + public void onTimeZoneChanged(TimeZone timeZone) {} + + @Override + public boolean shouldShowStatusArea() { + return true; + } +} |