diff options
| author | Leon Scroggins <scroggo@google.com> | 2009-10-02 15:55:59 -0400 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2009-10-09 10:57:48 -0400 |
| commit | 8d5fa439c93c336197cfca4a0bfca7147e43353d (patch) | |
| tree | aee3c8a9a92a40acae22e8a9f19804c82825c6dd /src/com/android/browser/BrowserActivity.java | |
| parent | 4f439baf097ac40d2face176e1660d4d1b367ed5 (diff) | |
File upload.
Requires changes in external/webkit and frameworks/base.
Fix http://b/issue?id=675743
Diffstat (limited to 'src/com/android/browser/BrowserActivity.java')
| -rw-r--r-- | src/com/android/browser/BrowserActivity.java | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/com/android/browser/BrowserActivity.java b/src/com/android/browser/BrowserActivity.java index 45b2cdd5..0eeb60f6 100644 --- a/src/com/android/browser/BrowserActivity.java +++ b/src/com/android/browser/BrowserActivity.java @@ -130,8 +130,6 @@ import android.widget.Toast; import java.io.BufferedOutputStream; import java.io.ByteArrayOutputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; @@ -1143,6 +1141,11 @@ public class BrowserActivity extends Activity } super.onDestroy(); + if (mUploadMessage != null) { + mUploadMessage.onReceiveValue(null); + mUploadMessage = null; + } + if (mTabControl == null) return; // Remove the current tab and sub window @@ -3490,6 +3493,18 @@ public class BrowserActivity extends Activity return mVideoProgressView; } + @Override + public void openFileChooser(ValueCallback<Uri> uploadMsg) { + if (mUploadMessage != null) return; + mUploadMessage = uploadMsg; + Intent i = new Intent(Intent.ACTION_GET_CONTENT); + i.addCategory(Intent.CATEGORY_OPENABLE); + i.setType("*/*"); + BrowserActivity.this.startActivityForResult( + Intent.createChooser(i, getString(R.string.choose_upload)), + FILE_SELECTED); + } + /** * Deliver a list of already-visited URLs * @hide pending API Council approval @@ -3510,6 +3525,11 @@ public class BrowserActivity extends Activity }; }; + /* + * The Object used to inform the WebView of the file to upload. + */ + private ValueCallback<Uri> mUploadMessage; + /** * Notify the host application a download should be done, or that * the data should be streamed if a streaming viewer is available. @@ -4227,6 +4247,14 @@ public class BrowserActivity extends Activity } } break; + // Choose a file from the file picker. + case FILE_SELECTED: + if (null == mUploadMessage) break; + Uri result = intent == null || resultCode != RESULT_OK ? null + : intent.getData(); + mUploadMessage.onReceiveValue(result); + mUploadMessage = null; + break; default: break; } @@ -4576,6 +4604,7 @@ public class BrowserActivity extends Activity final static int COMBO_PAGE = 1; final static int DOWNLOAD_PAGE = 2; final static int PREFERENCES_PAGE = 3; + final static int FILE_SELECTED = 4; // the default <video> poster private Bitmap mDefaultVideoPoster; |
