1 /* 2 * Copyright (C) 2023 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.launcher3.taskbar.navbutton 18 19 import android.content.res.Resources 20 import android.view.Gravity 21 import android.view.ViewGroup 22 import android.widget.FrameLayout 23 import android.widget.ImageView 24 import android.widget.LinearLayout 25 import android.widget.Space 26 import com.android.launcher3.DeviceProfile 27 import com.android.launcher3.taskbar.TaskbarActivityContext 28 29 /** Layoutter for showing gesture navigation on phone screen. No buttons here, no-op container */ 30 class PhoneGestureLayoutter( 31 resources: Resources, 32 navButtonsView: NearestTouchFrame, 33 navBarContainer: LinearLayout, 34 endContextualContainer: ViewGroup, 35 startContextualContainer: ViewGroup, 36 imeSwitcher: ImageView?, 37 a11yButton: ImageView?, 38 space: Space? 39 ) : 40 AbstractNavButtonLayoutter( 41 resources, 42 navBarContainer, 43 endContextualContainer, 44 startContextualContainer, 45 imeSwitcher, 46 a11yButton, 47 space 48 ) { 49 private val mNavButtonsView = navButtonsView 50 layoutButtonsnull51 override fun layoutButtons(context: TaskbarActivityContext, isA11yButtonPersistent: Boolean) { 52 // TODO: look into if we should use SetupNavLayoutter instead. 53 if (!context.isUserSetupComplete) { 54 // Since setup wizard only has back button enabled, it looks strange to be 55 // end-aligned, so start-align instead. 56 val navButtonsLayoutParams = navButtonContainer.layoutParams as FrameLayout.LayoutParams 57 val navButtonsViewLayoutParams = 58 mNavButtonsView.layoutParams as FrameLayout.LayoutParams 59 val deviceProfile: DeviceProfile = context.deviceProfile 60 61 navButtonsLayoutParams.marginEnd = 0 62 navButtonsLayoutParams.gravity = Gravity.START 63 context.setTaskbarWindowSize(context.setupWindowSize) 64 65 adjustForSetupInPhoneMode( 66 navButtonsLayoutParams, 67 navButtonsViewLayoutParams, 68 deviceProfile 69 ) 70 mNavButtonsView.layoutParams = navButtonsViewLayoutParams 71 navButtonContainer.layoutParams = navButtonsLayoutParams 72 } 73 74 endContextualContainer.removeAllViews() 75 startContextualContainer.removeAllViews() 76 } 77 } 78