diff options
author | knuthy <knuthy@gmail.com> | 2014-09-29 21:47:29 +0200 |
---|---|---|
committer | knuthy <knuthy@gmail.com> | 2014-09-29 21:47:29 +0200 |
commit | 2c929441a791889b9fdd2342702118563442ef7d (patch) | |
tree | f3359490e843370d45ddd3303501eaffc30ac069 /app/src | |
parent | 240bb9cd670857018e00c190370caa2c75dc392b (diff) |
a simple solution to resolve #13
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 39 | ||||
-rw-r--r-- | app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java | 7 | ||||
-rw-r--r-- | app/src/main/res/menu/pwdstore.xml | 2 |
3 files changed, 31 insertions, 17 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index 4fadb65e..4d3ed8ee 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -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); diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java index 289f9f43..3e40d4b9 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRepository.java @@ -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(); diff --git a/app/src/main/res/menu/pwdstore.xml b/app/src/main/res/menu/pwdstore.xml index 65bc0272..a3f44f73 100644 --- a/app/src/main/res/menu/pwdstore.xml +++ b/app/src/main/res/menu/pwdstore.xml @@ -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" |