Restore AllAppsContainerView UI to match spec.

Did some refactoring with Sunny's help.

Change-Id: Ie4c90c316f1e381829836e11c83eaaedfed4d621
This commit is contained in:
Jon Miranda
2016-09-26 14:01:56 -07:00
parent 8c855cb8c0
commit aca2145f2a
7 changed files with 42 additions and 22 deletions
+1 -2
View File
@@ -77,8 +77,7 @@
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
launcher:layout_ignoreInsets="true" />
android:visibility="invisible" />
</com.android.launcher3.dragndrop.DragLayer>
</com.android.launcher3.LauncherRootView>
+1 -2
View File
@@ -76,8 +76,7 @@
android:id="@+id/apps_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
launcher:layout_ignoreInsets="true" />
android:visibility="invisible" />
</com.android.launcher3.dragndrop.DragLayer>
</com.android.launcher3.LauncherRootView>
+3 -3
View File
@@ -46,10 +46,10 @@
<!-- DO NOT CHANGE THE ID -->
<com.android.launcher3.allapps.AllAppsRecyclerView
android:id="@+id/apps_list_view"
android:layout_below="@+id/search_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal|top"
android:layout_marginTop="@dimen/all_apps_search_bar_height"
android:clipToPadding="false"
android:descendantFocusability="afterDescendants"
android:focusable="true"
@@ -60,7 +60,6 @@
android:layout_width="match_parent"
android:layout_height="@dimen/all_apps_search_bar_height"
android:layout_gravity="center|top"
android:paddingTop="@dimen/all_apps_search_bar_margin_top"
android:gravity="center|bottom"
android:orientation="horizontal"
android:saveEnabled="false">
@@ -68,8 +67,9 @@
<com.android.launcher3.ExtendedEditText
android:id="@+id/search_box_input"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="@dimen/all_apps_search_bar_field_height"
android:background="@android:color/transparent"
android:layout_gravity="bottom"
android:focusableInTouchMode="true"
android:gravity="center"
android:imeOptions="actionSearch|flagNoExtractUi"
+1 -1
View File
@@ -64,8 +64,8 @@
<dimen name="all_apps_grid_view_start_margin">0dp</dimen>
<dimen name="all_apps_grid_section_y_offset">8dp</dimen>
<dimen name="all_apps_grid_section_text_size">24sp</dimen>
<dimen name="all_apps_search_bar_field_height">48dp</dimen>
<dimen name="all_apps_search_bar_height">60dp</dimen>
<dimen name="all_apps_search_bar_margin_top">12dp</dimen>
<dimen name="all_apps_search_bar_icon_margin_right">4dp</dimen>
<dimen name="all_apps_search_bar_icon_margin_top">1dp</dimen>
<dimen name="all_apps_list_bottom_padding">8dp</dimen>
+1 -1
View File
@@ -104,7 +104,7 @@ public class DeviceProfile {
public int hotseatCellWidthPx;
public int hotseatCellHeightPx;
public int hotseatIconSizePx;
private int hotseatBarHeightPx;
public int hotseatBarHeightPx;
private int hotseatBarTopPaddingPx;
private int hotseatLandGutterPx;
@@ -15,10 +15,8 @@
*/
package com.android.launcher3.allapps;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.text.Selection;
@@ -31,7 +29,6 @@ import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import com.android.launcher3.AppInfo;
@@ -43,6 +40,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.DragSource;
import com.android.launcher3.DropTarget;
import com.android.launcher3.ExtendedEditText;
import com.android.launcher3.Insettable;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherTransitionable;
@@ -134,7 +132,8 @@ final class SimpleSectionMergeAlgorithm implements AlphabeticalAppsList.MergeAlg
* The all apps view container.
*/
public class AllAppsContainerView extends BaseContainerView implements DragSource,
LauncherTransitionable, View.OnLongClickListener, AllAppsSearchBarController.Callbacks {
LauncherTransitionable, View.OnLongClickListener, AllAppsSearchBarController.Callbacks,
Insettable {
private static final int MIN_ROWS_IN_MERGED_SECTION_PHONE = 3;
private static final int MAX_NUM_MERGES_PHONE = 2;
@@ -158,7 +157,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
private int mNumAppsPerRow;
private int mNumPredictedAppsPerRow;
public AllAppsContainerView(Context context) {
this(context, null);
}
@@ -178,7 +176,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mApps.setAdapter(mAdapter);
mLayoutManager = mAdapter.getLayoutManager();
mItemDecoration = mAdapter.getItemDecoration();
DeviceProfile grid = mLauncher.getDeviceProfile();
mSearchQueryBuilder = new SpannableStringBuilder();
Selection.setSelection(mSearchQueryBuilder, 0);
}
@@ -354,6 +351,14 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
getContentView().setVisibility(View.VISIBLE);
getContentView().setBackground(null);
}
int maxScrollBarWidth = mAppsRecyclerView.getMaxScrollbarWidth();
int startInset = Math.max(mSectionNamesMargin, maxScrollBarWidth);
if (Utilities.isRtl(getResources())) {
mAppsRecyclerView.setPadding(maxScrollBarWidth, 0, startInset, 0);
} else {
mAppsRecyclerView.setPadding(startInset, 0, maxScrollBarWidth, 0);
}
}
@Override
@@ -378,13 +383,11 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
mAdapter.setNumAppsPerRow(mNumAppsPerRow);
mApps.setNumAppsPerRow(mNumAppsPerRow, mNumPredictedAppsPerRow, new FullMergeAlgorithm());
}
if (!grid.isVerticalBarLayout()) {
View navBarBg = findViewById(R.id.nav_bar_bg);
ViewGroup.LayoutParams params = navBarBg.getLayoutParams();
params.height = mLauncher.getDragLayer().getInsets().bottom;
navBarBg.setLayoutParams(params);
navBarBg.setVisibility(View.VISIBLE);
MarginLayoutParams searchContainerLp =
(MarginLayoutParams) mSearchContainer.getLayoutParams();
searchContainerLp.height = grid.hotseatBarHeightPx;
mSearchContainer.setLayoutParams(searchContainerLp);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
return;
@@ -593,4 +596,22 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
public boolean shouldRestoreImeState() {
return !TextUtils.isEmpty(mSearchInput.getText());
}
@Override
public void setInsets(Rect insets) {
DeviceProfile grid = mLauncher.getDeviceProfile();
if (grid.isVerticalBarLayout()) {
ViewGroup.MarginLayoutParams mlp = (MarginLayoutParams) getLayoutParams();
mlp.leftMargin = insets.left;
mlp.topMargin = insets.top;
mlp.rightMargin = insets.right;
setLayoutParams(mlp);
} else {
View navBarBg = findViewById(R.id.nav_bar_bg);
ViewGroup.LayoutParams navBarBgLp = navBarBg.getLayoutParams();
navBarBgLp.height = insets.bottom;
navBarBg.setLayoutParams(navBarBgLp);
navBarBg.setVisibility(View.VISIBLE);
}
}
}
@@ -21,6 +21,7 @@ import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.BubbleTextView.BubbleTextShadowHandler;
@@ -33,7 +34,7 @@ import com.android.launcher3.R;
* A container for RecyclerView to allow for the click shadow view to be shown behind an icon that
* is launching.
*/
public class AllAppsRecyclerViewContainerView extends FrameLayout
public class AllAppsRecyclerViewContainerView extends RelativeLayout
implements BubbleTextShadowHandler {
private final ClickShadowView mTouchFeedbackView;