mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-30 21:07:11 +01:00
Long click the url to see more options. Make getRedditUriByPath in LinkResolverActivity private.
This commit is contained in:
parent
1d857eed47
commit
321f4da623
@ -132,6 +132,7 @@ dependencies {
|
|||||||
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
implementation "io.noties.markwon:recycler-table:$markwonVersion"
|
||||||
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
implementation "io.noties.markwon:simple-ext:$markwonVersion"
|
||||||
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
implementation 'com.atlassian.commonmark:commonmark-ext-gfm-tables:0.14.0'
|
||||||
|
implementation 'me.saket:better-link-movement-method:2.2.0'
|
||||||
|
|
||||||
// Animations
|
// Animations
|
||||||
implementation 'com.airbnb.android:lottie:3.4.4'
|
implementation 'com.airbnb.android:lottie:3.4.4'
|
||||||
|
@ -139,7 +139,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
|
|
||||||
if (kind.equals(Message.TYPE_COMMENT)) {
|
if (kind.equals(Message.TYPE_COMMENT)) {
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||||
Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext());
|
Uri uri = Uri.parse(message.getContext());
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
||||||
@ -152,7 +152,7 @@ public class PullNotificationWorker extends Worker {
|
|||||||
builder.setContentIntent(summaryPendingIntent);
|
builder.setContentIntent(summaryPendingIntent);
|
||||||
} else if (kind.equals(Message.TYPE_LINK)) {
|
} else if (kind.equals(Message.TYPE_LINK)) {
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||||
Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext());
|
Uri uri = Uri.parse(message.getContext());
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
intent.putExtra(LinkResolverActivity.EXTRA_NEW_ACCOUNT_NAME, accountName);
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
intent.putExtra(LinkResolverActivity.EXTRA_MESSAGE_FULLNAME, message.getFullname());
|
||||||
|
@ -154,11 +154,7 @@ public class CommentActivity extends BaseActivity {
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(CommentActivity.this, LinkResolverActivity.class);
|
Intent intent = new Intent(CommentActivity.this, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -218,11 +214,7 @@ public class CommentActivity extends BaseActivity {
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(CommentActivity.this, LinkResolverActivity.class);
|
Intent intent = new Intent(CommentActivity.this, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -191,11 +191,7 @@ public class FullMarkdownActivity extends BaseActivity {
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(FullMarkdownActivity.this, LinkResolverActivity.class);
|
Intent intent = new Intent(FullMarkdownActivity.this, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, isNsfw);
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, isNsfw);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
|
@ -51,7 +51,7 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
@Inject
|
@Inject
|
||||||
CustomThemeWrapper mCustomThemeWrapper;
|
CustomThemeWrapper mCustomThemeWrapper;
|
||||||
|
|
||||||
public static Uri getRedditUriByPath(String path) {
|
private Uri getRedditUriByPath(String path) {
|
||||||
return Uri.parse("https://www.reddit.com" + path);
|
return Uri.parse("https://www.reddit.com" + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +62,13 @@ public class LinkResolverActivity extends AppCompatActivity {
|
|||||||
((Infinity) getApplication()).getAppComponent().inject(this);
|
((Infinity) getApplication()).getAppComponent().inject(this);
|
||||||
|
|
||||||
Uri uri = getIntent().getData();
|
Uri uri = getIntent().getData();
|
||||||
|
|
||||||
|
if (uri.getScheme() == null && uri.getHost() == null) {
|
||||||
|
handleUri(getRedditUriByPath(uri.toString()));
|
||||||
|
} else {
|
||||||
handleUri(uri);
|
handleUri(uri);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleUri(Uri uri) {
|
private void handleUri(Uri uri) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
|
@ -332,11 +332,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -420,11 +416,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -2992,11 +2984,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
mImageView.setOnClickListener(view -> {
|
mImageView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(mPost.getUrl());
|
Uri uri = Uri.parse(mPost.getUrl());
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(mPost.getUrl()));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
@ -3120,11 +3108,7 @@ public class CommentAndPostRecyclerViewAdapter extends RecyclerView.Adapter<Recy
|
|||||||
} else if (mPost.getPostType() == Post.LINK_TYPE || mPost.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
} else if (mPost.getPostType() == Post.LINK_TYPE || mPost.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(mPost.getUrl());
|
Uri uri = Uri.parse(mPost.getUrl());
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(mPost.getUrl()));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, mPost.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (mPost.getPostType() == Post.GALLERY_TYPE) {
|
} else if (mPost.getPostType() == Post.GALLERY_TYPE) {
|
||||||
|
@ -184,11 +184,7 @@ public class CommentsListingRecyclerViewAdapter extends PagedListAdapter<Comment
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -164,11 +164,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -238,7 +234,7 @@ public class MessageRecyclerViewAdapter extends PagedListAdapter<Message, Recycl
|
|||||||
((DataViewHolder) holder).itemView.setOnClickListener(view -> {
|
((DataViewHolder) holder).itemView.setOnClickListener(view -> {
|
||||||
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
if (mMessageType == FetchMessage.MESSAGE_TYPE_INBOX
|
||||||
&& message.getContext() != null && !message.getContext().equals("")) {
|
&& message.getContext() != null && !message.getContext().equals("")) {
|
||||||
Uri uri = LinkResolverActivity.getRedditUriByPath(message.getContext());
|
Uri uri = Uri.parse(message.getContext());
|
||||||
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
Intent intent = new Intent(mContext, LinkResolverActivity.class);
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
mContext.startActivity(intent);
|
mContext.startActivity(intent);
|
||||||
|
@ -2359,11 +2359,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(post.getUrl());
|
Uri uri = Uri.parse(post.getUrl());
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||||
@ -2731,11 +2727,7 @@ public class PostRecyclerViewAdapter extends PagedListAdapter<Post, RecyclerView
|
|||||||
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
} else if (post.getPostType() == Post.LINK_TYPE || post.getPostType() == Post.NO_PREVIEW_LINK_TYPE) {
|
||||||
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(mActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(post.getUrl());
|
Uri uri = Uri.parse(post.getUrl());
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(post.getUrl()));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW());
|
intent.putExtra(LinkResolverActivity.EXTRA_IS_NSFW, post.isNSFW());
|
||||||
mActivity.startActivity(intent);
|
mActivity.startActivity(intent);
|
||||||
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
} else if (post.getPostType() == Post.GALLERY_TYPE) {
|
||||||
|
@ -73,11 +73,7 @@ public class PrivateMessagesDetailRecyclerViewAdapter extends RecyclerView.Adapt
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(viewPrivateMessagesActivity, LinkResolverActivity.class);
|
Intent intent = new Intent(viewPrivateMessagesActivity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
viewPrivateMessagesActivity.startActivity(intent);
|
viewPrivateMessagesActivity.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,7 @@ public class RulesRecyclerViewAdapter extends RecyclerView.Adapter<RulesRecycler
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(context, LinkResolverActivity.class);
|
Intent intent = new Intent(context, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
|
package ml.docilealligator.infinityforreddit.bottomsheetfragments;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ActivityNotFoundException;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -25,6 +26,8 @@ import ml.docilealligator.infinityforreddit.R;
|
|||||||
public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment {
|
||||||
|
|
||||||
public static final String EXTRA_URL = "EU";
|
public static final String EXTRA_URL = "EU";
|
||||||
|
@BindView(R.id.link_text_view_url_menu_bottom_sheet_fragment)
|
||||||
|
TextView linkTextView;
|
||||||
@BindView(R.id.open_link_text_view_url_menu_bottom_sheet_fragment)
|
@BindView(R.id.open_link_text_view_url_menu_bottom_sheet_fragment)
|
||||||
TextView openLinkTextView;
|
TextView openLinkTextView;
|
||||||
@BindView(R.id.copy_link_text_view_url_menu_bottom_sheet_fragment)
|
@BindView(R.id.copy_link_text_view_url_menu_bottom_sheet_fragment)
|
||||||
@ -32,6 +35,7 @@ public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment
|
|||||||
@BindView(R.id.share_link_text_view_url_menu_bottom_sheet_fragment)
|
@BindView(R.id.share_link_text_view_url_menu_bottom_sheet_fragment)
|
||||||
TextView shareLinkTextView;
|
TextView shareLinkTextView;
|
||||||
private Activity activity;
|
private Activity activity;
|
||||||
|
private String url;
|
||||||
|
|
||||||
public UrlMenuBottomSheetFragment() {
|
public UrlMenuBottomSheetFragment() {
|
||||||
// Required empty public constructor
|
// Required empty public constructor
|
||||||
@ -43,7 +47,14 @@ public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment
|
|||||||
View rootView = inflater.inflate(R.layout.fragment_url_menu_bottom_sheet, container, false);
|
View rootView = inflater.inflate(R.layout.fragment_url_menu_bottom_sheet, container, false);
|
||||||
ButterKnife.bind(this, rootView);
|
ButterKnife.bind(this, rootView);
|
||||||
|
|
||||||
String url = getArguments().getString(EXTRA_URL);
|
url = getArguments().getString(EXTRA_URL);
|
||||||
|
|
||||||
|
Uri uri = Uri.parse(url);
|
||||||
|
if (uri.getScheme() == null && uri.getHost() == null) {
|
||||||
|
url = "https://www.reddit.com" + url;
|
||||||
|
}
|
||||||
|
|
||||||
|
linkTextView.setText(url);
|
||||||
|
|
||||||
openLinkTextView.setOnClickListener(view -> {
|
openLinkTextView.setOnClickListener(view -> {
|
||||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||||
@ -68,9 +79,11 @@ public class UrlMenuBottomSheetFragment extends RoundedBottomSheetDialogFragment
|
|||||||
Intent intent = new Intent(Intent.ACTION_SEND);
|
Intent intent = new Intent(Intent.ACTION_SEND);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, url);
|
intent.putExtra(Intent.EXTRA_TEXT, url);
|
||||||
if (intent.resolveActivity(activity.getPackageManager()) != null) {
|
try {
|
||||||
startActivity(intent);
|
Intent shareIntent = Intent.createChooser(intent, null);
|
||||||
} else {
|
startActivity(shareIntent);
|
||||||
|
} catch (ActivityNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
Toast.makeText(activity, R.string.no_app, Toast.LENGTH_SHORT).show();
|
Toast.makeText(activity, R.string.no_app, Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -34,17 +34,20 @@ import io.noties.markwon.MarkwonConfiguration;
|
|||||||
import io.noties.markwon.core.MarkwonTheme;
|
import io.noties.markwon.core.MarkwonTheme;
|
||||||
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
import io.noties.markwon.ext.strikethrough.StrikethroughPlugin;
|
||||||
import io.noties.markwon.linkify.LinkifyPlugin;
|
import io.noties.markwon.linkify.LinkifyPlugin;
|
||||||
|
import io.noties.markwon.movement.MovementMethodPlugin;
|
||||||
import io.noties.markwon.recycler.MarkwonAdapter;
|
import io.noties.markwon.recycler.MarkwonAdapter;
|
||||||
import io.noties.markwon.recycler.table.TableEntry;
|
import io.noties.markwon.recycler.table.TableEntry;
|
||||||
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
import io.noties.markwon.recycler.table.TableEntryPlugin;
|
||||||
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
import io.noties.markwon.simple.ext.SimpleExtPlugin;
|
||||||
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
import me.saket.bettermovementmethod.BetterLinkMovementMethod;
|
||||||
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
|
||||||
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditDataAsyncTask;
|
|
||||||
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
|
||||||
import ml.docilealligator.infinityforreddit.Infinity;
|
import ml.docilealligator.infinityforreddit.Infinity;
|
||||||
import ml.docilealligator.infinityforreddit.R;
|
import ml.docilealligator.infinityforreddit.R;
|
||||||
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
import ml.docilealligator.infinityforreddit.RedditDataRoomDatabase;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.LinkResolverActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.activities.ViewSubredditDetailActivity;
|
||||||
|
import ml.docilealligator.infinityforreddit.asynctasks.InsertSubredditDataAsyncTask;
|
||||||
|
import ml.docilealligator.infinityforreddit.bottomsheetfragments.UrlMenuBottomSheetFragment;
|
||||||
|
import ml.docilealligator.infinityforreddit.customtheme.CustomThemeWrapper;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
|
import ml.docilealligator.infinityforreddit.subreddit.FetchSubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditData;
|
||||||
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
|
import ml.docilealligator.infinityforreddit.subreddit.SubredditViewModel;
|
||||||
@ -111,16 +114,20 @@ public class SidebarFragment extends Fragment {
|
|||||||
builder.linkResolver((view, link) -> {
|
builder.linkResolver((view, link) -> {
|
||||||
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
Intent intent = new Intent(activity, LinkResolverActivity.class);
|
||||||
Uri uri = Uri.parse(link);
|
Uri uri = Uri.parse(link);
|
||||||
if (uri.getScheme() == null && uri.getHost() == null) {
|
|
||||||
intent.setData(LinkResolverActivity.getRedditUriByPath(link));
|
|
||||||
} else {
|
|
||||||
intent.setData(uri);
|
intent.setData(uri);
|
||||||
}
|
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.usePlugin(StrikethroughPlugin.create())
|
.usePlugin(StrikethroughPlugin.create())
|
||||||
|
.usePlugin(MovementMethodPlugin.create(BetterLinkMovementMethod.linkify(Linkify.WEB_URLS, recyclerView).setOnLinkLongClickListener((textView, url) -> {
|
||||||
|
UrlMenuBottomSheetFragment urlMenuBottomSheetFragment = new UrlMenuBottomSheetFragment();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putString(UrlMenuBottomSheetFragment.EXTRA_URL, url);
|
||||||
|
urlMenuBottomSheetFragment.setArguments(bundle);
|
||||||
|
urlMenuBottomSheetFragment.show(getChildFragmentManager(), urlMenuBottomSheetFragment.getTag());
|
||||||
|
return true;
|
||||||
|
})))
|
||||||
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
.usePlugin(LinkifyPlugin.create(Linkify.WEB_URLS))
|
||||||
.usePlugin(SimpleExtPlugin.create(plugin ->
|
.usePlugin(SimpleExtPlugin.create(plugin ->
|
||||||
plugin.addExtension(1, '^', (configuration, props) -> {
|
plugin.addExtension(1, '^', (configuration, props) -> {
|
||||||
|
@ -16,7 +16,10 @@
|
|||||||
android:id="@+id/markdown_recycler_view_sidebar_fragment"
|
android:id="@+id/markdown_recycler_view_sidebar_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:padding="8dp"
|
android:paddingTop="8dp"
|
||||||
|
android:paddingBottom="144dp"
|
||||||
|
android:paddingStart="8dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
android:clipToPadding="false" />
|
android:clipToPadding="false" />
|
||||||
|
|
||||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
@ -12,11 +12,23 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/link_text_view_url_menu_bottom_sheet_fragment"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="?attr/primaryTextColor"
|
||||||
|
android:textSize="?attr/font_default"
|
||||||
|
android:fontFamily="?attr/font_family"
|
||||||
|
android:paddingTop="16dp"
|
||||||
|
android:paddingBottom="16dp"
|
||||||
|
android:paddingStart="32dp"
|
||||||
|
android:paddingEnd="32dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/open_link_text_view_url_menu_bottom_sheet_fragment"
|
android:id="@+id/open_link_text_view_url_menu_bottom_sheet_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/copy_raw_text"
|
android:text="@string/open_link"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
@ -34,7 +46,7 @@
|
|||||||
android:id="@+id/copy_link_text_view_url_menu_bottom_sheet_fragment"
|
android:id="@+id/copy_link_text_view_url_menu_bottom_sheet_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/copy_markdown"
|
android:text="@string/copy_link"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
@ -52,7 +64,7 @@
|
|||||||
android:id="@+id/share_link_text_view_url_menu_bottom_sheet_fragment"
|
android:id="@+id/share_link_text_view_url_menu_bottom_sheet_fragment"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/copy_all_raw_text"
|
android:text="@string/share_link"
|
||||||
android:textColor="?attr/primaryTextColor"
|
android:textColor="?attr/primaryTextColor"
|
||||||
android:textSize="?attr/font_default"
|
android:textSize="?attr/font_default"
|
||||||
android:fontFamily="?attr/font_family"
|
android:fontFamily="?attr/font_family"
|
||||||
|
@ -583,6 +583,7 @@
|
|||||||
<string name="copy_gif_link">Copy Gif Link</string>
|
<string name="copy_gif_link">Copy Gif Link</string>
|
||||||
<string name="copy_video_link">Copy Video Link</string>
|
<string name="copy_video_link">Copy Video Link</string>
|
||||||
<string name="copy_link">Copy Link</string>
|
<string name="copy_link">Copy Link</string>
|
||||||
|
<string name="open_link">Open Link</string>
|
||||||
|
|
||||||
<string name="copy_success">Copied</string>
|
<string name="copy_success">Copied</string>
|
||||||
<string name="copy_link_failed">Cannot copy the link</string>
|
<string name="copy_link_failed">Cannot copy the link</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user