Skip to content

Commit 6b89b44

Browse files
authored
Merge pull request TeamNewPipe#8961 from dhruvpatidar359/Toast-Popup
Remove the redundant/overlapping toast "Copied to clipboard" for Android 13+
2 parents aad5e26 + 7b7ab3f commit 6b89b44

3 files changed

Lines changed: 5 additions & 14 deletions

File tree

app/src/main/java/org/schabi/newpipe/util/external_communication/ShareUtils.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,10 @@ public static void copyToClipboard(@NonNull final Context context, final String
314314
}
315315

316316
clipboardManager.setPrimaryClip(ClipData.newPlainText(null, text));
317-
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show();
317+
if (Build.VERSION.SDK_INT < 33) {
318+
// Android 13 has its own "copied to clipboard" dialog
319+
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show();
320+
}
318321
}
319322

320323
/**

app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ private boolean handlePopupItem(@NonNull ViewHolderItem h, @NonNull MenuItem opt
693693
.subscribeOn(Schedulers.computation())
694694
.observeOn(AndroidSchedulers.mainThread())
695695
.subscribe(result -> {
696-
Utility.copyToClipboard(mContext, result);
696+
ShareUtils.copyToClipboard(mContext, result);
697697
notificationManager.cancel(HASH_NOTIFICATION_ID);
698698
})
699699
);

app/src/main/java/us/shandian/giga/util/Utility.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,6 @@ public static int getIconForFileType(FileType type) {
192192
}
193193
}
194194

195-
public static void copyToClipboard(Context context, String str) {
196-
ClipboardManager cm = ContextCompat.getSystemService(context, ClipboardManager.class);
197-
198-
if (cm == null) {
199-
Toast.makeText(context, R.string.permission_denied, Toast.LENGTH_LONG).show();
200-
return;
201-
}
202-
203-
cm.setPrimaryClip(ClipData.newPlainText("text", str));
204-
Toast.makeText(context, R.string.msg_copied, Toast.LENGTH_SHORT).show();
205-
}
206-
207195
public static String checksum(final StoredFileHelper source, final int algorithmId)
208196
throws IOException {
209197
ByteString byteString;

0 commit comments

Comments
 (0)