summaryrefslogtreecommitdiffstats
path: root/core/java/android/preference
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2011-05-26 13:08:25 -0700
committerAmith Yamasani <yamasani@google.com>2011-05-26 15:20:14 -0700
commit405c1af75607fafdb1d6faf34e13e032e4934787 (patch)
tree4be466a5999293f56beb9d97323eefd189c12d85 /core/java/android/preference
parent1b9b34adf704c2c059ca439ace0c0b67c8c272f3 (diff)
downloadframeworks_base-405c1af75607fafdb1d6faf34e13e032e4934787.zip
frameworks_base-405c1af75607fafdb1d6faf34e13e032e4934787.tar.gz
frameworks_base-405c1af75607fafdb1d6faf34e13e032e4934787.tar.bz2
Manual merge. Preference activity changes to work on smaller tablet screens and phones.
Padding around fragments and to the left of preference items adjusted for different display sizes. Change-Id: I2d29e5525c381092a3f1d2fb1265ce07db893d78
Diffstat (limited to 'core/java/android/preference')
-rw-r--r--core/java/android/preference/Preference.java29
-rw-r--r--core/java/android/preference/PreferenceActivity.java36
-rw-r--r--core/java/android/preference/PreferenceFragment.java10
3 files changed, 30 insertions, 45 deletions
diff --git a/core/java/android/preference/Preference.java b/core/java/android/preference/Preference.java
index 5e1be21..b6d1594 100644
--- a/core/java/android/preference/Preference.java
+++ b/core/java/android/preference/Preference.java
@@ -472,11 +472,15 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
final View layout = layoutInflater.inflate(mLayoutResId, parent, false);
- if (mWidgetLayoutResId != 0) {
- final ViewGroup widgetFrame = (ViewGroup)layout.findViewById(com.android.internal.R.id.widget_frame);
- layoutInflater.inflate(mWidgetLayoutResId, widgetFrame);
+ final ViewGroup widgetFrame = (ViewGroup) layout
+ .findViewById(com.android.internal.R.id.widget_frame);
+ if (widgetFrame != null) {
+ if (mWidgetLayoutResId != 0) {
+ layoutInflater.inflate(mWidgetLayoutResId, widgetFrame);
+ } else {
+ widgetFrame.setVisibility(View.GONE);
+ }
}
-
return layout;
}
@@ -514,14 +518,18 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
}
ImageView imageView = (ImageView) view.findViewById(com.android.internal.R.id.icon);
- if (imageView != null && (mIconResId != 0 || mIcon != null)) {
- if (mIcon == null) {
- mIcon = getContext().getResources().getDrawable(mIconResId);
- }
- if (mIcon != null) {
- imageView.setImageDrawable(mIcon);
+ if (imageView != null) {
+ if (mIconResId != 0 || mIcon != null) {
+ if (mIcon == null) {
+ mIcon = getContext().getResources().getDrawable(mIconResId);
+ }
+ if (mIcon != null) {
+ imageView.setImageDrawable(mIcon);
+ }
}
+ imageView.setVisibility(mIcon != null ? View.VISIBLE : View.GONE);
}
+
if (mShouldDisableView) {
setEnabledStateOnViews(view, isEnabled());
}
@@ -633,6 +641,7 @@ public class Preference implements Comparable<Preference>, OnDependencyChangeLis
public void setIcon(Drawable icon) {
if ((icon == null && mIcon != null) || (icon != null && mIcon != icon)) {
mIcon = icon;
+
notifyChanged();
}
}
diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java
index 15d5898..14e7bed 100644
--- a/core/java/android/preference/PreferenceActivity.java
+++ b/core/java/android/preference/PreferenceActivity.java
@@ -18,9 +18,6 @@ package android.preference;
import com.android.internal.util.XmlUtils;
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
import android.app.ActionBar;
import android.app.Fragment;
import android.app.FragmentBreadCrumbs;
@@ -44,8 +41,8 @@ import android.util.TypedValue;
import android.util.Xml;
import android.view.LayoutInflater;
import android.view.View;
-import android.view.View.OnClickListener;
import android.view.ViewGroup;
+import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.Button;
@@ -58,6 +55,9 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
/**
* This is the base class for an activity to show a hierarchy of preferences
* to the user. Prior to {@link android.os.Build.VERSION_CODES#HONEYCOMB}
@@ -503,12 +503,7 @@ public abstract class PreferenceActivity extends ListActivity implements
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- if (getResources().getConfiguration().isLayoutSizeAtLeast(
- Configuration.SCREENLAYOUT_SIZE_LARGE)) {
- setContentView(com.android.internal.R.layout.preference_list_content_large);
- } else {
- setContentView(com.android.internal.R.layout.preference_list_content);
- }
+ setContentView(com.android.internal.R.layout.preference_list_content);
mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame);
@@ -585,12 +580,7 @@ public abstract class PreferenceActivity extends ListActivity implements
} else {
// If there are no headers, we are in the old "just show a screen
// of preferences" mode.
- if (getResources().getConfiguration().isLayoutSizeAtLeast(
- Configuration.SCREENLAYOUT_SIZE_LARGE)) {
- setContentView(com.android.internal.R.layout.preference_list_content_single_large);
- } else {
- setContentView(com.android.internal.R.layout.preference_list_content_single);
- }
+ setContentView(com.android.internal.R.layout.preference_list_content_single);
mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer);
mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs);
mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE);
@@ -674,17 +664,9 @@ public abstract class PreferenceActivity extends ListActivity implements
* enough.
*/
public boolean onIsMultiPane() {
- Configuration config = getResources().getConfiguration();
- if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK)
- == Configuration.SCREENLAYOUT_SIZE_XLARGE) {
- return true;
- }
- if ((config.screenLayout&Configuration.SCREENLAYOUT_SIZE_MASK)
- == Configuration.SCREENLAYOUT_SIZE_LARGE
- && config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- return true;
- }
- return false;
+ boolean preferMultiPane = getResources().getBoolean(
+ com.android.internal.R.bool.preferences_prefer_dual_pane);
+ return preferMultiPane;
}
/**
diff --git a/core/java/android/preference/PreferenceFragment.java b/core/java/android/preference/PreferenceFragment.java
index 7511e14..9d46b7a 100644
--- a/core/java/android/preference/PreferenceFragment.java
+++ b/core/java/android/preference/PreferenceFragment.java
@@ -152,14 +152,8 @@ public abstract class PreferenceFragment extends Fragment implements
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
- if (getResources().getConfiguration().isLayoutSizeAtLeast(
- Configuration.SCREENLAYOUT_SIZE_LARGE)) {
- return inflater.inflate(com.android.internal.R.layout.preference_list_fragment_large,
- container, false);
- } else {
- return inflater.inflate(com.android.internal.R.layout.preference_list_fragment,
- container, false);
- }
+ return inflater.inflate(com.android.internal.R.layout.preference_list_fragment, container,
+ false);
}
@Override