1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.systemui.plugins;
18 
19 import android.appwidget.AppWidgetHostView;
20 
21 import com.android.systemui.plugins.annotations.ProvidesInterface;
22 
23 /**
24  * Implement this plugin interface to add a custom widget.
25  */
26 @ProvidesInterface(action = CustomWidgetPlugin.ACTION, version = CustomWidgetPlugin.VERSION)
27 public interface CustomWidgetPlugin extends Plugin {
28 
29     String ACTION = "com.android.systemui.action.PLUGIN_CUSTOM_WIDGET";
30     int VERSION = 1;
31 
32     /**
33      * The label to display to the user in the AppWidget picker.
34      */
getLabel()35     String getLabel();
36 
37     /**
38      * The default width of the widget when added to a host, in dp. The widget will get
39      * at least this width, and will often be given more, depending on the host.
40      */
getSpanX()41     int getSpanX();
42 
43     /**
44      * The default height of the widget when added to a host, in dp. The widget will get
45      * at least this height, and will often be given more, depending on the host.
46      */
getSpanY()47     int getSpanY();
48 
49     /**
50      * Minimum width (in dp) which the widget can be resized to. This field has no effect if it
51      * is greater than minWidth or if horizontal resizing isn't enabled.
52      */
getMinSpanX()53     int getMinSpanX();
54 
55     /**
56      * Minimum height (in dp) which the widget can be resized to. This field has no effect if it
57      * is greater than minHeight or if vertical resizing isn't enabled.
58      */
getMinSpanY()59     int getMinSpanY();
60 
61     /**
62      * The rules by which a widget can be resized.
63      */
getResizeMode()64     int getResizeMode();
65 
66     /**
67      * Notify the plugin that container of the widget has been rendered, where the custom widget
68      * can be attached to.
69      */
onViewCreated(AppWidgetHostView parent)70     void onViewCreated(AppWidgetHostView parent);
71 }
72