diff options
author | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-09-04 15:35:50 +0000 |
---|---|---|
committer | Docile-Alligator <25734209+Docile-Alligator@users.noreply.github.com> | 2024-09-04 15:35:50 +0000 |
commit | e217d6222eec6b3cb21f99458446e9d6dae96585 (patch) | |
tree | ab482daf923859090faf649614ee265f5b2056e6 /app/src/main/java | |
parent | 2352b0466eef62fcb5d1412d8e725447c08a3a9d (diff) | |
download | infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar.gz infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar.bz2 infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar.lz infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar.xz infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.tar.zst infinity-for-reddit-e217d6222eec6b3cb21f99458446e9d6dae96585.zip |
Use SubscribedThingListingActivity to select subreddits.
Diffstat (limited to '')
10 files changed, 87 insertions, 21 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java index 833c5d27..ec6dfb82 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostGalleryActivity.java @@ -283,8 +283,11 @@ public class PostGalleryActivity extends BaseActivity implements FlairBottomShee }); binding.subredditRelativeLayoutPostGalleryActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java index 052827dd..f781e07f 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostImageActivity.java @@ -244,8 +244,11 @@ public class PostImageActivity extends BaseActivity implements FlairBottomSheetF }); binding.subredditRelativeLayoutPostImageActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java index 0eb9c33e..de85c123 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostLinkActivity.java @@ -237,8 +237,11 @@ public class PostLinkActivity extends BaseActivity implements FlairBottomSheetFr }); binding.subredditRelativeLayoutPostLinkActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java index ca58380e..89c4cfc2 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostPollActivity.java @@ -254,8 +254,11 @@ public class PostPollActivity extends BaseActivity implements FlairBottomSheetFr }); binding.subredditRelativeLayoutPostPollActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java index 7b79066a..8521c97b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostTextActivity.java @@ -249,8 +249,11 @@ public class PostTextActivity extends BaseActivity implements FlairBottomSheetFr }); binding.subredditRelativeLayoutPostTextActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java index b159fa29..97e865a3 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/PostVideoActivity.java @@ -267,8 +267,11 @@ public class PostVideoActivity extends BaseActivity implements FlairBottomSheetF }); binding.subredditRelativeLayoutPostVideoActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); 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 9f726e05..3073979e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SearchActivity.java @@ -339,6 +339,7 @@ public class SearchActivity extends BaseActivity { binding.subredditNameRelativeLayoutSearchActivity.setOnClickListener(view -> { Intent intent = new Intent(this, SubscribedThingListingActivity.class); intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_EXTRA_CLEAR_SELECTION, true); requestThingSelectionForCurrentActivityLauncher.launch(intent); }); } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java index d146a88c..956f8d05 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubmitCrosspostActivity.java @@ -269,8 +269,11 @@ public class SubmitCrosspostActivity extends BaseActivity implements FlairBottom }); binding.subredditNameTextViewSubmitCrosspostActivity.setOnClickListener(view -> { - Intent intent = new Intent(this, SubredditSelectionActivity.class); - intent.putExtra(SubredditSelectionActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + Intent intent = new Intent(this, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_SPECIFIED_ACCOUNT, selectedAccount); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, SUBREDDIT_SELECTION_REQUEST_CODE); }); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java index a00aa2b1..c220195e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/SubscribedThingListingActivity.java @@ -36,11 +36,13 @@ import org.greenrobot.eventbus.Subscribe; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Executor; +import java.util.concurrent.TimeUnit; import javax.inject.Inject; import javax.inject.Named; import ml.docilealligator.infinityforreddit.ActivityToolbarInterface; +import ml.docilealligator.infinityforreddit.AnyAccountAccessTokenAuthenticator; import ml.docilealligator.infinityforreddit.FetchSubscribedThing; import ml.docilealligator.infinityforreddit.FragmentCommunicator; import ml.docilealligator.infinityforreddit.Infinity; @@ -67,6 +69,8 @@ import ml.docilealligator.infinityforreddit.subscribedsubreddit.SubscribedSubred import ml.docilealligator.infinityforreddit.subscribeduser.SubscribedUserData; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; import ml.docilealligator.infinityforreddit.utils.Utils; +import okhttp3.ConnectionPool; +import okhttp3.OkHttpClient; import retrofit2.Retrofit; public class SubscribedThingListingActivity extends BaseActivity implements ActivityToolbarInterface { @@ -74,6 +78,8 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti public static final String EXTRA_SHOW_MULTIREDDITS = "ESM"; public static final String EXTRA_THING_SELECTION_MODE = "ETSM"; public static final String EXTRA_THING_SELECTION_TYPE = "ETST"; + public static final String EXTRA_SPECIFIED_ACCOUNT = "ESA"; + public static final String EXTRA_EXTRA_CLEAR_SELECTION = "EECS"; public static final int EXTRA_THING_SELECTION_TYPE_ALL = 0; public static final int EXTRA_THING_SELECTION_TYPE_SUBREDDIT = 1; public static final int EXTRA_THING_SELECTION_TYPE_USER = 2; @@ -81,6 +87,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti private static final String INSERT_MULTIREDDIT_STATE = "IMS"; @Inject + @Named("no_oauth") + Retrofit mRetrofit; + @Inject @Named("oauth") Retrofit mOauthRetrofit; @Inject @@ -100,6 +109,7 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti private boolean showMultiReddits; private boolean isThingSelectionMode; private int thingSelectionType; + private String mAccountProfileImageUrl; private SectionsPagerAdapter sectionsPagerAdapter; private Menu mMenu; private ActivityResultLauncher<Intent> requestSearchThingLauncher; @@ -150,6 +160,27 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti getSupportActionBar().setDisplayHomeAsUpEnabled(true); setToolbarGoToTop(binding.toolbarSubscribedThingListingActivity); + if (getIntent().hasExtra(EXTRA_SPECIFIED_ACCOUNT)) { + Account specifiedAccount = getIntent().getParcelableExtra(EXTRA_SPECIFIED_ACCOUNT); + if (specifiedAccount != null) { + accessToken = specifiedAccount.getAccessToken(); + accountName = specifiedAccount.getAccountName(); + mAccountProfileImageUrl = specifiedAccount.getProfileImageUrl(); + + mOauthRetrofit = mOauthRetrofit.newBuilder().client(new OkHttpClient.Builder().authenticator(new AnyAccountAccessTokenAuthenticator(mRetrofit, mRedditDataRoomDatabase, specifiedAccount, mCurrentAccountSharedPreferences)) + .connectTimeout(30, TimeUnit.SECONDS) + .readTimeout(30, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .connectionPool(new ConnectionPool(0, 1, TimeUnit.NANOSECONDS)) + .build()) + .build(); + } else { + mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null); + } + } else { + mAccountProfileImageUrl = mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null); + } + if (savedInstanceState != null) { mInsertSuccess = savedInstanceState.getBoolean(INSERT_SUBSCRIBED_SUBREDDIT_STATE); mInsertMultiredditSuccess = savedInstanceState.getBoolean(INSERT_MULTIREDDIT_STATE); @@ -160,6 +191,10 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti isThingSelectionMode = getIntent().getBooleanExtra(EXTRA_THING_SELECTION_MODE, false); thingSelectionType = getIntent().getIntExtra(EXTRA_THING_SELECTION_TYPE, EXTRA_THING_SELECTION_TYPE_ALL); + if (isThingSelectionMode && thingSelectionType != EXTRA_THING_SELECTION_TYPE_ALL) { + binding.tabLayoutSubscribedThingListingActivity.setVisibility(View.GONE); + } + if (accountName.equals(Account.ANONYMOUS_ACCOUNT) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { binding.searchEditTextSubscribedThingListingActivity.setImeOptions(binding.searchEditTextSubscribedThingListingActivity.getImeOptions() | EditorInfoCompat.IME_FLAG_NO_PERSONALIZED_LEARNING); } @@ -515,9 +550,9 @@ public class SubscribedThingListingActivity extends BaseActivity implements Acti SubscribedSubredditsListingFragment fragment = new SubscribedSubredditsListingFragment(); Bundle bundle = new Bundle(); bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_IS_SUBREDDIT_SELECTION, isThingSelectionMode); - bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION, isThingSelectionMode); - bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, - mCurrentAccountSharedPreferences.getString(SharedPreferencesUtils.ACCOUNT_IMAGE_URL, null)); + bundle.putBoolean(SubscribedSubredditsListingFragment.EXTRA_EXTRA_CLEAR_SELECTION, + isThingSelectionMode && getIntent().getBooleanExtra(EXTRA_EXTRA_CLEAR_SELECTION, false)); + bundle.putString(SubscribedSubredditsListingFragment.EXTRA_ACCOUNT_PROFILE_IMAGE_URL, mAccountProfileImageUrl); fragment.setArguments(bundle); return fragment; } 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 f114eb84..b3753dcf 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/CustomizeMainPageTabsFragment.java @@ -30,7 +30,7 @@ import ml.docilealligator.infinityforreddit.account.Account; import ml.docilealligator.infinityforreddit.activities.MultiredditSelectionActivity; import ml.docilealligator.infinityforreddit.activities.SearchActivity; import ml.docilealligator.infinityforreddit.activities.SettingsActivity; -import ml.docilealligator.infinityforreddit.activities.SubredditSelectionActivity; +import ml.docilealligator.infinityforreddit.activities.SubscribedThingListingActivity; import ml.docilealligator.infinityforreddit.databinding.FragmentCustomizeMainPageTabsBinding; import ml.docilealligator.infinityforreddit.multireddit.MultiReddit; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; @@ -502,7 +502,10 @@ public class CustomizeMainPageTabsFragment extends Fragment { case 0: switch (tab1CurrentPostType) { case 3: { - Intent intent = new Intent(activity, SubredditSelectionActivity.class); + Intent intent = new Intent(activity, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, tab); break; } @@ -522,7 +525,10 @@ public class CustomizeMainPageTabsFragment extends Fragment { case 1: switch (tab2CurrentPostType) { case 3: { - Intent intent = new Intent(activity, SubredditSelectionActivity.class); + Intent intent = new Intent(activity, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, tab); break; } @@ -542,7 +548,10 @@ public class CustomizeMainPageTabsFragment extends Fragment { case 2: switch (tab3CurrentPostType) { case 3: { - Intent intent = new Intent(activity, SubredditSelectionActivity.class); + Intent intent = new Intent(activity, SubscribedThingListingActivity.class); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_MODE, true); + intent.putExtra(SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE, + SubscribedThingListingActivity.EXTRA_THING_SELECTION_TYPE_SUBREDDIT); startActivityForResult(intent, tab); break; } |