|
|
@@ -1,9 +1,7 @@
|
|
|
package info.knacki.pass.ui;
|
|
|
|
|
|
-import android.content.DialogInterface;
|
|
|
import android.os.Bundle;
|
|
|
import android.support.v7.app.AppCompatActivity;
|
|
|
-import android.view.View;
|
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
@@ -38,18 +36,13 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
private final static Logger log = Logger.getLogger(GitPullActivity.class.getName());
|
|
|
public final static String COMMIT_MSG = "Android pass sync";
|
|
|
|
|
|
- public final static int ACTIVITY_REQUEST_CODE_BROWSEGPG = 1;
|
|
|
-
|
|
|
private GitInterface fGitInterfage;
|
|
|
private GitCommit fHeadCommit;
|
|
|
|
|
|
private void onMsg(final String msg) {
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- TextView logView = findViewById(R.id.logView);
|
|
|
- logView.append(msg +"\n");
|
|
|
- }
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> {
|
|
|
+ TextView logView = findViewById(R.id.logView);
|
|
|
+ logView.append(msg +"\n");
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -77,37 +70,24 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
@Override
|
|
|
public void onResponse(GitCommit result) {
|
|
|
fHeadCommit = result;
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- GitPullActivity.this.OnTreeStructureFetched();
|
|
|
- }
|
|
|
- });
|
|
|
+ GitPullActivity.this.runOnUiThread(GitPullActivity.this::OnTreeStructureFetched);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(final String msg, Throwable e) {
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
- pg.setIndeterminate(false);
|
|
|
- pg.setMax(1);
|
|
|
- pg.setProgress(1);
|
|
|
- TextView logView = findViewById(R.id.logView);
|
|
|
- logView.append(msg +"\n");
|
|
|
- findViewById(R.id.close_bt).setEnabled(true);
|
|
|
- }
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> {
|
|
|
+ ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
+ pg.setIndeterminate(false);
|
|
|
+ pg.setMax(1);
|
|
|
+ pg.setProgress(1);
|
|
|
+ TextView logView = findViewById(R.id.logView);
|
|
|
+ logView.append(msg +"\n");
|
|
|
+ findViewById(R.id.close_bt).setEnabled(true);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- findViewById(R.id.close_bt).setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- GitPullActivity.this.finish();
|
|
|
- }
|
|
|
- });
|
|
|
+ findViewById(R.id.close_bt).setOnClickListener(v -> GitPullActivity.this.finish());
|
|
|
}
|
|
|
|
|
|
public static String LOCALGIT_HASH_VERSION_FILE;
|
|
|
@@ -177,33 +157,22 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
}
|
|
|
|
|
|
void AskForConflicts(final GitLocal localVersion, final HashMap<String, GitObject.GitBlob> conflicts, final HashMap<String, GitObject.GitBlob> filesToPull, final Set<String> filesToPush) {
|
|
|
- runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- AlertPrompt pt = AlertPromptGenerator.StaticMake(GitPullActivity.this)
|
|
|
- .setCancelable(true)
|
|
|
- .setNegativeButton(R.string.cancel, new AlertPrompt.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialogInterface, View view) {
|
|
|
- GitPullActivity.this.finish();
|
|
|
- }
|
|
|
- })
|
|
|
- .setPositiveButton(R.string.ok, new AlertPrompt.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(DialogInterface dialogInterface, View v) {
|
|
|
- ConflictView.ConflictViewResult viewResult = ((ConflictView) v).GetResult();
|
|
|
- for (String s: viewResult.fUseTheir) {
|
|
|
- filesToPull.put(s, conflicts.get(s));
|
|
|
- }
|
|
|
- filesToPush.addAll(viewResult.fUseMine);
|
|
|
- SyncFiles(localVersion, filesToPull, filesToPush);
|
|
|
- }
|
|
|
- })
|
|
|
- .setTitle(R.string.conflictingFiles);
|
|
|
- ConflictView view = new ConflictView(GitPullActivity.this, pt, conflicts.keySet());
|
|
|
- pt.setView(view).show();
|
|
|
- view.UpdateButtonState();
|
|
|
- }
|
|
|
+ runOnUiThread(() -> {
|
|
|
+ AlertPrompt pt = AlertPromptGenerator.StaticMake(GitPullActivity.this)
|
|
|
+ .setCancelable(true)
|
|
|
+ .setNegativeButton(R.string.cancel, (dialogInterface, view) -> GitPullActivity.this.finish())
|
|
|
+ .setPositiveButton(R.string.ok, (dialogInterface, v) -> {
|
|
|
+ ConflictView.ConflictViewResult viewResult = ((ConflictView) v).GetResult();
|
|
|
+ for (String s: viewResult.fUseTheir) {
|
|
|
+ filesToPull.put(s, conflicts.get(s));
|
|
|
+ }
|
|
|
+ filesToPush.addAll(viewResult.fUseMine);
|
|
|
+ SyncFiles(localVersion, filesToPull, filesToPush);
|
|
|
+ })
|
|
|
+ .setTitle(R.string.conflictingFiles);
|
|
|
+ ConflictView view = new ConflictView(GitPullActivity.this, pt, conflicts.keySet());
|
|
|
+ pt.setView(view).show();
|
|
|
+ view.UpdateButtonState();
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -224,31 +193,25 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
final OnStreamResponseListener<Void> allDone = new OnStreamResponseListener<Void>() {
|
|
|
@Override
|
|
|
public void onResponse(Void result) {
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
- pg.setIndeterminate(false);
|
|
|
- pg.setMax(1);
|
|
|
- pg.setProgress(1);
|
|
|
- localVersion.Write(new File(LOCALGIT_HASH_VERSION_FILE));
|
|
|
- RmEmptyDirs(new File(PathUtils.GetPassDir(GitPullActivity.this)), true);
|
|
|
- findViewById(R.id.close_bt).setEnabled(true);
|
|
|
- }
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> {
|
|
|
+ ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
+ pg.setIndeterminate(false);
|
|
|
+ pg.setMax(1);
|
|
|
+ pg.setProgress(1);
|
|
|
+ localVersion.Write(new File(LOCALGIT_HASH_VERSION_FILE));
|
|
|
+ RmEmptyDirs(new File(PathUtils.GetPassDir(GitPullActivity.this)), true);
|
|
|
+ findViewById(R.id.close_bt).setEnabled(true);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void onError(String msg, Throwable e) {
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
- pg.setIndeterminate(false);
|
|
|
- pg.setMax(1);
|
|
|
- pg.setProgress(1);
|
|
|
- findViewById(R.id.close_bt).setEnabled(true);
|
|
|
- }
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> {
|
|
|
+ ProgressBar pg = findViewById(R.id.progressBar);
|
|
|
+ pg.setIndeterminate(false);
|
|
|
+ pg.setMax(1);
|
|
|
+ pg.setProgress(1);
|
|
|
+ findViewById(R.id.close_bt).setEnabled(true);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -258,16 +221,13 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- final Runnable afterFetching = new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- if (filesToPush.size() > 0) {
|
|
|
- GitPullActivity.this.onMsg("Updating remote repository");
|
|
|
- PushBlobs(filesToPush, localVersion, allDone);
|
|
|
- } else {
|
|
|
- GitPullActivity.this.onMsg("Nothing to push");
|
|
|
- allDone.onResponse(null);
|
|
|
- }
|
|
|
+ final Runnable afterFetching = () -> {
|
|
|
+ if (filesToPush.size() > 0) {
|
|
|
+ GitPullActivity.this.onMsg("Updating remote repository");
|
|
|
+ PushBlobs(filesToPush, localVersion, allDone);
|
|
|
+ } else {
|
|
|
+ GitPullActivity.this.onMsg("Nothing to push");
|
|
|
+ allDone.onResponse(null);
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -308,14 +268,11 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
final GitObject.GitBlob blob = files.peek().getValue();
|
|
|
final OnResponseListener<byte[]> _this = this;
|
|
|
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- WriteFile(filename, localVersion, blob, result);
|
|
|
- logView.append("Done fetching " +files.peek().getValue().GetFilename() +"\n");
|
|
|
- files.pop();
|
|
|
- DownloadNext(files, localVersion, _this, resp);
|
|
|
- }
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> {
|
|
|
+ WriteFile(filename, localVersion, blob, result);
|
|
|
+ logView.append("Done fetching " +files.peek().getValue().GetFilename() +"\n");
|
|
|
+ files.pop();
|
|
|
+ DownloadNext(files, localVersion, _this, resp);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -323,12 +280,7 @@ public class GitPullActivity extends AppCompatActivity {
|
|
|
public void onError(final String msg, Throwable e) {
|
|
|
log.log(Level.SEVERE, msg, e);
|
|
|
|
|
|
- GitPullActivity.this.runOnUiThread(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- logView.append("Error while fetching " +files.peek().getValue().GetFilename() +": " +msg);
|
|
|
- }
|
|
|
- });
|
|
|
+ GitPullActivity.this.runOnUiThread(() -> logView.append("Error while fetching " +files.peek().getValue().GetFilename() +": " +msg));
|
|
|
|
|
|
files.pop();
|
|
|
if (!files.empty()) {
|