From dc0bba648d98d5f7fe78b1cb5b8c1c05641e8a88 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Mon, 12 May 2014 18:30:51 -0700 Subject: Make ActionBar scroll together with other lists * Refactor PanelSlideListener into its own member variable to make the code cleaner * Offset the ActionBar appropriately in onPanelSlide so that it appears to be sliding together with the rest of the list Bug: 14234101 Change-Id: I7060f015ed72b5d0ece7069e50590b569b729142 --- res/layout/lists_fragment.xml | 2 +- src/com/android/dialer/list/ListsFragment.java | 73 ++++++++++++++++---------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/res/layout/lists_fragment.xml b/res/layout/lists_fragment.xml index f97b33670..d75095aaf 100644 --- a/res/layout/lists_fragment.xml +++ b/res/layout/lists_fragment.xml @@ -18,13 +18,13 @@ xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="?android:attr/actionBarSize" android:animateLayoutChanges="true" android:id="@+id/lists_frame"> 0) { + SwipeableShortcutCard v = + (SwipeableShortcutCard) mShortcutCardsListView.getChildAt(0); + v.clipCard(ratioCardHidden); + } + + if (mActionBar != null) { + // Amount of available space that is not being hidden by the bottom pane + final int topPaneHeight = (int) (slideOffset * mShortcutCardsListView.getHeight()); + + final int availableActionBarHeight = + Math.min(mActionBar.getHeight(), topPaneHeight); + mActionBar.setHideOffset(mActionBar.getHeight() - availableActionBarHeight); + } + } + + @Override + public void onPanelOpened(View panel) { + } + + @Override + public void onPanelClosed(View panel) { + } + }; + public class ViewPagerAdapter extends FragmentPagerAdapter { public ViewPagerAdapter(FragmentManager fm) { super(fm); @@ -194,7 +231,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste final SharedPreferences prefs = getActivity().getSharedPreferences( DialtactsActivity.SHARED_PREFS_NAME, Context.MODE_PRIVATE); mLastCallShortcutDate = prefs.getLong(KEY_LAST_DISMISSED_CALL_SHORTCUT_DATE, 0); - + mActionBar = getActivity().getActionBar(); fetchCalls(); mCallLogAdapter.setLoading(true); } @@ -204,6 +241,7 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste // Wipe the cache to refresh the call shortcut item. This is not that expensive because // it only contains one item. mCallLogAdapter.invalidateCache(); + mActionBar = null; super.onPause(); } @@ -226,11 +264,10 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste mViewPagerTabs.setViewPager(mViewPager); addOnPageChangeListener(mViewPagerTabs); - final ListView shortcutCardsListView = - (ListView) parentView.findViewById(R.id.shortcut_card_list); - shortcutCardsListView.setAdapter(mMergedAdapter); + mShortcutCardsListView = (ListView) parentView.findViewById(R.id.shortcut_card_list); + mShortcutCardsListView.setAdapter(mMergedAdapter); - setupPaneLayout((OverlappingPaneLayout) parentView, shortcutCardsListView); + setupPaneLayout((OverlappingPaneLayout) parentView); return parentView; } @@ -298,34 +335,12 @@ public class ListsFragment extends Fragment implements CallLogQueryHandler.Liste } } - private void setupPaneLayout(OverlappingPaneLayout paneLayout, - final ListView shortcutCardsListView) { + private void setupPaneLayout(OverlappingPaneLayout paneLayout) { // TODO: Remove the notion of a capturable view. The entire view be slideable, once // the framework better supports nested scrolling. paneLayout.setCapturableView(mViewPagerTabs); paneLayout.openPane(); - paneLayout.setPanelSlideListener(new PanelSlideListener() { - @Override - public void onPanelSlide(View panel, float slideOffset) { - // For every 2 percent that the panel is slid upwards, clip 3 percent from each edge - // of the shortcut card, to achieve the animated effect of the shortcut card - // rapidly shrinking and disappearing from view when the panel is slid upwards. - float ratioCardHidden = (1 - slideOffset) * 1.5f; - if (shortcutCardsListView.getCount() > 0) { - SwipeableShortcutCard v = - (SwipeableShortcutCard) shortcutCardsListView.getChildAt(0); - v.clipCard(ratioCardHidden); - } - } - - @Override - public void onPanelOpened(View panel) { - } - - @Override - public void onPanelClosed(View panel) { - } - }); + paneLayout.setPanelSlideListener(mPanelSlideListener); LayoutTransition transition = paneLayout.getLayoutTransition(); // Turns on animations for all types of layout changes so that they occur for -- cgit v1.2.3