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.view.ViewGroup.LayoutParams.MATCH_PARENT 23 import android.widget.ImageView 24 import android.widget.LinearLayout 25 import android.widget.Space 26 import com.android.launcher3.R 27 28 class PhoneSeascapeNavLayoutter( 29 resources: Resources, 30 navBarContainer: LinearLayout, 31 endContextualContainer: ViewGroup, 32 startContextualContainer: ViewGroup, 33 imeSwitcher: ImageView?, 34 a11yButton: ImageView?, 35 space: Space? 36 ) : 37 PhoneLandscapeNavLayoutter( 38 resources, 39 navBarContainer, 40 endContextualContainer, 41 startContextualContainer, 42 imeSwitcher, 43 a11yButton, 44 space 45 ) { 46 addThreeButtonsnull47 override fun addThreeButtons() { 48 // Flip ordering of back and recents buttons 49 navButtonContainer.addView(backButton) 50 navButtonContainer.addView(homeButton) 51 navButtonContainer.addView(recentsButton) 52 } 53 repositionContextualButtonsnull54 override fun repositionContextualButtons(buttonSize: Int) { 55 endContextualContainer.removeAllViews() 56 startContextualContainer.removeAllViews() 57 58 val roundedCornerContentMargin = 59 resources.getDimensionPixelSize(R.dimen.taskbar_phone_rounded_corner_content_margin) 60 val contentPadding = resources.getDimensionPixelSize(R.dimen.taskbar_phone_content_padding) 61 repositionContextualContainer( 62 startContextualContainer, 63 buttonSize, 64 roundedCornerContentMargin + contentPadding, 65 0, 66 Gravity.TOP 67 ) 68 repositionContextualContainer( 69 endContextualContainer, 70 buttonSize, 71 0, 72 roundedCornerContentMargin + contentPadding, 73 Gravity.BOTTOM 74 ) 75 76 startContextualContainer.addView(space, MATCH_PARENT, MATCH_PARENT) 77 if (imeSwitcher != null) { 78 endContextualContainer.addView(imeSwitcher) 79 imeSwitcher.layoutParams = getParamsToCenterView() 80 } 81 if (a11yButton != null) { 82 endContextualContainer.addView(a11yButton) 83 a11yButton.layoutParams = getParamsToCenterView() 84 } 85 } 86 } 87