mirror of
https://github.com/android-password-store/Android-Password-Store.git
synced 2025-09-06 17:04:09 +02:00
a simple solution to resolve #13
This commit is contained in:
parent
240bb9cd67
commit
2c929441a7
|
@ -10,19 +10,11 @@ import android.content.SharedPreferences;
|
|||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.JSchException;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.zeapo.pwdstore.crypto.PgpHandler;
|
||||
import com.zeapo.pwdstore.utils.PasswordItem;
|
||||
import com.zeapo.pwdstore.utils.PasswordRepository;
|
||||
|
@ -30,12 +22,6 @@ import com.zeapo.pwdstore.utils.PasswordRepository;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.eclipse.jgit.api.CommitCommand;
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.eclipse.jgit.transport.JschConfigSessionFactory;
|
||||
import org.eclipse.jgit.transport.OpenSshConfig;
|
||||
import org.eclipse.jgit.transport.SshSessionFactory;
|
||||
import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
|
||||
import org.eclipse.jgit.util.FS;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -91,6 +77,14 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||
int id = item.getItemId();
|
||||
Intent intent;
|
||||
|
||||
AlertDialog.Builder initBefore = new AlertDialog.Builder(this)
|
||||
.setMessage("Please clone or create a new repository below before trying to add a password or any synchronization operation.")
|
||||
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
}
|
||||
});
|
||||
|
||||
switch (id) {
|
||||
case R.id.user_pref:
|
||||
try {
|
||||
|
@ -104,6 +98,11 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||
return true;
|
||||
|
||||
case R.id.menu_add_password:
|
||||
if (PasswordRepository.isInitialized()) {
|
||||
initBefore.show();
|
||||
break;
|
||||
}
|
||||
|
||||
createPassword(getCurrentFocus());
|
||||
break;
|
||||
|
||||
|
@ -111,6 +110,11 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||
// break;
|
||||
|
||||
case R.id.git_push:
|
||||
if (PasswordRepository.isInitialized()) {
|
||||
initBefore.show();
|
||||
break;
|
||||
}
|
||||
|
||||
intent = new Intent(this, GitHandler.class);
|
||||
intent.putExtra("Operation", GitHandler.REQUEST_PUSH);
|
||||
startActivityForResult(intent, GitHandler.REQUEST_PUSH);
|
||||
|
@ -118,6 +122,11 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
|
|||
return true;
|
||||
|
||||
case R.id.git_pull:
|
||||
if (PasswordRepository.isInitialized()) {
|
||||
initBefore.show();
|
||||
break;
|
||||
}
|
||||
|
||||
intent = new Intent(this, GitHandler.class);
|
||||
intent.putExtra("Operation", GitHandler.REQUEST_PULL);
|
||||
startActivityForResult(intent, GitHandler.REQUEST_PULL);
|
||||
|
|
|
@ -26,6 +26,7 @@ import static java.util.Collections.sort;
|
|||
public class PasswordRepository {
|
||||
|
||||
private static Repository repository;
|
||||
private static boolean initialized = false;
|
||||
|
||||
protected PasswordRepository(){ }
|
||||
|
||||
|
@ -37,7 +38,7 @@ public class PasswordRepository {
|
|||
.readEnvironment()
|
||||
.findGitDir()
|
||||
.build();
|
||||
|
||||
initialized = true;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -46,6 +47,10 @@ public class PasswordRepository {
|
|||
return repository;
|
||||
}
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return initialized;
|
||||
}
|
||||
|
||||
public static void createRepository(File localDir) {
|
||||
localDir.delete();
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
<item android:id="@+id/referesh"
|
||||
android:title="Refresh list"
|
||||
android:showAsAction="ifRoom"
|
||||
android:showAsAction="never"
|
||||
android:icon="@drawable/ico_sync"/>
|
||||
|
||||
<item android:id="@+id/user_pref"
|
||||
|
|
Loading…
Reference in a new issue