Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed react-native-text-input-reset dependency #4243

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ protected List<ReactPackage> getPackages() {
packages.add(new ZulipNativePackage());
packages.add(new NotificationsPackage());
packages.add(new SharingPackage());
packages.add(new TextResetPackage());

// Unimodules:
packages.add(new ModuleRegistryAdapter(mModuleRegistryProvider));
Expand Down
48 changes: 48 additions & 0 deletions android/app/src/main/java/com/zulipmobile/TextReset.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.zulipmobile;

import android.util.Base64;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.uimanager.UIManagerModule;
import com.facebook.react.uimanager.UIBlock;
import com.facebook.react.uimanager.NativeViewHierarchyManager;
import android.content.Context;
import android.view.View;
import android.widget.TextView;
import android.view.inputmethod.InputMethodManager;
import android.util.Log;

public class TextReset extends ReactContextBaseJavaModule {

public TextReset(ReactApplicationContext reactContext) {
super(reactContext);
}

@Override
public String getName() {
return "TextReset";
}

@ReactMethod
public void resetKeyboardInput(final int reactTagToReset) {
UIManagerModule uiManager = getReactApplicationContext().getNativeModule(UIManagerModule.class);
uiManager.addUIBlock(new UIBlock() {
@Override
public void execute(NativeViewHierarchyManager nativeViewHierarchyManager) {
InputMethodManager imm = (InputMethodManager) getReactApplicationContext().getBaseContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null) {
View viewToReset = nativeViewHierarchyManager.resolveView(reactTagToReset);
imm.restartInput(viewToReset);
try {
TextView textView = (TextView) viewToReset;
textView.setText("");
} catch (Exception e) {}
}
}
});
}

}

33 changes: 33 additions & 0 deletions android/app/src/main/java/com/zulipmobile/TextResetPackage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.zulipmobile;

import com.facebook.react.ReactPackage;
import com.facebook.react.bridge.JavaScriptModule;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.uimanager.ViewManager;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class TextResetPackage implements ReactPackage {

@Override
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
return Collections.emptyList();
}

@Override
public List<NativeModule> createNativeModules(
ReactApplicationContext reactContext) {
List<NativeModule> modules = new ArrayList<>();

modules.add(new TextReset(reactContext));

return modules;
}

public List<Class<? extends JavaScriptModule>> createJSModules() {
return new ArrayList<>();
}
}
Loading