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

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

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

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

Loading…
Cancel
Save