aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java
diff options
context:
space:
mode:
authorDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-06-20 22:41:27 +0000
committerDocile-Alligator <25734209+Docile-Alligator@users.noreply.github.com>2023-06-20 22:41:27 +0000
commit6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2 (patch)
tree75a614aa87dac24a58d0c9a2ec5a63f8458ce211 /app/src/main/java
parent2ae64f684919e87a3fa0feca736a2558124b34ea (diff)
downloadinfinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar.gz
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar.bz2
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar.lz
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar.xz
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.tar.zst
infinity-for-reddit-6eb7f8e5c8999c2ff3b6050748f838f16c2a65f2.zip
Showing info related to the Reddit API changes
Diffstat (limited to '')
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java16
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RedditAPIInfoBottomSheetFragment.java71
-rw-r--r--app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java1
3 files changed, 84 insertions, 4 deletions
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 5b4f1ff5..1be2d576 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java
@@ -14,7 +14,6 @@ import android.os.Bundle;
import android.os.Handler;
import android.text.Editable;
import android.text.TextWatcher;
-import android.util.Log;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.Menu;
@@ -34,9 +33,6 @@ import androidx.appcompat.app.AppCompatDelegate;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
-import androidx.core.view.OnApplyWindowInsetsListener;
-import androidx.core.view.ViewCompat;
-import androidx.core.view.WindowInsetsCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
@@ -95,6 +91,7 @@ import ml.docilealligator.infinityforreddit.bottomsheetfragments.FABMoreOptionsB
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostLayoutBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.PostTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.RandomBottomSheetFragment;
+import ml.docilealligator.infinityforreddit.bottomsheetfragments.RedditAPIInfoBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTimeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.bottomsheetfragments.SortTypeBottomSheetFragment;
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
@@ -338,6 +335,13 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
mMessageFullname = getIntent().getStringExtra(EXTRA_MESSSAGE_FULLNAME);
mNewAccountName = getIntent().getStringExtra(EXTRA_NEW_ACCOUNT_NAME);
}
+
+ if (!mInternalSharedPreferences.getBoolean(SharedPreferencesUtils.DO_NOT_SHOW_REDDIT_API_INFO_AGAIN, false)) {
+ RedditAPIInfoBottomSheetFragment fragment = new RedditAPIInfoBottomSheetFragment();
+ fragment.setCancelable(false);
+ fragment.show(getSupportFragmentManager(), fragment.getTag());
+ }
+
initializeNotificationAndBindView();
}
@@ -1530,6 +1534,10 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
InsertReadPost.insertReadPost(mRedditDataRoomDatabase, mExecutor, mAccountName, post.getId());
}
+ public void doNotShowRedditAPIInfoAgain() {
+ mInternalSharedPreferences.edit().putBoolean(SharedPreferencesUtils.DO_NOT_SHOW_REDDIT_API_INFO_AGAIN, true).apply();
+ }
+
private class SectionsPagerAdapter extends FragmentStateAdapter {
int tabCount;
boolean showFavoriteMultiReddits;
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RedditAPIInfoBottomSheetFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RedditAPIInfoBottomSheetFragment.java
new file mode 100644
index 00000000..188e6a29
--- /dev/null
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/bottomsheetfragments/RedditAPIInfoBottomSheetFragment.java
@@ -0,0 +1,71 @@
+package ml.docilealligator.infinityforreddit.bottomsheetfragments;
+
+import android.content.Context;
+import android.content.Intent;
+import android.net.Uri;
+import android.os.Bundle;
+import android.text.SpannableString;
+import android.text.util.Linkify;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+
+import me.saket.bettermovementmethod.BetterLinkMovementMethod;
+import ml.docilealligator.infinityforreddit.R;
+import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
+import ml.docilealligator.infinityforreddit.activities.MainActivity;
+import ml.docilealligator.infinityforreddit.customviews.LandscapeExpandedRoundedBottomSheetDialogFragment;
+import ml.docilealligator.infinityforreddit.databinding.FragmentRedditApiInfoBottomSheetBinding;
+import ml.docilealligator.infinityforreddit.utils.Utils;
+
+public class RedditAPIInfoBottomSheetFragment extends LandscapeExpandedRoundedBottomSheetDialogFragment {
+
+ private MainActivity mainActivity;
+
+ public RedditAPIInfoBottomSheetFragment() {
+ // Required empty public constructor
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ // Inflate the layout for this fragment
+ FragmentRedditApiInfoBottomSheetBinding binding = FragmentRedditApiInfoBottomSheetBinding.inflate(inflater, container, false);
+
+ if (mainActivity != null && mainActivity.typeface != null) {
+ Utils.setFontToAllTextViews(binding.getRoot(), mainActivity.typeface);
+ }
+
+ SpannableString message = new SpannableString(getString(R.string.reddit_api_info, "https://www.reddit.com/r/reddit/comments/145bram/addressing_the_community_about_changes_to_our_api", "https://www.reddit.com/r/Infinity_For_Reddit/comments/147bhsg/the_future_of_infinity"));
+ Linkify.addLinks(message, Linkify.WEB_URLS);
+ binding.messageTextViewRedditApiInfoBottomSheetFragment.setText(message);
+ binding.messageTextViewRedditApiInfoBottomSheetFragment.setMovementMethod(BetterLinkMovementMethod.newInstance().setOnLinkClickListener((textView, url) -> {
+ Intent intent = new Intent(mainActivity, LinkResolverActivity.class);
+ intent.setData(Uri.parse(url));
+ startActivity(intent);
+ return true;
+ }));
+ binding.messageTextViewRedditApiInfoBottomSheetFragment.setLinkTextColor(getResources().getColor(R.color.colorAccent));
+
+ binding.doNotShowThisAgainTextView.setOnClickListener(view -> {
+ binding.doNotShowThisAgainCheckBox.toggle();
+ });
+
+ binding.continueButtonRedditApiInfoBottomSheetFragment.setOnClickListener(view -> {
+ if (binding.doNotShowThisAgainCheckBox.isChecked()) {
+ mainActivity.doNotShowRedditAPIInfoAgain();
+ }
+ dismiss();
+ });
+
+ return binding.getRoot();
+ }
+
+ @Override
+ public void onAttach(@NonNull Context context) {
+ super.onAttach(context);
+ mainActivity = (MainActivity) context;
+ }
+} \ No newline at end of file
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
index dc97ea85..1e328a49 100644
--- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
+++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java
@@ -368,6 +368,7 @@ public class SharedPreferencesUtils {
public static final String INTERNAL_SHARED_PREFERENCES_FILE = "ml.docilealligator.infinityforreddit.internal";
public static final String HAS_REQUESTED_NOTIFICATION_PERMISSION = "has_requested_notification_permission";
+ public static final String DO_NOT_SHOW_REDDIT_API_INFO_AGAIN = "do_not_show_reddit_api_info_again";
//Legacy Settings
public static final String MAIN_PAGE_TAB_1_TITLE_LEGACY = "main_page_tab_1_title";