summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/all_apps.xml5
-rw-r--r--res/values-v26/styles.xml6
-rw-r--r--res/values/attrs.xml1
-rw-r--r--res/values/styles.xml8
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java29
-rw-r--r--src/com/android/launcher3/DeleteDropTarget.java6
-rw-r--r--src/com/android/launcher3/DropTargetBar.java52
-rw-r--r--src/com/android/launcher3/allapps/AllAppsContainerView.java2
8 files changed, 90 insertions, 19 deletions
diff --git a/res/layout/all_apps.xml b/res/layout/all_apps.xml
index 6340619ab..39df2b193 100644
--- a/res/layout/all_apps.xml
+++ b/res/layout/all_apps.xml
@@ -68,11 +68,10 @@
</com.android.launcher3.allapps.AllAppsRecyclerViewContainerView>
<View
- style="@style/AllAppsNavBarProtection"
android:id="@+id/nav_bar_bg"
+ android:background="?attr/allAppsNavBarScrimColor"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="bottom"
- android:focusable="false"
- android:visibility="invisible" />
+ android:focusable="false" />
</com.android.launcher3.allapps.AllAppsContainerView> \ No newline at end of file
diff --git a/res/values-v26/styles.xml b/res/values-v26/styles.xml
index fd6fc4d50..b25f46a0c 100644
--- a/res/values-v26/styles.xml
+++ b/res/values-v26/styles.xml
@@ -26,10 +26,4 @@
<item name="android:colorPrimaryDark">#616161</item> <!-- Gray 700 -->
</style>
- <!-- From O and above, we show a dark nav bar in all-apps -->
- <style name="AllAppsNavBarProtection">
- <item name="android:alpha">0.6</item>
- <item name="android:background">?android:attr/colorPrimary</item>
- </style>
-
</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index 7b52dae5d..68b628fb7 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -20,6 +20,7 @@
<!-- Attributes used for launcher theme -->
<attr name="allAppsScrimColor" format="color" />
+ <attr name="allAppsNavBarScrimColor" format="color" />
<attr name="popupColorPrimary" format="color" />
<attr name="popupColorSecondary" format="color" />
<attr name="popupColorTertiary" format="color" />
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 17bc7f9de..5d06705f8 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -30,6 +30,7 @@
<style name="BaseLauncherThemeWithCustomAttrs" parent="@style/BaseLauncherTheme">
<item name="allAppsScrimColor">#CCFFFFFF</item>
+ <item name="allAppsNavBarScrimColor">#66FFFFFF</item>
<item name="popupColorPrimary">#FFF</item>
<item name="popupColorSecondary">#F5F5F5</item> <!-- Gray 100 -->
<item name="popupColorTertiary">#E0E0E0</item> <!-- Gray 300 -->
@@ -62,6 +63,7 @@
<item name="android:colorControlHighlight">#A0FFFFFF</item>
<item name="android:colorPrimary">#FF333333</item>
<item name="allAppsScrimColor">#7A000000</item>
+ <item name="allAppsNavBarScrimColor">#80000000</item>
<item name="popupColorPrimary">?android:attr/colorPrimary</item>
<item name="popupColorSecondary">#424242</item> <!-- Gray 800 -->
<item name="popupColorTertiary">#757575</item> <!-- Gray 600 -->
@@ -103,12 +105,6 @@
<item name="android:includeFontPadding">false</item>
</style>
- <!-- Style for nav bar background in all-apps screen -->
- <style name="AllAppsNavBarProtection">
- <item name="android:alpha">?android:attr/spotShadowAlpha</item>
- <item name="android:background">@color/default_shadow_color_no_alpha</item>
- </style>
-
<!-- Base theme for BubbleTextView and sub classes -->
<style name="BaseIcon">
<item name="android:layout_width">match_parent</item>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index e4a322622..632e49059 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -29,6 +29,7 @@ import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.view.View.OnClickListener;
@@ -69,6 +70,7 @@ public abstract class ButtonDropTarget extends TextView
/** The paint applied to the drag view on hover */
protected int mHoverColor = 0;
+ protected CharSequence mText;
protected ColorStateList mOriginalTextColor;
protected Drawable mDrawable;
@@ -96,6 +98,7 @@ public abstract class ButtonDropTarget extends TextView
@Override
protected void onFinishInflate() {
super.onFinishInflate();
+ mText = getText();
mOriginalTextColor = getTextColors();
}
@@ -297,4 +300,30 @@ public abstract class ButtonDropTarget extends TextView
public int getTextColor() {
return getTextColors().getDefaultColor();
}
+
+ /**
+ * Returns True if any update was made.
+ */
+ public boolean updateText(boolean hide) {
+ if ((hide && getText().toString().isEmpty()) || (!hide && mText.equals(getText()))) {
+ return false;
+ }
+
+ setText(hide ? "" : mText);
+ return true;
+ }
+
+ public boolean isTextTruncated() {
+ int availableWidth = getMeasuredWidth();
+ if (mHideParentOnDisable) {
+ ViewGroup parent = (ViewGroup) getParent();
+ availableWidth = parent.getMeasuredWidth() - parent.getPaddingLeft()
+ - parent.getPaddingRight();
+ }
+ availableWidth -= (getPaddingLeft() + getPaddingRight() + mDrawable.getIntrinsicWidth()
+ + getCompoundDrawablePadding());
+ CharSequence displayedText = TextUtils.ellipsize(mText, getPaint(), availableWidth,
+ TextUtils.TruncateAt.END);
+ return !mText.equals(displayedText);
+ }
}
diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java
index 975675a6f..4dcb64f01 100644
--- a/src/com/android/launcher3/DeleteDropTarget.java
+++ b/src/com/android/launcher3/DeleteDropTarget.java
@@ -65,9 +65,11 @@ public class DeleteDropTarget extends ButtonDropTarget {
* Set the drop target's text to either "Remove" or "Cancel" depending on the drag source.
*/
public void setTextBasedOnDragSource(DragSource dragSource) {
- if (!TextUtils.isEmpty(getText())) {
- setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label
+ if (!TextUtils.isEmpty(mText)) {
+ mText = getResources().getString(dragSource.supportsDeleteDropTarget()
+ ? R.string.remove_drop_target_label
: android.R.string.cancel);
+ requestLayout();
}
}
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index 0840b7015..29a1349d5 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -78,6 +78,58 @@ public class DropTargetBar extends LinearLayout implements DragController.DragLi
setupButtonDropTarget(this, dragController);
}
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ boolean hideText = hideTextHelper(false /* shouldUpdateText */, false /* no-op */);
+ if (hideTextHelper(true /* shouldUpdateText */, hideText)) {
+ // Text has changed, so we need to re-measure.
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+ }
+ }
+
+ /**
+ * Helper method that iterates through the children and returns whether any of the visible
+ * {@link ButtonDropTarget} has truncated text.
+ *
+ * @param shouldUpdateText If True, updates the text of all children.
+ * @param hideText If True and {@param shouldUpdateText} is True, clears the text of all
+ * children; otherwise it sets the original text value.
+ *
+ *
+ * @return If shouldUpdateText is True, returns whether any of the children updated their text.
+ * Else, returns whether any of the children have truncated their text.
+ */
+ private boolean hideTextHelper(boolean shouldUpdateText, boolean hideText) {
+ boolean result = false;
+ View visibleView;
+ ButtonDropTarget dropTarget;
+ for (int i = getChildCount() - 1; i >= 0; --i) {
+ if (getChildAt(i) instanceof ButtonDropTarget) {
+ visibleView = dropTarget = (ButtonDropTarget) getChildAt(i);
+ } else if (getChildAt(i) instanceof ViewGroup) {
+ // The Drop Target is wrapped in a FrameLayout.
+ visibleView = getChildAt(i);
+ dropTarget = (ButtonDropTarget) ((ViewGroup) visibleView).getChildAt(0);
+ } else {
+ // Ignore other views.
+ continue;
+ }
+
+ if (visibleView.getVisibility() == View.VISIBLE) {
+ if (shouldUpdateText) {
+ result |= dropTarget.updateText(hideText);
+ } else if (dropTarget.isTextTruncated()) {
+ result = true;
+ break;
+ }
+ }
+ }
+
+ return result;
+ }
+
private void setupButtonDropTarget(View view, DragController dragController) {
if (view instanceof ButtonDropTarget) {
ButtonDropTarget bdt = (ButtonDropTarget) view;
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 5cd072223..4eba5c6df 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -350,8 +350,6 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc
ViewGroup.LayoutParams navBarBgLp = navBarBg.getLayoutParams();
navBarBgLp.height = insets.bottom;
navBarBg.setLayoutParams(navBarBgLp);
- navBarBg.setVisibility(FeatureFlags.LAUNCHER3_GRADIENT_ALL_APPS
- ? View.INVISIBLE : View.VISIBLE);
}
}