Skip to content

Commit

Permalink
fix(android): focus on TextInputEditText view (#11277)
Browse files Browse the repository at this point in the history
* fix(android): focus on TextInputEditText view

* fix(android): validate proxy
  • Loading branch information
garymathews authored and lokeshchdhry committed Oct 14, 2019
1 parent 1e3d161 commit 8192ea2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,9 @@ public void onTextChanged(CharSequence s, int start, int before, int count)
public void focus()
{
super.focus();
if (tv != null) {
if (proxy.hasProperty(TiC.PROPERTY_EDITABLE)
&& !(TiConvert.toBoolean(proxy.getProperty(TiC.PROPERTY_EDITABLE)))) {
TiUIHelper.showSoftKeyboard(tv, false);
} else {
TiUIHelper.showSoftKeyboard(tv, true);
}
if (tv != null && proxy != null && proxy.getProperties() != null) {
final boolean editable = proxy.getProperties().optBoolean(TiC.PROPERTY_EDITABLE, false);
TiUIHelper.showSoftKeyboard(tv, editable);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1116,20 +1116,14 @@ public static void requestSoftInputChange(KrollProxy proxy, View view)
*/
public static void showSoftKeyboard(View view, boolean show)
{
InputMethodManager imm = (InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);

final InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm != null) {
boolean useForce =
(Build.VERSION.SDK_INT <= Build.VERSION_CODES.DONUT || Build.VERSION.SDK_INT >= 8) ? true : false;
String model = APSAnalyticsMeta.getModel();
if (model.toLowerCase().startsWith("droid")) {
useForce = true;
}
view.requestFocus();
if (show) {
imm.showSoftInput(view, useForce ? InputMethodManager.SHOW_FORCED : InputMethodManager.SHOW_IMPLICIT);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
} else {
imm.hideSoftInputFromWindow(view.getWindowToken(),
useForce ? 0 : InputMethodManager.HIDE_IMPLICIT_ONLY);
imm.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
}
}
}
Expand Down

0 comments on commit 8192ea2

Please sign in to comment.