diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/app/FragmentBreadCrumbs.java | 33 | ||||
-rw-r--r-- | core/java/android/preference/PreferenceActivity.java | 21 | ||||
-rw-r--r-- | core/java/android/preference/PreferenceFrameLayout.java | 6 | ||||
-rw-r--r-- | core/res/res/layout/fragment_bread_crumb_item.xml | 30 | ||||
-rw-r--r-- | core/res/res/layout/preference_list_content.xml | 33 | ||||
-rw-r--r-- | core/res/res/layout/preference_list_fragment.xml | 2 | ||||
-rw-r--r-- | core/res/res/values/styles.xml | 2 |
7 files changed, 97 insertions, 30 deletions
diff --git a/core/java/android/app/FragmentBreadCrumbs.java b/core/java/android/app/FragmentBreadCrumbs.java index 139095f..8d76ffe 100644 --- a/core/java/android/app/FragmentBreadCrumbs.java +++ b/core/java/android/app/FragmentBreadCrumbs.java @@ -41,6 +41,7 @@ public class FragmentBreadCrumbs extends ViewGroup Activity mActivity; LayoutInflater mInflater; LinearLayout mContainer; + int mMaxVisible = -1; // Hahah BackStackRecord mTopEntry; @@ -74,6 +75,14 @@ public class FragmentBreadCrumbs extends ViewGroup } /** + * The maximum number of crumbs to show. + * @hide + */ + public void setMaxVisible(int visibleCrumbs) { + mMaxVisible = visibleCrumbs; + } + + /** * Set a custom title for the bread crumbs. This will be the first entry * shown at the left, representing the root of the bread crumbs. If the * title is null, it will not be shown. @@ -160,17 +169,17 @@ public class FragmentBreadCrumbs extends ViewGroup } } if (viewI >= numViews) { - View item = mInflater.inflate( + final View item = mInflater.inflate( com.android.internal.R.layout.fragment_bread_crumb_item, this, false); - TextView text = (TextView)item.findViewById(com.android.internal.R.id.title); + final TextView text = (TextView) item.findViewById(com.android.internal.R.id.title); text.setText(bse.getBreadCrumbTitle()); - item.setTag(bse); + text.setTag(bse); if (viewI == 0) { - text.setCompoundDrawables(null, null, null, null); + item.findViewById(com.android.internal.R.id.left_icon).setVisibility(View.GONE); } mContainer.addView(item); - item.setOnClickListener(mOnClickListener); + text.setOnClickListener(mOnClickListener); } } int viewI = mTopEntry != null ? numEntries + 1 : numEntries; @@ -179,6 +188,20 @@ public class FragmentBreadCrumbs extends ViewGroup mContainer.removeViewAt(numViews-1); numViews--; } + // Adjust the visibility and availability of the bread crumbs and divider + for (int i = 0; i < numViews; i++) { + final View child = mContainer.getChildAt(i); + // Disable the last one + child.findViewById(com.android.internal.R.id.title).setEnabled(i < numViews - 1); + if (mMaxVisible > 0) { + // Make only the last mMaxVisible crumbs visible + child.setVisibility(i < numViews - mMaxVisible ? View.GONE : View.VISIBLE); + final View leftIcon = child.findViewById(com.android.internal.R.id.left_icon); + // Remove the divider for all but the last mMaxVisible - 1 + leftIcon.setVisibility(i > numViews - mMaxVisible && i != 0 ? View.VISIBLE + : View.GONE); + } + } } private OnClickListener mOnClickListener = new OnClickListener() { diff --git a/core/java/android/preference/PreferenceActivity.java b/core/java/android/preference/PreferenceActivity.java index aedbfca..6172ce9 100644 --- a/core/java/android/preference/PreferenceActivity.java +++ b/core/java/android/preference/PreferenceActivity.java @@ -171,7 +171,7 @@ public abstract class PreferenceActivity extends ListActivity implements private FrameLayout mListFooter; - private View mPrefsContainer; + private ViewGroup mPrefsContainer; private FragmentBreadCrumbs mFragmentBreadCrumbs; @@ -491,7 +491,7 @@ public abstract class PreferenceActivity extends ListActivity implements setContentView(com.android.internal.R.layout.preference_list_content); mListFooter = (FrameLayout)findViewById(com.android.internal.R.id.list_footer); - mPrefsContainer = findViewById(com.android.internal.R.id.prefs); + mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs_frame); boolean hidingHeaders = onIsHidingHeaders(); mSinglePane = hidingHeaders || !onIsMultiPane(); String initialFragment = getIntent().getStringExtra(EXTRA_SHOW_FRAGMENT); @@ -559,7 +559,7 @@ public abstract class PreferenceActivity extends ListActivity implements // of preferences" mode. setContentView(com.android.internal.R.layout.preference_list_content_single); mListFooter = (FrameLayout) findViewById(com.android.internal.R.id.list_footer); - mPrefsContainer = findViewById(com.android.internal.R.id.prefs); + mPrefsContainer = (ViewGroup) findViewById(com.android.internal.R.id.prefs); mPreferenceManager = new PreferenceManager(this, FIRST_REQUEST_CODE); mPreferenceManager.setOnPreferenceTreeClickListener(this); } @@ -990,13 +990,16 @@ public abstract class PreferenceActivity extends ListActivity implements */ public void showBreadCrumbs(CharSequence title, CharSequence shortTitle) { if (mFragmentBreadCrumbs == null) { - mFragmentBreadCrumbs = new FragmentBreadCrumbs(this); - mFragmentBreadCrumbs.setActivity(this); - - ActionBar actionBar = getActionBar(); - if (actionBar != null) { - actionBar.setCustomNavigationMode(mFragmentBreadCrumbs); + mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(android.R.id.title); + if (mFragmentBreadCrumbs == null) { + mFragmentBreadCrumbs = new FragmentBreadCrumbs(this); + ActionBar actionBar = getActionBar(); + if (actionBar != null) { + actionBar.setCustomNavigationMode(mFragmentBreadCrumbs); + } } + mFragmentBreadCrumbs.setMaxVisible(2); + mFragmentBreadCrumbs.setActivity(this); } mFragmentBreadCrumbs.setTitle(title, shortTitle); } diff --git a/core/java/android/preference/PreferenceFrameLayout.java b/core/java/android/preference/PreferenceFrameLayout.java index 4c737b5..75372aa 100644 --- a/core/java/android/preference/PreferenceFrameLayout.java +++ b/core/java/android/preference/PreferenceFrameLayout.java @@ -16,13 +16,12 @@ package android.preference; +import android.app.FragmentBreadCrumbs; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import android.view.View; -import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; -import android.widget.FrameLayout.LayoutParams; /** * @hide @@ -36,7 +35,7 @@ public class PreferenceFrameLayout extends FrameLayout { private final int mBorderBottom; private final int mBorderLeft; private final int mBorderRight; - private boolean mPaddingApplied = false; + private boolean mPaddingApplied; public PreferenceFrameLayout(Context context) { this(context, null); @@ -70,7 +69,6 @@ public class PreferenceFrameLayout extends FrameLayout { com.android.internal.R.styleable.PreferenceFrameLayout_borderRight, defaultRightPadding); - a.recycle(); } diff --git a/core/res/res/layout/fragment_bread_crumb_item.xml b/core/res/res/layout/fragment_bread_crumb_item.xml index 517c570..e97508f 100644 --- a/core/res/res/layout/fragment_bread_crumb_item.xml +++ b/core/res/res/layout/fragment_bread_crumb_item.xml @@ -13,14 +13,28 @@ See the License for the specific language governing permissions and limitations under the License. --> - -<TextView xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/title" +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="match_parent" - android:gravity="center_vertical" - android:textAppearance="?android:attr/textAppearanceMedium" - android:drawableLeft="@drawable/nav_divider" - android:paddingLeft="12dp" - android:drawablePadding="12dp" + android:orientation="horizontal" + > + <ImageView + android:id="@android:id/left_icon" + android:src="@drawable/nav_divider" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_marginTop="8dip" + android:layout_marginBottom="8dip" /> + + <TextView + android:id="@+id/title" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:paddingLeft="8dip" + android:paddingRight="8dip" + android:gravity="center_vertical" + android:textAppearance="?android:attr/textAppearanceMedium" + android:background="?android:attr/selectableItemBackground" + /> +</LinearLayout>
\ No newline at end of file diff --git a/core/res/res/layout/preference_list_content.xml b/core/res/res/layout/preference_list_content.xml index fd488bd..e7783da 100644 --- a/core/res/res/layout/preference_list_content.xml +++ b/core/res/res/layout/preference_list_content.xml @@ -56,7 +56,8 @@ </LinearLayout> - <android.preference.PreferenceFrameLayout android:id="@+id/prefs" + <LinearLayout + android:id="@+id/prefs_frame" android:layout_width="0px" android:layout_height="match_parent" android:layout_weight="20" @@ -65,7 +66,35 @@ android:layout_marginTop="16dp" android:layout_marginBottom="16dp" android:background="?attr/preferencePanelBackground" - android:visibility="gone" /> + android:orientation="vertical" + android:visibility="gone" > + + <!-- Breadcrumb inserted here --> + <android.app.FragmentBreadCrumbs + android:id="@android:id/title" + android:layout_height="72dip" + android:layout_width="match_parent" + android:paddingTop="16dip" + android:paddingBottom="8dip" + android:gravity="center_vertical|left" + android:layout_marginLeft="48dip" + android:layout_marginRight="48dip" + /> + + <ImageView + android:layout_width="match_parent" + android:layout_height="1dip" + android:paddingLeft="32dip" + android:paddingRight="32dip" + android:src="#404040" + /> + <android.preference.PreferenceFrameLayout android:id="@+id/prefs" + android:layout_width="match_parent" + android:layout_height="0dip" + android:layout_weight="1" + android:layout_marginTop="-1dip" + /> + </LinearLayout> </LinearLayout> <RelativeLayout android:id="@+id/button_bar" diff --git a/core/res/res/layout/preference_list_fragment.xml b/core/res/res/layout/preference_list_fragment.xml index 69fb73a..393cecf 100644 --- a/core/res/res/layout/preference_list_fragment.xml +++ b/core/res/res/layout/preference_list_fragment.xml @@ -28,7 +28,7 @@ android:layout_width="match_parent" android:layout_height="0px" android:layout_weight="1" - android:paddingTop="48dip" + android:paddingTop="0dip" android:paddingBottom="48dip" android:paddingLeft="32dip" android:paddingRight="32dip" diff --git a/core/res/res/values/styles.xml b/core/res/res/values/styles.xml index c00e59a..fd51c0b 100644 --- a/core/res/res/values/styles.xml +++ b/core/res/res/values/styles.xml @@ -2070,7 +2070,7 @@ </style> <style name="Widget.Holo.PreferenceFrameLayout"> - <item name="android:borderTop">48dip</item> + <item name="android:borderTop">0dip</item> <item name="android:borderBottom">48dip</item> <item name="android:borderLeft">32dip</item> <item name="android:borderRight">32dip</item> |