feat(apk): copier renvoie a l'app d'avant, recherche prete a l'ouverture et au retour

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
r-zakarya
2026-09-18 14:28:52 +01:00
parent 9a09cc5d29
commit 946880ecf4
3 changed files with 70 additions and 0 deletions
+48
View File
@@ -42,6 +42,14 @@ procedure TintSystemBars(ATop, ABottom: TAlphaColor);
/// decide de la suite d'apres la reponse.
function HideSoftKeyboard: Boolean;
/// Deplie le clavier pour le champ qui a le focus (la recherche). Un focus()
/// JavaScript seul pose le curseur sans ouvrir le clavier.
procedure ShowSoftKeyboard;
/// Renvoie l'application en arriere-plan : on retombe sur l'app d'ou l'on
/// venait, prete a recevoir le collage.
procedure MoveAppToBack;
implementation
{$IF DEFINED(ANDROID)}
@@ -126,4 +134,44 @@ begin
end;
{$ENDIF}
{$IF DEFINED(ANDROID)}
procedure ShowSoftKeyboard;
var
LService: JObject;
LView: JView;
begin
try
LView := TAndroidHelper.Activity.getWindow.getDecorView.findFocus;
if LView = nil then Exit;
LService := TAndroidHelper.Context.getSystemService(
TJContext.JavaClass.INPUT_METHOD_SERVICE);
if LService = nil then Exit;
TJInputMethodManager.Wrap(LService).showSoftInput(LView, 0);
except
// Pas de clavier : la recherche reste a un appui.
end;
end;
procedure MoveAppToBack;
begin
CallInUIThread(
procedure
begin
try
TAndroidHelper.Activity.moveTaskToBack(True);
except
// Reste au premier plan : on colle apres un retour manuel.
end;
end);
end;
{$ELSE}
procedure ShowSoftKeyboard;
begin
end;
procedure MoveAppToBack;
begin
end;
{$ENDIF}
end.
+9
View File
@@ -1877,6 +1877,15 @@ document.getElementById('back').addEventListener('click', goList);
// --- appele par Delphi -----------------------------------------------------
var PM = {
/// Recherche prete a taper : focus, texte precedent selectionne (la frappe le
/// remplace), puis Delphi deplie le clavier - un focus() seul ne le fait pas.
focusSearch: function () {
if (view !== 'list') return;
q.focus();
q.select();
send('kbd');
},
setVault: function (json) {
vaultOpen = true;
var d = JSON.parse(json);
+13
View File
@@ -1939,6 +1939,10 @@ begin
SaveEntryField(TNetEncoding.URL.Decode(Param('f')),
TNetEncoding.URL.Decode(Param('v')))
// La page vient de poser le focus sur la recherche : on deplie le clavier.
else if LAction = 'kbd' then
ShowSoftKeyboard
else if LAction = 'copy' then
begin
// LES SECRETS NE TRANSITENT PAS PAR LE PONT. La page envoie un rang,
@@ -2394,6 +2398,7 @@ begin
try
LSw := TStopwatch.StartNew;
AdoptVault(LPlain);
WebCall('PM.focusSearch()'); // on ouvre pour chercher : clavier pret
Log(' displayed in ' + LSw.ElapsedMilliseconds.ToString + ' ms');
// Afficher d'abord, synchroniser ensuite : le coffre est a l'ecran, le
// reseau se debrouille derriere. Sans mot de passe range, on ne peut
@@ -3015,6 +3020,10 @@ begin
FClipTimer.Enabled := True;
WebCall('PM.toast(' + JsArg(ALabel + ' copied - clipboard cleared in ' +
CLIPBOARD_CLEAR_SECONDS.ToString + ' s') + ')');
// COPIER POUR COLLER AILLEURS : on rend la main a l'app d'ou l'on venait,
// il ne reste qu'a coller. Le retour dans Vault retrouve la liste telle
// quelle (delai de grace avant verrouillage).
MoveAppToBack;
end;
procedure TForm8.OnClipTimer(Sender: TObject);
@@ -3089,6 +3098,10 @@ begin
FWeb.Visible := True;
end;
FBackgroundAt := 0;
// RETOUR DANS VAULT = on vient chercher un mot de passe : la recherche
// est prete, texte precedent selectionne pour etre remplace.
if (FWebView = 'list') and (FPlain <> '') then
WebCall('PM.focusSearch()');
end;
end;
end;