From 6c02c6ab25dc4012a552ff95df54df21383b4e67 Mon Sep 17 00:00:00 2001 From: shaoweishen Date: Wed, 28 Feb 2024 10:10:02 +0000 Subject: [PATCH] [Physical Keyboard Setting] Update layout for one pane land screen If device is one pane and is land orientation, set new layout for it to match with UX markup, this change will not effect on tablet, which is two pane setting. Bug: 325878673 Test: verify on device Screenshot: https://screenshot.googleplex.com/BkETMhqp9GXM3cc.png Change-Id: I066c3d782a2de8993a3fe9632676b67c2203d638 --- .../keyboard_layout_picker_one_pane_land.xml | 75 +++++++++++++++++++ res/values/dimens.xml | 2 + .../NewKeyboardLayoutPickerFragment.java | 11 ++- 3 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 res/layout/keyboard_layout_picker_one_pane_land.xml diff --git a/res/layout/keyboard_layout_picker_one_pane_land.xml b/res/layout/keyboard_layout_picker_one_pane_land.xml new file mode 100644 index 00000000000..fb5554f98ab --- /dev/null +++ b/res/layout/keyboard_layout_picker_one_pane_land.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 4b96486be7b..164f4877ae6 100755 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -168,6 +168,8 @@ 68dp 24dp + 48dp + 24dp 16dp 28dp 16sp diff --git a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerFragment.java b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerFragment.java index 85ba5fb3270..674b5bf7cce 100644 --- a/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerFragment.java +++ b/src/com/android/settings/inputmethod/NewKeyboardLayoutPickerFragment.java @@ -16,9 +16,11 @@ package com.android.settings.inputmethod; +import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.view.View.GONE; import static android.view.View.VISIBLE; +import android.content.res.Configuration; import android.graphics.drawable.Drawable; import android.hardware.input.InputManager; import android.hardware.input.KeyboardLayout; @@ -35,6 +37,7 @@ import androidx.fragment.app.Fragment; import com.android.hardware.input.Flags; import com.android.settings.R; +import com.android.settings.activityembedding.ActivityEmbeddingUtils; //TODO: b/316243168 - [Physical Keyboard Setting] Refactor NewKeyboardLayoutPickerFragment public class NewKeyboardLayoutPickerFragment extends Fragment { @@ -81,7 +84,7 @@ public class NewKeyboardLayoutPickerFragment extends Fragment { Bundle savedInstanceState) { mInputManager = requireContext().getSystemService(InputManager.class); ViewGroup fragmentView = (ViewGroup) inflater.inflate( - R.layout.keyboard_layout_picker, container, false); + getPickerLayout(getResources().getConfiguration()), container, false); mKeyboardLayoutPreview = fragmentView.findViewById(R.id.keyboard_layout_preview); mKeyboardLayoutPreviewText = fragmentView.findViewById(R.id.keyboard_layout_preview_name); if (!Flags.keyboardLayoutPreviewFlag()) { @@ -102,6 +105,12 @@ public class NewKeyboardLayoutPickerFragment extends Fragment { return fragmentView; } + private int getPickerLayout(Configuration configuration) { + return !ActivityEmbeddingUtils.isAlreadyEmbedded(this.getActivity()) + && configuration.orientation == ORIENTATION_LANDSCAPE + ? R.layout.keyboard_layout_picker_one_pane_land : R.layout.keyboard_layout_picker; + } + private void updateViewMarginForPreviewFlagOff(ViewGroup fragmentView) { LinearLayout previewContainer = fragmentView.findViewById( R.id.keyboard_layout_picker_container);