Merge "DocumentUI: Plish the design of footer bottons." into mnc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
b7d072f42f
@@ -19,13 +19,13 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:baselineAligned="false"
|
||||
android:gravity="center_vertical"
|
||||
android:gravity="end"
|
||||
android:paddingEnd="8dp"
|
||||
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" />
|
||||
@@ -33,7 +33,5 @@
|
||||
android:id="@android:id/button1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:textAllCaps="false"
|
||||
style="?android:attr/buttonBarPositiveButtonStyle" />
|
||||
</LinearLayout>
|
||||
|
||||
@@ -44,8 +44,6 @@
|
||||
<string name="menu_share">Share</string>
|
||||
<!-- Menu item title that deletes the selected documents [CHAR LIMIT=24] -->
|
||||
<string name="menu_delete">Delete</string>
|
||||
<!-- Menu item title that selects the current directory [CHAR LIMIT=48] -->
|
||||
<string name="menu_select">Select \"<xliff:g id="directory" example="My Directory">^1</xliff:g>\"</string>
|
||||
<!-- Menu item title that selects all documents in the current directory [CHAR LIMIT=24] -->
|
||||
<string name="menu_select_all">Select All</string>
|
||||
<!-- Menu item title that copies the selected documents [CHAR LIMIT=24] -->
|
||||
@@ -65,7 +63,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] -->
|
||||
<!-- Button label that select the current directory [CHAR LIMIT=24] -->
|
||||
<string name="button_select">Select</string>
|
||||
<!-- Button label that copies files to the current directory [CHAR LIMIT=24] -->
|
||||
<string name="button_copy">Copy</string>
|
||||
|
||||
<!-- Action mode title summarizing the number of documents selected [CHAR LIMIT=32] -->
|
||||
|
||||
@@ -571,9 +571,7 @@ public class DocumentsActivity extends BaseActivity {
|
||||
mState.action == ACTION_OPEN_COPY_DESTINATION) {
|
||||
final PickFragment pick = PickFragment.get(fm);
|
||||
if (pick != null) {
|
||||
final CharSequence displayName = (mState.stack.size() <= 1) ? root.title
|
||||
: cwd.displayName;
|
||||
pick.setPickTarget(mState.action, cwd, displayName);
|
||||
pick.setPickTarget(mState.action, cwd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,15 +38,19 @@ import java.util.Locale;
|
||||
public class PickFragment extends Fragment {
|
||||
public static final String TAG = "PickFragment";
|
||||
|
||||
private int mAction;
|
||||
private DocumentInfo mPickTarget;
|
||||
|
||||
private View mContainer;
|
||||
private Button mPick;
|
||||
private Button mCancel;
|
||||
|
||||
public static void show(FragmentManager fm) {
|
||||
final PickFragment fragment = new PickFragment();
|
||||
// Fragment can be restored by FragmentManager automatically.
|
||||
if (get(fm) != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final PickFragment fragment = new PickFragment();
|
||||
final FragmentTransaction ft = fm.beginTransaction();
|
||||
ft.replace(R.id.container_save, fragment, TAG);
|
||||
ft.commitAllowingStateLoss();
|
||||
@@ -67,8 +71,7 @@ public class PickFragment extends Fragment {
|
||||
mCancel = (Button) mContainer.findViewById(android.R.id.button2);
|
||||
mCancel.setOnClickListener(mCancelListener);
|
||||
|
||||
setPickTarget(0, null, null);
|
||||
|
||||
updateView();
|
||||
return mContainer;
|
||||
}
|
||||
|
||||
@@ -92,32 +95,38 @@ public class PickFragment extends Fragment {
|
||||
/**
|
||||
* @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 (pickTarget != null) {
|
||||
final Locale locale = getResources().getConfiguration().locale;
|
||||
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.");
|
||||
}
|
||||
}
|
||||
if (pickTarget != null && pickTarget.isCreateSupported()) {
|
||||
mContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
public void setPickTarget(int action, DocumentInfo pickTarget) {
|
||||
mAction = action;
|
||||
mPickTarget = pickTarget;
|
||||
if (mContainer != null) {
|
||||
updateView();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the state of fragment to the view components.
|
||||
*/
|
||||
private void updateView() {
|
||||
switch (mAction) {
|
||||
case BaseActivity.State.ACTION_OPEN_TREE:
|
||||
mPick.setText(R.string.button_select);
|
||||
mCancel.setVisibility(View.GONE);
|
||||
break;
|
||||
case BaseActivity.State.ACTION_OPEN_COPY_DESTINATION:
|
||||
mPick.setText(R.string.button_copy);
|
||||
mCancel.setVisibility(View.VISIBLE);
|
||||
break;
|
||||
default:
|
||||
mContainer.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mPickTarget != null && (
|
||||
mAction == BaseActivity.State.ACTION_OPEN_TREE ||
|
||||
mPickTarget.isCreateSupported())) {
|
||||
mContainer.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mContainer.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user