Add Android autofill service packaging
This commit is contained in:
@@ -30,6 +30,7 @@ import (
|
||||
"git.julianfamily.org/keepassgo/apiaudit"
|
||||
"git.julianfamily.org/keepassgo/apitokens"
|
||||
keepassassets "git.julianfamily.org/keepassgo/assets"
|
||||
"git.julianfamily.org/keepassgo/autofillcache"
|
||||
"git.julianfamily.org/keepassgo/appstate"
|
||||
"git.julianfamily.org/keepassgo/clipboard"
|
||||
"git.julianfamily.org/keepassgo/passwords"
|
||||
@@ -86,6 +87,7 @@ type statePaths struct {
|
||||
RecentVaultsPath string
|
||||
RecentRemotesPath string
|
||||
UIPreferencesPath string
|
||||
AutofillCachePath string
|
||||
}
|
||||
|
||||
type recentVaultRecord struct {
|
||||
@@ -293,6 +295,7 @@ type ui struct {
|
||||
recentVaultsPath string
|
||||
uiPreferencesPath string
|
||||
recentRemotesPath string
|
||||
autofillCachePath string
|
||||
editingEntry bool
|
||||
groupControlsHidden bool
|
||||
recentVaults []string
|
||||
@@ -409,6 +412,7 @@ func newUIWithState(mode string, sess appstate.CurrentSession, paths statePaths)
|
||||
recentVaultsPath: paths.RecentVaultsPath,
|
||||
uiPreferencesPath: paths.UIPreferencesPath,
|
||||
recentRemotesPath: paths.RecentRemotesPath,
|
||||
autofillCachePath: paths.AutofillCachePath,
|
||||
recentVaultGroups: map[string][]string{},
|
||||
recentVaultUsedAt: map[string]time.Time{},
|
||||
now: time.Now,
|
||||
@@ -436,6 +440,7 @@ func newUIWithState(mode string, sess appstate.CurrentSession, paths statePaths)
|
||||
u.restoreStartupLifecycleTarget()
|
||||
u.loadUIPreferences()
|
||||
u.filter()
|
||||
u.syncAutofillCache()
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -469,6 +474,7 @@ func defaultStatePaths(stateDir string) statePaths {
|
||||
RecentVaultsPath: filepath.Join(baseDir, "recent-vaults.json"),
|
||||
RecentRemotesPath: filepath.Join(baseDir, "recent-remotes.json"),
|
||||
UIPreferencesPath: filepath.Join(baseDir, "ui-prefs.json"),
|
||||
AutofillCachePath: filepath.Join(baseDir, "autofill-cache.json"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1432,6 +1438,7 @@ func (u *ui) runAction(label string, action func() error) {
|
||||
return
|
||||
}
|
||||
u.loadingMessage = ""
|
||||
u.syncAutofillCache()
|
||||
u.state.ErrorMessage = ""
|
||||
if suppressStatusMessage(label) {
|
||||
u.state.StatusMessage = ""
|
||||
@@ -1442,6 +1449,18 @@ func (u *ui) runAction(label string, action func() error) {
|
||||
u.statusExpiresAt = u.now().Add(statusBannerDuration)
|
||||
}
|
||||
|
||||
func (u *ui) syncAutofillCache() {
|
||||
if strings.TrimSpace(u.autofillCachePath) == "" {
|
||||
return
|
||||
}
|
||||
model, err := u.state.Session.Current()
|
||||
if err != nil {
|
||||
_ = autofillcache.Clear(u.autofillCachePath)
|
||||
return
|
||||
}
|
||||
_ = autofillcache.Write(u.autofillCachePath, model, u.now())
|
||||
}
|
||||
|
||||
func suppressStatusMessage(label string) bool {
|
||||
switch strings.TrimSpace(label) {
|
||||
case "open vault", "open remote vault":
|
||||
|
||||
Reference in New Issue
Block a user