rename SynchronizeDatabase => StartSynchronizeDatabase; add experimental UI for displaying sync-in-progress

This commit is contained in:
Philipp Crocoll
2025-05-06 13:29:47 +02:00
parent e95cc84a15
commit fefcf8f30e
4 changed files with 37 additions and 22 deletions

View File

@@ -1212,7 +1212,7 @@ namespace keepass2android
return true;
case Resource.Id.menu_sync:
new SyncUtil(this).SynchronizeDatabase(() => { });
new SyncUtil(this).StartSynchronizeDatabase();
return true;
case Resource.Id.menu_work_offline:
@@ -1223,7 +1223,7 @@ namespace keepass2android
case Resource.Id.menu_work_online:
App.Kp2a.OfflineMode = App.Kp2a.OfflineModePreference = false;
UpdateOfflineModeMenu();
new SyncUtil(this).SynchronizeDatabase(() => { });
new SyncUtil(this).StartSynchronizeDatabase();
return true;
case Resource.Id.menu_open_other_db:
AppTask.SetActivityResult(this, KeePass.ExitLoadAnotherDb);

View File

@@ -339,10 +339,10 @@ namespace keepass2android
if (PreferenceManager.GetDefaultSharedPreferences(this)
.GetBoolean(GetString(Resource.String.SyncAfterQuickUnlock_key), false))
{
new SyncUtil(this).SynchronizeDatabase(Finish);
new SyncUtil(this).StartSynchronizeDatabase();
}
else
Finish();
Finish();

View File

@@ -354,13 +354,37 @@
android:layout_height="1dp"
android:layout_above="@id/bottom_bar"
android:background="#b8b8b8" />
<LinearLayout
android:id="@+id/background_ops_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/md_theme_surfaceVariant"
android:layout_below="@id/top"
android:orientation="vertical" >
<com.google.android.material.progressindicator.LinearProgressIndicator
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:indeterminate="true" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Synchronisierung läuft..." />
</LinearLayout>
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/divider2"
android:layout_below="@id/top"
android:layout_below="@id/background_ops_container"
android:fitsSystemWindows="true">
<fragment
android:name="keepass2android.GroupListFragment"

View File

@@ -49,7 +49,7 @@ namespace keepass2android
}
public void SynchronizeDatabase(Action runAfterSuccess)
public void StartSynchronizeDatabase()
{
var filestorage = App.Kp2a.GetFileStorage(App.Kp2a.CurrentDb.Ioc);
OperationWithFinishHandler task;
@@ -65,16 +65,10 @@ namespace keepass2android
if (App.Kp2a.CurrentDb?.OtpAuxFileIoc != null)
{
var task2 = new SyncOtpAuxFile(_activity, App.Kp2a.CurrentDb.OtpAuxFileIoc);
task2.operationFinishedHandler = new ActionOnOperationFinished(_activity, (b, s, activeActivity) =>
{
runAfterSuccess();
});
new BlockingOperationRunner(App.Kp2a, activity, task2).Run(true);
}
else
{
runAfterSuccess();
//TODO new BackgroundOperationRunner(App.Kp2a, activity, task2).Run(true);
}
});
if (filestorage is CachingFileStorage)
@@ -84,15 +78,12 @@ namespace keepass2android
}
else
{
//TODO do we want this to run in the background?
task = new CheckDatabaseForChanges(_activity, App.Kp2a, onOperationFinishedHandler);
}
var progressTask = new BlockingOperationRunner(App.Kp2a, _activity, task);
progressTask.Run();
//TODO var backgroundTaskRunner = new BackgroundOperationRunner(App.Kp2a, _activity, task);
//TODO backgroundTaskRunner.Run();
}
}