Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit 38d0288

Browse files
committed
Do not lock the interface for any operation in the gitactivity
1 parent bbd7f66 commit 38d0288

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

app/src/main/java/com/zeapo/pwdstore/PasswordStore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ private void checkLocalRepository() {
352352

353353
int lastSync = settings.getInt("last_sync", -1);
354354
int currentTime = (int) Calendar.getInstance().getTimeInMillis() / 1000;
355-
if (settings.getBoolean("git_auto_sync", false) && currentTime > lastSync + 10) {
355+
if (settings.getBoolean("git_auto_sync", false) && currentTime > lastSync + 3600) {
356356
Toast.makeText(getApplicationContext(), "Running git auto sync", Toast.LENGTH_LONG).show();
357357
SyncOperation op = new SyncOperation(localDir.getAbsoluteFile(), activity).setCommands();
358358

app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,10 @@ public void onClick(DialogInterface dialogInterface, int i) {
632632
}
633633

634634
try {
635-
op.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"), true);
635+
op.executeAfterAuthentication(connectionMode,
636+
settings.getString("git_remote_username", "git"),
637+
new File(getFilesDir() + "/.ssh_key"), true);
638+
activity.finish();
636639
} catch (Exception e) {
637640
e.printStackTrace();
638641
}

app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,15 @@ public GitAsyncTask(Activity activity, boolean finishOnEnd, boolean refreshListO
3232
}
3333

3434
protected void onPreExecute() {
35-
// Toast.makeText(activity.getApplicationContext(), String.format("Running %s", operation.toString()), Toast.LENGTH_LONG).show();
36-
snack = Snackbar.make(activity.findViewById(R.id.main_layout),
37-
Html.fromHtml(String.format("<font color=\"#ffffff\">Running the Git operation %s</font>", operation.toString())),
38-
Snackbar.LENGTH_INDEFINITE);
39-
snack.show();
35+
Toast.makeText(activity.getApplicationContext(),
36+
Html.fromHtml(String.format("<font color=\"#ffffff\">Running %s</font>", operation.getClass().getSimpleName())),
37+
Toast.LENGTH_LONG).show();
4038
}
4139

4240
protected void onProgressUpdate(String... progress) {
43-
if (this.snack != null) snack.dismiss();
44-
snack = Snackbar.make(activity.findViewById(R.id.main_layout),
45-
Html.fromHtml(String.format("<font color=\"#ffffff\">Running: <strong>%s</strong></font>", progress[0])),
46-
Snackbar.LENGTH_INDEFINITE);
47-
snack.show();
41+
Toast.makeText(activity.getApplicationContext(),
42+
Html.fromHtml(String.format("<font color=\"#ffffff\">Running jgit command: <strong>%s</strong></font>", progress[0])),
43+
Toast.LENGTH_LONG).show();
4844
}
4945

5046
@Override
@@ -63,7 +59,8 @@ protected String doInBackground(GitCommand... commands) {
6359
} else {
6460
command.call();
6561
}
66-
publishProgress(command.getClass().getName());
62+
String opName = command.getClass().getSimpleName();
63+
publishProgress(opName);
6764
} catch (Exception e) {
6865
e.printStackTrace();
6966
return e.getMessage() + "\nCaused by:\n" + e.getCause();
@@ -73,13 +70,6 @@ protected String doInBackground(GitCommand... commands) {
7370
}
7471

7572
protected void onPostExecute(String result) {
76-
if (this.snack != null)
77-
try {
78-
this.snack.dismiss();
79-
} catch (Exception e) {
80-
// ignore
81-
}
82-
8373
if (result == null)
8474
result = "Unexpected error";
8575

0 commit comments

Comments
 (0)