Refactoring

pull/204/head
M66B 3 years ago
parent 3ca8c54889
commit e0bab3e77c

@ -28,7 +28,6 @@ import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.EditText;
@ -165,10 +164,7 @@ public class AdapterKeyword extends RecyclerView.Adapter<AdapterKeyword.ViewHold
@Override
public void run() {
etKeyword.requestFocus();
InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(etKeyword, InputMethodManager.SHOW_IMPLICIT);
Helper.showKeyboard(etKeyword);
}
});
} else if (itemId == R.id.ibSave) {

@ -93,7 +93,6 @@ import android.view.MotionEvent;
import android.view.SubMenu;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.InputMethodManager;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.CheckBox;
@ -6171,18 +6170,10 @@ public class FragmentCompose extends FragmentBase {
target.requestFocus();
Context context = target.getContext();
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean keyboard = prefs.getBoolean("keyboard", true);
if (!keyboard || !restore)
return;
InputMethodManager imm =
(InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm == null)
return;
imm.showSoftInput(target, InputMethodManager.SHOW_IMPLICIT);
if (keyboard && restore)
Helper.showKeyboard(target);
} catch (Throwable ex) {
Log.e(ex);

@ -103,7 +103,6 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
@ -5961,11 +5960,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
etSearch.setText(null);
etSearch.setVisibility(View.VISIBLE);
etSearch.requestFocus();
InputMethodManager imm =
(InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
if (imm != null)
imm.showSoftInput(etSearch, InputMethodManager.SHOW_IMPLICIT);
Helper.showKeyboard(etSearch);
}
private void endSearch() {

@ -1131,22 +1131,26 @@ public class Helper {
return (tv.string != null && !"light".contentEquals(tv.string));
}
static void hideKeyboard(final View view) {
static void showKeyboard(final View view) {
final Context context = view.getContext();
InputMethodManager imm =
(InputMethodManager) view.getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
(InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm == null)
return;
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
Log.i("showKeyboard view=" + view);
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}
static void hideKeyboard(Activity activity) {
if (activity == null)
return;
View focused = activity.getCurrentFocus();
if (focused == null)
static void hideKeyboard(final View view) {
final Context context = view.getContext();
InputMethodManager imm =
(InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
if (imm == null)
return;
hideKeyboard(focused);
Log.i("hideKeyboard view=" + view);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
// Formatting

Loading…
Cancel
Save