Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c9f519f authored by Amith Yamasani's avatar Amith Yamasani
Browse files

Move the breadcrumbs to the right pane.

Bug: 3236568
parent 3345f27f
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -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() {
+12 −9
Original line number Diff line number Diff line
@@ -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);
        }
@@ -989,15 +989,18 @@ public abstract class PreferenceActivity extends ListActivity implements
     * {@link android.app.FragmentBreadCrumbs} for more information.
     */
    public void showBreadCrumbs(CharSequence title, CharSequence shortTitle) {
        if (mFragmentBreadCrumbs == null) {
            mFragmentBreadCrumbs = (FragmentBreadCrumbs) findViewById(android.R.id.title);
            if (mFragmentBreadCrumbs == null) {
                mFragmentBreadCrumbs = new FragmentBreadCrumbs(this);
            mFragmentBreadCrumbs.setActivity(this);

                ActionBar actionBar = getActionBar();
                if (actionBar != null) {
                    actionBar.setCustomNavigationMode(mFragmentBreadCrumbs);
                }
            }
            mFragmentBreadCrumbs.setMaxVisible(2);
            mFragmentBreadCrumbs.setActivity(this);
        }
        mFragmentBreadCrumbs.setTitle(title, shortTitle);
    }

+2 −4
Original line number Diff line number Diff line
@@ -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();
    }

+22 −8
Original line number Diff line number Diff line
@@ -13,14 +13,28 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        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 xmlns:android="http://schemas.android.com/apk/res/android"
    <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:drawableLeft="@drawable/nav_divider"
        android:paddingLeft="12dp"
        android:drawablePadding="12dp"
            android:background="?android:attr/selectableItemBackground"
            />
</LinearLayout>
 No newline at end of file
+31 −2
Original line number Diff line number Diff line
@@ -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"
Loading