From 835bbc01dc7a76f71702ccb8a07b19558285327c Mon Sep 17 00:00:00 2001 From: Zeapo Date: Thu, 7 Aug 2014 00:15:07 +0100 Subject: use home button to return from preferences --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.java | 6 +----- .../main/java/com/zeapo/pwdstore/UserPreference.java | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'app/src') diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java index f49a7dca..374163a9 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.java @@ -78,6 +78,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI System.out.println("Exception caught :("); e.printStackTrace(); } + this.leftActivity = true; return true; case R.id.menu_add_password: @@ -91,11 +92,6 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI refreshListAdapter(); return true; - - case android.R.id.home: - getFragmentManager().popBackStack(); - return true; - default: break; } diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java index a0c5d49c..6a3967d1 100644 --- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.java +++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.java @@ -2,6 +2,7 @@ package com.zeapo.pwdstore; import android.os.Bundle; import android.preference.PreferenceActivity; +import android.view.MenuItem; public class UserPreference extends PreferenceActivity { @@ -12,4 +13,20 @@ public class UserPreference extends PreferenceActivity { getActionBar().setDisplayHomeAsUpEnabled(true); } + + + @Override + public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + switch (id) { + case android.R.id.home: + setResult(RESULT_OK); + finish(); + return true; + } + return super.onOptionsItemSelected(item); + } } -- cgit v1.2.3