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

Commit 05a566bf authored by Tony Huang's avatar Tony Huang
Browse files

Fix drawer title not update to system language

Because operation like copy or move, the drawer tile is set by previous
activity. It will not update when activity recreate cause by system
language update.
Change it only set string id and get string on PickerActivity.

Fix: 140392869
Test: manual
Test: DocumentsUIGooglteTests
Change-Id: Ia502fe4ea61690e0e3d36b8eacb63df1bbee3be5
parent c12e4d60
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -896,7 +896,7 @@ public class DirectoryFragment extends Fragment implements SwipeRefreshLayout.On
                throw new UnsupportedOperationException("Unknown mode: " + mode);
        }

        intent.putExtra(DocumentsContract.EXTRA_PROMPT, getResources().getString(drawerTitleId));
        intent.putExtra(DocumentsContract.EXTRA_PROMPT, drawerTitleId);

        // Model must be accessed in UI thread, since underlying cursor is not threadsafe.
        List<DocumentInfo> docs = mModel.getDocuments(selected);
+21 −13
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import static com.android.documentsui.base.State.ACTION_OPEN_TREE;
import static com.android.documentsui.base.State.ACTION_PICK_COPY_DESTINATION;

import android.content.Intent;
import android.content.res.Resources;
import android.graphics.Color;
import android.net.Uri;
import android.os.Bundle;
@@ -264,21 +265,28 @@ public class PickActivity extends BaseActivity implements ActionHandler.Addons {

    @Override
    public String getDrawerTitle() {
        String title = getIntent().getStringExtra(DocumentsContract.EXTRA_PROMPT);
        String title;
        try {
            // Internal use case, we will send string id instead of string text.
            title = getResources().getString(
                    getIntent().getIntExtra(DocumentsContract.EXTRA_PROMPT, -1));
        } catch (Resources.NotFoundException e) {
            // 3rd party use case, it should send string text.
            title = getIntent().getStringExtra(DocumentsContract.EXTRA_PROMPT);
            if (title == null) {
            if (mState.action == ACTION_OPEN ||
                mState.action == ACTION_GET_CONTENT ||
                mState.action == ACTION_OPEN_TREE) {
                if (mState.action == ACTION_OPEN
                        || mState.action == ACTION_GET_CONTENT
                        || mState.action == ACTION_OPEN_TREE) {
                    title = getResources().getString(R.string.title_open);
            } else if (mState.action == ACTION_CREATE ||
                       mState.action == ACTION_PICK_COPY_DESTINATION) {
                } else if (mState.action == ACTION_CREATE
                        || mState.action == ACTION_PICK_COPY_DESTINATION) {
                    title = getResources().getString(R.string.title_save);
                } else {
                    // If all else fails, just call it "Documents".
                    title = getResources().getString(R.string.app_label);
                }
            }

        }
        return title;
    }