diff options
Diffstat (limited to 'app')
11 files changed, 65 insertions, 94 deletions
diff --git a/app/build.gradle b/app/build.gradle index 51ac3203..7e4bbd6d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -164,9 +164,6 @@ dependencies { // Loading ProgressBar implementation 'com.lsjwzh:materialloadingprogressbar:0.5.8-RELEASE' - // SearchView - implementation 'com.github.Ferfalk:SimpleSearchView:0.2.0' - // Customizable TextView implementation 'com.libRG:customtextview:2.4' diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java index 26c67ca9..ce1e5f78 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -539,7 +539,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: return R.drawable.ic_post_layout_24dp; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SEARCH: - return R.drawable.ic_search_black_24dp; + return R.drawable.ic_search_24dp; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT: return R.drawable.ic_subreddit_24dp; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_GO_TO_USER: @@ -639,7 +639,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb fab.setImageResource(R.drawable.ic_post_layout_24dp); break; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_SEARCH: - fab.setImageResource(R.drawable.ic_search_black_24dp); + fab.setImageResource(R.drawable.ic_search_24dp); break; case SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT: fab.setImageResource(R.drawable.ic_subreddit_24dp); 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 533fb345..60a2c6e2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -4,12 +4,15 @@ import android.app.Activity; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.drawable.ColorDrawable; import android.os.Bundle; -import android.view.Menu; +import android.text.Editable; +import android.text.TextWatcher; +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.RelativeLayout; import android.widget.TextView; @@ -20,9 +23,6 @@ import androidx.coordinatorlayout.widget.CoordinatorLayout; import androidx.lifecycle.ViewModelProvider; import androidx.recyclerview.widget.RecyclerView; -import com.ferfalk.simplesearchview.SimpleOnQueryTextListener; -import com.ferfalk.simplesearchview.SimpleSearchView; -import com.ferfalk.simplesearchview.SimpleSearchViewListener; import com.google.android.material.appbar.AppBarLayout; import com.r0adkll.slidr.Slidr; @@ -86,8 +86,8 @@ public class SearchActivity extends BaseActivity { AppBarLayout appBarLayout; @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.search_view_search_activity) - SimpleSearchView simpleSearchView; + @BindView(R.id.search_edit_text_search_activity) + EditText searchEditText; @BindView(R.id.subreddit_name_relative_layout_search_activity) RelativeLayout subredditNameRelativeLayout; @BindView(R.id.search_in_text_view_search_activity) @@ -152,18 +152,11 @@ public class SearchActivity extends BaseActivity { searchOnlyUsers = getIntent().getBooleanExtra(EXTRA_SEARCH_ONLY_USERS, false); if (searchOnlySubreddits) { - simpleSearchView.setHint(getText(R.string.search_only_subreddits_hint)); + searchEditText.setHint(getText(R.string.search_only_subreddits_hint)); } else if (searchOnlyUsers) { - simpleSearchView.setHint(getText(R.string.search_only_users_hint)); + searchEditText.setHint(getText(R.string.search_only_users_hint)); } - simpleSearchView.setOnSearchViewListener(new SimpleSearchViewListener() { - @Override - public void onSearchViewClosed() { - finish(); - } - }); - mAccountName = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_NAME, null); mAccessToken = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCESS_TOKEN, null); boolean nsfw = mNsfwAndSpoilerSharedPreferences.getBoolean((mAccountName == null ? "" : mAccountName) + SharedPreferencesUtils.NSFW_BASE, false); @@ -189,21 +182,26 @@ public class SearchActivity extends BaseActivity { finish(); }); - simpleSearchView.setOnQueryTextListener(new SimpleOnQueryTextListener() { + searchEditText.addTextChangedListener(new TextWatcher() { @Override - public boolean onQueryTextSubmit(@NonNull String query) { - search(query); - return true; + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + } @Override - public boolean onQueryTextChange(@NonNull String newText) { - if (!newText.isEmpty()) { + public void afterTextChanged(Editable s) { + if (!s.toString().trim().isEmpty()) { if (subredditAutocompleteCall != null) { subredditAutocompleteCall.cancel(); } + subredditAutocompleteCall = mOauthRetrofit.create(RedditAPI.class).subredditAutocomplete(APIUtils.getOAuthHeader(mAccessToken), - newText, nsfw); + s.toString(), nsfw); subredditAutocompleteCall.enqueue(new Callback<String>() { @Override public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { @@ -228,10 +226,18 @@ public class SearchActivity extends BaseActivity { } }); + } + } + }); + + searchEditText.setOnEditorActionListener((v, actionId, event) -> { + if ((actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN )) { + if (!searchEditText.getText().toString().isEmpty()) { + search(searchEditText.getText().toString()); return true; } - return false; } + return false; }); if (savedInstanceState != null) { @@ -243,11 +249,10 @@ public class SearchActivity extends BaseActivity { } else { subredditNameTextView.setText(subredditName); } - bindView(); } else { query = getIntent().getStringExtra(EXTRA_QUERY); - bindView(); } + bindView(); if (searchOnlySubreddits || searchOnlyUsers) { subredditNameRelativeLayout.setVisibility(View.GONE); @@ -351,12 +356,9 @@ public class SearchActivity extends BaseActivity { protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); - simpleSearchView.setSearchBackground(new ColorDrawable(mCustomThemeWrapper.getColorPrimary())); int toolbarPrimaryTextAndIconColorColor = mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor(); - simpleSearchView.setIconsColor(toolbarPrimaryTextAndIconColorColor); - simpleSearchView.setTextColor(toolbarPrimaryTextAndIconColorColor); - simpleSearchView.setBackIconColor(toolbarPrimaryTextAndIconColorColor); - simpleSearchView.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + searchEditText.setTextColor(toolbarPrimaryTextAndIconColorColor); + searchEditText.setHintTextColor(mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); int colorAccent = mCustomThemeWrapper.getColorAccent(); searchInTextView.setTextColor(colorAccent); subredditNameTextView.setTextColor(mCustomThemeWrapper.getPrimaryTextColor()); @@ -369,11 +371,10 @@ public class SearchActivity extends BaseActivity { @Override protected void onStart() { super.onStart(); - simpleSearchView.showSearch(false); - simpleSearchView.requestFocus(); + searchEditText.requestFocus(); if (query != null) { - simpleSearchView.setQuery(query, false); + searchEditText.setText(query); query = null; } @@ -388,16 +389,12 @@ public class SearchActivity extends BaseActivity { super.onPause(); InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); if (imm != null) { - imm.hideSoftInputFromWindow(simpleSearchView.getWindowToken(), 0); + imm.hideSoftInputFromWindow(searchEditText.getWindowToken(), 0); } } @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { - if (data != null && simpleSearchView.onActivityResult(requestCode, resultCode, data)) { - return; - } - if (resultCode == RESULT_OK && data != null) { if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) { subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME); @@ -441,13 +438,6 @@ public class SearchActivity extends BaseActivity { } @Override - public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.search_activity, menu); - simpleSearchView.setMenuItem(menu.findItem(R.id.action_search_search_activity)); - return true; - } - - @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { finish(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java index ab60515e..2f9c1a9a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java @@ -286,7 +286,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect fab.setImageResource(R.drawable.ic_post_layout_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: - fab.setImageResource(R.drawable.ic_search_black_24dp); + fab.setImageResource(R.drawable.ic_search_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT: fab.setImageResource(R.drawable.ic_subreddit_24dp); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java index 5da073f8..220207a2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewMultiRedditDetailActivity.java @@ -299,7 +299,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT fab.setImageResource(R.drawable.ic_post_layout_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: - fab.setImageResource(R.drawable.ic_search_black_24dp); + fab.setImageResource(R.drawable.ic_search_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT: fab.setImageResource(R.drawable.ic_subreddit_24dp); @@ -525,7 +525,7 @@ public class ViewMultiRedditDetailActivity extends BaseActivity implements SortT case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: return R.drawable.ic_post_layout_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: - return R.drawable.ic_search_black_24dp; + return R.drawable.ic_search_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT: return R.drawable.ic_subreddit_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_USER: diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java index 0f829906..25155685 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -743,7 +743,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: return R.drawable.ic_post_layout_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: - return R.drawable.ic_search_black_24dp; + return R.drawable.ic_search_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT: return R.drawable.ic_subreddit_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_USER: @@ -853,7 +853,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp fab.setImageResource(R.drawable.ic_post_layout_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: - fab.setImageResource(R.drawable.ic_search_black_24dp); + fab.setImageResource(R.drawable.ic_search_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT: fab.setImageResource(R.drawable.ic_subreddit_24dp); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java index d2b636c2..eaa6cc38 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -813,7 +813,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele fab.setImageResource(R.drawable.ic_post_layout_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: - fab.setImageResource(R.drawable.ic_search_black_24dp); + fab.setImageResource(R.drawable.ic_search_24dp); break; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_GO_TO_SUBREDDIT: fab.setImageResource(R.drawable.ic_subreddit_24dp); @@ -1029,7 +1029,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_CHANGE_POST_LAYOUT: return R.drawable.ic_post_layout_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: - return R.drawable.ic_search_black_24dp; + return R.drawable.ic_search_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_SUBREDDIT: return R.drawable.ic_subreddit_24dp; case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_GO_TO_USER: diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java index c21ac456..dd9e07e2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WebViewActivity.java @@ -114,7 +114,7 @@ public class WebViewActivity extends BaseActivity { protected void applyCustomTheme() { coordinatorLayout.setBackgroundColor(mCustomThemeWrapper.getBackgroundColor()); applyAppBarLayoutAndCollapsingToolbarLayoutAndToolbarTheme(appBarLayout, null, toolbar); - Drawable closeIcon = Utils.getTintedDrawable(this, R.drawable.ic_close_black_24dp, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); + Drawable closeIcon = Utils.getTintedDrawable(this, R.drawable.ic_close_24dp, mCustomThemeWrapper.getToolbarPrimaryTextAndIconColor()); toolbar.setNavigationIcon(closeIcon); } diff --git a/app/src/main/res/layout/activity_search.xml b/app/src/main/res/layout/activity_search.xml index 29b5b94f..cb3305fe 100644 --- a/app/src/main/res/layout/activity_search.xml +++ b/app/src/main/res/layout/activity_search.xml @@ -13,32 +13,28 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay"> - <FrameLayout - android:id="@+id/toolbar_frame_layout_search_activity" + <androidx.appcompat.widget.Toolbar + android:id="@+id/toolbar" android:layout_width="match_parent" - android:layout_height="wrap_content"> - - <androidx.appcompat.widget.Toolbar - android:id="@+id/toolbar" - android:layout_width="match_parent" - android:layout_height="wrap_content" - android:minHeight="?attr/actionBarSize" - app:popupTheme="@style/AppTheme.PopupOverlay" /> + android:layout_height="wrap_content" + android:minHeight="?attr/actionBarSize" + app:popupTheme="@style/AppTheme.PopupOverlay" + app:navigationIcon="?attr/homeAsUpIndicator"> - <com.ferfalk.simplesearchview.SimpleSearchView - android:id="@+id/search_view_search_activity" + <EditText + android:id="@+id/search_edit_text_search_activity" android:layout_width="match_parent" android:layout_height="match_parent" - app:backIconAlpha="1" - app:backIconTint="@android:color/white" - app:cursorColor="@android:color/white" - app:hintColor="#E0E0E0" - app:iconsAlpha="1" - app:iconsTint="@android:color/white" - app:searchBackground="?attr/colorPrimary" - app:voiceSearch="true" /> - - </FrameLayout> + android:background="#00000000" + android:gravity="top" + android:hint="@string/search" + android:maxLines="1" + android:textSize="?attr/font_20" + android:fontFamily="?attr/font_family" + android:inputType="textNoSuggestions" + android:imeOptions="actionSearch" /> + + </androidx.appcompat.widget.Toolbar> </com.google.android.material.appbar.AppBarLayout> diff --git a/app/src/main/res/layout/activity_view_post_detail.xml b/app/src/main/res/layout/activity_view_post_detail.xml index 3746f5c6..6fd17685 100644 --- a/app/src/main/res/layout/activity_view_post_detail.xml +++ b/app/src/main/res/layout/activity_view_post_detail.xml @@ -113,7 +113,7 @@ android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:padding="8dp" - android:src="@drawable/ic_close_black_24dp" + android:src="@drawable/ic_close_24dp" android:background="?actionBarItemBackground" android:clickable="true" android:focusable="true" /> diff --git a/app/src/main/res/menu/search_activity.xml b/app/src/main/res/menu/search_activity.xml deleted file mode 100644 index b7abcc32..00000000 --- a/app/src/main/res/menu/search_activity.xml +++ /dev/null @@ -1,12 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<menu xmlns:android="http://schemas.android.com/apk/res/android" - xmlns:app="http://schemas.android.com/apk/res-auto" - xmlns:tools="http://schemas.android.com/tools" - tools:application="ml.docilealligator.infinityforreddit.activities.SearchResultActivity"> - <item - android:id="@+id/action_search_search_activity" - android:orderInCategory="1" - android:title="@string/action_search" - android:icon="@drawable/ic_search_toolbar_24dp" - app:showAsAction="ifRoom" /> -</menu> |