From 310a9889937677091868ae7759c90d033ca08bb6 Mon Sep 17 00:00:00 2001 From: Peter Schiller Date: Thu, 30 Jun 2016 13:52:36 -0700 Subject: [PATCH] Updating all apps to match spec Change-Id: Ie351fdea2e3b05ca911e6533f0c5d00c17e0847c --- res/drawable/all_apps_search_bg.xml | 10 +-- res/drawable/all_apps_search_hint.xml | 20 ++++++ res/drawable/ic_allapps_search.xml | 24 +++++++ res/layout/all_apps.xml | 55 +++++++++------- res/values/dimens.xml | 4 +- res/values/strings.xml | 2 +- .../BaseRecyclerViewFastScrollPopup.java | 4 +- src/com/android/launcher3/Launcher.java | 4 +- .../allapps/AllAppsContainerView.java | 66 +++++++++++++++---- .../allapps/AllAppsTransitionController.java | 1 + 10 files changed, 142 insertions(+), 48 deletions(-) create mode 100644 res/drawable/all_apps_search_hint.xml create mode 100644 res/drawable/ic_allapps_search.xml diff --git a/res/drawable/all_apps_search_bg.xml b/res/drawable/all_apps_search_bg.xml index b0ed9b54b0..cf63d41c21 100644 --- a/res/drawable/all_apps_search_bg.xml +++ b/res/drawable/all_apps_search_bg.xml @@ -15,14 +15,6 @@ limitations under the License. --> - - - - - - + android:color="?android:attr/colorAccent"/> \ No newline at end of file diff --git a/res/drawable/all_apps_search_hint.xml b/res/drawable/all_apps_search_hint.xml new file mode 100644 index 0000000000..b2ff7a428e --- /dev/null +++ b/res/drawable/all_apps_search_hint.xml @@ -0,0 +1,20 @@ + + + + + + \ No newline at end of file diff --git a/res/drawable/ic_allapps_search.xml b/res/drawable/ic_allapps_search.xml new file mode 100644 index 0000000000..2aeb9479bd --- /dev/null +++ b/res/drawable/ic_allapps_search.xml @@ -0,0 +1,24 @@ + + + + diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml index 1b843ed7d6..a0b73f0341 100644 --- a/res/layout/all_apps.xml +++ b/res/layout/all_apps.xml @@ -1,5 +1,5 @@ - - + android:saveEnabled="false" + android:visibility="gone"> + android:clipToPadding="false" + android:descendantFocusability="afterDescendants" + android:focusable="true" + android:theme="@style/CustomOverscroll.Light" /> + android:saveEnabled="false"> + + diff --git a/res/values/dimens.xml b/res/values/dimens.xml index c7dd3753b1..c8a05b7812 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -64,6 +64,8 @@ 8dp 24sp 60dp + 4dp + 1dp 8dp 24dp @@ -76,7 +78,7 @@ 475dp - 4dp + 3dp 16dp 6dp diff --git a/res/values/strings.xml b/res/values/strings.xml index 4e5fcff817..11760f4e17 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -47,7 +47,7 @@ - Search Apps… + Search Apps Loading Apps… diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java index da7fa419e5..37584fedea 100644 --- a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java +++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java @@ -32,9 +32,9 @@ public class BaseRecyclerViewFastScrollPopup { private static final float FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR = 1.5f; - private static final int SHADOW_INSET = 6; + private static final int SHADOW_INSET = 5; private static final int SHADOW_SHIFT_Y = 4; - private static final float SHADOW_ALPHA_MULTIPLIER = 0.6f; + private static final float SHADOW_ALPHA_MULTIPLIER = 0.5f; private Resources mRes; private BaseRecyclerView mRv; diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 84c29dcfa4..a31c8aeb35 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1370,7 +1370,9 @@ public class Launcher extends Activity mDragController.addDropTarget(mWorkspace); mDropTargetBar.setup(mDragController); - mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace); + if (FeatureFlags.LAUNCHER3_ALL_APPS_PULL_UP) { + mAllAppsController.setupViews(mAppsView, mHotseat, mWorkspace); + } if (TestingUtils.MEMORY_DUMP_ENABLED) { TestingUtils.addWeightWatcher(this); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index c3da491243..868408f14e 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -25,11 +25,14 @@ import android.text.Selection; import android.text.SpannableStringBuilder; import android.text.method.TextKeyListener; import android.util.AttributeSet; +import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewConfiguration; +import android.view.inputmethod.InputMethodManager; +import android.widget.ImageView; import android.widget.LinearLayout; import com.android.launcher3.AppInfo; @@ -58,7 +61,6 @@ import java.util.ArrayList; import java.util.List; - /** * A merge algorithm that merges every section indiscriminately. */ @@ -66,8 +68,8 @@ final class FullMergeAlgorithm implements AlphabeticalAppsList.MergeAlgorithm { @Override public boolean continueMerging(AlphabeticalAppsList.SectionInfo section, - AlphabeticalAppsList.SectionInfo withSection, - int sectionAppCount, int numAppsPerRow, int mergeCount) { + AlphabeticalAppsList.SectionInfo withSection, + int sectionAppCount, int numAppsPerRow, int mergeCount) { // Don't merge the predicted apps if (section.firstAppItem.viewType != AllAppsGridAdapter.ICON_VIEW_TYPE) { return false; @@ -98,8 +100,8 @@ final class SimpleSectionMergeAlgorithm implements AlphabeticalAppsList.MergeAlg @Override public boolean continueMerging(AlphabeticalAppsList.SectionInfo section, - AlphabeticalAppsList.SectionInfo withSection, - int sectionAppCount, int numAppsPerRow, int mergeCount) { + AlphabeticalAppsList.SectionInfo withSection, + int sectionAppCount, int numAppsPerRow, int mergeCount) { // Don't merge the predicted apps if (section.firstAppItem.viewType != AllAppsGridAdapter.ICON_VIEW_TYPE) { return false; @@ -148,6 +150,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc private View mSearchContainer; private ExtendedEditText mSearchInput; + private ImageView mSearchIcon; private HeaderElevationController mElevationController; private SpannableStringBuilder mSearchQueryBuilder = null; @@ -232,6 +235,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc mSearchBarController.setVisibility(View.INVISIBLE); } } + /** * Sets the search bar that shows above the a-z list. */ @@ -261,8 +265,8 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc Utilities.mapCoordInSelfToDescendent(mAppsRecyclerView, this, point); // if the MotionEvent is inside the thumb, container should not be pulled down. - if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])){ - return false; + if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])) { + return false; } // If scroller is at the very top, then it's okay for the container to be pulled down. if (Float.compare(0f, mAppsRecyclerView.getScrollBar().getThumbOffset().y) == 0) { @@ -270,6 +274,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc } return false; } + /** * Focuses the search field and begins an app search. */ @@ -305,6 +310,42 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc mSearchContainer = findViewById(R.id.search_container); mSearchInput = (ExtendedEditText) findViewById(R.id.search_box_input); + mSearchIcon = (ImageView) findViewById(R.id.search_icon); + + final LinearLayout.LayoutParams searchParams = + (LinearLayout.LayoutParams) mSearchInput.getLayoutParams(); + mSearchInput.setOnFocusChangeListener(new OnFocusChangeListener() { + @Override + public void onFocusChange(View view, boolean focused) { + if (focused) { + searchParams.width = LayoutParams.MATCH_PARENT; + mSearchInput.setLayoutParams(searchParams); + mSearchInput.setGravity(Gravity.FILL_HORIZONTAL | Gravity.CENTER_VERTICAL); + mSearchIcon.setVisibility(View.GONE); + } else { + searchParams.width = LayoutParams.WRAP_CONTENT; + mSearchInput.setLayoutParams(searchParams); + mSearchInput.setGravity(Gravity.START | Gravity.CENTER_VERTICAL); + mSearchIcon.setVisibility(View.VISIBLE); + } + } + }); + + final OnClickListener searchFocusListener = new OnClickListener() { + @Override + public void onClick(View view) { + if (!mSearchInput.isFocused()) { + mSearchInput.requestFocus(); + final InputMethodManager imm = + (InputMethodManager)getContext().getSystemService( + Context.INPUT_METHOD_SERVICE); + imm.showSoftInput(mSearchInput, 0); + } + } + }; + mSearchInput.setOnClickListener(searchFocusListener); + mSearchContainer.setOnClickListener(searchFocusListener); + mElevationController = Utilities.ATLEAST_LOLLIPOP ? new HeaderElevationController.ControllerVL(mSearchContainer) : new HeaderElevationController.ControllerV16(mSearchContainer); @@ -379,7 +420,11 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc if (mNumAppsPerRow > 0) { int iconSize = availableWidth / mNumAppsPerRow; int iconSpacing = (iconSize - grid.allAppsIconSizePx) / 2; - mSearchInput.setPaddingRelative(iconSpacing, 0, iconSpacing, 0); + final int thumbMaxWidth = + getResources().getDimensionPixelSize( + R.dimen.container_fastscroll_thumb_max_width); + mSearchContainer.setPaddingRelative( + iconSpacing + thumbMaxWidth, 0, iconSpacing + thumbMaxWidth, 0); } } super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -452,7 +497,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc lp.leftMargin = bgPadding.left; lp.rightMargin = bgPadding.right; - // Clip the view to the left and right edge of the background to // to prevent shadows from rendering beyond the edges final Rect newClipBounds = new Rect( @@ -472,7 +516,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams(); Rect insets = mLauncher.getDragLayer().getInsets(); - getContentView().setPadding(0,0,0, insets.bottom); + getContentView().setPadding(0, 0, 0, insets.bottom); int height = insets.top + grid.hotseatCellHeightPx; mlp.topMargin = height; @@ -482,10 +526,10 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc (LinearLayout.LayoutParams) mSearchInput.getLayoutParams(); llp.topMargin = insets.top; mSearchInput.setLayoutParams(llp); + mSearchIcon.setLayoutParams(llp); lp.height = height; } - mSearchContainer.getBackground().setAlpha(0); } mSearchContainer.setLayoutParams(lp); } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index 8a14a666b2..ac256b1263 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -408,6 +408,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul mAppsView.setVisibility(View.INVISIBLE); mHotseat.setBackgroundTransparent(false /* transparent */); mHotseat.setVisibility(View.VISIBLE); + mAppsView.reset(); setProgress(mShiftRange); }