1 /* 2 * Copyright (C) 2020 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.animation.Animator; 20 import android.annotation.NonNull; 21 import android.view.View; 22 23 import com.android.systemui.plugins.annotations.ProvidesInterface; 24 25 /** 26 * Customize toasts displayed by SystemUI (via Toast#makeText) 27 */ 28 @ProvidesInterface(action = ToastPlugin.ACTION, version = ToastPlugin.VERSION) 29 public interface ToastPlugin extends Plugin { 30 31 String ACTION = "com.android.systemui.action.PLUGIN_TOAST"; 32 int VERSION = 1; 33 34 /** 35 * Creates a CustomPluginToast. 36 */ createToast(CharSequence text, String packageName, int userId)37 @NonNull Toast createToast(CharSequence text, String packageName, int userId); 38 39 /** 40 * Custom Toast with the ability to change toast positioning, styling and animations. 41 */ 42 interface Toast { 43 /** 44 * Retrieve the Toast view's gravity. 45 * If no changes, returns null. 46 */ getGravity()47 default Integer getGravity() { 48 return null; 49 } 50 51 /** 52 * Retrieve the Toast view's X-offset. 53 * If no changes, returns null. 54 */ getXOffset()55 default Integer getXOffset() { 56 return null; 57 } 58 59 /** 60 * Retrieve the Toast view's Y-offset. 61 * If no changes, returns null. 62 */ getYOffset()63 default Integer getYOffset() { 64 return null; 65 } 66 67 /** 68 * Retrieve the Toast view's horizontal margin. 69 * If no changes, returns null. 70 */ getHorizontalMargin()71 default Integer getHorizontalMargin() { 72 return null; 73 } 74 75 /** 76 * Retrieve the Toast view's vertical margin. 77 * If no changes, returns null. 78 */ getVerticalMargin()79 default Integer getVerticalMargin() { 80 return null; 81 } 82 83 /** 84 * Retrieve the Toast view to show. 85 * If no changes, returns null. 86 */ getView()87 default View getView() { 88 return null; 89 } 90 91 /** 92 * Retrieve the Toast's animate in. 93 * If no changes, returns null. 94 */ getInAnimation()95 default Animator getInAnimation() { 96 return null; 97 } 98 99 /** 100 * Retrieve the Toast's animate out. 101 * If no changes, returns null. 102 */ getOutAnimation()103 default Animator getOutAnimation() { 104 return null; 105 } 106 107 /** 108 * Called on orientation changes. 109 */ onOrientationChange(int orientation)110 default void onOrientationChange(int orientation) { } 111 } 112 } 113