Enabled split keyboard for landscape (#46)

* Enabled split keyboard for landscape

Enable split keyboard is available from medium-sized (720dp) phones (landscape). On smaller phones, this toggle will be hidden. No change on tablet layout behavior.
This commit is contained in:
Md. Rifat Hasan Jihan 2023-08-29 10:52:51 +06:00 committed by GitHub
parent e0174d1872
commit 38edc6fb3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 703 additions and 19 deletions

View file

@ -29,8 +29,9 @@ import androidx.core.content.edit
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme
import org.dslul.openboard.inputmethod.latin.R import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.common.Constants
import org.dslul.openboard.inputmethod.latin.define.ProductionFlags import org.dslul.openboard.inputmethod.latin.define.ProductionFlags
import java.lang.Float.max
import java.lang.Float.min
import java.util.* import java.util.*
/** /**
@ -88,10 +89,13 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
} }
setupTheme() setupTheme()
if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED ||
Constants.isPhone(Settings.readScreenMetrics(resources))) { val widthDp = activity.resources.displayMetrics.widthPixels / activity.resources.displayMetrics.density
val heightDp = activity.resources.displayMetrics.heightPixels / activity.resources.displayMetrics.density
if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED || (min(widthDp, heightDp) < 600 && max(widthDp, heightDp) < 720)) {
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD) removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD)
} }
setupKeyboardHeight( setupKeyboardHeight(
Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE) Settings.PREF_KEYBOARD_HEIGHT_SCALE, SettingsValues.DEFAULT_SIZE_SCALE)
} }

View file

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<switch>
<case
latin:keyboardLayoutSet="farsi|kannada|nepali_romanized|nepali_traditional|telugu"
latin:languageSwitchKeyEnabled="true"
>
<Key
latin:keyStyle="languageSwitchKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="13%p" />
<Key
latin:keyStyle="zwnjKeyStyle" />
</case>
<case
latin:keyboardLayoutSet="farsi|kannada|nepali_romanized|nepali_traditional|telugu"
latin:languageSwitchKeyEnabled="false"
>
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="21%p" />
<Key
latin:keyStyle="zwnjKeyStyle" />
</case>
<case
latin:languageSwitchKeyEnabled="true"
latin:emojiKeyEnabled="false"
>
<Key
latin:keyStyle="languageSwitchKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="21%p" />
</case>
<case
latin:languageSwitchKeyEnabled="false"
latin:emojiKeyEnabled="true"
>
<Key
latin:keyStyle="emojiKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="21%p" />
</case>
<case
latin:languageSwitchKeyEnabled="true"
latin:emojiKeyEnabled="true"
>
<Key
latin:keyStyle="languageSwitchKeyStyle" />
<Key
latin:keyStyle="emojiKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="13%p" />
</case>
<!-- languageSwitchKeyEnabled="false" -->
<default>
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="29%p" />
</default>
</switch>
</merge>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto">
<switch>
<case
latin:numberRowEnabled="true"
latin:isSplitLayout="true"
>
<Row
latin:keyWidth="8%p"
>
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_left1" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_right1" />
</Row>
</case>
<case
latin:numberRowEnabled="true"
latin:isSplitLayout="false"
>
<Row
latin:keyWidth="10%p"
>
<include
latin:keyboardLayout="@xml/rowkeys_symbols1" />
</Row>
</case>
</switch>
</merge>

View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<switch>
<!-- Split the 4th row for split layouts -->
<case
latin:isSplitLayout="true"
>
<Row
latin:keyWidth="8.0%p"
latin:backgroundType="functional"
>
<Key
latin:keyStyle="toSymbolKeyStyle" />
<include
latin:keyboardLayout="@xml/key_comma" />
<!-- Space key. -->
<include
latin:keyboardLayout="@xml/key_space_3kw"
latin:backgroundType="normal" />
<Spacer
latin:keyWidth="15.0%p" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="21.0%p" />
<include
latin:keyboardLayout="@xml/key_period" />
<Key
latin:keyStyle="enterKeyStyle"
latin:keyWidth="fillRight" />
</Row>
</case>
<default>
<Row
latin:keyWidth="10%p"
>
<Key
latin:keyStyle="toSymbolKeyStyle"
latin:keyWidth="15%p" />
<include
latin:keyboardLayout="@xml/key_comma" />
<include
latin:keyXPos="25%p"
latin:keyboardLayout="@xml/key_space_5kw" />
<include
latin:keyboardLayout="@xml/key_period" />
<Key
latin:keyStyle="enterKeyStyle"
latin:keyWidth="fillRight" />
</Row>
</default>
</switch>
</merge>

View file

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2011, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<include
latin:keyboardLayout="@xml/key_styles_common" />
<include
latin:keyboardLayout="@xml/row_optional_number_row" />
<!-- First row -->
<Row>
<switch>
<!-- Split keyboard layout for the first row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_azerty1_left5"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_azerty1_right5"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the first row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_azerty1"
latin:keyWidth="10%p"/>
</default>
</switch>
</Row>
<!-- Second row -->
<Row>
<switch>
<!-- Split keyboard layout for the second row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_azerty2_left5"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_azerty2_right5"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the second row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_azerty2"
latin:keyWidth="10%p" />
</default>
</switch>
</Row>
<!-- Third row row -->
<Row>
<switch>
<!-- Split keyboard layout for the third row -->
<case
latin:isSplitLayout="true"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="13.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_azerty3_left4"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_azerty3_right3"
latin:keyWidth="8.0%p" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</case>
<!-- Regular layout for the third row -->
<default
latin:keyWidth="10%p"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="15%p" />
<include
latin:keyboardLayout="@xml/rowkeys_azerty3" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</default>
</switch>
</Row>
<include
latin:keyboardLayout="@xml/row_qwerty4" />
</merge>

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<include
latin:keyboardLayout="@xml/key_styles_common" />
<include
latin:keyboardLayout="@xml/row_optional_number_row" />
<!-- First row -->
<Row>
<switch>
<!-- Split keyboard layout for the first row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy1_left5"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy1_right5"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the first row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy1"
latin:keyWidth="10%p"/>
</default>
</switch>
</Row>
<!-- Second row -->
<Row>
<switch>
<!-- Split keyboard layout for the second row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy2_left5"
latin:keyXPos="5.0%p"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy2_right4"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the second row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy2"
latin:keyWidth="10%p"
latin:keyXPos="5%p" />
</default>
</switch>
</Row>
<!-- Third row row -->
<Row>
<switch>
<!-- Split keyboard layout for the third row -->
<case
latin:isSplitLayout="true"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="13.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy3_left4"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy3_right3"
latin:keyWidth="8.0%p" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</case>
<!-- Regular layout for the third row -->
<default
latin:keyWidth="10%p"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="15%p" />
<include
latin:keyboardLayout="@xml/rowkeys_bengali_unijoy3" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</default>
</switch>
</Row>
<include
latin:keyboardLayout="@xml/row_qwerty4" />
</merge>

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2014, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<include
latin:keyboardLayout="@xml/key_styles_common" />
<include
latin:keyboardLayout="@xml/row_optional_number_row" />
<!-- First row -->
<Row>
<switch>
<!-- Split keyboard layout for the first row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_qwerty1_left5"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwerty1_right5"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the first row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_qwerty1"
latin:keyWidth="10%p"/>
</default>
</switch>
</Row>
<!-- Second row -->
<Row>
<switch>
<!-- Split keyboard layout for the second row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_qwerty2_left5"
latin:keyXPos="5.0%p"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwerty2_right4"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the second row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_qwerty2"
latin:keyWidth="10%p"
latin:keyXPos="5%p" />
</default>
</switch>
</Row>
<!-- Third row row -->
<Row>
<switch>
<!-- Split keyboard layout for the third row -->
<case
latin:isSplitLayout="true"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="13.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwerty3_left4"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwerty3_right3"
latin:keyWidth="8.0%p" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</case>
<!-- Regular layout for the third row -->
<default
latin:keyWidth="10%p"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="15%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwerty3" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</default>
</switch>
</Row>
<include
latin:keyboardLayout="@xml/row_qwerty4" />
</merge>

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2010, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto"
>
<include
latin:keyboardLayout="@xml/key_styles_common" />
<include
latin:keyboardLayout="@xml/row_optional_number_row" />
<!-- First row -->
<Row>
<switch>
<!-- Split keyboard layout for the first row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_qwertz1_left5"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwertz1_right5"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the first row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_qwertz1"
latin:keyWidth="10%p"/>
</default>
</switch>
</Row>
<!-- Second row -->
<Row>
<switch>
<!-- Split keyboard layout for the second row -->
<case
latin:isSplitLayout="true"
>
<include
latin:keyboardLayout="@xml/rowkeys_qwertz2_left5"
latin:keyXPos="5.0%p"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwertz2_right4"
latin:keyWidth="8.0%p" />
</case>
<!-- Regular layout for the second row -->
<default>
<include
latin:keyboardLayout="@xml/rowkeys_qwertz2"
latin:keyWidth="10%p"
latin:keyXPos="5%p" />
</default>
</switch>
</Row>
<!-- Third row row -->
<Row>
<switch>
<!-- Split keyboard layout for the third row -->
<case
latin:isSplitLayout="true"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="13.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwertz3_left4"
latin:keyWidth="8.0%p" />
<Spacer
latin:keyWidth="18.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwertz3_right3"
latin:keyWidth="8.0%p" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</case>
<!-- Regular layout for the third row -->
<default
latin:keyWidth="10%p"
>
<Key
latin:keyStyle="shiftKeyStyle"
latin:keyWidth="15%p" />
<include
latin:keyboardLayout="@xml/rowkeys_qwertz3" />
<Key
latin:keyStyle="deleteKeyStyle"
latin:keyWidth="fillRight" />
</default>
</switch>
</Row>
<include
latin:keyboardLayout="@xml/row_qwerty4" />
</merge>

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:latin="http://schemas.android.com/apk/res-auto">
<switch>
<case
latin:numberRowEnabled="true"
latin:isSplitLayout="true"
>
<Row
latin:keyWidth="8%p"
>
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_left1" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_right1" />
</Row>
</case>
<case
latin:numberRowEnabled="true"
latin:isSplitLayout="false"
>
<Row
latin:keyWidth="10%p"
>
<include
latin:keyboardLayout="@xml/rowkeys_symbols1" />
</Row>
</case>
</switch>
</merge>

View file

@ -5,22 +5,6 @@
<switch> <switch>
<case <case
latin:numberRowEnabled="true" latin:numberRowEnabled="true"
latin:isSplitLayout="true"
>
<Row
latin:keyWidth="8%p"
>
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_left1" />
<Spacer
latin:keyWidth="20.0%p" />
<include
latin:keyboardLayout="@xml/rowkeys_symbols1_right1" />
</Row>
</case>
<case
latin:numberRowEnabled="true"
latin:isSplitLayout="false"
> >
<Row <Row
latin:keyWidth="10%p" latin:keyWidth="10%p"