diff options
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/android/launcher3/ButtonDropTarget.java | 21 | ||||
-rw-r--r-- | src/com/android/launcher3/DeleteDropTarget.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 27 |
3 files changed, 15 insertions, 36 deletions
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index d8826831a..af1ebde8f 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -24,11 +24,13 @@ import android.animation.ValueAnimator.AnimatorUpdateListener; import android.annotation.TargetApi; import android.content.Context; import android.content.res.ColorStateList; +import android.content.res.TypedArray; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; import android.graphics.PointF; import android.graphics.Rect; import android.graphics.drawable.Drawable; +import android.graphics.drawable.InsetDrawable; import android.os.Build; import android.util.AttributeSet; import android.view.View; @@ -52,6 +54,8 @@ public abstract class ButtonDropTarget extends TextView private static final int DRAG_VIEW_DROP_DURATION = 285; + private final boolean mHideParentOnDisable; + protected Launcher mLauncher; private int mBottomDragPadding; protected BaseDropTargetBar mDropTargetBar; @@ -65,12 +69,9 @@ public abstract class ButtonDropTarget extends TextView protected ColorStateList mOriginalTextColor; protected Drawable mDrawable; - protected DeviceProfile mDeviceProfile; - private AnimatorSet mCurrentColorAnim; @Thunk ColorMatrix mSrcFilter, mDstFilter, mCurrentFilter; - public ButtonDropTarget(Context context, AttributeSet attrs) { this(context, attrs, 0); } @@ -78,18 +79,17 @@ public abstract class ButtonDropTarget extends TextView public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding); + + TypedArray a = context.obtainStyledAttributes(attrs, + R.styleable.ButtonDropTarget, defStyle, 0); + mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false); + a.recycle(); } @Override protected void onFinishInflate() { super.onFinishInflate(); mOriginalTextColor = getTextColors(); - - // Remove the text in the Phone UI in landscape - mDeviceProfile = ((Launcher) getContext()).getDeviceProfile(); - if (mDeviceProfile.isVerticalBarLayout()) { - setText(""); - } } @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) @@ -203,7 +203,8 @@ public abstract class ButtonDropTarget extends TextView mCurrentColorAnim = null; } setTextColor(mOriginalTextColor); - ((ViewGroup) getParent()).setVisibility(mActive ? View.VISIBLE : View.GONE); + (mHideParentOnDisable ? ((ViewGroup) getParent()) : this) + .setVisibility(mActive ? View.VISIBLE : View.GONE); } @Override diff --git a/src/com/android/launcher3/DeleteDropTarget.java b/src/com/android/launcher3/DeleteDropTarget.java index 997ded2d3..f24e00b5c 100644 --- a/src/com/android/launcher3/DeleteDropTarget.java +++ b/src/com/android/launcher3/DeleteDropTarget.java @@ -19,6 +19,7 @@ package com.android.launcher3; import android.animation.TimeInterpolator; import android.content.Context; import android.graphics.PointF; +import android.text.TextUtils; import android.util.AttributeSet; import android.view.View; import android.view.animation.AnimationUtils; @@ -69,7 +70,7 @@ 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 (!mDeviceProfile.isVerticalBarLayout()) { + if (!TextUtils.isEmpty(getText())) { setText(dragSource.supportsDeleteDropTarget() ? R.string.remove_drop_target_label : android.R.string.cancel); } diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 5bfa716ee..7c6f39e9c 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -31,7 +31,6 @@ import android.view.ViewGroup; import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.MarginLayoutParams; import android.widget.FrameLayout; -import android.widget.LinearLayout; import com.android.launcher3.config.FeatureFlags; @@ -469,7 +468,7 @@ public class DeviceProfile { // Layout the search bar space Rect searchBarBounds = getSearchBarBounds(isLayoutRtl); View searchBar = launcher.getSearchDropTargetBar(); - lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP); + lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); lp.width = searchBarBounds.width(); lp.height = searchBarBounds.height(); lp.topMargin = searchBarTopExtraPaddingPx; @@ -477,7 +476,7 @@ public class DeviceProfile { // Layout the app info bar space View appInfoBar = launcher.getAppInfoDropTargetBar(); - lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM); + lp = (FrameLayout.LayoutParams) appInfoBar.getLayoutParams(); lp.bottomMargin = hotseatBarHeightPx; appInfoBar.setLayoutParams(lp); @@ -584,28 +583,6 @@ public class DeviceProfile { } } - private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout, - View dropTargetBar, int verticalGravity) { - FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams(); - if (hasVerticalBarLayout) { - // Vertical drop target bar space -- The drop target bar is fixed in the layout to be on - // the left of the screen regardless of RTL - lp.gravity = Gravity.LEFT; - lp.width = normalSearchBarSpaceHeightPx; - - LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar); - targets.setOrientation(LinearLayout.VERTICAL); - FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams(); - targetsLp.gravity = verticalGravity; - targetsLp.height = LayoutParams.WRAP_CONTENT; - } else { - // Horizontal drop target bar space - lp.gravity = verticalGravity | Gravity.CENTER_HORIZONTAL; - lp.height = searchBarSpaceHeightPx; - } - return lp; - } - private int getCurrentWidth() { return isLandscape ? Math.max(widthPx, heightPx) |