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

Commit f680c9d3 authored by Katherine Kuan's avatar Katherine Kuan Committed by Android (Google) Code Review
Browse files

Merge "Use text (instead of icons) for action bar tabs on tablet"

parents 2ca5a25a aaadf939
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
    private final MyTabListener mTabListener = new MyTabListener();

    private boolean mShowHomeIcon;
    private boolean mShowTabsAsText;

    public enum TabState {
        GROUPS,
@@ -98,7 +99,8 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
    private static final TabState DEFAULT_TAB = TabState.ALL;
    private TabState mCurrentTab = DEFAULT_TAB;

    public ActionBarAdapter(Context context, Listener listener, ActionBar actionBar) {
    public ActionBarAdapter(Context context, Listener listener, ActionBar actionBar,
            boolean isUsingTwoPanes) {
        mContext = context;
        mListener = listener;
        mActionBar = actionBar;
@@ -106,6 +108,9 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {

        mShowHomeIcon = mContext.getResources().getBoolean(R.bool.show_home_icon);

        // On wide screens, show the tabs as text (instead of icons)
        mShowTabsAsText = isUsingTwoPanes;

        // Set up search view.
        View customSearchView = LayoutInflater.from(mActionBar.getThemedContext()).inflate(
                R.layout.custom_action_bar, null);
@@ -153,12 +158,16 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
        mListener = listener;
    }

    private void addTab(TabState tabState, int icon, int contentDescription) {
    private void addTab(TabState tabState, int icon, int description) {
        final Tab tab = mActionBar.newTab();
        tab.setTag(tabState);
        tab.setIcon(icon);
        tab.setContentDescription(contentDescription);
        tab.setTabListener(mTabListener);
        if (mShowTabsAsText) {
            tab.setText(description);
        } else {
            tab.setIcon(icon);
            tab.setContentDescription(description);
        }
        mActionBar.addTab(tab);
    }

+4 −3
Original line number Diff line number Diff line
@@ -317,7 +317,8 @@ public class PeopleActivity extends ContactsActivity
        final FragmentTransaction transaction = fragmentManager.beginTransaction();

        // Prepare the fragments which are used both on 1-pane and on 2-pane.
        if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this);
        if (isUsingTwoPanes) {
            mFavoritesFragment = getFragment(R.id.favorites_fragment);
            mAllFragment = getFragment(R.id.all_fragment);
            mGroupsFragment = getFragment(R.id.groups_fragment);
@@ -367,7 +368,7 @@ public class PeopleActivity extends ContactsActivity
        transaction.hide(mAllFragment);
        transaction.hide(mGroupsFragment);

        if (PhoneCapabilityTester.isUsingTwoPanes(this)) {
        if (isUsingTwoPanes) {
            // Prepare 2-pane only fragments/views...

            // Container views for fragments
@@ -410,7 +411,7 @@ public class PeopleActivity extends ContactsActivity
        }

        // Configure action bar
        mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar());
        mActionBarAdapter = new ActionBarAdapter(this, this, getActionBar(), isUsingTwoPanes);
        mActionBarAdapter.initialize(savedState, mRequest);

        invalidateOptionsMenuIfNeeded();