diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-17 03:36:11 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-08-17 03:36:11 +0000 |
commit | 036417bdf1b3eb9279991a5dbf3e092ca46a63c8 (patch) | |
tree | ef99e5ccf37b76bde1bbcafd51822ea247c78e82 /app/src | |
parent | 482e8b3c732b543fd1dc932ddea36a1002bed08f (diff) | |
download | infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar.gz infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar.bz2 infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar.lz infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar.xz infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.tar.zst infinity-for-reddit-036417bdf1b3eb9279991a5dbf3e092ca46a63c8.zip |
Fix build issue and use Utils' hideKeyboard() and showKeyboard() in SearchActivity.
Diffstat (limited to 'app/src')
3 files changed, 10 insertions, 26 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java index a09d3b1a..4505a355 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -1,7 +1,6 @@ package ml.docilealligator.infinityforreddit.activities; import android.app.Activity; -import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.ColorStateList; @@ -16,11 +15,6 @@ import android.view.KeyEvent; import android.view.MenuItem; import android.view.View; import android.view.inputmethod.EditorInfo; -import android.view.inputmethod.InputMethodManager; -import android.widget.EditText; -import android.widget.ImageView; -import android.widget.RelativeLayout; -import android.widget.TextView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -272,17 +266,17 @@ public class SearchActivity extends BaseActivity { .setTitle(R.string.confirm) .setMessage(R.string.confirm_delete_all_recent_searches) .setPositiveButton(R.string.yes, (dialogInterface, i) -> { - hideKeyboard(true); + Utils.hideKeyboard(SearchActivity.this); + executor.execute(() -> { List<RecentSearchQuery> deletedQueries = mRedditDataRoomDatabase.recentSearchQueryDao().getAllRecentSearchQueries(accountName); mRedditDataRoomDatabase.recentSearchQueryDao().deleteAllRecentSearchQueries(accountName); - view.post(() -> Snackbar.make(view, R.string.deleted_all_recent_search, Snackbar.LENGTH_LONG) + handler.post(() -> Snackbar.make(view, R.string.all_recent_searches_deleted, Snackbar.LENGTH_LONG) .setAction(R.string.undo, v -> executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().insertAll(deletedQueries))) .addCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar transientBottomBar, int event) { - super.onDismissed(transientBottomBar, event); - hideKeyboard(false); + Utils.showKeyboard(SearchActivity.this, handler, binding.searchEditTextSearchActivity); } }) .show()); @@ -336,16 +330,16 @@ public class SearchActivity extends BaseActivity { @Override public void onDelete(RecentSearchQuery recentSearchQuery) { - hideKeyboard(true); + Utils.hideKeyboard(SearchActivity.this); + executor.execute(() -> { mRedditDataRoomDatabase.recentSearchQueryDao().deleteRecentSearchQueries(recentSearchQuery); - Snackbar.make(appBarLayout, R.string.deleted_recent_search, Snackbar.LENGTH_SHORT) + Snackbar.make(binding.getRoot(), R.string.recent_search_deleted, Snackbar.LENGTH_SHORT) .setAction(R.string.undo, v -> executor.execute(() -> mRedditDataRoomDatabase.recentSearchQueryDao().insert(recentSearchQuery))) .addCallback(new Snackbar.Callback() { @Override public void onDismissed(Snackbar transientBottomBar, int event) { - super.onDismissed(transientBottomBar, event); - hideKeyboard(false); + Utils.showKeyboard(SearchActivity.this, handler, binding.searchEditTextSearchActivity); } }) .show(); @@ -394,15 +388,6 @@ public class SearchActivity extends BaseActivity { } } - private void hideKeyboard(Boolean hide) { - View view = this.getCurrentFocus(); - if (view != null) { - InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - if (hide) imm.hideSoftInputFromWindow(view.getWindowToken(), 0); - else imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT); - } - } - private void search(String query) { if (query.equalsIgnoreCase("suicide") && mSharedPreferences.getBoolean(SharedPreferencesUtils.SHOW_SUICIDE_PREVENTION_ACTIVITY, true)) { Intent intent = new Intent(this, SuicidePreventionActivity.class); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java index 3cfdf2fb..9b7a91c8 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java @@ -2,7 +2,6 @@ package ml.docilealligator.infinityforreddit.adapters; import android.content.res.ColorStateList; import android.view.LayoutInflater; -import android.view.View; import android.view.ViewGroup; import androidx.annotation.NonNull; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e1f8faea..b8575b0c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -265,8 +265,8 @@ <string name="confirm">Confirm</string> <string name="confirm_delete_all_recent_searches">Are you sure you want to delete all recent search queries?</string> - <string name="deleted_all_recent_search">Deleted all recent searches</string> - <string name="deleted_recent_search">Deleted recent search</string> + <string name="all_recent_searches_deleted">All recent searches deleted</string> + <string name="recent_search_deleted">Recent search Deleted</string> <string name="undo">Undo</string> <string name="sort_best">Best</string> |