users get directly onto the ssh-key selection screen rather than having to do it manually

This commit is contained in:
zeapo 2014-10-19 22:42:07 +02:00
parent 01a1522194
commit 7469b865b6
4 changed files with 15 additions and 4 deletions

View file

@ -651,6 +651,7 @@ public class GitHandler extends ActionBarActivity {
public void onClick(DialogInterface dialog, int id) { public void onClick(DialogInterface dialog, int id) {
try { try {
Intent intent = new Intent(getApplicationContext(), UserPreference.class); Intent intent = new Intent(getApplicationContext(), UserPreference.class);
intent.putExtra("operation", "get_ssh_key");
startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE); startActivityForResult(intent, GET_SSH_KEY_FROM_CLONE);
} catch (Exception e) { } catch (Exception e) {
System.out.println("Exception caught :("); System.out.println("Exception caught :(");

View file

@ -82,7 +82,6 @@ public class PasswordFragment extends Fragment{
if (item.getType() == PasswordItem.TYPE_CATEGORY) { if (item.getType() == PasswordItem.TYPE_CATEGORY) {
passListStack.push((ArrayList<PasswordItem>) recyclerAdapter.getValues().clone()); passListStack.push((ArrayList<PasswordItem>) recyclerAdapter.getValues().clone());
scrollPosition.push(recyclerView.getVerticalScrollbarPosition()); scrollPosition.push(recyclerView.getVerticalScrollbarPosition());
Log.d("FRAG", scrollPosition.peek() + "");
recyclerView.scrollToPosition(0); recyclerView.scrollToPosition(0);
recyclerAdapter.clear(); recyclerAdapter.clear();
recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile())); recyclerAdapter.addAll(PasswordRepository.getPasswords(item.getFile()));

View file

@ -41,6 +41,11 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (getIntent() != null) {
if (getIntent().getStringExtra("operation").equals("get_ssh_key")) {
getSshKey();
}
}
getFragmentManager().beginTransaction() getFragmentManager().beginTransaction()
.replace(android.R.id.content, new PrefsFragment()).commit(); .replace(android.R.id.content, new PrefsFragment()).commit();
@ -63,6 +68,12 @@ public class UserPreference extends ActionBarActivity implements Preference.OnPr
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
public void getSshKey() {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
startActivityForResult(intent, 1);
}
@Override @Override
public boolean onPreferenceClick(Preference pref) { public boolean onPreferenceClick(Preference pref) {
if (pref.getKey().equals("openpgp_key_id")) { 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"); intent.putExtra("Operation", "GET_KEY_ID");
startActivityForResult(intent, 0); startActivityForResult(intent, 0);
} else if (pref.getKey().equals("ssh_key")) { } else if (pref.getKey().equals("ssh_key")) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT); getSshKey();
intent.setType("*/*");
startActivityForResult(intent, 1);
} }
return true; return true;
} }

View file

@ -89,6 +89,8 @@ public class PasswordRecyclerAdapter extends RecyclerView.Adapter<PasswordRecycl
listener.onFragmentInteraction(pass); listener.onFragmentInteraction(pass);
} }
}); });
} }
// Return the size of your dataset (invoked by the layout manager) // Return the size of your dataset (invoked by the layout manager)