From b8397607ee17709c9f743edce2d4e1fa23c8bb27 Mon Sep 17 00:00:00 2001 From: Steve McKay Date: Thu, 18 Feb 2016 11:32:26 -0800 Subject: [PATCH] Fix CTS failure. Loosen the reigns on setPickTarget to accommodate no sub command mode. Change-Id: Ia11c4194970c93fe86e98dfd0d23ed4fa1cea765 --- .../src/com/android/documentsui/PickFragment.java | 15 +++++++++------ .../src/com/android/documentsui/State.java | 6 ++++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java index 287c90466a861..32543c82621e5 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java +++ b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java @@ -16,8 +16,9 @@ package com.android.documentsui; -import static com.android.documentsui.services.FileOperationService.OPERATION_COPY; +import static com.android.documentsui.services.FileOperationService.OPERATION_DELETE; import static com.android.documentsui.services.FileOperationService.OPERATION_MOVE; +import static com.android.documentsui.services.FileOperationService.OPERATION_UNKNOWN; import static com.android.internal.util.Preconditions.checkArgument; import android.app.Activity; @@ -40,7 +41,8 @@ public class PickFragment extends Fragment { public static final String TAG = "PickFragment"; private int mAction; - private @OpType int mOperationType; + // Only legal values are OPERATION_COPY, OPERATION_MOVE, and unset (OPERATION_UNKNOWN). + private @OpType int mCopyOperationSubType = OPERATION_UNKNOWN; private DocumentInfo mPickTarget; private View mContainer; private Button mPick; @@ -97,10 +99,11 @@ public class PickFragment extends Fragment { /** * @param action Which action defined in State is the picker shown for. */ - public void setPickTarget(int action, @OpType int operationType, DocumentInfo pickTarget) { - checkArgument(operationType == OPERATION_COPY || operationType == OPERATION_MOVE); + public void setPickTarget( + int action, @OpType int copyOperationSubType, DocumentInfo pickTarget) { + checkArgument(copyOperationSubType != OPERATION_DELETE); mAction = action; - mOperationType = operationType; + mCopyOperationSubType = copyOperationSubType; mPickTarget = pickTarget; if (mContainer != null) { updateView(); @@ -117,7 +120,7 @@ public class PickFragment extends Fragment { mCancel.setVisibility(View.GONE); break; case State.ACTION_PICK_COPY_DESTINATION: - mPick.setText(mOperationType == OPERATION_MOVE + mPick.setText(mCopyOperationSubType == OPERATION_MOVE ? R.string.button_move : R.string.button_copy); mCancel.setVisibility(View.VISIBLE); break; diff --git a/packages/DocumentsUI/src/com/android/documentsui/State.java b/packages/DocumentsUI/src/com/android/documentsui/State.java index 81a063545691f..0948ab1e75718 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/State.java +++ b/packages/DocumentsUI/src/com/android/documentsui/State.java @@ -30,6 +30,7 @@ import com.android.documentsui.model.DocumentInfo; import com.android.documentsui.model.DocumentStack; import com.android.documentsui.model.DurableUtils; import com.android.documentsui.model.RootInfo; +import com.android.documentsui.services.FileOperationService; import com.android.documentsui.services.FileOperationService.OpType; import java.lang.annotation.Retention; @@ -93,9 +94,10 @@ public class State implements android.os.Parcelable { /** * This is basically a sub-type for the copy operation. It can be either COPY or MOVE. - * The only legal values are: OPERATION_COPY, OPERATION_MOVE. + * The only legal values, if set, are: OPERATION_COPY, OPERATION_MOVE. Other pick + * operations don't use this. In those cases OPERATION_UNKNOWN is also legal. */ - public @OpType int copyOperationSubType; + public @OpType int copyOperationSubType = FileOperationService.OPERATION_UNKNOWN; /** Current user navigation stack; empty implies recents. */ public DocumentStack stack = new DocumentStack();