summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Bertschler <bmario@google.com>2017-12-13 16:22:24 -0800
committerMario Bertschler <bmario@google.com>2017-12-14 11:20:46 -0800
commitd8ab4671e3f623ddd1e37115e51f448be134c708 (patch)
tree03db6c786f024281669b2d90610a2521310e4224
parent30d276cb92f507170311ff11463d8b0bdf949bae (diff)
downloadandroid_packages_apps_Trebuchet-d8ab4671e3f623ddd1e37115e51f448be134c708.tar.gz
android_packages_apps_Trebuchet-d8ab4671e3f623ddd1e37115e51f448be134c708.tar.bz2
android_packages_apps_Trebuchet-d8ab4671e3f623ddd1e37115e51f448be134c708.zip
Moving divider line into predictionview.
Change-Id: I40753aaa154023641cead2bd7dcf906fa5a4c2d7
-rw-r--r--res/layout/all_apps.xml8
-rw-r--r--res/values/dimens.xml1
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java2
-rw-r--r--src/com/android/launcher3/allapps/FloatingHeaderView.java23
-rw-r--r--src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java8
-rw-r--r--src/com/android/launcher3/allapps/PredictionRowView.java30
6 files changed, 41 insertions, 31 deletions
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 3f6be2c6a..8cf32bd0e 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -41,14 +41,6 @@
<include layout="@layout/predictions_view" android:id="@+id/header_content" />
- <include layout="@layout/all_apps_divider"
- android:id="@+id/divider"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_marginLeft="@dimen/all_apps_tabs_side_padding"
- android:layout_marginRight="@dimen/all_apps_tabs_side_padding"
- android:layout_alignBottom="@+id/tabs" />
-
<com.android.launcher3.allapps.PersonalWorkSlidingTabStrip
android:id="@+id/tabs"
android:layout_width="match_parent"
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 93c5114b7..c77a0387a 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -97,6 +97,7 @@
<dimen name="all_apps_work_profile_tab_footer_top_padding">16dp</dimen>
<dimen name="all_apps_work_profile_tab_footer_bottom_padding">20dp</dimen>
<dimen name="all_apps_tabs_side_padding">12dp</dimen>
+ <dimen name="all_apps_divider_height">1dp</dimen>
<!-- Search bar in All Apps -->
<dimen name="all_apps_header_max_elevation">3dp</dimen>
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index b98d85231..815484569 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -547,7 +547,7 @@ public class AllAppsContainerView extends RelativeLayout implements DragSource,
return mHeader;
}
- private void setupHeader() {
+ public void setupHeader() {
if (mHeader == null) {
return;
}
diff --git a/src/com/android/launcher3/allapps/FloatingHeaderView.java b/src/com/android/launcher3/allapps/FloatingHeaderView.java
index 409985c23..1419a2a7c 100644
--- a/src/com/android/launcher3/allapps/FloatingHeaderView.java
+++ b/src/com/android/launcher3/allapps/FloatingHeaderView.java
@@ -18,7 +18,6 @@ package com.android.launcher3.allapps;
import android.animation.ValueAnimator;
import android.content.Context;
-import android.content.res.Resources;
import android.graphics.Point;
import android.graphics.Rect;
import android.support.annotation.NonNull;
@@ -66,7 +65,6 @@ public class FloatingHeaderView extends RelativeLayout implements
private PredictionRowView mPredictionRow;
private ViewGroup mTabLayout;
- private View mDivider;
private AllAppsRecyclerView mMainRV;
private AllAppsRecyclerView mWorkRV;
private AllAppsRecyclerView mCurrentRV;
@@ -90,7 +88,6 @@ public class FloatingHeaderView extends RelativeLayout implements
protected void onFinishInflate() {
super.onFinishInflate();
mTabLayout = findViewById(R.id.tabs);
- mDivider = findViewById(R.id.divider);
mPredictionRow = findViewById(R.id.header_content);
}
@@ -98,17 +95,15 @@ public class FloatingHeaderView extends RelativeLayout implements
HashMap<ComponentKey, AppInfo> componentToAppMap, int numPredictedAppsPerRow) {
mTabsHidden = mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView == null;
mTabLayout.setVisibility(mTabsHidden ? View.GONE : View.VISIBLE);
- mPredictionRow.setPadding(0, 0, 0, mTabsHidden ? getResources()
- .getDimensionPixelSize(R.dimen.all_apps_prediction_row_divider_height) : 0);
mPredictionRow.setup(mAH[AllAppsContainerView.AdapterHolder.MAIN].adapter,
componentToAppMap, numPredictedAppsPerRow);
+ mPredictionRow.setShowDivider(mTabsHidden);
mMaxTranslation = mPredictionRow.getExpectedHeight();
mMainRV = setupRV(mMainRV, mAH[AllAppsContainerView.AdapterHolder.MAIN].recyclerView);
mWorkRV = setupRV(mWorkRV, mAH[AllAppsContainerView.AdapterHolder.WORK].recyclerView);
mParent = (ViewGroup) mMainRV.getParent();
setMainActive(true);
reset();
- setupDivider();
}
private AllAppsRecyclerView setupRV(AllAppsRecyclerView old, AllAppsRecyclerView updated) {
@@ -118,17 +113,6 @@ public class FloatingHeaderView extends RelativeLayout implements
return updated;
}
- private void setupDivider() {
- Resources res = getResources();
- int verticalGap = res.getDimensionPixelSize(R.dimen.all_apps_divider_margin_vertical);
- int sideGap = res.getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
- mDivider.setPadding(sideGap, verticalGap,sideGap, mTabsHidden ? verticalGap : 0);
- RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) mDivider.getLayoutParams();
- lp.removeRule(RelativeLayout.ALIGN_BOTTOM);
- lp.addRule(RelativeLayout.ALIGN_BOTTOM, mTabsHidden ? R.id.header_content : R.id.tabs);
- mDivider.setLayoutParams(lp);
- }
-
public void setMainActive(boolean active) {
mCurrentRV = active ? mMainRV : mWorkRV;
}
@@ -137,10 +121,6 @@ public class FloatingHeaderView extends RelativeLayout implements
return mPredictionRow;
}
- public View getDivider() {
- return mDivider;
- }
-
private boolean canSnapAt(int currentScrollY) {
return Math.abs(currentScrollY) <= mPredictionRow.getHeight();
}
@@ -180,7 +160,6 @@ public class FloatingHeaderView extends RelativeLayout implements
mPredictionRow.setTranslationY(uncappedTranslationY);
}
mTabLayout.setTranslationY(mTranslationY);
- mDivider.setTranslationY(mTabsHidden ? uncappedTranslationY : mTranslationY);
mClip.top = mMaxTranslation + mTranslationY;
// clipping on a draw might cause additional redraw
mMainRV.setClipBounds(mClip);
diff --git a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
index 54948b0a5..057c64a5d 100644
--- a/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
+++ b/src/com/android/launcher3/allapps/PersonalWorkSlidingTabStrip.java
@@ -35,6 +35,7 @@ import com.android.launcher3.util.Themes;
public class PersonalWorkSlidingTabStrip extends LinearLayout {
private final Paint mPersonalTabIndicatorPaint;
private final Paint mWorkTabIndicatorPaint;
+ private final Paint mDividerPaint;
private int mSelectedIndicatorHeight;
private int mIndicatorLeft = -1;
@@ -59,6 +60,10 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout {
mWorkTabIndicatorPaint.setColor(getResources().getColor(R.color.work_profile_color));
mIsRtl = Utilities.isRtl(getResources());
+
+ mDividerPaint = new Paint();
+ mDividerPaint.setColor(Themes.getAttrColor(context, android.R.attr.colorControlHighlight));
+ mDividerPaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));
}
public void updateIndicatorPosition(int position, float positionOffset) {
@@ -116,6 +121,9 @@ public class PersonalWorkSlidingTabStrip extends LinearLayout {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
+ float y = getHeight() - mDividerPaint.getStrokeWidth();
+ canvas.drawLine(getPaddingLeft(), y, getWidth() - getPaddingRight(), y, mDividerPaint);
+
final float middleX = getWidth() / 2.0f;
if (mIndicatorLeft <= middleX) {
canvas.drawRect(mIndicatorLeft, getHeight() - mSelectedIndicatorHeight,
diff --git a/src/com/android/launcher3/allapps/PredictionRowView.java b/src/com/android/launcher3/allapps/PredictionRowView.java
index 1aee948e5..4aacc6d70 100644
--- a/src/com/android/launcher3/allapps/PredictionRowView.java
+++ b/src/com/android/launcher3/allapps/PredictionRowView.java
@@ -17,6 +17,8 @@
package com.android.launcher3.allapps;
import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
@@ -27,9 +29,11 @@ import android.widget.LinearLayout;
import com.android.launcher3.AppInfo;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.Launcher;
+import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.ComponentKeyMapper;
+import com.android.launcher3.util.Themes;
import java.util.ArrayList;
import java.util.Collections;
@@ -46,8 +50,10 @@ public class PredictionRowView extends LinearLayout {
private final List<ComponentKeyMapper<AppInfo>> mPredictedAppComponents = new ArrayList<>();
// The set of predicted apps resolved from the component names and the current set of apps
private final List<AppInfo> mPredictedApps = new ArrayList<>();
+ private final Paint mPaint;
// This adapter is only used to create an identical item w/ same behavior as in the all apps RV
private AllAppsGridAdapter mAdapter;
+ private boolean mShowDivider;
public PredictionRowView(@NonNull Context context) {
this(context, null);
@@ -56,6 +62,10 @@ public class PredictionRowView extends LinearLayout {
public PredictionRowView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.HORIZONTAL);
+ setWillNotDraw(false);
+ mPaint = new Paint();
+ mPaint.setColor(Themes.getAttrColor(context, android.R.attr.colorControlHighlight));
+ mPaint.setStrokeWidth(getResources().getDimensionPixelSize(R.dimen.all_apps_divider_height));
}
public void setup(AllAppsGridAdapter adapter, HashMap<ComponentKey, AppInfo> componentToAppMap,
@@ -82,6 +92,13 @@ public class PredictionRowView extends LinearLayout {
return height;
}
+ public void setShowDivider(boolean showDivider) {
+ mShowDivider = showDivider;
+ int paddingBottom = showDivider ? getResources()
+ .getDimensionPixelSize(R.dimen.all_apps_prediction_row_divider_height) : 0;
+ setPadding(getPaddingLeft(), getPaddingTop(), getPaddingRight(), paddingBottom);
+ }
+
/**
* Sets the number of apps per row.
*/
@@ -169,4 +186,17 @@ public class PredictionRowView extends LinearLayout {
}
return predictedApps;
}
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ super.onDraw(canvas);
+
+ if (mShowDivider) {
+ int side = getResources().getDimensionPixelSize(R.dimen.dynamic_grid_edge_margin);
+ int y = getHeight() - (getPaddingBottom() / 2);
+ int x1 = getPaddingLeft() + side;
+ int x2 = getWidth() - getPaddingRight() - side;
+ canvas.drawLine(x1, y, x2, y, mPaint);
+ }
+ }
}