diff --git a/app/src/main/java/org/mifos/mobilebanking/ui/activities/SettingsActivity.java b/app/src/main/java/org/mifos/mobilebanking/ui/activities/SettingsActivity.java index 48065c0e2..43e952276 100644 --- a/app/src/main/java/org/mifos/mobilebanking/ui/activities/SettingsActivity.java +++ b/app/src/main/java/org/mifos/mobilebanking/ui/activities/SettingsActivity.java @@ -2,13 +2,17 @@ import android.content.Intent; import android.os.Bundle; +import android.support.v4.app.ActivityCompat; import org.mifos.mobilebanking.R; import org.mifos.mobilebanking.ui.activities.base.BaseActivity; import org.mifos.mobilebanking.ui.fragments.SettingsFragment; +import org.mifos.mobilebanking.utils.Constants; public class SettingsActivity extends BaseActivity { + private boolean hasSettingsChanged; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -16,12 +20,19 @@ protected void onCreate(Bundle savedInstanceState) { setToolbarTitle(getString(R.string.settings)); showBackButton(); replaceFragment(SettingsFragment.newInstance(), false, R.id.container); + if (getIntent().hasExtra(Constants.HAS_SETTINGS_CHANGED)) { + hasSettingsChanged = getIntent().getBooleanExtra(Constants.HAS_SETTINGS_CHANGED, + false); + } } @Override public void onBackPressed() { super.onBackPressed(); - Intent i = new Intent(this, HomeActivity.class); - startActivity(i); + if (hasSettingsChanged) { + ActivityCompat.finishAffinity(this); + Intent i = new Intent(this, HomeActivity.class); + startActivity(i); + } } } diff --git a/app/src/main/java/org/mifos/mobilebanking/ui/fragments/SettingsFragment.java b/app/src/main/java/org/mifos/mobilebanking/ui/fragments/SettingsFragment.java index 60a7f481d..d78dbaaec 100644 --- a/app/src/main/java/org/mifos/mobilebanking/ui/fragments/SettingsFragment.java +++ b/app/src/main/java/org/mifos/mobilebanking/ui/fragments/SettingsFragment.java @@ -11,6 +11,7 @@ import org.mifos.mobilebanking.R; import org.mifos.mobilebanking.utils.ConfigurationPreference; import org.mifos.mobilebanking.utils.ConfigurationDialogFragmentCompat; +import org.mifos.mobilebanking.utils.Constants; import org.mifos.mobilebanking.utils.LanguageHelper; /** @@ -68,7 +69,9 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin if (preference instanceof ListPreference) { ListPreference listPreference = (ListPreference) preference; LanguageHelper.setLocale(getContext(), listPreference.getValue()); - startActivity(new Intent(getActivity(), getActivity().getClass())); + Intent intent = new Intent(getActivity(), getActivity().getClass()); + intent.putExtra(Constants.HAS_SETTINGS_CHANGED, true); + startActivity(intent); getActivity().finish(); } } diff --git a/app/src/main/java/org/mifos/mobilebanking/utils/Constants.java b/app/src/main/java/org/mifos/mobilebanking/utils/Constants.java index ce144178f..eb58774c3 100644 --- a/app/src/main/java/org/mifos/mobilebanking/utils/Constants.java +++ b/app/src/main/java/org/mifos/mobilebanking/utils/Constants.java @@ -116,4 +116,6 @@ public class Constants { public static final String INDEX = "index"; public static final String DATE_PICKER_TYPE = "datePickerType"; + + public static final String HAS_SETTINGS_CHANGED = "hasSettingsChanged"; } \ No newline at end of file