Fix titles for PreferenceFragment screens
The title of PreferenceFragment screens were not being displayed
properly after rework to Settings menu. This patch fixes the issue.
Change-Id: Ic4ebf4e049b215ce4e588c9b2787072836fb5863
diff --git a/res/layout-port/autofill_settings_fragment.xml b/res/layout-port/autofill_settings_fragment.xml
index 9f26fd9..0916dc6 100644
--- a/res/layout-port/autofill_settings_fragment.xml
+++ b/res/layout-port/autofill_settings_fragment.xml
@@ -16,6 +16,10 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:paddingStart="?android:attr/listPreferredItemPaddingStart"
+ android:paddingLeft="?android:attr/listPreferredItemPaddingStart"
+ android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
+ android:paddingRight="?android:attr/listPreferredItemPaddingEnd"
android:orientation="vertical">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
diff --git a/src/com/android/browser/AutoFillSettingsFragment.java b/src/com/android/browser/AutoFillSettingsFragment.java
index 5a97ede..d0ca946 100644
--- a/src/com/android/browser/AutoFillSettingsFragment.java
+++ b/src/com/android/browser/AutoFillSettingsFragment.java
@@ -20,6 +20,7 @@
import com.android.browser.R;
+import android.app.ActionBar;
import android.app.Fragment;
import android.content.Context;
import android.os.Bundle;
@@ -124,6 +125,16 @@
}
@Override
+ public void onResume() {
+ super.onResume();
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.pref_general_autofill_title);
+ bar.setDisplayHomeAsUpEnabled(false);
+ }
+ }
+
+ @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.autofill_profile_editor, menu);
mSaveMenuItem = menu.findItem(R.id.autofill_profile_editor_save_profile_menu_id);
diff --git a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
index 312f813..4daecd1 100644
--- a/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AccessibilityPreferencesFragment.java
@@ -16,6 +16,7 @@
package com.android.browser.preferences;
+import android.app.ActionBar;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
@@ -68,6 +69,16 @@
*/
}
+ @Override
+ public void onResume() {
+ super.onResume();
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.pref_accessibility_title);
+ bar.setDisplayHomeAsUpEnabled(false);
+ }
+ }
+
private CharSequence getVisualDefaultZoomName(String enumName) {
Resources res = getActivity().getResources();
CharSequence[] visualNames = res.getTextArray(R.array.pref_default_zoom_choices);
diff --git a/src/com/android/browser/preferences/DebugPreferencesFragment.java b/src/com/android/browser/preferences/DebugPreferencesFragment.java
index 3a0b32f..413e463 100644
--- a/src/com/android/browser/preferences/DebugPreferencesFragment.java
+++ b/src/com/android/browser/preferences/DebugPreferencesFragment.java
@@ -16,6 +16,7 @@
package com.android.browser.preferences;
+import android.app.ActionBar;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
@@ -39,4 +40,14 @@
public boolean onPreferenceClick(Preference preference) {
return false;
}
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.pref_development_title);
+ bar.setDisplayHomeAsUpEnabled(false);
+ }
+ }
}
diff --git a/src/com/android/browser/preferences/GeneralPreferencesFragment.java b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
index 6937ac5..e7850de 100644
--- a/src/com/android/browser/preferences/GeneralPreferencesFragment.java
+++ b/src/com/android/browser/preferences/GeneralPreferencesFragment.java
@@ -16,6 +16,7 @@
package com.android.browser.preferences;
+import android.app.ActionBar;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
@@ -193,6 +194,12 @@
}
void refreshUi() {
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.menu_preferences);
+ bar.setDisplayHomeAsUpEnabled(true);
+ }
+
PreferenceScreen autoFillSettings =
(PreferenceScreen)findPreference(PreferenceKeys.PREF_AUTOFILL_PROFILE);
autoFillSettings.setDependency(PreferenceKeys.PREF_AUTOFILL_ENABLED);
diff --git a/src/com/android/browser/preferences/WebsiteSettingsFragment.java b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
index 601305e..259a3e1 100644
--- a/src/com/android/browser/preferences/WebsiteSettingsFragment.java
+++ b/src/com/android/browser/preferences/WebsiteSettingsFragment.java
@@ -16,6 +16,7 @@
package com.android.browser.preferences;
+import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
@@ -767,6 +768,11 @@
public void onResume() {
super.onResume();
mAdapter.askForOrigins();
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.pref_extras_website_settings);
+ bar.setDisplayHomeAsUpEnabled(false);
+ }
}
private void finish() {