From 7469b865b64e8e7f91a749188fc3647cdbd72322 Mon Sep 17 00:00:00 2001 From: zeapo Date: Sun, 19 Oct 2014 22:42:07 +0200 Subject: users get directly onto the ssh-key selection screen rather than having to do it manually --- app/src/main/java/com/zeapo/pwdstore/GitHandler.java | 1 + .../main/java/com/zeapo/pwdstore/PasswordFragment.java | 1 - app/src/main/java/com/zeapo/pwdstore/UserPreference.java | 15 ++++++++++++--- .../com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java | 2 ++ 4 files changed, 15 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java index c0bbfd79..8dd56364 100644 --- a/app/src/main/java/com/zeapo/pwdstore/GitHandler.java +++ b/app/src/main/java/com/zeapo/pwdstore/GitHandler.java @@ -651,6 +651,7 @@ public class GitHandler extends ActionBarActivity { public void onClick(DialogInterface dialog, int id) { try { Intent intent = new Intent(getApplicationContext(), UserPreference.class); + intent.putExtra("operation", "get_ssh_key"); startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE); } catch (Exception e) { System.out.println("Exception caught :("); diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java index 615087c8..2c898cb4 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordFragment.java @@ -82,7 +82,6 @@ public class PasswordFragment extends Fragment{ if (item.getType() == PasswordItem.TYPE_CATEGORY) { passListStack.push((ArrayList) recyclerAdapter.getValues().clone()); scrollPosition.push(recyclerView.getVerticalScrollbarPosition()); - Log.d("FRAG", scrollPosition.peek() + ""); recyclerView.scrollToPosition(0); recyclerAdapter.clear(); recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile())); diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index fa4ee9c9..f811efea 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -41,6 +41,11 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (getIntent() != null) { + if (getIntent().getStringExtra("operation").equals("get_ssh_key")) { + getSshKey(); + } + } getFragmentManager().beginTransaction() .replace(android.R.id.content, new PrefsFragment()).commit(); @@ -63,6 +68,12 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr return super.onOptionsItemSelected(item); } + public void getSshKey() { + Intent intent = new Intent(Intent.ACTION_GET_CONTENT); + intent.setType("*/*"); + startActivityForResult(intent, 1); + } + @Override public boolean onPreferenceClick(Preference pref) { if (pref.getKey().equals("openpgp_key_id")) { @@ -70,9 +81,7 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr intent.putExtra("Operation", "GET_KEY_ID"); startActivityForResult(intent, 0); } else if (pref.getKey().equals("ssh_key")) { - Intent intent = new Intent(Intent.ACTION_GET_CONTENT); - intent.setType("*/*"); - startActivityForResult(intent, 1); + getSshKey(); } return true; } diff --git a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java index eb611995..7a6d1320 100644 --- a/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java +++ b/app/src/main/java/com/zeapo/pwdstore/utils/PasswordRecyclerAdapter.java @@ -89,6 +89,8 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter