1 /* <lambda>null2 * Copyright (C) 2024 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.wm.shell.compatui.components 18 19 import android.annotation.SuppressLint 20 import android.graphics.Point 21 import android.view.LayoutInflater 22 import android.view.View 23 import android.window.TaskConstants 24 import com.android.wm.shell.R 25 import com.android.wm.shell.compatui.api.CompatUILayout 26 import com.android.wm.shell.compatui.api.CompatUILifecyclePredicates 27 import com.android.wm.shell.compatui.api.CompatUISpec 28 29 /** 30 * CompatUISpec for the Restart Button 31 */ 32 @SuppressLint("InflateParams") 33 val RestartButtonSpec = CompatUISpec( 34 name = "restartButton", 35 lifecycle = CompatUILifecyclePredicates( 36 creationPredicate = { info, _ -> 37 info.taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat 38 }, infonull39 removalPredicate = { info, _, _ -> 40 !info.taskInfo.appCompatTaskInfo.isTopActivityInSizeCompat 41 } 42 ), 43 layout = CompatUILayout( 44 zOrder = TaskConstants.TASK_CHILD_LAYER_COMPAT_UI + 10, ctxnull45 viewBuilder = { ctx, _, _ -> 46 LayoutInflater.from(ctx).inflate( 47 R.layout.compat_ui_restart_button_layout, 48 null 49 ) 50 }, viewnull51 viewBinder = { view, _, _, _ -> 52 view.visibility = View.VISIBLE 53 view.findViewById<View>(R.id.size_compat_restart_button)?.visibility = View.VISIBLE 54 }, 55 // TODO(b/360288344): Calculate right position from stable bounds _null56 positionFactory = { _, _, _, _ -> Point(500, 500) } 57 ) 58 ) 59