Skip to content

Commit e82548b

Browse files
committed
migrate module to kotlin
1 parent 3903dfe commit e82548b

3 files changed

Lines changed: 30 additions & 42 deletions

File tree

android/app/src/main/java/com/expensify/chat/RNTextInputResetModule.java

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.expensify.chat;
2+
3+
import com.facebook.react.bridge.ReactApplicationContext;
4+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
5+
import com.facebook.react.bridge.ReactMethod;
6+
import com.facebook.react.uimanager.util.ReactFindViewUtil;
7+
8+
import android.content.Context;
9+
import android.os.Build
10+
import android.view.View;
11+
import android.view.inputmethod.InputMethodManager;
12+
import androidx.annotation.RequiresApi
13+
14+
class RNTextInputResetModule(private val reactContext: ReactApplicationContext): ReactContextBaseJavaModule(reactContext) {
15+
override fun getName(): String = "RNTextInputReset"
16+
17+
// Props to https://github.com/MattFoley for this temporary hack
18+
// https://github.com/facebook/react-native/pull/12462#issuecomment-298812731
19+
@ReactMethod
20+
fun resetKeyboardInput(nativeId: String) {
21+
reactContext.runOnUiQueueThread {
22+
val imm = reactApplicationContext.baseContext.getSystemService(Context.INPUT_METHOD_SERVICE) as? InputMethodManager
23+
24+
val reactNativeView = currentActivity?.findViewById<View>(android.R.id.content)
25+
val viewToReset = reactNativeView?.let { ReactFindViewUtil.findView(it, nativeId) }
26+
imm?.restartInput(viewToReset)
27+
}
28+
}
29+
}

src/types/modules/react-native.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type AppStateTrackerModule = {
1515
};
1616

1717
type RNTextInputResetModule = {
18-
resetKeyboardInput: (nodeHandle: string) => void;
18+
resetKeyboardInput: (nativeId: string) => void;
1919
};
2020

2121
type RNNavBarManagerModule = {

0 commit comments

Comments
 (0)