Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 55b5610c authored by Ben Lin's avatar Ben Lin Committed by android-build-merger
Browse files

Updating DropShadow as drag and drop hovers over views.

am: 1c456299

Change-Id: Ib07b6813b5513c99976a181ea6238bab69b7e747
parents 882f7a44 1c456299
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <solid android:color="@color/item_doc_background" />
  <solid android:color="@color/item_drag_shadow_background" />
  <stroke
      android:width="1dp"
      android:color="#ff9f9f9f" />
+28 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<shape xmlns:android="http://schemas.android.com/apk/res/android"
       android:shape="rectangle">
  <solid android:color="@color/item_drag_shadow_background_no_drop" />
  <stroke
      android:width="1dp"
      android:color="#ff9f9f9f" />
  <corners
      android:bottomRightRadius="3dp"
      android:bottomLeftRadius="3dp"
      android:topLeftRadius="3dp"
      android:topRightRadius="3dp"/>
</shape>
+3 −0
Original line number Diff line number Diff line
@@ -39,4 +39,7 @@
    <color name="item_doc_background_selected">@*android:color/accent_device_default_50</color>
    <color name="item_breadcrumb_background_hovered">#1affffff</color>

    <color name="item_drag_shadow_background">#fffafafa</color>
    <color name="item_drag_shadow_background_no_drop">#ffffb6c1</color>

</resources>
+5 −0
Original line number Diff line number Diff line
@@ -487,6 +487,11 @@ public abstract class BaseActivity<T extends ActionHandler>
        return mState;
    }

    public DragShadowBuilder getShadowBuilder() {
        throw new UnsupportedOperationException(
                "Drag and drop not supported, can't get shadow builder");
    }

    /**
     * Set internal storage visible based on explicit user action.
     */
+39 −15
Original line number Diff line number Diff line
@@ -14,7 +14,7 @@
 * limitations under the License.
 */

package com.android.documentsui.dirlist;
package com.android.documentsui;

import android.content.Context;
import android.graphics.Canvas;
@@ -26,23 +26,26 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.documentsui.R;
import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.Shared;
import com.android.documentsui.dirlist.IconHelper;
import com.android.documentsui.dirlist.Model;
import com.android.documentsui.selection.Selection;

import java.util.List;
import java.util.function.Function;

final class DragShadowBuilder extends View.DragShadowBuilder {
public final class DragShadowBuilder extends View.DragShadowBuilder {

    private final View mShadowView;
    private final TextView mTitle;
    private final ImageView mIcon;
    private final int mWidth;
    private final int mHeight;
    private final Drawable mDefaultBackground;
    private final Drawable mNoDropBackground;

    public DragShadowBuilder(Context context, String title, Drawable icon) {
    public DragShadowBuilder(Context context) {
        mWidth = context.getResources().getDimensionPixelSize(R.dimen.drag_shadow_width);
        mHeight = context.getResources().getDimensionPixelSize(R.dimen.drag_shadow_height);

@@ -50,8 +53,10 @@ final class DragShadowBuilder extends View.DragShadowBuilder {
        mTitle = (TextView) mShadowView.findViewById(android.R.id.title);
        mIcon = (ImageView) mShadowView.findViewById(android.R.id.icon);

        mTitle.setText(title);
        mIcon.setImageDrawable(icon);
        mDefaultBackground = context.getResources().getDrawable(R.drawable.drag_shadow_background,
                null);
        mNoDropBackground = context.getResources()
                .getDrawable(R.drawable.drag_shadow_background_no_drop, null);
    }

    @Override
@@ -72,20 +77,39 @@ final class DragShadowBuilder extends View.DragShadowBuilder {
        mShadowView.draw(canvas);
    }

    public void updateTitle(String title) {
        mTitle.setText(title);
    }

    public void updateIcon(Drawable icon) {
        mIcon.setImageDrawable(icon);
    }

    public void resetBackground() {
        mShadowView.setBackground(mDefaultBackground);
    }

    public void setNoDropBackground() {
        mShadowView.setBackground(mNoDropBackground);
    }

    /**
     * Provides a means of fully isolating the mechanics of building drag shadows (and builders)
     * in support of testing.
     */
    public static final class Factory implements Function<Selection, DragShadowBuilder> {
    public static final class Updater implements Function<Selection, DragShadowBuilder> {

        private final Context mContext;
        private final IconHelper mIconHelper;
        private final Drawable mDefaultDragIcon;
        private Model mModel;
        private final Model mModel;
        private final DragShadowBuilder mShadowBuilder;

        public Factory(
                Context context, Model model, IconHelper iconHelper, Drawable defaultDragIcon) {
        public Updater(
                Context context, DragShadowBuilder shadowBuilder, Model model,
                IconHelper iconHelper, Drawable defaultDragIcon) {
            mContext = context;
            mShadowBuilder = shadowBuilder;
            mModel = model;
            mIconHelper = iconHelper;
            mDefaultDragIcon = defaultDragIcon;
@@ -93,10 +117,10 @@ final class DragShadowBuilder extends View.DragShadowBuilder {

        @Override
        public DragShadowBuilder apply(Selection selection) {
            return new DragShadowBuilder(
                    mContext,
                    getDragTitle(selection),
                    getDragIcon(selection));
            mShadowBuilder.updateTitle(getDragTitle(selection));
            mShadowBuilder.updateIcon(getDragIcon(selection));

            return mShadowBuilder;
        }

        private Drawable getDragIcon(Selection selection) {
Loading