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

Commit 738ed142 authored by Daichi Hirono's avatar Daichi Hirono Committed by Android (Google) Code Review
Browse files

Merge "DocumentsUI: Polish buttons of copy destination dialog."

parents 3abfa03e de021abe
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -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>
+3 −2
Original line number Diff line number Diff line
@@ -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] -->
+1 −1
Original line number Diff line number Diff line
@@ -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);
            }
        }

+37 −6
Original line number Diff line number Diff line
@@ -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;
                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;
    }
}