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 import android.content.Context; 21 22 import com.android.systemui.plugins.annotations.ProvidesInterface; 23 24 /** 25 * Implement this plugin interface to add a custom widget. 26 */ 27 @ProvidesInterface(action = CustomWidgetPlugin.ACTION, version = CustomWidgetPlugin.VERSION) 28 public interface CustomWidgetPlugin extends Plugin { 29 30 String ACTION = "com.android.systemui.action.PLUGIN_CUSTOM_WIDGET"; 31 int VERSION = 1; 32 33 /** 34 * The label to display to the user in the AppWidget picker. 35 */ getLabel(Context context)36 String getLabel(Context context); 37 38 /** 39 * The default width of the widget when added to a host, in dp. The widget will get 40 * at least this width, and will often be given more, depending on the host. 41 */ getSpanX(Context context)42 int getSpanX(Context context); 43 44 /** 45 * The default height of the widget when added to a host, in dp. The widget will get 46 * at least this height, and will often be given more, depending on the host. 47 */ getSpanY(Context context)48 int getSpanY(Context context); 49 50 /** 51 * Minimum width (in dp) which the widget can be resized to. This field has no effect if it 52 * is greater than minWidth or if horizontal resizing isn't enabled. 53 */ getMinSpanX(Context context)54 int getMinSpanX(Context context); 55 56 /** 57 * Minimum height (in dp) which the widget can be resized to. This field has no effect if it 58 * is greater than minHeight or if vertical resizing isn't enabled. 59 */ getMinSpanY(Context context)60 int getMinSpanY(Context context); 61 62 /** 63 * The rules by which a widget can be resized. 64 */ getResizeMode(Context context)65 int getResizeMode(Context context); 66 67 /** 68 * Notify the plugin that container of the widget has been rendered, where the custom widget 69 * can be attached to. 70 */ onViewCreated(Context context, AppWidgetHostView parent)71 void onViewCreated(Context context, AppWidgetHostView parent); 72 } 73