From d06410dd7e24701d01a677222de355413c3eb913 Mon Sep 17 00:00:00 2001 From: r-zakarya <82443831+r-zakarya@users.noreply.github.com> Date: Fri, 21 Aug 2026 23:04:03 +0100 Subject: [PATCH] fix(android): emptying the clipboard is not copying into it The white "copied" chip appearing long after the gesture was Android's, and it was ours to stop causing: the 45 s auto-clear wrote an empty string through setPrimaryClip, which the system reads as a copy and announces like one. The comment claimed the visible result was the same. It is not, and the API has distinguished emptying from copying since 2018 - clearPrimaryClip, kept behind an API 28 check because minSdk is 23. It only showed every other time because the timer clears only if the clipboard still holds our text; copying anything else in between cancels it. Nothing to fix on the sensitive flag: it is set, the chip shows no content, and that generic wording is exactly what the flag produces. --- android-client/PMA.Clipboard.pas | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/android-client/PMA.Clipboard.pas b/android-client/PMA.Clipboard.pas index c782cf4..e02a7bf 100644 --- a/android-client/PMA.Clipboard.pas +++ b/android-client/PMA.Clipboard.pas @@ -98,10 +98,32 @@ begin end; procedure ClearClipboard; +var + LMgr: Jcontent_ClipboardManager; begin - // Un contenu vide plutot qu'un appel a clearPrimaryClip, absent avant l'API - // 28 : le resultat visible est le meme. - CopySensitive(''); + // clearPrimaryClip QUAND IL EXISTE, et un contenu vide seulement en dessous + // de l'API 28. + // + // Le resultat n'est PAS le meme, contrairement a ce qui etait ecrit ici : + // ecrire un contenu vide reste une COPIE aux yeux du systeme, et Android + // affiche donc sa vignette "copie" - quarante-cinq secondes apres le geste + // de l'utilisateur, sans que rien ne l'explique. Vider n'est pas copier, et + // l'API le distingue depuis 2018. + // + // Elle ne se montre pas a chaque fois : le minuteur ne vide que si le + // presse-papiers contient TOUJOURS notre texte, donc copier autre chose + // entre-temps la supprime. D'ou une apparition sur deux. + try + LMgr := Manager; + if LMgr = nil then Exit; + if TJBuild_VERSION.JavaClass.SDK_INT >= 28 then + LMgr.clearPrimaryClip + else + CopySensitive(''); + except + // Un presse-papiers qu'on n'a pas pu vider vaut mieux qu'une exception : + // le contenu partira au prochain copier de l'utilisateur. + end; end; {$ELSE} uses