1 /* 2 * Copyright (C) 2021 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.car.ui.appstyledview; 18 19 import static java.lang.annotation.RetentionPolicy.SOURCE; 20 21 import android.view.View; 22 import android.view.WindowManager; 23 24 import androidx.annotation.IntDef; 25 26 import java.lang.annotation.Retention; 27 28 /** 29 * An interface for accessing a Chassis AppStyledView, regardless of how the underlying views are 30 * represented. 31 */ 32 public interface AppStyledViewController { 33 34 /** 35 * Callback to be invoked when the close icon is clicked. 36 */ 37 interface AppStyledVCloseClickListener { 38 39 /** 40 * Called when the close icon is clicked. 41 */ onClick()42 void onClick(); 43 } 44 45 /** 46 * Callback to be invoked when the dialog is dismissed. 47 */ 48 interface AppStyledDismissListener { 49 50 /** 51 * Called when the dialog is dismissed. 52 */ onDismiss()53 void onDismiss(); 54 } 55 56 /** 57 * The possible values for AppStyledViewNavIcon. 58 */ 59 @IntDef({ 60 AppStyledViewNavIcon.BACK, 61 AppStyledViewNavIcon.CLOSE, 62 }) 63 @Retention(SOURCE) 64 @interface AppStyledViewNavIcon { 65 66 /** 67 * Show a back icon 68 */ 69 int BACK = 0; 70 71 /** 72 * Show a close icon 73 */ 74 int CLOSE = 1; 75 } 76 77 /** 78 * Creates a app styled view. 79 * 80 * @return the view used for app styled view. 81 */ getAppStyledView(View contentView)82 View getAppStyledView(View contentView); 83 84 /** 85 * Sets the nav icon to be used. 86 */ setNavIcon(@ppStyledViewNavIcon int navIcon)87 void setNavIcon(@AppStyledViewNavIcon int navIcon); 88 89 /** 90 * Sets the {@link AppStyledVCloseClickListener} 91 */ setOnCloseClickListener(AppStyledVCloseClickListener listener)92 void setOnCloseClickListener(AppStyledVCloseClickListener listener); 93 94 /** 95 * Returns the layout params for the AppStyledView dialog 96 */ getDialogWindowLayoutParam(WindowManager.LayoutParams params)97 WindowManager.LayoutParams getDialogWindowLayoutParam(WindowManager.LayoutParams params); 98 } 99