mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2026-02-04 12:45:26 +00:00
Show keyboard when trying to add tag (#8148)
When trying to press the "add tag" plus icon and the text box is empty, show the keyboard to indicate how to add one.
This commit is contained in:
committed by
GitHub
parent
0842bf14c6
commit
93e9ddcad4
@ -0,0 +1,29 @@
|
||||
package de.danoeh.antennapod.ui.common;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
public class Keyboard {
|
||||
private Keyboard() {
|
||||
}
|
||||
|
||||
public static void show(Context context, View view) {
|
||||
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(view, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static void hide(Activity activity) {
|
||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
View view = activity.getCurrentFocus();
|
||||
//If no view currently has focus, create a new one, just so we can grab a window token from it
|
||||
if (view == null) {
|
||||
view = new View(activity);
|
||||
}
|
||||
view.clearFocus();
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,11 @@
|
||||
package de.danoeh.antennapod.ui.discovery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
@ -26,6 +24,7 @@ import de.danoeh.antennapod.net.discovery.PodcastSearchResult;
|
||||
import de.danoeh.antennapod.net.discovery.PodcastSearcher;
|
||||
import de.danoeh.antennapod.net.discovery.PodcastSearcherRegistry;
|
||||
import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import io.reactivex.rxjava3.disposables.Disposable;
|
||||
|
||||
public class OnlineSearchFragment extends Fragment {
|
||||
@ -111,9 +110,7 @@ public class OnlineSearchFragment extends Fragment {
|
||||
@Override
|
||||
public void onScrollStateChanged(AbsListView view, int scrollState) {
|
||||
if (scrollState == SCROLL_STATE_TOUCH_SCROLL) {
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
Keyboard.hide(getActivity());
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,7 +152,7 @@ public class OnlineSearchFragment extends Fragment {
|
||||
});
|
||||
sv.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
|
||||
if (hasFocus) {
|
||||
showInputMethod(view.findFocus());
|
||||
Keyboard.show(getContext(), view.findFocus());
|
||||
}
|
||||
});
|
||||
searchItem.setOnActionExpandListener(new MenuItem.OnActionExpandListener() {
|
||||
@ -208,11 +205,4 @@ public class OnlineSearchFragment extends Fragment {
|
||||
txtvEmpty.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void showInputMethod(View view) {
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(view, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,10 @@
|
||||
package de.danoeh.antennapod.ui.preferences.screen.synchronization;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
@ -25,6 +23,7 @@ import de.danoeh.antennapod.storage.preferences.SynchronizationCredentials;
|
||||
import de.danoeh.antennapod.storage.preferences.SynchronizationSettings;
|
||||
import de.danoeh.antennapod.net.sync.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.net.sync.gpoddernet.model.GpodnetDevice;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import de.danoeh.antennapod.ui.preferences.R;
|
||||
import io.reactivex.rxjava3.core.Completable;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@ -120,9 +119,7 @@ public class GpodderAuthenticationFragment extends DialogFragment {
|
||||
login.setEnabled(false);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
txtvError.setVisibility(View.GONE);
|
||||
InputMethodManager inputManager = (InputMethodManager) getContext()
|
||||
.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
inputManager.hideSoftInputFromWindow(login.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
|
||||
Keyboard.hide(getActivity());
|
||||
|
||||
Completable.fromAction(() -> {
|
||||
service.setCredentials(usernameStr, passwordStr);
|
||||
|
||||
Reference in New Issue
Block a user