aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java12
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java53
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java29
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java8
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java10
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/InsertRecentSearchQuery.java4
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/RecentSearchQuery.java28
8 files changed, 98 insertions, 50 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
index 3891e495..9a9afc4d 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/RedditDataRoomDatabase.java
@@ -43,7 +43,7 @@ import ml.docilealligator.infinityforreddit.user.UserData;
@Database(entities = {Account.class, SubredditData.class, SubscribedSubredditData.class, UserData.class,
SubscribedUserData.class, MultiReddit.class, CustomTheme.class, RecentSearchQuery.class,
ReadPost.class, PostFilter.class, PostFilterUsage.class, AnonymousMultiredditSubreddit.class,
- CommentFilter.class, CommentFilterUsage.class}, version = 26)
+ CommentFilter.class, CommentFilterUsage.class}, version = 27)
public abstract class RedditDataRoomDatabase extends RoomDatabase {
public static RedditDataRoomDatabase create(final Context context) {
@@ -55,7 +55,7 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
MIGRATION_13_14, MIGRATION_14_15, MIGRATION_15_16, MIGRATION_16_17,
MIGRATION_17_18, MIGRATION_18_19, MIGRATION_19_20, MIGRATION_20_21,
MIGRATION_21_22, MIGRATION_22_23, MIGRATION_23_24, MIGRATION_24_25,
- MIGRATION_25_26)
+ MIGRATION_25_26, MIGRATION_26_27)
.build();
}
@@ -418,4 +418,12 @@ public abstract class RedditDataRoomDatabase extends RoomDatabase {
database.execSQL("ALTER TABLE comment_filter ADD COLUMN display_mode INTEGER DEFAULT 0 NOT NULL");
}
};
+
+ private static final Migration MIGRATION_26_27 = new Migration(26, 27) {
+ @Override
+ public void migrate(@NonNull SupportSQLiteDatabase database) {
+ database.execSQL("ALTER TABLE recent_search_queries ADD COLUMN search_in_subreddit_or_user_name TEXT");
+ database.execSQL("ALTER TABLE recent_search_queries ADD COLUMN search_in_is_user INTEGER DEFAULT 0 NOT NULL");
+ }
+ };
}
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 802152c4..052ec4ab 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java
@@ -60,8 +60,8 @@ import retrofit2.Retrofit;
public class SearchActivity extends BaseActivity {
public static final String EXTRA_QUERY = "EQ";
- public static final String EXTRA_SUBREDDIT_NAME = "ESN";
- public static final String EXTRA_SUBREDDIT_IS_USER = "ESIU";
+ public static final String EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME = "ESISOUN";
+ public static final String EXTRA_SEARCH_IN_SUBREDDIT_IS_USER = "ESISIU";
public static final String EXTRA_SEARCH_ONLY_SUBREDDITS = "ESOS";
public static final String EXTRA_SEARCH_ONLY_USERS = "ESOU";
public static final String EXTRA_RETURN_SUBREDDIT_NAME = "ERSN";
@@ -99,8 +99,8 @@ public class SearchActivity extends BaseActivity {
@Inject
Executor executor;
private String query;
- private String subredditName;
- private boolean subredditIsUser;
+ private String searchInSubredditOrUserName;
+ private boolean searchInIsUser;
private boolean searchOnlySubreddits;
private boolean searchOnlyUsers;
private SearchActivityRecyclerViewAdapter adapter;
@@ -230,7 +230,7 @@ public class SearchActivity extends BaseActivity {
});
binding.searchEditTextSearchActivity.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 ((actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_ACTION_SEARCH) || (event.getKeyCode() == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)) {
if (!binding.searchEditTextSearchActivity.getText().toString().isEmpty()) {
search(binding.searchEditTextSearchActivity.getText().toString());
return true;
@@ -264,13 +264,13 @@ public class SearchActivity extends BaseActivity {
});
if (savedInstanceState != null) {
- subredditName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
- subredditIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
+ searchInSubredditOrUserName = savedInstanceState.getString(SUBREDDIT_NAME_STATE);
+ searchInIsUser = savedInstanceState.getBoolean(SUBREDDIT_IS_USER_STATE);
- if (subredditName == null) {
+ if (searchInSubredditOrUserName == null) {
binding.subredditNameTextViewSearchActivity.setText(R.string.all_subreddits);
} else {
- binding.subredditNameTextViewSearchActivity.setText(subredditName);
+ binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName);
}
} else {
query = getIntent().getStringExtra(EXTRA_QUERY);
@@ -288,10 +288,10 @@ public class SearchActivity extends BaseActivity {
}
Intent intent = getIntent();
- if (intent.hasExtra(EXTRA_SUBREDDIT_NAME)) {
- subredditName = intent.getStringExtra(EXTRA_SUBREDDIT_NAME);
- binding.subredditNameTextViewSearchActivity.setText(subredditName);
- subredditIsUser = intent.getBooleanExtra(EXTRA_SUBREDDIT_IS_USER, false);
+ if (intent.hasExtra(EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME)) {
+ searchInSubredditOrUserName = intent.getStringExtra(EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME);
+ binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName);
+ searchInIsUser = intent.getBooleanExtra(EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, false);
}
}
@@ -299,8 +299,10 @@ public class SearchActivity extends BaseActivity {
if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)) {
adapter = new SearchActivityRecyclerViewAdapter(this, mCustomThemeWrapper, new SearchActivityRecyclerViewAdapter.ItemOnClickListener() {
@Override
- public void onClick(String query) {
- search(query);
+ public void onClick(RecentSearchQuery recentSearchQuery) {
+ searchInSubredditOrUserName = recentSearchQuery.getSearchInSubredditOrUserName();
+ searchInIsUser = recentSearchQuery.isSearchInIsUser();
+ search(recentSearchQuery.getSearchQuery());
}
@Override
@@ -374,12 +376,9 @@ public class SearchActivity extends BaseActivity {
} else {
Intent intent = new Intent(SearchActivity.this, SearchResultActivity.class);
intent.putExtra(SearchResultActivity.EXTRA_QUERY, query);
- if (subredditName != null) {
- if (subredditIsUser) {
- intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, "u_" + subredditName);
- } else {
- intent.putExtra(SearchResultActivity.EXTRA_SUBREDDIT_NAME, subredditName);
- }
+ if (searchInSubredditOrUserName != null) {
+ intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, searchInSubredditOrUserName);
+ intent.putExtra(SearchResultActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, searchInIsUser);
}
startActivity(intent);
finish();
@@ -443,13 +442,13 @@ public class SearchActivity extends BaseActivity {
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (resultCode == RESULT_OK && data != null) {
if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) {
- subredditName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
- subredditIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
+ searchInSubredditOrUserName = data.getStringExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_NAME);
+ searchInIsUser = data.getBooleanExtra(SubredditSelectionActivity.EXTRA_RETURN_SUBREDDIT_IS_USER, false);
- if (subredditName == null) {
+ if (searchInSubredditOrUserName == null) {
binding.subredditNameTextViewSearchActivity.setText(R.string.all_subreddits);
} else {
- binding.subredditNameTextViewSearchActivity.setText(subredditName);
+ binding.subredditNameTextViewSearchActivity.setText(searchInSubredditOrUserName);
}
} else if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) {
Intent returnIntent = new Intent();
@@ -496,8 +495,8 @@ public class SearchActivity extends BaseActivity {
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
- outState.putString(SUBREDDIT_NAME_STATE, subredditName);
- outState.putBoolean(SUBREDDIT_IS_USER_STATE, subredditIsUser);
+ outState.putString(SUBREDDIT_NAME_STATE, searchInSubredditOrUserName);
+ outState.putBoolean(SUBREDDIT_IS_USER_STATE, searchInIsUser);
}
@Override
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 fe7bec33..0ce65f0a 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchResultActivity.java
@@ -83,7 +83,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
static final String EXTRA_QUERY = "EQ";
static final String EXTRA_TRENDING_SOURCE = "ETS";
- static final String EXTRA_SUBREDDIT_NAME = "ESN";
+ static final String EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME = "ESISOUN";
+ public static final String EXTRA_SEARCH_IN_SUBREDDIT_IS_USER = "ESISIU";
private static final String INSERT_SEARCH_QUERY_SUCCESS_STATE = "ISQSS";
@@ -116,7 +117,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
Executor executor;
private Call<String> subredditAutocompleteCall;
private String mQuery;
- private String mSubredditName;
+ private String mSearchInSubredditOrUserName;
+ private boolean mSearchInIsUser;
private boolean mInsertSearchQuerySuccess;
private FragmentManager fragmentManager;
private SectionsPagerAdapter sectionsPagerAdapter;
@@ -173,7 +175,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
Intent intent = getIntent();
String query = intent.getStringExtra(EXTRA_QUERY);
- mSubredditName = intent.getStringExtra(EXTRA_SUBREDDIT_NAME);
+ mSearchInSubredditOrUserName = intent.getStringExtra(EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME);
+ mSearchInIsUser = intent.getBooleanExtra(EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, false);
if (query != null) {
mQuery = query;
@@ -325,8 +328,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
- if (mSubredditName != null && !mSubredditName.equals("")) {
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) {
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, mSearchInIsUser);
}
startActivity(intent);
break;
@@ -372,7 +376,8 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
if (!accountName.equals(Account.ANONYMOUS_ACCOUNT)&& mSharedPreferences.getBoolean(SharedPreferencesUtils.ENABLE_SEARCH_HISTORY, true) && !mInsertSearchQuerySuccess && mQuery != null) {
InsertRecentSearchQuery.insertRecentSearchQueryListener(executor, new Handler(getMainLooper()),
- mRedditDataRoomDatabase, accountName, mQuery, () -> mInsertSearchQuerySuccess = true);
+ mRedditDataRoomDatabase, accountName, mQuery, mSearchInSubredditOrUserName, mSearchInIsUser,
+ () -> mInsertSearchQuerySuccess = true);
}
}
@@ -412,8 +417,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
return true;
} else if (itemId == R.id.action_search_search_result_activity) {
Intent intent = new Intent(this, SearchActivity.class);
- if (mSubredditName != null && !mSubredditName.equals("")) {
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) {
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, mSearchInIsUser);
}
intent.putExtra(SearchActivity.EXTRA_QUERY, mQuery);
finish();
@@ -524,8 +530,9 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
Intent intent = new Intent(this, SearchActivity.class);
- if (mSubredditName != null && !mSubredditName.equals("")) {
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, mSubredditName);
+ if (mSearchInSubredditOrUserName != null && !mSearchInSubredditOrUserName.equals("")) {
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, mSearchInSubredditOrUserName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, mSearchInIsUser);
}
startActivity(intent);
break;
@@ -755,7 +762,7 @@ public class SearchResultActivity extends BaseActivity implements SortTypeSelect
PostFragment mFragment = new PostFragment();
Bundle bundle = new Bundle();
bundle.putInt(PostFragment.EXTRA_POST_TYPE, PostPagingSource.TYPE_SEARCH);
- bundle.putString(PostFragment.EXTRA_NAME, mSubredditName);
+ bundle.putString(PostFragment.EXTRA_NAME, mSearchInIsUser ? "u_" + mSearchInSubredditOrUserName : mSearchInSubredditOrUserName);
bundle.putString(PostFragment.EXTRA_QUERY, mQuery);
bundle.putString(PostFragment.EXTRA_TRENDING_SOURCE, getIntent().getStringExtra(EXTRA_TRENDING_SOURCE));
mFragment.setArguments(bundle);
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 9e8de3df..b0526981 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java
@@ -610,7 +610,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, subredditName);
startActivity(intent);
break;
}
@@ -874,7 +874,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, subredditName);
startActivity(intent);
break;
}
@@ -1087,7 +1087,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
return true;
} else if (itemId == R.id.action_search_view_subreddit_detail_activity) {
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, subredditName);
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_subreddit_detail_activity) {
@@ -1338,7 +1338,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, subredditName);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, subredditName);
startActivity(intent);
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
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 a5905254..bf2cfaf8 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java
@@ -826,6 +826,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_FAB_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, username);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, true);
startActivity(intent);
break;
}
@@ -914,6 +916,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
}
case SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SEARCH: {
Intent intent = new Intent(this, SearchActivity.class);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, username);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, true);
startActivity(intent);
break;
}
@@ -1091,8 +1095,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
return true;
} else if (itemId == R.id.action_search_view_user_detail_activity) {
Intent intent = new Intent(this, SearchActivity.class);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_NAME, username);
- intent.putExtra(SearchActivity.EXTRA_SUBREDDIT_IS_USER, true);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, username);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, true);
startActivity(intent);
return true;
} else if (itemId == R.id.action_refresh_view_user_detail_activity) {
@@ -1277,6 +1281,8 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_SEARCH:
Intent intent = new Intent(this, SearchActivity.class);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_OR_USER_NAME, username);
+ intent.putExtra(SearchActivity.EXTRA_SEARCH_IN_SUBREDDIT_IS_USER, true);
startActivity(intent);
break;
case FABMoreOptionsBottomSheetFragment.FAB_OPTION_GO_TO_SUBREDDIT: {
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 9ba5dc72..058b5a05 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/SearchActivityRecyclerViewAdapter.java
@@ -23,7 +23,7 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
private final ItemOnClickListener itemOnClickListener;
public interface ItemOnClickListener {
- void onClick(String query);
+ void onClick(RecentSearchQuery recentSearchQuery);
void onDelete(RecentSearchQuery recentSearchQuery);
}
@@ -92,7 +92,7 @@ public class SearchActivityRecyclerViewAdapter extends RecyclerView.Adapter<Recy
itemView.setOnClickListener(view -> {
if (recentSearchQueries != null && !recentSearchQueries.isEmpty()) {
- itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()).getSearchQuery());
+ itemOnClickListener.onClick(recentSearchQueries.get(getBindingAdapterPosition()));
}
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/InsertRecentSearchQuery.java b/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/InsertRecentSearchQuery.java
index fba3ef5f..5980128b 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/InsertRecentSearchQuery.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/InsertRecentSearchQuery.java
@@ -16,6 +16,8 @@ public class InsertRecentSearchQuery {
RedditDataRoomDatabase redditDataRoomDatabase,
String username,
String recentSearchQuery,
+ String searchInSubredditOrUserName,
+ boolean searchInIsUser,
InsertRecentSearchQueryListener insertRecentSearchQueryListener) {
executor.execute(() -> {
RecentSearchQueryDao recentSearchQueryDao = redditDataRoomDatabase.recentSearchQueryDao();
@@ -26,7 +28,7 @@ public class InsertRecentSearchQuery {
}
}
- recentSearchQueryDao.insert(new RecentSearchQuery(username, recentSearchQuery));
+ recentSearchQueryDao.insert(new RecentSearchQuery(username, recentSearchQuery, searchInSubredditOrUserName, searchInIsUser));
handler.post(insertRecentSearchQueryListener::success);
});
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/RecentSearchQuery.java b/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/RecentSearchQuery.java
index 5075842c..a951243f 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/RecentSearchQuery.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/recentsearchquery/RecentSearchQuery.java
@@ -1,6 +1,7 @@
package ml.docilealligator.infinityforreddit.recentsearchquery;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
@@ -17,12 +18,20 @@ public class RecentSearchQuery {
@NonNull
@ColumnInfo(name = "search_query")
private String searchQuery;
+ @Nullable
+ @ColumnInfo(name = "search_in_subreddit_or_user_name")
+ private String searchInSubredditOrUserName;
+ @ColumnInfo(name = "search_in_is_user")
+ private boolean searchInIsUser;
@ColumnInfo(name = "time")
private long time;
- public RecentSearchQuery(@NonNull String username, @NonNull String searchQuery) {
+ public RecentSearchQuery(@NonNull String username, @NonNull String searchQuery,
+ @Nullable String searchInSubredditOrUserName, boolean searchInIsUser) {
this.username = username;
this.searchQuery = searchQuery;
+ this.searchInSubredditOrUserName = searchInSubredditOrUserName;
+ this.searchInIsUser = searchInIsUser;
this.time = System.currentTimeMillis();
}
@@ -44,6 +53,23 @@ public class RecentSearchQuery {
this.searchQuery = searchQuery;
}
+ @Nullable
+ public String getSearchInSubredditOrUserName() {
+ return searchInSubredditOrUserName;
+ }
+
+ public void setSearchInSubredditOrUserName(@Nullable String searchInSubredditOrUserName) {
+ this.searchInSubredditOrUserName = searchInSubredditOrUserName;
+ }
+
+ public boolean isSearchInIsUser() {
+ return searchInIsUser;
+ }
+
+ public void setSearchInIsUser(boolean searchInIsUser) {
+ this.searchInIsUser = searchInIsUser;
+ }
+
public long getTime() {
return time;
}