aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-12-03 12:33:32 +0100
committeriNPUTmice <daniel@gultsch.de>2014-12-03 12:33:32 +0100
commita38005ec89d8410e762469d7b88d9b7b07abe774 (patch)
treeb6a6ca4356fa78859f5080e37788f280d1df5daf /src/main
parent9e97529b3d902e469804b5c35a22ee9825c9f19d (diff)
fixed #544
Diffstat (limited to '')
-rw-r--r--src/main/java/eu/siacs/conversations/ui/SettingsFragment.java52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/SettingsFragment.java b/src/main/java/eu/siacs/conversations/ui/SettingsFragment.java
index 7e1c3698..e4185abc 100644
--- a/src/main/java/eu/siacs/conversations/ui/SettingsFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/SettingsFragment.java
@@ -1,10 +1,51 @@
package eu.siacs.conversations.ui;
-import eu.siacs.conversations.R;
+import android.app.Dialog;
import android.os.Bundle;
+import android.preference.Preference;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.ViewParent;
+import android.widget.FrameLayout;
+import android.widget.LinearLayout;
+
+import eu.siacs.conversations.R;
public class SettingsFragment extends PreferenceFragment {
+
+ //http://stackoverflow.com/questions/16374820/action-bar-home-button-not-functional-with-nested-preferencescreen/16800527#16800527
+ private void initializeActionBar(PreferenceScreen preferenceScreen) {
+ final Dialog dialog = preferenceScreen.getDialog();
+
+ if (dialog != null) {
+ View homeBtn = dialog.findViewById(android.R.id.home);
+
+ if (homeBtn != null) {
+ View.OnClickListener dismissDialogClickListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ dialog.dismiss();
+ }
+ };
+
+ ViewParent homeBtnContainer = homeBtn.getParent();
+
+ if (homeBtnContainer instanceof FrameLayout) {
+ ViewGroup containerParent = (ViewGroup) homeBtnContainer.getParent();
+ if (containerParent instanceof LinearLayout) {
+ ((LinearLayout) containerParent).setOnClickListener(dismissDialogClickListener);
+ } else {
+ ((FrameLayout) homeBtnContainer).setOnClickListener(dismissDialogClickListener);
+ }
+ } else {
+ homeBtn.setOnClickListener(dismissDialogClickListener);
+ }
+ }
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -12,4 +53,13 @@ public class SettingsFragment extends PreferenceFragment {
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
}
+
+ @Override
+ public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) {
+ super.onPreferenceTreeClick(preferenceScreen, preference);
+ if (preference instanceof PreferenceScreen) {
+ initializeActionBar((PreferenceScreen) preference);
+ }
+ return false;
+ }
}