summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI
diff options
context:
space:
mode:
authorDaichi Hirono <hirono@google.com>2015-04-14 12:16:59 +0900
committerDaichi Hirono <hirono@google.com>2015-04-15 12:57:53 +0900
commitde021abe409a293492d998d8b837ea1aee9604ff (patch)
treec4d18d6e9456703bdf7775967ce342d0b6ad09b0 /packages/DocumentsUI
parentfff30439cafb737eb54de807caab4fb61432f2cc (diff)
downloadframeworks_base-de021abe409a293492d998d8b837ea1aee9604ff.zip
frameworks_base-de021abe409a293492d998d8b837ea1aee9604ff.tar.gz
frameworks_base-de021abe409a293492d998d8b837ea1aee9604ff.tar.bz2
DocumentsUI: Polish buttons of copy destination dialog.
* Add cancel button to directory picker dialog. * Turns "select" label to "copy to" label for copy destination picker. BUG=20170953 Change-Id: I66214804aed75a6fccc716d1a01163c634e73d7f
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r--packages/DocumentsUI/res/layout/fragment_pick.xml13
-rw-r--r--packages/DocumentsUI/res/values/strings.xml5
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java2
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/PickFragment.java43
4 files changed, 51 insertions, 12 deletions
diff --git a/packages/DocumentsUI/res/layout/fragment_pick.xml b/packages/DocumentsUI/res/layout/fragment_pick.xml
index 5735871..87dc4f8 100644
--- a/packages/DocumentsUI/res/layout/fragment_pick.xml
+++ b/packages/DocumentsUI/res/layout/fragment_pick.xml
@@ -21,12 +21,19 @@
android:baselineAligned="false"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall">
-
+ <Button
+ android:id="@android:id/button2"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_weight="1"
+ android:text="@android:string/cancel"
+ android:visibility="gone"
+ style="?android:attr/buttonBarNegativeButtonStyle" />
<Button
android:id="@android:id/button1"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="match_parent"
+ android:layout_weight="1"
android:textAllCaps="false"
style="?android:attr/buttonBarPositiveButtonStyle" />
-
</LinearLayout>
diff --git a/packages/DocumentsUI/res/values/strings.xml b/packages/DocumentsUI/res/values/strings.xml
index 3ca239a..2de3af9 100644
--- a/packages/DocumentsUI/res/values/strings.xml
+++ b/packages/DocumentsUI/res/values/strings.xml
@@ -65,6 +65,9 @@
<!-- Menu item that hides the sizes of displayed files [CHAR LIMIT=24] -->
<string name="menu_file_size_hide">Hide file size</string>
+ <!-- Button label that copies files to the current directory [CHAR LIMIT=48] -->
+ <string name="button_copy">Copy</string>
+
<!-- Action mode title summarizing the number of documents selected [CHAR LIMIT=32] -->
<string name="mode_selected_count"><xliff:g id="count" example="3">%1$d</xliff:g> selected</string>
@@ -112,8 +115,6 @@
<!-- Title of dialog when prompting user to select an app to share documents with [CHAR LIMIT=32] -->
<string name="share_via">Share via</string>
- <!-- Title of the cancel button [CHAR LIMIT=24] -->
- <string name="cancel">Cancel</string>
<!-- Title of the copy notification [CHAR LIMIT=24] -->
<string name="copy_notification_title">Copying files</string>
<!-- Text shown on the copy notification to indicate remaining time, in minutes [CHAR LIMIT=24] -->
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
index 1e798eb..b6e0711 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DocumentsActivity.java
@@ -906,7 +906,7 @@ public class DocumentsActivity extends BaseActivity {
if (pick != null) {
final CharSequence displayName = (mState.stack.size() <= 1) ? root.title
: cwd.displayName;
- pick.setPickTarget(cwd, displayName);
+ pick.setPickTarget(mState.action, cwd, displayName);
}
}
diff --git a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java
index 4b008ca..5e565bf 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/PickFragment.java
@@ -16,6 +16,8 @@
package com.android.documentsui;
+import android.R.string;
+import android.app.Activity;
import android.app.Fragment;
import android.app.FragmentManager;
import android.app.FragmentTransaction;
@@ -40,6 +42,7 @@ public class PickFragment extends Fragment {
private View mContainer;
private Button mPick;
+ private Button mCancel;
public static void show(FragmentManager fm) {
final PickFragment fragment = new PickFragment();
@@ -61,7 +64,10 @@ public class PickFragment extends Fragment {
mPick = (Button) mContainer.findViewById(android.R.id.button1);
mPick.setOnClickListener(mPickListener);
- setPickTarget(null, null);
+ mCancel = (Button) mContainer.findViewById(android.R.id.button2);
+ mCancel.setOnClickListener(mCancelListener);
+
+ setPickTarget(0, null, null);
return mContainer;
}
@@ -74,18 +80,43 @@ public class PickFragment extends Fragment {
}
};
- public void setPickTarget(DocumentInfo pickTarget, CharSequence displayName) {
- mPickTarget = pickTarget;
+ private View.OnClickListener mCancelListener = new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ final BaseActivity activity = BaseActivity.get(PickFragment.this);
+ activity.setResult(Activity.RESULT_CANCELED);
+ activity.finish();
+ }
+ };
+ /**
+ * @param action Which action defined in BaseActivity.State is the picker shown for.
+ */
+ public void setPickTarget(int action,
+ DocumentInfo pickTarget,
+ CharSequence displayName) {
if (mContainer != null) {
- if (mPickTarget != null) {
+ if (pickTarget != null) {
mContainer.setVisibility(View.VISIBLE);
final Locale locale = getResources().getConfiguration().locale;
- final String raw = getString(R.string.menu_select).toUpperCase(locale);
- mPick.setText(TextUtils.expandTemplate(raw, displayName));
+ switch (action) {
+ case BaseActivity.State.ACTION_OPEN_TREE:
+ final String raw = getString(R.string.menu_select).toUpperCase(locale);
+ mPick.setText(TextUtils.expandTemplate(raw, displayName));
+ mCancel.setVisibility(View.GONE);
+ break;
+ case BaseActivity.State.ACTION_OPEN_COPY_DESTINATION:
+ mPick.setText(getString(R.string.button_copy).toUpperCase(locale));
+ mCancel.setVisibility(View.VISIBLE);
+ break;
+ default:
+ throw new IllegalArgumentException("Illegal action for PickFragment.");
+ }
+
} else {
mContainer.setVisibility(View.GONE);
}
}
+ mPickTarget = pickTarget;
}
}