fix(apk): 2 min de grace apres une copie, retour automatique decoche par defaut

Android ne laisse pas choisir l'app qui passe devant : moveTaskToBack
ramenait souvent l'ecran d'accueil. Le coffre se reverrouillait aussi
apres 30 s, avant qu'on revienne chercher le mot de passe.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-09-18 14:48:23 +01:00
parent f99fb90ed8
commit 255d685e73
2 changed files with 27 additions and 6 deletions
+5 -3
View File
@@ -631,11 +631,13 @@
"Diagnostics" au-dessus de rien. --> "Diagnostics" au-dessus de rien. -->
<h2>Copy and search</h2> <h2>Copy and search</h2>
<label class="opt"><input type="checkbox" id="sBack"> <label class="opt"><input type="checkbox" id="sBack">
Go back to the previous app after copying</label> Hide Vault after copying (may show the home screen)</label>
<label class="opt"><input type="checkbox" id="sKbd"> <label class="opt"><input type="checkbox" id="sKbd">
Open the keyboard on the search when the vault opens</label> Open the keyboard on the search when the vault opens</label>
<div class="note">Copy, and you are back in the browser or app you came <div class="note">To jump back to the app you came from, use Android's own
from, ready to paste. Come back and the search is ready to type.</div> gesture: swipe along the bottom bar, or tap the recent-apps button twice.
After a copy the vault stays open for 2 minutes in the background, time
to paste the username and come back for the password.</div>
<h2 id="sDiagH">Diagnostics</h2> <h2 id="sDiagH">Diagnostics</h2>
<button class="btn wide" id="sLog">Show the log</button> <button class="btn wide" id="sLog">Show the log</button>
+22 -3
View File
@@ -87,6 +87,10 @@ const
// pour aller coller un mot de passe ailleurs et revenir ; trop court pour // pour aller coller un mot de passe ailleurs et revenir ; trop court pour
// qu'un telephone repose ouvert. // qu'un telephone repose ouvert.
BACKGROUND_GRACE_SECONDS = 30; BACKGROUND_GRACE_SECONDS = 30;
// APRES UNE COPIE, plus long : on part coller l'identifiant puis on revient
// chercher le mot de passe, et 30 s n'y suffisaient pas - le coffre se
// reverrouillait au milieu du geste.
COPY_GRACE_SECONDS = 120;
// Duree minimale entre deux rafraichissements de fond. // Duree minimale entre deux rafraichissements de fond.
// //
@@ -157,6 +161,9 @@ type
// Reglages d'usage (Settings -> Copy and search), vrais par defaut. Rien de // Reglages d'usage (Settings -> Copy and search), vrais par defaut. Rien de
// secret : un petit fichier en clair dans le dossier prive de l'app. // secret : un petit fichier en clair dans le dossier prive de l'app.
FUiBackAfterCopy, FUiKbdOnSearch: Boolean; FUiBackAfterCopy, FUiKbdOnSearch: Boolean;
// Une copie vient d'etre faite : le prochain passage en arriere-plan a
// droit au delai long (COPY_GRACE_SECONDS).
FCopyGrace: Boolean;
// La cle du verrouillage d'ecran est morte (schema retire ou reinitialise) : // La cle du verrouillage d'ecran est morte (schema retire ou reinitialise) :
// on ouvre la copie de secours, scellee sous le mot de passe. // on ouvre la copie de secours, scellee sous le mot de passe.
FRecover: Boolean; FRecover: Boolean;
@@ -1687,6 +1694,12 @@ begin
end); end);
end; end;
function GraceSeconds(AAfterCopy: Boolean): Integer;
begin
if AAfterCopy then Result := COPY_GRACE_SECONDS
else Result := BACKGROUND_GRACE_SECONDS;
end;
function UiPrefsPath: string; function UiPrefsPath: string;
begin begin
Result := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetHomePath, 'ui-prefs.txt'); Result := System.IOUtils.TPath.Combine(System.IOUtils.TPath.GetHomePath, 'ui-prefs.txt');
@@ -1696,12 +1709,15 @@ procedure TForm8.LoadUiPrefs;
var var
LText: string; LText: string;
begin begin
FUiBackAfterCopy := True; // Retour automatique DECOCHE par defaut : Android ne laisse pas choisir
// l'app qui passe devant, et selon la facon dont Vault a ete ouvert c'est
// l'ecran d'accueil qui revient, pas l'app d'avant.
FUiBackAfterCopy := False;
FUiKbdOnSearch := True; FUiKbdOnSearch := True;
try try
if not TFile.Exists(UiPrefsPath) then Exit; if not TFile.Exists(UiPrefsPath) then Exit;
LText := TFile.ReadAllText(UiPrefsPath); LText := TFile.ReadAllText(UiPrefsPath);
FUiBackAfterCopy := not LText.Contains('back=0'); FUiBackAfterCopy := LText.Contains('back=1');
FUiKbdOnSearch := not LText.Contains('kbd=0'); FUiKbdOnSearch := not LText.Contains('kbd=0');
except except
// Illisible : on garde les valeurs par defaut. // Illisible : on garde les valeurs par defaut.
@@ -3069,6 +3085,7 @@ begin
// l'application. // l'application.
if not CopySensitive(AText) then Exit; if not CopySensitive(AText) then Exit;
FCopied := AText; FCopied := AText;
FCopyGrace := True;
// Reprogramme depuis zero : deux copies successives donnent au second // Reprogramme depuis zero : deux copies successives donnent au second
// contenu son delai complet, pas le reste de celui du premier. // contenu son delai complet, pas le reste de celui du premier.
FClipTimer.Enabled := False; FClipTimer.Enabled := False;
@@ -3137,7 +3154,8 @@ begin
if FVault.Count > 0 then if FVault.Count > 0 then
begin begin
if (FBackgroundAt > 0) and if (FBackgroundAt > 0) and
(SecondsBetween(Now, FBackgroundAt) >= BACKGROUND_GRACE_SECONDS) then (SecondsBetween(Now, FBackgroundAt) >=
GraceSeconds(FCopyGrace)) then
LockVault LockVault
else else
// Retour a temps : on rend l'ecran quitte, pas un autre. La page a // Retour a temps : on rend l'ecran quitte, pas un autre. La page a
@@ -3153,6 +3171,7 @@ begin
FWeb.Visible := True; FWeb.Visible := True;
end; end;
FBackgroundAt := 0; FBackgroundAt := 0;
FCopyGrace := False;
// RETOUR DANS VAULT = on vient chercher un mot de passe : la recherche // RETOUR DANS VAULT = on vient chercher un mot de passe : la recherche
// est prete, texte precedent selectionne pour etre remplace. // est prete, texte precedent selectionne pour etre remplace.
if FUiKbdOnSearch and (FWebView = 'list') and (FPlain <> '') then if FUiKbdOnSearch and (FWebView = 'list') and (FPlain <> '') then