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.
This commit is contained in:
@@ -98,10 +98,32 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ClearClipboard;
|
procedure ClearClipboard;
|
||||||
|
var
|
||||||
|
LMgr: Jcontent_ClipboardManager;
|
||||||
begin
|
begin
|
||||||
// Un contenu vide plutot qu'un appel a clearPrimaryClip, absent avant l'API
|
// clearPrimaryClip QUAND IL EXISTE, et un contenu vide seulement en dessous
|
||||||
// 28 : le resultat visible est le meme.
|
// 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('');
|
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;
|
end;
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
uses
|
uses
|
||||||
|
|||||||
Reference in New Issue
Block a user