mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-22 16:50:04 +02:00
Fix issues with long press
This commit is contained in:
parent
27ef0003d7
commit
53bd8024de
3 changed files with 14 additions and 6 deletions
|
@ -263,10 +263,10 @@ public class CrossActionHelper {
|
||||||
/**
|
/**
|
||||||
* Fetch and federate the remote status
|
* Fetch and federate the remote status
|
||||||
*/
|
*/
|
||||||
public static void fetchRemoteStatus(@NonNull Context context, @NonNull Account ownerAccount, Status targetedStatus, Callback callback) {
|
public static void fetchRemoteStatus(@NonNull Context context, @NonNull Account ownerAccount, String url, Callback callback) {
|
||||||
MastodonSearchService mastodonSearchService = init(context, MainActivity.currentInstance);
|
MastodonSearchService mastodonSearchService = init(context, MainActivity.currentInstance);
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
Call<Results> resultsCall = mastodonSearchService.search(ownerAccount.token, targetedStatus.url, null, "statuses", false, true, false, 0, null, null, 1);
|
Call<Results> resultsCall = mastodonSearchService.search(ownerAccount.token, url, null, "statuses", false, true, false, 0, null, null, 1);
|
||||||
Results results = null;
|
Results results = null;
|
||||||
if (resultsCall != null) {
|
if (resultsCall != null) {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -229,13 +229,17 @@ public class SpannableHelper {
|
||||||
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.shared_via));
|
||||||
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
|
sendIntent.putExtra(Intent.EXTRA_TEXT, url);
|
||||||
sendIntent.setType("text/plain");
|
sendIntent.setType("text/plain");
|
||||||
context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.share_with)));
|
sendIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
Intent intentChooser = Intent.createChooser(sendIntent, context.getString(R.string.share_with));
|
||||||
|
intentChooser.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
context.startActivity(intentChooser);
|
||||||
alertDialog.dismiss();
|
alertDialog.dismiss();
|
||||||
});
|
});
|
||||||
|
|
||||||
popupLinksBinding.openOtherApp.setOnClickListener(v -> {
|
popupLinksBinding.openOtherApp.setOnClickListener(v -> {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(url));
|
intent.setData(Uri.parse(url));
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
try {
|
try {
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -289,7 +293,7 @@ public class SpannableHelper {
|
||||||
Handler mainHandler = new Handler(context.getMainLooper());
|
Handler mainHandler = new Handler(context.getMainLooper());
|
||||||
String finalRedirect = redirect;
|
String finalRedirect = redirect;
|
||||||
Runnable myRunnable = () -> {
|
Runnable myRunnable = () -> {
|
||||||
AlertDialog.Builder builder1 = new AlertDialog.Builder(context, Helper.dialogStyle());
|
AlertDialog.Builder builder1 = new AlertDialog.Builder(view.getContext(), Helper.dialogStyle());
|
||||||
if (finalRedirect != null) {
|
if (finalRedirect != null) {
|
||||||
builder1.setMessage(context.getString(R.string.redirect_detected, url, finalRedirect));
|
builder1.setMessage(context.getString(R.string.redirect_detected, url, finalRedirect));
|
||||||
builder1.setNegativeButton(R.string.copy_link, (dialog, which) -> {
|
builder1.setNegativeButton(R.string.copy_link, (dialog, which) -> {
|
||||||
|
@ -339,11 +343,12 @@ public class SpannableHelper {
|
||||||
Matcher matcherLink = link.matcher(url);
|
Matcher matcherLink = link.matcher(url);
|
||||||
if (matcherLink.find() && !url.contains("medium.com")) {
|
if (matcherLink.find() && !url.contains("medium.com")) {
|
||||||
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
if (matcherLink.group(3) != null && Objects.requireNonNull(matcherLink.group(3)).length() > 0) { //It's a toot
|
||||||
CrossActionHelper.fetchRemoteStatus(context, MainActivity.accountWeakReference.get(), status, new CrossActionHelper.Callback() {
|
CrossActionHelper.fetchRemoteStatus(context, MainActivity.accountWeakReference.get(), url, new CrossActionHelper.Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void federatedStatus(Status status) {
|
public void federatedStatus(Status status) {
|
||||||
Intent intent = new Intent(context, ContextActivity.class);
|
Intent intent = new Intent(context, ContextActivity.class);
|
||||||
intent.putExtra(Helper.ARG_STATUS, status);
|
intent.putExtra(Helper.ARG_STATUS, status);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,6 +370,7 @@ public class SpannableHelper {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putSerializable(Helper.ARG_ACCOUNT, account);
|
b.putSerializable(Helper.ARG_ACCOUNT, account);
|
||||||
intent.putExtras(b);
|
intent.putExtras(b);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -211,7 +211,9 @@ public class FragmentMastodonTimeline extends Fragment {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scrollToTop() {
|
public void scrollToTop() {
|
||||||
binding.recyclerView.scrollToPosition(0);
|
if (binding != null) {
|
||||||
|
binding.recyclerView.scrollToPosition(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue