Loading res/drawable/drag_shadow_background.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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" /> Loading res/drawable/drag_shadow_background_no_drop.xml 0 → 100644 +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> res/values/colors.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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> src/com/android/documentsui/BaseActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading src/com/android/documentsui/dirlist/DragShadowBuilder.java→src/com/android/documentsui/DragShadowBuilder.java +39 −15 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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 Loading @@ -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; Loading @@ -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 Loading
res/drawable/drag_shadow_background.xml +1 −1 Original line number Diff line number Diff line Loading @@ -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" /> Loading
res/drawable/drag_shadow_background_no_drop.xml 0 → 100644 +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>
res/values/colors.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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>
src/com/android/documentsui/BaseActivity.java +5 −0 Original line number Diff line number Diff line Loading @@ -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. */ Loading
src/com/android/documentsui/dirlist/DragShadowBuilder.java→src/com/android/documentsui/DragShadowBuilder.java +39 −15 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); Loading @@ -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 Loading @@ -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; Loading @@ -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