OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.ui; | 5 package org.chromium.ui; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.ContentResolver; | 8 import android.content.ContentResolver; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.database.Cursor; | 10 import android.database.Cursor; |
11 import android.net.Uri; | 11 import android.net.Uri; |
12 import android.os.Environment; | 12 import android.os.Environment; |
13 import android.provider.MediaStore; | 13 import android.provider.MediaStore; |
14 | 14 |
15 import java.io.File; | 15 import java.io.File; |
16 import java.util.ArrayList; | 16 import java.util.ArrayList; |
17 import java.util.Arrays; | 17 import java.util.Arrays; |
18 import java.util.List; | 18 import java.util.List; |
19 | 19 |
20 import org.chromium.base.CalledByNative; | 20 import org.chromium.base.CalledByNative; |
21 import org.chromium.base.JNINamespace; | 21 import org.chromium.base.JNINamespace; |
22 import org.chromium.ui.gfx.NativeWindow; | 22 import org.chromium.ui.gfx.NativeWindow; |
23 | 23 |
24 /** | 24 /** |
25 * A dialog that is triggered from a file input field that allows a user to sele
ct a file based on | 25 * A dialog that is triggered from a file input field that allows a user to sele
ct a file based on |
26 * a set of accepted file types. The path of the selected file is passed to the
native dialog. | 26 * a set of accepted file types. The path of the selected file is passed to the
native dialog. |
27 */ | 27 */ |
28 @JNINamespace("ui") | 28 @JNINamespace("ui") |
29 class SelectFileDialog implements NativeWindow.IntentCallback{ | 29 class SelectFileDialog implements NativeWindow.IntentCallback{ |
30 // TODO (aurimas): Swap these constants with AppResources when it gets moved
to base to support | 30 // TODO (aurimas): Move these constants into strings.xml within ui (after cr
bug.com/136704 is |
31 // internationalization. | 31 // fixed) to support internationalization. |
32 private static final String LOW_MEMORY_ERROR = | 32 private static final String LOW_MEMORY_ERROR = |
33 "Unable to complete previous operation due to low memory"; | 33 "Unable to complete previous operation due to low memory"; |
34 private static final String OPENING_FILE_ERROR = "Failed to open selected fi
le"; | 34 private static final String OPENING_FILE_ERROR = "Failed to open selected fi
le"; |
35 | 35 |
36 private static final String IMAGE_TYPE = "image/"; | 36 private static final String IMAGE_TYPE = "image/"; |
37 private static final String VIDEO_TYPE = "video/"; | 37 private static final String VIDEO_TYPE = "video/"; |
38 private static final String AUDIO_TYPE = "audio/"; | 38 private static final String AUDIO_TYPE = "audio/"; |
39 private static final String ALL_IMAGE_TYPES = IMAGE_TYPE + "*"; | 39 private static final String ALL_IMAGE_TYPES = IMAGE_TYPE + "*"; |
40 private static final String ALL_VIDEO_TYPES = VIDEO_TYPE + "*"; | 40 private static final String ALL_VIDEO_TYPES = VIDEO_TYPE + "*"; |
41 private static final String ALL_AUDIO_TYPES = AUDIO_TYPE + "*"; | 41 private static final String ALL_AUDIO_TYPES = AUDIO_TYPE + "*"; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 248 |
249 @CalledByNative | 249 @CalledByNative |
250 private static SelectFileDialog create(int nativeSelectFileDialog) { | 250 private static SelectFileDialog create(int nativeSelectFileDialog) { |
251 return new SelectFileDialog(nativeSelectFileDialog); | 251 return new SelectFileDialog(nativeSelectFileDialog); |
252 } | 252 } |
253 | 253 |
254 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl, | 254 private native void nativeOnFileSelected(int nativeSelectFileDialogImpl, |
255 String filePath); | 255 String filePath); |
256 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl); | 256 private native void nativeOnFileNotSelected(int nativeSelectFileDialogImpl); |
257 } | 257 } |
OLD | NEW |