From 43b9abd6ee455158553fbbc70df3c27eedd22b21 Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Sun, 10 Oct 2021 21:51:10 +0800 Subject: New option: Link Handler. Removed option: Open Link In App. --- .../infinityforreddit/activities/LinkResolverActivity.java | 7 +++++-- .../infinityforreddit/settings/AdvancedPreferenceFragment.java | 8 +++++--- .../infinityforreddit/utils/SharedPreferencesUtils.java | 3 ++- 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java index 3db1af77..2c337c63 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/LinkResolverActivity.java @@ -298,10 +298,13 @@ public class LinkResolverActivity extends AppCompatActivity { return; } - if (mSharedPreferences.getBoolean(SharedPreferencesUtils.OPEN_LINK_IN_APP, false)) { + int linkHandler = Integer.parseInt(mSharedPreferences.getString(SharedPreferencesUtils.LINK_HANDLER, "0")); + if (linkHandler == 0) { + openInBrowser(uri, pm, true); + } else if (linkHandler == 1) { openInCustomTabs(uri, pm, true); } else { - openInBrowser(uri, pm, true); + openInWebView(uri); } } diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java index f133863d..45661b85 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/settings/AdvancedPreferenceFragment.java @@ -1,5 +1,8 @@ package ml.docilealligator.infinityforreddit.settings; +import static android.app.Activity.RESULT_OK; +import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE; + import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -39,9 +42,6 @@ import ml.docilealligator.infinityforreddit.asynctasks.RestoreSettings; import ml.docilealligator.infinityforreddit.events.RecreateActivityEvent; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; -import static android.app.Activity.RESULT_OK; -import static android.content.Intent.ACTION_OPEN_DOCUMENT_TREE; - /** * A simple {@link Fragment} subclass. */ @@ -230,6 +230,8 @@ public class AdvancedPreferenceFragment extends PreferenceFragmentCompat { editor.remove(SharedPreferencesUtils.NSFW_KEY_LEGACY); editor.remove(SharedPreferencesUtils.BLUR_NSFW_KEY_LEGACY); editor.remove(SharedPreferencesUtils.BLUR_SPOILER_KEY_LEGACY); + editor.remove(SharedPreferencesUtils.CONFIRM_TO_EXIT_LEGACY); + editor.remove(SharedPreferencesUtils.OPEN_LINK_IN_APP_LEGACY); SharedPreferences.Editor sortTypeEditor = mSortTypeSharedPreferences.edit(); sortTypeEditor.remove(SharedPreferencesUtils.SORT_TYPE_ALL_POST_LEGACY); 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 9e3f8c69..6235c3c6 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/utils/SharedPreferencesUtils.java @@ -93,7 +93,7 @@ public class SharedPreferencesUtils { public static final String VOLUME_KEYS_NAVIGATE_COMMENTS = "volume_keys_navigate_comments"; public static final String VOLUME_KEYS_NAVIGATE_POSTS = "volume_keys_navigate_posts"; public static final String MUTE_VIDEO = "mute_video"; - public static final String OPEN_LINK_IN_APP = "open_link_in_app"; + public static final String LINK_HANDLER = "link_handler"; public static final String VIDEO_AUTOPLAY = "video_autoplay"; public static final String VIDEO_AUTOPLAY_VALUE_ALWAYS_ON = "2"; public static final String VIDEO_AUTOPLAY_VALUE_ON_WIFI = "1"; @@ -363,4 +363,5 @@ public class SharedPreferencesUtils { public static final String BLUR_NSFW_KEY_LEGACY = "blur_nsfw"; public static final String BLUR_SPOILER_KEY_LEGACY = "blur_spoiler"; public static final String CONFIRM_TO_EXIT_LEGACY = "confirm_to_exit"; + public static final String OPEN_LINK_IN_APP_LEGACY = "open_link_in_app"; } -- cgit v1.2.3