Do not lock the interface for any operation in the gitactivity

This commit is contained in:
zeapo 2017-06-05 14:46:16 +02:00
parent bbd7f66191
commit 38d02885ec
3 changed files with 13 additions and 20 deletions

View file

@ -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();

View file

@ -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();
}

View file

@ -32,19 +32,15 @@ public class GitAsyncTask extends AsyncTask<GitCommand, String, String> {
}
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("<font color=\"#ffffff\">Running the Git operation %s</font>", operation.toString())),
Snackbar.LENGTH_INDEFINITE);
snack.show();
Toast.makeText(activity.getApplicationContext(),
Html.fromHtml(String.format("<font color=\"#ffffff\">Running %s</font>", 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("<font color=\"#ffffff\">Running: <strong>%s</strong></font>", progress[0])),
Snackbar.LENGTH_INDEFINITE);
snack.show();
Toast.makeText(activity.getApplicationContext(),
Html.fromHtml(String.format("<font color=\"#ffffff\">Running jgit command: <strong>%s</strong></font>", progress[0])),
Toast.LENGTH_LONG).show();
}
@Override
@ -63,7 +59,8 @@ public class GitAsyncTask extends AsyncTask<GitCommand, String, String> {
} 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<GitCommand, String, String> {
}
protected void onPostExecute(String result) {
if (this.snack != null)
try {
this.snack.dismiss();
} catch (Exception e) {
// ignore
}
if (result == null)
result = "Unexpected error";