Merge pull request #8961 from dhruvpatidar359/Toast-Popup

Remove the redundant/overlapping toast "Copied to clipboard" for Android 13+
This commit is contained in:
AudricV 2022-11-26 21:33:12 +01:00 committed by GitHub
commit 6b89b44dcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 14 deletions

View File

@ -314,7 +314,10 @@ public final class ShareUtils {
} }
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, text)); clipboardManager.setPrimaryClip(ClipData.newPlainText(null, text));
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show(); if (Build.VERSION.SDK_INT < 33) {
// Android 13 has its own "copied to clipboard" dialog
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show();
}
} }
/** /**

View File

@ -693,7 +693,7 @@ public class MissionAdapter extends Adapter<ViewHolder> implements Handler.Callb
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(result -> { .subscribe(result -> {
Utility.copyToClipboard(mContext, result); ShareUtils.copyToClipboard(mContext, result);
notificationManager.cancel(HASH_NOTIFICATION_ID); notificationManager.cancel(HASH_NOTIFICATION_ID);
}) })
); );

View File

@ -192,18 +192,6 @@ public class Utility {
} }
} }
public static void copyToClipboard(Context context, String str) {
ClipboardManager cm = ContextCompat.getSystemService(context, ClipboardManager.class);
if (cm == null) {
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show();
return;
}
cm.setPrimaryClip(ClipData.newPlainText("text", str));
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show();
}
public static String checksum(final StoredFileHelper source, final int algorithmId) public static String checksum(final StoredFileHelper source, final int algorithmId)
throws IOException { throws IOException {
ByteString byteString; ByteString byteString;