From 38d02885ecc3a153d13efec2a3ee5613fad15227 Mon Sep 17 00:00:00 2001 From: zeapo Date: Mon, 5 Jun 2017 14:46:16 +0200 Subject: Do not lock the interface for any operation in the gitactivity --- .../java/com/zeapo/pwdstore/PasswordStore.java | 2 +- .../java/com/zeapo/pwdstore/git/GitActivity.java | 5 ++++- .../java/com/zeapo/pwdstore/git/GitAsyncTask.java | 26 +++++++--------------- 3 files changed, 13 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 028d8263..4fb21428 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -352,7 +352,7 @@ public class PasswordStore extends AppCompatActivity { int lastSync = settings.getInt("last_sync", -1); int currentTime = (int) Calendar.getInstance().getTimeInMillis() / 1000; - if (settings.getBoolean("git_auto_sync", false) && currentTime > lastSync + 10) { + if (settings.getBoolean("git_auto_sync", false) && currentTime > lastSync + 3600) { Toast.makeText(getApplicationContext(), "Running git auto sync", Toast.LENGTH_LONG).show(); SyncOperation op = new SyncOperation(localDir.getAbsoluteFile(), activity).setCommands(); diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java index 5d72cd34..e0a63ab0 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitActivity.java @@ -632,7 +632,10 @@ public class GitActivity extends AppCompatActivity { } try { - op.executeAfterAuthentication(connectionMode, settings.getString("git_remote_username", "git"), new File(getFilesDir() + "/.ssh_key"), true); + op.executeAfterAuthentication(connectionMode, + settings.getString("git_remote_username", "git"), + new File(getFilesDir() + "/.ssh_key"), true); + activity.finish(); } catch (Exception e) { e.printStackTrace(); } diff --git a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java index 644d3c6b..06a9376e 100644 --- a/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java +++ b/app/src/main/java/com/zeapo/pwdstore/git/GitAsyncTask.java @@ -32,19 +32,15 @@ public class GitAsyncTask extends AsyncTask { } protected void onPreExecute() { -// Toast.makeText(activity.getApplicationContext(), String.format("Running %s", operation.toString()), Toast.LENGTH_LONG).show(); - snack = Snackbar.make(activity.findViewById(R.id.main_layout), - Html.fromHtml(String.format("Running the Git operation %s", operation.toString())), - Snackbar.LENGTH_INDEFINITE); - snack.show(); + Toast.makeText(activity.getApplicationContext(), + Html.fromHtml(String.format("Running %s", operation.getClass().getSimpleName())), + Toast.LENGTH_LONG).show(); } protected void onProgressUpdate(String... progress) { - if (this.snack != null) snack.dismiss(); - snack = Snackbar.make(activity.findViewById(R.id.main_layout), - Html.fromHtml(String.format("Running: %s", progress[0])), - Snackbar.LENGTH_INDEFINITE); - snack.show(); + Toast.makeText(activity.getApplicationContext(), + Html.fromHtml(String.format("Running jgit command: %s", progress[0])), + Toast.LENGTH_LONG).show(); } @Override @@ -63,7 +59,8 @@ public class GitAsyncTask extends AsyncTask { } else { command.call(); } - publishProgress(command.getClass().getName()); + String opName = command.getClass().getSimpleName(); + publishProgress(opName); } catch (Exception e) { e.printStackTrace(); return e.getMessage() + "\nCaused by:\n" + e.getCause(); @@ -73,13 +70,6 @@ public class GitAsyncTask extends AsyncTask { } protected void onPostExecute(String result) { - if (this.snack != null) - try { - this.snack.dismiss(); - } catch (Exception e) { - // ignore - } - if (result == null) result = "Unexpected error"; -- cgit v1.2.3