diff options
Diffstat (limited to 'app/src')
8 files changed, 50 insertions, 46 deletions
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 6852e8a5..8112918d 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -34,7 +34,8 @@ android:theme="@style/AppTheme" android:usesCleartextTraffic="true" tools:replace="android:label"> - <activity android:name=".activities.EditProfileActivity" + <activity + android:name=".activities.EditProfileActivity" android:label="@string/edit_profile_activity_label" android:parentActivityName=".activities.MainActivity" android:theme="@style/AppTheme.Slidable" @@ -209,7 +210,8 @@ android:label="@string/account_saved_thing_activity_label" android:parentActivityName=".activities.MainActivity" android:theme="@style/AppTheme.Slidable" /> - <activity android:name=".activities.ShareDataResolverActivity" + <activity + android:name=".activities.ShareDataResolverActivity" android:exported="false"> <intent-filter> <action android:name="android.intent.action.SEND" /> @@ -268,39 +270,41 @@ android:label="@string/search_subreddits_activity_label" android:parentActivityName=".activities.MainActivity" android:theme="@style/AppTheme.Slidable" /> - <activity android:name=".activities.LinkResolverActivity" + <activity + android:name=".activities.LinkResolverActivity" android:exported="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> + <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> - <data android:scheme="https"/> - <data android:scheme="http"/> - - <data android:host="www.reddit.com"/> - <data android:host="reddit.com"/> - <data android:host="v.redd.it"/> - <data android:host="amp.reddit.com"/> - <data android:host="m.reddit.com"/> - <data android:host="old.reddit.com"/> - <data android:host="new.reddit.com"/> - <data android:host="np.reddit.com"/> - <data android:host="reddit.app.link"/> - <data android:host="redd.it"/> - <data android:host="s.reddit.com"/> - <data android:host="click.redditmail.com"/> + <data android:scheme="https" /> + <data android:scheme="http" /> + <data android:host="www.reddit.com" /> + <data android:host="reddit.com" /> + <data android:host="v.redd.it" /> + <data android:host="amp.reddit.com" /> + <data android:host="m.reddit.com" /> + <data android:host="old.reddit.com" /> + <data android:host="new.reddit.com" /> + <data android:host="np.reddit.com" /> + <data android:host="reddit.app.link" /> + <data android:host="redd.it" /> + <data android:host="s.reddit.com" /> + <data android:host="click.redditmail.com" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.VIEW" /> + <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> + <data android:host="www.google.com" - android:scheme="https" - android:pathPattern="/amp/s/amp.reddit.com/.*" /> + android:pathPattern="/amp/s/amp.reddit.com/.*" + android:scheme="https" /> </intent-filter> - </activity> <activity android:name=".activities.SearchActivity" @@ -360,10 +364,10 @@ android:theme="@style/AppTheme.Slidable" /> <activity android:name=".activities.MainActivity" + android:exported="true" android:label="@string/application_name" android:theme="@style/AppTheme.Launcher" - android:windowSoftInputMode="adjustPan" - android:exported="true"> + android:windowSoftInputMode="adjustPan"> <intent-filter> <action android:name="android.intent.action.MAIN" /> 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 990fbe83..11a9dc13 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/MainActivity.java @@ -138,8 +138,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb private static final String FETCH_USER_INFO_STATE = "FUIS"; private static final String FETCH_SUBSCRIPTIONS_STATE = "FSS"; private static final String DRAWER_ON_ACCOUNT_SWITCH_STATE = "DOASS"; - private static final String ACCESS_TOKEN_STATE = "ATS"; - private static final String ACCOUNT_NAME_STATE = "ANS"; private static final String MESSAGE_FULLNAME_STATE = "MFS"; private static final String NEW_ACCOUNT_NAME_STATE = "NANS"; private static final String INBOX_COUNT_STATE = "ICS"; @@ -574,7 +572,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb } if (showBottomAppBar) { - int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4); + int optionCount = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_COUNT, 4); int option1 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS); int option2 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.MAIN_ACTIVITY_BOTTOM_APP_BAR_OPTION_MULTIREDDITS); @@ -1117,8 +1115,6 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb outState.putBoolean(FETCH_USER_INFO_STATE, mFetchUserInfoSuccess); outState.putBoolean(FETCH_SUBSCRIPTIONS_STATE, mFetchSubscriptionsSuccess); outState.putBoolean(DRAWER_ON_ACCOUNT_SWITCH_STATE, mDrawerOnAccountSwitch); - outState.putString(ACCESS_TOKEN_STATE, mAccessToken); - outState.putString(ACCOUNT_NAME_STATE, mAccountName); outState.putString(MESSAGE_FULLNAME_STATE, mMessageFullname); outState.putString(NEW_ACCOUNT_NAME_STATE, mNewAccountName); outState.putInt(INBOX_COUNT_STATE, inboxCount); 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 b81c06fe..1ce4a44e 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewSubredditDetailActivity.java @@ -404,7 +404,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp builder.linkColor(mCustomThemeWrapper.getLinkColor()); } }) - .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, descriptionTextView).setOnLinkLongClickListener((textView, url) -> { + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url); @@ -777,7 +777,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp } if (showBottomAppBar) { - int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); + int optionCount = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); int option1 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME); int option2 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS); 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 16ec23b9..583be59d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewUserDetailActivity.java @@ -400,7 +400,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele builder.linkColor(mCustomThemeWrapper.getLinkColor()); } }) - .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, descriptionTextView).setOnLinkLongClickListener((textView, url) -> { + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url); @@ -728,7 +728,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele } if (showBottomAppBar) { - int optionCount = mBottomAppBarSharedPreference.getInt(SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); + int optionCount = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_COUNT, 4); int option1 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_1, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_HOME); int option2 = mBottomAppBarSharedPreference.getInt((mAccessToken == null ? "-" : "") + SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_2, SharedPreferencesUtils.OTHER_ACTIVITIES_BOTTOM_APP_BAR_OPTION_SUBSCRIPTIONS); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java index 4568cfe5..755a1c7b 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/WikiActivity.java @@ -2,14 +2,10 @@ package ml.docilealligator.infinityforreddit.activities; import android.content.Intent; import android.content.SharedPreferences; -import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Bundle; -import android.text.SpannableStringBuilder; import android.text.Spanned; -import android.text.TextPaint; -import android.text.style.ClickableSpan; import android.text.util.Linkify; import android.view.MenuItem; import android.view.View; @@ -38,9 +34,6 @@ import org.greenrobot.eventbus.Subscribe; import org.json.JSONException; import org.json.JSONObject; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - import javax.inject.Inject; import javax.inject.Named; @@ -57,21 +50,23 @@ import io.noties.markwon.inlineparser.BangInlineProcessor; import io.noties.markwon.inlineparser.HtmlInlineProcessor; import io.noties.markwon.inlineparser.MarkwonInlineParserPlugin; import io.noties.markwon.linkify.LinkifyPlugin; +import io.noties.markwon.movement.MovementMethodPlugin; import io.noties.markwon.recycler.MarkwonAdapter; import io.noties.markwon.recycler.table.TableEntry; import io.noties.markwon.recycler.table.TableEntryPlugin; +import me.saket.bettermovementmethod.BetterLinkMovementMethod; import ml.docilealligator.infinityforreddit.Infinity; import ml.docilealligator.infinityforreddit.R; import ml.docilealligator.infinityforreddit.apis.RedditAPI; +import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment; import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper; import ml.docilealligator.infinityforreddit.customviews.LinearLayoutManagerBugFixed; import ml.docilealligator.infinityforreddit.customviews.MarkwonLinearLayoutManager; import ml.docilealligator.infinityforreddit.events.SwitchAccountEvent; import ml.docilealligator.infinityforreddit.markdown.SpoilerParserPlugin; -import ml.docilealligator.infinityforreddit.markdown.SpoilerSpan; +import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor; import ml.docilealligator.infinityforreddit.utils.JSONUtils; import ml.docilealligator.infinityforreddit.utils.SharedPreferencesUtils; -import ml.docilealligator.infinityforreddit.markdown.SuperscriptInlineProcessor; import ml.docilealligator.infinityforreddit.utils.Utils; import retrofit2.Call; import retrofit2.Callback; @@ -204,6 +199,14 @@ public class WikiActivity extends BaseActivity { }) .usePlugin(SpoilerParserPlugin.create(markdownColor, spoilerBackgroundColor)) .usePlugin(StrikethroughPlugin.create()) + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { + UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); + Bundle bundle = new Bundle(); + bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url); + urlMenuBottomSheetFragment.setArguments(bundle); + urlMenuBottomSheetFragment.show(getSupportFragmentManager(), urlMenuBottomSheetFragment.getTag()); + return true; + }))) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) .usePlugin(TableEntryPlugin.create(this)) .build(); @@ -259,8 +262,9 @@ public class WikiActivity extends BaseActivity { public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) { if (response.isSuccessful()) { try { - markwonAdapter.setMarkdown(markwon, new JSONObject(response.body()) - .getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.CONTENT_MD_KEY)); + String markdown = new JSONObject(response.body()) + .getJSONObject(JSONUtils.DATA_KEY).getString(JSONUtils.CONTENT_MD_KEY); + markwonAdapter.setMarkdown(markwon, Utils.modifyMarkdown(markdown)); markwonAdapter.notifyDataSetChanged(); } catch (JSONException e) { e.printStackTrace(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java index 17bd2e8a..97ea961d 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/PostDetailRecyclerViewAdapter.java @@ -282,7 +282,7 @@ public class PostDetailRecyclerViewAdapter extends RecyclerView.Adapter<Recycler }) .usePlugin(SpoilerParserPlugin.create(markdownColor, postSpoilerBackgroundColor)) .usePlugin(StrikethroughPlugin.create()) - .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> { + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java index d82fcf8d..13e5e6a1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/adapters/RulesRecyclerViewAdapter.java @@ -76,7 +76,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler builder.linkColor(customThemeWrapper.getLinkColor()); } }) - .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, activity).setOnLinkLongClickListener((textView, url) -> { + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { if (activity != null && !activity.isDestroyed() && !activity.isFinishing()) { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java index bea0c4ed..a7116540 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/SidebarFragment.java @@ -157,7 +157,7 @@ public class SidebarFragment extends Fragment { }) .usePlugin(StrikethroughPlugin.create()) .usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS)) - .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, recyclerView).setOnLinkLongClickListener((textView, url) -> { + .usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS).setOnLinkLongClickListener((textView, url) -> { UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment(); Bundle bundle = new Bundle(); bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url); |