mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Fix width too long in landscape mode
This commit is contained in:
parent
d692e7b96a
commit
f795a7228e
@ -22,7 +22,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Preferable keyboard height in absolute scale: 58.0mm -->
|
<!-- Preferable keyboard height in absolute scale: 58.0mm -->
|
||||||
<!-- This config_default_keyboard_height value should match with keyboard-heights.xml -->
|
<!-- This config_default_keyboard_height value should match with keyboard-heights.xml -->
|
||||||
<dimen name="config_default_keyboard_height">365.4dp</dimen>
|
<dimen name="config_default_keyboard_height">302.4dp</dimen>
|
||||||
<fraction name="config_min_keyboard_height">35%p</fraction>
|
<fraction name="config_min_keyboard_height">35%p</fraction>
|
||||||
|
|
||||||
<fraction name="config_keyboard_top_padding_holo">1.896%p</fraction>
|
<fraction name="config_keyboard_top_padding_holo">1.896%p</fraction>
|
@ -22,7 +22,7 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<!-- Preferable keyboard height in absolute scale: 48.0mm -->
|
<!-- Preferable keyboard height in absolute scale: 48.0mm -->
|
||||||
<!-- This config_default_keyboard_height value should match with keyboard-heights.xml -->
|
<!-- This config_default_keyboard_height value should match with keyboard-heights.xml -->
|
||||||
<dimen name="config_default_keyboard_height">302.4dp</dimen>
|
<dimen name="config_default_keyboard_height">365.4dp</dimen>
|
||||||
<fraction name="config_max_keyboard_height">46%p</fraction>
|
<fraction name="config_max_keyboard_height">46%p</fraction>
|
||||||
<fraction name="config_min_keyboard_height">-35.0%p</fraction>
|
<fraction name="config_min_keyboard_height">-35.0%p</fraction>
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ import android.util.Log;
|
|||||||
import android.view.ContextThemeWrapper;
|
import android.view.ContextThemeWrapper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.Window;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@ -149,13 +150,15 @@ public final class KeyboardSwitcher implements SwitchActions {
|
|||||||
|
|
||||||
Rect padding = new Rect();
|
Rect padding = new Rect();
|
||||||
|
|
||||||
|
Window window = mLatinIMELegacy.getInputMethodService().getWindow().getWindow();
|
||||||
|
|
||||||
if(computedSize instanceof SplitKeyboardSize) {
|
if(computedSize instanceof SplitKeyboardSize) {
|
||||||
keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(window, res);
|
||||||
keyboardHeight = ((SplitKeyboardSize) computedSize).getHeight();
|
keyboardHeight = ((SplitKeyboardSize) computedSize).getHeight();
|
||||||
splitLayoutWidth = ((SplitKeyboardSize) computedSize).getSplitLayoutWidth();
|
splitLayoutWidth = ((SplitKeyboardSize) computedSize).getSplitLayoutWidth();
|
||||||
padding = ((SplitKeyboardSize) computedSize).getPadding();
|
padding = ((SplitKeyboardSize) computedSize).getPadding();
|
||||||
}else if(computedSize instanceof RegularKeyboardSize) {
|
}else if(computedSize instanceof RegularKeyboardSize) {
|
||||||
keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(window, res);
|
||||||
keyboardHeight = ((RegularKeyboardSize) computedSize).getHeight();
|
keyboardHeight = ((RegularKeyboardSize) computedSize).getHeight();
|
||||||
padding = ((RegularKeyboardSize) computedSize).getPadding();
|
padding = ((RegularKeyboardSize) computedSize).getPadding();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package org.futo.inputmethod.latin.uix
|
package org.futo.inputmethod.latin.uix
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.app.KeyguardManager
|
|
||||||
import android.content.ClipDescription
|
import android.content.ClipDescription
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
@ -62,11 +61,15 @@ import androidx.compose.ui.unit.LayoutDirection
|
|||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.lifecycle.LifecycleCoroutineScope
|
import androidx.lifecycle.LifecycleCoroutineScope
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
import androidx.window.layout.FoldingFeature
|
||||||
|
import androidx.window.layout.WindowInfoTracker
|
||||||
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import org.futo.inputmethod.accessibility.AccessibilityUtils
|
import org.futo.inputmethod.accessibility.AccessibilityUtils
|
||||||
import org.futo.inputmethod.latin.AudioAndHapticFeedbackManager
|
import org.futo.inputmethod.latin.AudioAndHapticFeedbackManager
|
||||||
import org.futo.inputmethod.latin.BuildConfig
|
import org.futo.inputmethod.latin.BuildConfig
|
||||||
|
import org.futo.inputmethod.latin.FoldingOptions
|
||||||
import org.futo.inputmethod.latin.LanguageSwitcherDialog
|
import org.futo.inputmethod.latin.LanguageSwitcherDialog
|
||||||
import org.futo.inputmethod.latin.LatinIME
|
import org.futo.inputmethod.latin.LatinIME
|
||||||
import org.futo.inputmethod.latin.R
|
import org.futo.inputmethod.latin.R
|
||||||
@ -103,6 +106,12 @@ val LocalThemeProvider = compositionLocalOf<DynamicThemeProvider> {
|
|||||||
error("No LocalThemeProvider provided")
|
error("No LocalThemeProvider provided")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val LocalFoldingState = compositionLocalOf<FoldingOptions> {
|
||||||
|
FoldingOptions(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private class LatinIMEActionInputTransaction(
|
private class LatinIMEActionInputTransaction(
|
||||||
private val inputLogic: InputLogic,
|
private val inputLogic: InputLogic,
|
||||||
shouldApplySpace: Boolean,
|
shouldApplySpace: Boolean,
|
||||||
@ -323,6 +332,8 @@ class UixManager(private val latinIME: LatinIME) {
|
|||||||
isShowingActionEditor.value = true
|
isShowingActionEditor.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val foldingOptions = mutableStateOf(FoldingOptions(null))
|
||||||
|
|
||||||
var isInputOverridden = mutableStateOf(false)
|
var isInputOverridden = mutableStateOf(false)
|
||||||
|
|
||||||
var currWindowActionWindow: ActionWindow? = null
|
var currWindowActionWindow: ActionWindow? = null
|
||||||
@ -622,35 +633,39 @@ class UixManager(private val latinIME: LatinIME) {
|
|||||||
CompositionLocalProvider(LocalManager provides keyboardManagerForAction) {
|
CompositionLocalProvider(LocalManager provides keyboardManagerForAction) {
|
||||||
CompositionLocalProvider(LocalThemeProvider provides latinIME.getDrawableProvider()) {
|
CompositionLocalProvider(LocalThemeProvider provides latinIME.getDrawableProvider()) {
|
||||||
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
|
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
|
||||||
InputDarkener(isInputOverridden.value || isShowingActionEditor.value) {
|
CompositionLocalProvider(LocalFoldingState provides foldingOptions.value) {
|
||||||
closeActionWindow()
|
InputDarkener(isInputOverridden.value || isShowingActionEditor.value) {
|
||||||
isShowingActionEditor.value = false
|
closeActionWindow()
|
||||||
}
|
isShowingActionEditor.value = false
|
||||||
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
Spacer(modifier = Modifier.weight(1.0f))
|
Spacer(modifier = Modifier.weight(1.0f))
|
||||||
Surface(modifier = Modifier.onSizeChanged {
|
Surface(modifier = Modifier.onSizeChanged {
|
||||||
latinIME.updateTouchableHeight(it.height)
|
latinIME.updateTouchableHeight(it.height)
|
||||||
}, color = latinIME.keyboardColor) {
|
}, color = latinIME.keyboardColor) {
|
||||||
Box {
|
Box {
|
||||||
Column {
|
Column {
|
||||||
when {
|
when {
|
||||||
currWindowActionWindow != null -> ActionViewWithHeader(
|
currWindowActionWindow != null -> ActionViewWithHeader(
|
||||||
currWindowActionWindow!!
|
currWindowActionWindow!!
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> MainKeyboardViewWithActionBar()
|
else -> MainKeyboardViewWithActionBar()
|
||||||
|
}
|
||||||
|
|
||||||
|
latinIME.LegacyKeyboardView(hidden = isMainKeyboardHidden)
|
||||||
}
|
}
|
||||||
|
|
||||||
latinIME.LegacyKeyboardView(hidden = isMainKeyboardHidden)
|
ForgetWordDialog()
|
||||||
}
|
}
|
||||||
|
|
||||||
ForgetWordDialog()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ActionEditorHost()
|
}
|
||||||
|
|
||||||
|
ActionEditorHost()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -852,6 +867,13 @@ class UixManager(private val latinIME: LatinIME) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isActionsExpanded.value = latinIME.getSettingBlocking(ActionBarExpanded)
|
isActionsExpanded.value = latinIME.getSettingBlocking(ActionBarExpanded)
|
||||||
|
|
||||||
|
latinIME.lifecycleScope.launch(Dispatchers.Main) {
|
||||||
|
WindowInfoTracker.getOrCreate(latinIME).windowLayoutInfo(latinIME).collect {
|
||||||
|
foldingOptions.value = FoldingOptions(it.displayFeatures.filterIsInstance<FoldingFeature>().firstOrNull())
|
||||||
|
latinIME.invalidateKeyboard(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onPersistentStatesUnlocked() {
|
fun onPersistentStatesUnlocked() {
|
||||||
|
@ -18,11 +18,15 @@ package org.futo.inputmethod.latin.utils;
|
|||||||
|
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
|
import android.graphics.Insets;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.view.WindowInsets;
|
||||||
|
import android.view.WindowMetrics;
|
||||||
|
|
||||||
import org.futo.inputmethod.annotations.UsedForTesting;
|
import org.futo.inputmethod.annotations.UsedForTesting;
|
||||||
import org.futo.inputmethod.latin.R;
|
import org.futo.inputmethod.latin.R;
|
||||||
@ -182,9 +186,14 @@ public final class ResourceUtils {
|
|||||||
return matchedAll;
|
return matchedAll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getDefaultKeyboardWidth(final Resources res) {
|
public static int getDefaultKeyboardWidth(final Window window, final Resources res) {
|
||||||
final DisplayMetrics dm = res.getDisplayMetrics();
|
if(window != null && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)) {
|
||||||
return dm.widthPixels;
|
WindowMetrics metrics = window.getWindowManager().getCurrentWindowMetrics();
|
||||||
|
Insets insets = metrics.getWindowInsets().getInsetsIgnoringVisibility(WindowInsets.Type.navigationBars() | WindowInsets.Type.displayCutout());
|
||||||
|
|
||||||
|
return metrics.getBounds().width() - (insets.left + insets.right);
|
||||||
|
}
|
||||||
|
return (int)(res.getConfiguration().screenWidthDp * res.getDisplayMetrics().density);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getKeyboardHeight(final Resources res, final SettingsValues settingsValues) {
|
public static int getKeyboardHeight(final Resources res, final SettingsValues settingsValues) {
|
||||||
|
@ -143,7 +143,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
|||||||
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) {
|
||||||
final Context context = getContext();
|
final Context context = getContext();
|
||||||
final Resources res = context.getResources();
|
final Resources res = context.getResources();
|
||||||
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
|
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(null, res);
|
||||||
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
|
||||||
|
|
||||||
final RichInputMethodSubtype richInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
final RichInputMethodSubtype richInputMethodSubtype = RichInputMethodSubtype.getRichInputMethodSubtype(subtype);
|
||||||
|
Loading…
Reference in New Issue
Block a user