diff options
4 files changed, 13 insertions, 19 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java index fd937ab2..ffb1b44a 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/InboxActivity.java @@ -39,6 +39,7 @@ import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.RecyclerViewContentScrollingInterface; import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase; +import ml.docilealligator.infinityforreddit.SelectThingReturnKey; import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.apis.RedditAPI; import ml.docilealligator.infinityforreddit.asynctasks.AccountManagement; @@ -321,7 +322,7 @@ public class InboxActivity extends BaseActivity implements ActivityToolbarInterf protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && requestCode == SEARCH_USER_REQUEST_CODE && data != null) { - String username = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + String username = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); Intent intent = new Intent(this, SendPrivateMessageActivity.class); intent.putExtra(SendPrivateMessageActivity.EXTRA_RECIPIENT_USERNAME, username); startActivity(intent); 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 5499f2a8..9f726e05 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -74,8 +74,6 @@ public class SearchActivity extends BaseActivity { public static final String EXTRA_SEARCH_SUBREDDITS_AND_USERS = "ESSAU"; public static final String RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES = "RESSN"; public static final String RETURN_EXTRA_SELECTED_USERNAMES = "RESU"; - public static final String EXTRA_RETURN_USER_NAME = "ERUN"; - public static final String EXTRA_RETURN_USER_ICON_URL = "ERUIU"; public static final String EXTRA_IS_MULTI_SELECTION = "EIMS"; public static final int SUICIDE_PREVENTION_ACTIVITY_REQUEST_CODE = 101; @@ -83,7 +81,6 @@ public class SearchActivity extends BaseActivity { private static final String SEARCH_IN_THING_TYPE_STATE = "SITTS"; private static final String SEARCH_IN_MULTIREDDIT_STATE = "SIMS"; - private static final int SUBREDDIT_SELECTION_REQUEST_CODE = 0; private static final int SUBREDDIT_SEARCH_REQUEST_CODE = 1; private static final int USER_SEARCH_REQUEST_CODE = 2; @@ -325,8 +322,8 @@ public class SearchActivity extends BaseActivity { } searchInSubredditOrUserName = returnIntent.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); - searchInThingType = returnIntent.getIntExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); searchInMultiReddit = returnIntent.getParcelableExtra(SelectThingReturnKey.RETRUN_EXTRA_MULTIREDDIT); + searchInThingType = returnIntent.getIntExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); setSearchInThingText(); }); @@ -530,18 +527,14 @@ public class SearchActivity extends BaseActivity { @Override protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { if (resultCode == RESULT_OK && data != null) { - if (requestCode == SUBREDDIT_SELECTION_REQUEST_CODE) { - searchInSubredditOrUserName = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); - searchInThingType = data.getIntExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); - - setSearchInThingText(); - } else if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) { + if (requestCode == SUBREDDIT_SEARCH_REQUEST_CODE) { Intent returnIntent = new Intent(); if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) { returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES, data.getStringArrayListExtra(SearchSubredditsResultActivity.RETURN_EXTRA_SELECTED_SUBREDDIT_NAMES)); } else { returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME, data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME)); returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_ICON, data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_ICON)); + returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.SUBREDDIT); } setResult(Activity.RESULT_OK, returnIntent); finish(); @@ -550,10 +543,9 @@ public class SearchActivity extends BaseActivity { if (getIntent().getBooleanExtra(EXTRA_IS_MULTI_SELECTION, false)) { returnIntent.putStringArrayListExtra(RETURN_EXTRA_SELECTED_USERNAMES, data.getStringArrayListExtra(SearchUsersResultActivity.RETURN_EXTRA_SELECTED_USERNAMES)); } else { - String username = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); - String iconUrl = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_ICON); - returnIntent.putExtra(EXTRA_RETURN_USER_NAME, username); - returnIntent.putExtra(EXTRA_RETURN_USER_ICON_URL, iconUrl); + returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME, data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME)); + returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_ICON, data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_ICON)); + returnIntent.putExtra(SelectThingReturnKey.RETURN_EXTRA_THING_TYPE, SelectThingReturnKey.THING_TYPE.USER); } setResult(Activity.RESULT_OK, returnIntent); finish(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java index 98009c46..65cfa242 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SelectedSubredditsAndUsersActivity.java @@ -20,6 +20,7 @@ import javax.inject.Named; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; +import ml.docilealligator.infinityforreddit.SelectThingReturnKey; import ml.docilealligator.infinityforreddit.adapters.SelectedSubredditsRecyclerViewAdapter; import ml.docilealligator.infinityforreddit.bottomsheetfragments.SelectSubredditsOrUsersOptionsBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; @@ -151,7 +152,7 @@ public class SelectedSubredditsAndUsersActivity extends BaseActivity implements if (subreddits == null) { subreddits = new ArrayList<>(); } - adapter.addUserInSubredditType("u_" + data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME)); + adapter.addUserInSubredditType("u_" + data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME)); } } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java index ca0bdfdb..f114eb84 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java @@ -581,7 +581,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); } } else if (thingType == SelectThingReturnKey.THING_TYPE.USER) { - tab1CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab1CurrentName = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); binding.tab1NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab1CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_1_NAME, tab1CurrentName).apply(); } @@ -599,7 +599,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); } } else if (thingType == SelectThingReturnKey.THING_TYPE.USER) { - tab2CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab2CurrentName = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); binding.tab2NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab2CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_2_NAME, tab2CurrentName).apply(); } @@ -617,7 +617,7 @@ public class CustomizeMainPageTabsFragment extends Fragment { mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); } } else if (thingType == SelectThingReturnKey.THING_TYPE.USER) { - tab3CurrentName = data.getStringExtra(SearchActivity.EXTRA_RETURN_USER_NAME); + tab3CurrentName = data.getStringExtra(SelectThingReturnKey.RETURN_EXTRA_SUBREDDIT_OR_USER_NAME); binding.tab3NameSummaryTextViewCustomizeMainPageTabsFragment.setText(tab3CurrentName); mainActivityTabsSharedPreferences.edit().putString((activity.accountName.equals(Account.ANONYMOUS_ACCOUNT) ? "" : activity.accountName) + SharedPreferencesUtils.MAIN_PAGE_TAB_3_NAME, tab3CurrentName).apply(); } |