From 915692d82877404e778855733fb61fbf2a47fbf9 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 11 Mar 2025 22:04:15 +0800 Subject: [PATCH] Do not use extra keyboard on Android (#8651) --- app/components/post_draft/post_draft.tsx | 3 +- app/screens/navigation.ts | 37 +++++++----------------- 2 files changed, 13 insertions(+), 27 deletions(-) diff --git a/app/components/post_draft/post_draft.tsx b/app/components/post_draft/post_draft.tsx index 704c14d05..dd7343e52 100644 --- a/app/components/post_draft/post_draft.tsx +++ b/app/components/post_draft/post_draft.tsx @@ -2,6 +2,7 @@ // See LICENSE.txt for license information. import React, {useEffect, useState} from 'react'; +import {Platform} from 'react-native'; import Autocomplete from '@components/autocomplete'; import {ExtraKeyboard} from '@context/extra_keyboard'; @@ -122,7 +123,7 @@ function PostDraft({ <> {draftHandler} {autoComplete} - + {Platform.OS !== 'android' && } ); } diff --git a/app/screens/navigation.ts b/app/screens/navigation.ts index 95995ae08..38c1674ac 100644 --- a/app/screens/navigation.ts +++ b/app/screens/navigation.ts @@ -3,15 +3,14 @@ /* eslint-disable max-lines */ -import RNUtils from '@mattermost/rnutils'; import merge from 'deepmerge'; import {Appearance, DeviceEventEmitter, StatusBar, Platform, Alert, type EmitterSubscription} from 'react-native'; -import {type ComponentWillAppearEvent, type ImageResource, type LayoutOrientation, Navigation, type Options, OptionsModalPresentationStyle, type OptionsTopBarButton, type ScreenPoppedEvent, type EventSubscription, type ComponentDidAppearEvent} from 'react-native-navigation'; +import {type ComponentWillAppearEvent, type ImageResource, type LayoutOrientation, Navigation, type Options, OptionsModalPresentationStyle, type OptionsTopBarButton, type ScreenPoppedEvent, type EventSubscription} from 'react-native-navigation'; import tinyColor from 'tinycolor2'; import CompassIcon from '@components/compass_icon'; import {Events, Screens, Launch} from '@constants'; -import {NOT_READY, SCREENS_WITH_EXTRA_KEYBOARD} from '@constants/screens'; +import {NOT_READY} from '@constants/screens'; import {getDefaultThemeByAppearance} from '@context/theme'; import EphemeralStore from '@store/ephemeral_store'; import NavigationStore from '@store/navigation_store'; @@ -40,8 +39,15 @@ export function registerNavigationListeners() { Navigation.events().registerScreenPoppedListener(onPoppedListener), Navigation.events().registerCommandListener(onCommandListener), Navigation.events().registerComponentWillAppearListener(onScreenWillAppear), - Navigation.events().registerComponentDidAppearListener(onScreenDidAppear), - Navigation.events().registerComponentDidDisappearListener(onScreenDidDisappear), + + /** + * For the time being and until we add the emoji picker in the keyboard area + * will keep Android as adjustResize cause useAnimatedKeyboard from reanimated + * is reporting the wrong values when the keyboard was opened but we switch + * to a different channel or thread. + */ + // Navigation.events().registerComponentDidAppearListener(onScreenDidAppear), + // Navigation.events().registerComponentDidDisappearListener(onScreenDidDisappear), ]; } @@ -79,33 +85,12 @@ function onPoppedListener({componentId}: ScreenPoppedEvent) { NavigationStore.removeScreenFromStack(componentId as AvailableScreens); } -function setAndroidSoftKeyboard(screen: AvailableScreens) { - if (Platform.OS !== 'android') { - return; - } - - if (SCREENS_WITH_EXTRA_KEYBOARD.has(screen) || (isTablet() && screen === Screens.HOME)) { - RNUtils.setSoftKeyboardToAdjustNothing(); - } else { - RNUtils.setSoftKeyboardToAdjustResize(); - } -} - function onScreenWillAppear(event: ComponentWillAppearEvent) { if (event.componentId === Screens.HOME) { DeviceEventEmitter.emit(Events.TAB_BAR_VISIBLE, true); } } -function onScreenDidAppear(event: ComponentDidAppearEvent) { - setAndroidSoftKeyboard(event.componentId as AvailableScreens); -} - -function onScreenDidDisappear() { - const screen = NavigationStore.getVisibleScreen(); - setAndroidSoftKeyboard(screen); -} - export const loginAnimationOptions = () => { const theme = getThemeFromState(); return {