mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2026-02-04 21:15:35 +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
@ -12,7 +12,6 @@ import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.activity.result.ActivityResultLauncher;
|
||||
import androidx.activity.result.contract.ActivityResultContracts;
|
||||
@ -40,6 +39,7 @@ import de.danoeh.antennapod.net.discovery.FyydPodcastSearcher;
|
||||
import de.danoeh.antennapod.net.discovery.ItunesPodcastSearcher;
|
||||
import de.danoeh.antennapod.net.discovery.PodcastIndexPodcastSearcher;
|
||||
import de.danoeh.antennapod.ui.appstartintent.OnlineFeedviewActivityStarter;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import de.danoeh.antennapod.ui.discovery.OnlineSearchFragment;
|
||||
import de.danoeh.antennapod.ui.screen.feed.FeedItemlistFragment;
|
||||
import de.danoeh.antennapod.ui.view.LiftOnScrollListener;
|
||||
@ -156,9 +156,8 @@ public class AddFeedFragment extends Fragment {
|
||||
}
|
||||
|
||||
private void performSearch() {
|
||||
Keyboard.hide(getActivity());
|
||||
viewBinding.combinedFeedSearchEditText.clearFocus();
|
||||
InputMethodManager in = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
in.hideSoftInputFromWindow(viewBinding.combinedFeedSearchEditText.getWindowToken(), 0);
|
||||
String query = viewBinding.combinedFeedSearchEditText.getText().toString();
|
||||
if (query.matches("http[s]?://.*")) {
|
||||
addUrl(query);
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package de.danoeh.antennapod.ui.screen;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
@ -11,7 +10,6 @@ import android.view.LayoutInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.ProgressBar;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -26,6 +24,7 @@ import com.google.android.material.chip.Chip;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import de.danoeh.antennapod.ui.episodeslist.EpisodeItemListAdapter;
|
||||
import de.danoeh.antennapod.ui.screen.subscriptions.HorizontalFeedListAdapter;
|
||||
import de.danoeh.antennapod.ui.MenuItemUtils;
|
||||
@ -214,7 +213,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||
}
|
||||
searchView.setOnQueryTextFocusChangeListener((view, hasFocus) -> {
|
||||
if (hasFocus && !isOtherViewInFoucus) {
|
||||
showInputMethod(view.findFocus());
|
||||
Keyboard.show(getContext(), view.findFocus());
|
||||
}
|
||||
});
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@ -222,9 +221,7 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
InputMethodManager imm = (InputMethodManager)
|
||||
getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(recyclerView.getWindowToken(), 0);
|
||||
Keyboard.hide(getActivity());
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -437,20 +434,12 @@ public class SearchFragment extends Fragment implements EpisodeItemListAdapter.O
|
||||
}, error -> Log.e(TAG, Log.getStackTraceString(error)));
|
||||
}
|
||||
|
||||
private void showInputMethod(View view) {
|
||||
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (imm != null) {
|
||||
imm.showSoftInput(view, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void searchOnline() {
|
||||
if (adapter != null && adapter.inActionMode()) {
|
||||
adapter.endSelectMode();
|
||||
}
|
||||
searchView.clearFocus();
|
||||
InputMethodManager in = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
in.hideSoftInputFromWindow(searchView.getWindowToken(), 0);
|
||||
Keyboard.hide(getActivity());
|
||||
String query = searchView.getQuery().toString();
|
||||
if (query.matches("http[s]?://.*")) {
|
||||
startActivity(new OnlineFeedviewActivityStarter(getContext(), query).getIntent());
|
||||
|
||||
@ -23,6 +23,7 @@ import de.danoeh.antennapod.storage.database.DBWriter;
|
||||
import de.danoeh.antennapod.storage.database.NavDrawerData;
|
||||
import de.danoeh.antennapod.storage.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.ui.SimpleChipAdapter;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import de.danoeh.antennapod.ui.view.ItemOffsetDecoration;
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.rxjava3.core.Observable;
|
||||
@ -138,6 +139,8 @@ public class TagSettingsDialog extends DialogFragment {
|
||||
|
||||
private void addTag(String name) {
|
||||
if (TextUtils.isEmpty(name) || displayedTags.contains(name) || FeedPreferences.TAG_UNTAGGED.equals(name)) {
|
||||
viewBinding.newTagEditText.requestFocus();
|
||||
Keyboard.show(getContext(), viewBinding.newTagEditText);
|
||||
return;
|
||||
}
|
||||
displayedTags.add(name);
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
package de.danoeh.antennapod.ui.screen.playback;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@ -11,7 +10,6 @@ import android.text.format.DateFormat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
@ -27,6 +25,7 @@ import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
@ -192,10 +191,6 @@ public class SleepTimerDialog extends BottomSheetDialogFragment {
|
||||
startActivity(playbackIntent);
|
||||
dismiss();
|
||||
});
|
||||
viewBinding.timeEditText.postDelayed(() -> {
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.showSoftInput(viewBinding.timeEditText, InputMethodManager.SHOW_IMPLICIT);
|
||||
}, 100);
|
||||
refreshUiState();
|
||||
viewBinding.autoEnableCheckbox.setChecked(SleepTimerPreferences.autoEnable());
|
||||
viewBinding.shakeToResetCheckbox.setChecked(SleepTimerPreferences.shakeToReset());
|
||||
@ -237,7 +232,7 @@ public class SleepTimerDialog extends BottomSheetDialogFragment {
|
||||
if (controller != null) {
|
||||
controller.setSleepTimer(SleepTimerPreferences.timerMillisOrEpisodes());
|
||||
}
|
||||
closeKeyboard(viewBinding.getRoot());
|
||||
Keyboard.hide(getActivity());
|
||||
} catch (NumberFormatException e) {
|
||||
e.printStackTrace();
|
||||
Snackbar.make(viewBinding.getRoot(), R.string.time_dialog_invalid_input, Snackbar.LENGTH_LONG).show();
|
||||
@ -443,9 +438,4 @@ public class SleepTimerDialog extends BottomSheetDialogFragment {
|
||||
viewBinding.time.setText(Converter.getDurationStringLong((int) event.getDisplayTimeLeft()));
|
||||
}
|
||||
}
|
||||
|
||||
private void closeKeyboard(View content) {
|
||||
InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Activity.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(content.getWindowToken(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,8 +6,6 @@ import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import com.bytehamster.lib.preferencesearch.SearchPreferenceResult;
|
||||
@ -16,6 +14,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.event.MessageEvent;
|
||||
import de.danoeh.antennapod.ui.common.Keyboard;
|
||||
import de.danoeh.antennapod.ui.common.ToolbarActivity;
|
||||
import de.danoeh.antennapod.ui.preferences.databinding.SettingsActivityBinding;
|
||||
import de.danoeh.antennapod.ui.preferences.screen.AutoDownloadPreferencesFragment;
|
||||
@ -134,13 +133,7 @@ public class PreferenceActivity extends ToolbarActivity implements SearchPrefere
|
||||
if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
|
||||
finish();
|
||||
} else {
|
||||
InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
View view = 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(this);
|
||||
}
|
||||
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
|
||||
Keyboard.hide(this);
|
||||
getSupportFragmentManager().popBackStack();
|
||||
}
|
||||
return true;
|
||||
|
||||
@ -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