OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.chrome.browser.photo_picker; | 5 package org.chromium.chrome.browser.photo_picker; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Bundle; | 8 import android.os.Bundle; |
9 import android.support.annotation.Nullable; | |
9 import android.support.v7.app.AlertDialog; | 10 import android.support.v7.app.AlertDialog; |
10 import android.view.ViewGroup.LayoutParams; | 11 import android.view.ViewGroup.LayoutParams; |
11 import android.view.WindowManager; | 12 import android.view.WindowManager; |
12 | 13 |
14 import org.chromium.base.VisibleForTesting; | |
13 import org.chromium.chrome.R; | 15 import org.chromium.chrome.R; |
14 import org.chromium.ui.PhotoPickerListener; | 16 import org.chromium.ui.PhotoPickerListener; |
15 | 17 |
18 import java.util.List; | |
19 | |
16 /** | 20 /** |
17 * UI for the photo chooser that shows on the Android platform as a result of | 21 * UI for the photo chooser that shows on the Android platform as a result of |
18 * <input type=file accept=image > form element. | 22 * <input type=file accept=image > form element. |
19 */ | 23 */ |
20 public class PhotoPickerDialog extends AlertDialog { | 24 public class PhotoPickerDialog extends AlertDialog { |
21 // The category we're showing photos for. | 25 // The category we're showing photos for. |
22 private PickerCategoryView mCategoryView; | 26 private PickerCategoryView mCategoryView; |
23 | 27 |
24 /** | 28 /** |
25 * The PhotoPickerDialog constructor. | 29 * The PhotoPickerDialog constructor. |
26 * @param context The context to use. | 30 * @param context The context to use. |
27 * @param listener The listener object that gets notified when an action is taken. | 31 * @param listener The listener object that gets notified when an action is taken. |
28 * @param multiSelectionAllowed Whether the photo picker should allow multip le items to be | 32 * @param multiSelectionAllowed Whether the photo picker should allow multip le items to be |
29 * selected. | 33 * selected. |
34 * @param testFiles A list of photos to show (testing use only). | |
30 */ | 35 */ |
31 public PhotoPickerDialog( | 36 public PhotoPickerDialog(Context context, PhotoPickerListener listener, |
32 Context context, PhotoPickerListener listener, boolean multiSelectio nAllowed) { | 37 boolean multiSelectionAllowed, @Nullable List<PickerBitmap> testFile s) { |
Theresa
2017/05/19 16:52:42
Rather than passing test files into the constructo
Finnur
2017/05/23 13:19:50
Good idea. Thanks! Done.
| |
33 super(context, R.style.FullscreenWhite); | 38 super(context, R.style.FullscreenWhite); |
34 | 39 |
35 // Initialize the main content view. | 40 // Initialize the main content view. |
36 mCategoryView = new PickerCategoryView(context); | 41 mCategoryView = new PickerCategoryView(context, testFiles); |
37 mCategoryView.initialize(this, listener, multiSelectionAllowed); | 42 mCategoryView.initialize(this, listener, multiSelectionAllowed); |
38 setView(mCategoryView); | 43 setView(mCategoryView); |
39 } | 44 } |
40 | 45 |
41 @Override | 46 @Override |
42 protected void onCreate(Bundle savedInstanceState) { | 47 protected void onCreate(Bundle savedInstanceState) { |
43 super.onCreate(savedInstanceState); | 48 super.onCreate(savedInstanceState); |
44 | 49 |
45 getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARE NT); | 50 getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARE NT); |
46 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, | 51 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, |
47 WindowManager.LayoutParams.FLAG_FULLSCREEN); | 52 WindowManager.LayoutParams.FLAG_FULLSCREEN); |
48 } | 53 } |
49 | 54 |
50 @Override | 55 @Override |
51 public void dismiss() { | 56 public void dismiss() { |
52 super.dismiss(); | 57 super.dismiss(); |
53 mCategoryView.onDialogDismissed(); | 58 mCategoryView.onDialogDismissed(); |
54 } | 59 } |
60 | |
61 @VisibleForTesting | |
62 public PickerCategoryView getCategoryViewForTesting() { | |
63 return mCategoryView; | |
64 } | |
55 } | 65 } |
OLD | NEW |