• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
5  * except in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the
10  * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
11  * KIND, either express or implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */
14 package com.android.systemui.plugins;
15 
16 import android.graphics.Bitmap;
17 import android.graphics.Paint.Style;
18 import android.view.View;
19 
20 import com.android.systemui.plugins.annotations.ProvidesInterface;
21 
22 import java.util.TimeZone;
23 
24 /**
25  * Plugin used to replace main clock in keyguard.
26  * @deprecated Migrating to ClockProviderPlugin
27  */
28 @Deprecated
29 @ProvidesInterface(action = ClockPlugin.ACTION, version = ClockPlugin.VERSION)
30 public interface ClockPlugin extends Plugin {
31 
32     String ACTION = "com.android.systemui.action.PLUGIN_CLOCK";
33     int VERSION = 5;
34 
35     /**
36      * Get the name of the clock face.
37      *
38      * This name should not be translated.
39      */
getName()40     String getName();
41 
42     /**
43      * Get the title of the clock face to be shown in the picker app.
44      */
getTitle()45     String getTitle();
46 
47     /**
48      * Get thumbnail of clock face to be shown in the picker app.
49      */
getThumbnail()50     Bitmap getThumbnail();
51 
52     /**
53      * Get preview images of clock face to be shown in the picker app.
54      *
55      * Preview image should be realistic and show what the clock face will look like on AOD and lock
56      * screen.
57      *
58      * @param width width of the preview image, should be the same as device width in pixels.
59      * @param height height of the preview image, should be the same as device height in pixels.
60      */
getPreview(int width, int height)61     Bitmap getPreview(int width, int height);
62 
63     /**
64      * Get clock view.
65      * @return clock view from plugin.
66      */
getView()67     View getView();
68 
69     /**
70      * Get clock view for a large clock that appears behind NSSL.
71      */
getBigClockView()72     default View getBigClockView() {
73         return null;
74     }
75 
76     /**
77      * Returns the preferred Y position of the clock.
78      *
79      * @param totalHeight Height of the parent container.
80      * @return preferred Y position.
81      */
getPreferredY(int totalHeight)82     int getPreferredY(int totalHeight);
83 
84     /**
85      * Allows the plugin to clean up resources when no longer needed.
86      *
87      * Called when the view previously created by {@link ClockPlugin#getView()} has been detached
88      * from the view hierarchy.
89      */
onDestroyView()90     void onDestroyView();
91 
92     /**
93      * Set clock paint style.
94      * @param style The new style to set in the paint.
95      */
setStyle(Style style)96     void setStyle(Style style);
97 
98     /**
99      * Set clock text color.
100      * @param color A color value.
101      */
setTextColor(int color)102     void setTextColor(int color);
103 
104     /**
105      * Sets the color palette for the clock face.
106      * @param supportsDarkText Whether dark text can be displayed.
107      * @param colors Colors that should be used on the clock face, ordered from darker to lighter.
108      */
setColorPalette(boolean supportsDarkText, int[] colors)109     default void setColorPalette(boolean supportsDarkText, int[] colors) {}
110 
111     /**
112      * Set the amount (ratio) that the device has transitioned to doze.
113      * @param darkAmount Amount of transition to doze: 1f for doze and 0f for awake.
114      */
setDarkAmount(float darkAmount)115     default void setDarkAmount(float darkAmount) {}
116 
117     /**
118      * Notifies that time tick alarm from doze service fired.
119      *
120      * Implement this method instead of registering a broadcast listener for TIME_TICK.
121      */
onTimeTick()122     default void onTimeTick() {}
123 
124     /**
125      * Notifies that the time zone has changed.
126      *
127      * Implement this method instead of registering a broadcast listener for TIME_ZONE_CHANGED.
128      */
onTimeZoneChanged(TimeZone timeZone)129     default void onTimeZoneChanged(TimeZone timeZone) {}
130 
131     /**
132      * Notifies that the time format has changed.
133      *
134      * @param timeFormat "12" for 12-hour format, "24" for 24-hour format
135      */
onTimeFormatChanged(String timeFormat)136     default void onTimeFormatChanged(String timeFormat) {}
137 
138     /**
139      * Indicates whether the keyguard status area (date) should be shown below
140      * the clock.
141      */
shouldShowStatusArea()142     default boolean shouldShowStatusArea() {
143         return true;
144     }
145 }
146