Merge "Move the breadcrumbs to the right pane."
This commit is contained in:
committed by
Android (Google) Code Review
commit
9f02357a82
@@ -41,6 +41,7 @@ public class FragmentBreadCrumbs extends ViewGroup
|
||||
Activity mActivity;
|
||||
LayoutInflater mInflater;
|
||||
LinearLayout mContainer;
|
||||
int mMaxVisible = -1;
|
||||
|
||||
// Hahah
|
||||
BackStackRecord mTopEntry;
|
||||
@@ -73,6 +74,14 @@ public class FragmentBreadCrumbs extends ViewGroup
|
||||
setLayoutTransition(new LayoutTransition());
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -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() {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user