Merge "Fix drawer title not update to system language"
diff --git a/src/com/android/documentsui/dirlist/DirectoryFragment.java b/src/com/android/documentsui/dirlist/DirectoryFragment.java
index 76c7e05..cd040fe 100644
--- a/src/com/android/documentsui/dirlist/DirectoryFragment.java
+++ b/src/com/android/documentsui/dirlist/DirectoryFragment.java
@@ -902,7 +902,7 @@
                 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);
diff --git a/src/com/android/documentsui/picker/PickActivity.java b/src/com/android/documentsui/picker/PickActivity.java
index d240422..48ebc0b 100644
--- a/src/com/android/documentsui/picker/PickActivity.java
+++ b/src/com/android/documentsui/picker/PickActivity.java
@@ -23,6 +23,7 @@
 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 @@
 
     @Override
     public String getDrawerTitle() {
-        String title = getIntent().getStringExtra(DocumentsContract.EXTRA_PROMPT);
-        if (title == null) {
-            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) {
-                title = getResources().getString(R.string.title_save);
-            } else {
-                // If all else fails, just call it "Documents".
-                title = getResources().getString(R.string.app_label);
+        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) {
+                    title = getResources().getString(R.string.title_open);
+                } 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;
     }