OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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; | 5 package org.chromium.chrome.browser; |
6 | 6 |
7 import android.Manifest; | 7 import android.Manifest; |
8 import android.app.Activity; | 8 import android.app.Activity; |
9 import android.content.BroadcastReceiver; | 9 import android.content.BroadcastReceiver; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 28 matching lines...) Expand all Loading... | |
39 // notifyDiscoveryState(). | 39 // notifyDiscoveryState(). |
40 static final int DISCOVERY_FAILED_TO_START = 0; | 40 static final int DISCOVERY_FAILED_TO_START = 0; |
41 static final int DISCOVERING = 1; | 41 static final int DISCOVERING = 1; |
42 static final int DISCOVERY_IDLE = 2; | 42 static final int DISCOVERY_IDLE = 2; |
43 | 43 |
44 // Values passed to nativeOnDialogFinished:eventType, and only used in the n ative function. | 44 // Values passed to nativeOnDialogFinished:eventType, and only used in the n ative function. |
45 static final int DIALOG_FINISHED_DENIED_PERMISSION = 0; | 45 static final int DIALOG_FINISHED_DENIED_PERMISSION = 0; |
46 static final int DIALOG_FINISHED_CANCELLED = 1; | 46 static final int DIALOG_FINISHED_CANCELLED = 1; |
47 static final int DIALOG_FINISHED_SELECTED = 2; | 47 static final int DIALOG_FINISHED_SELECTED = 2; |
48 | 48 |
49 private static final ItemChooserDialog.ItemChooserRowIcon | |
50 SIGNAL_STRENGTH_ICONS[] = new ItemChooserDialog.ItemChooserRowIcon[] { | |
51 new ItemChooserDialog.ItemChooserRowIcon( | |
52 R.drawable.ic_signal_cellular_0_bar_black_48dp, | |
juncai
2016/08/26 19:37:48
Are the signal strength icon images added in diffe
ortuno
2016/09/12 05:11:27
Each directory has a copy of the image in a differ
juncai
2016/09/12 20:05:49
ah, I see. Thanks!
| |
53 R.drawable.ic_signal_cellular_0_bar_white_48dp, | |
juncai
2016/08/26 19:37:48
The filename probably doesn't need to include "48d
ortuno
2016/09/12 05:11:27
They all have the same dp so I think the name is a
juncai
2016/09/12 20:05:49
Acknowledged.
| |
54 "Signal Strengh Level: Lowest"), | |
juncai
2016/08/26 19:37:48
typo:
s/Strengh/Strength
ortuno
2016/09/12 05:11:27
Done.
| |
55 new ItemChooserDialog.ItemChooserRowIcon( | |
56 R.drawable.ic_signal_cellular_1_bar_black_48dp, | |
57 R.drawable.ic_signal_cellular_1_bar_white_48dp, | |
58 "Signal Strengh Level: Lower"), | |
juncai
2016/08/26 19:37:48
How about naming them something more straightforwa
ortuno
2016/09/12 05:11:27
Ahh good idea. That also reminded me to not hard c
| |
59 new ItemChooserDialog.ItemChooserRowIcon( | |
60 R.drawable.ic_signal_cellular_2_bar_black_48dp, | |
61 R.drawable.ic_signal_cellular_2_bar_white_48dp, | |
juncai
2016/08/26 19:37:48
As I understand, the black image is for item not s
ortuno
2016/09/12 05:11:27
Done.
| |
62 "Signal Strengh Level: Low"), | |
63 new ItemChooserDialog.ItemChooserRowIcon( | |
64 R.drawable.ic_signal_cellular_3_bar_black_48dp, | |
65 R.drawable.ic_signal_cellular_3_bar_white_48dp, | |
66 "Signal Strengh Level: Medium"), | |
67 new ItemChooserDialog.ItemChooserRowIcon( | |
68 R.drawable.ic_signal_cellular_4_bar_black_48dp, | |
69 R.drawable.ic_signal_cellular_4_bar_white_48dp, | |
70 "Signal Strengh Level: High")}; | |
71 | |
49 // The window that owns this dialog. | 72 // The window that owns this dialog. |
50 final WindowAndroid mWindowAndroid; | 73 final WindowAndroid mWindowAndroid; |
51 | 74 |
52 // Always equal to mWindowAndroid.getActivity().get(), but stored separately to make sure it's | 75 // Always equal to mWindowAndroid.getActivity().get(), but stored separately to make sure it's |
53 // not GC'ed. | 76 // not GC'ed. |
54 final Activity mActivity; | 77 final Activity mActivity; |
55 | 78 |
56 // The dialog to show to let the user pick a device. | 79 // The dialog to show to let the user pick a device. |
57 ItemChooserDialog mItemChooserDialog; | 80 ItemChooserDialog mItemChooserDialog; |
58 | 81 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
330 return null; | 353 return null; |
331 } | 354 } |
332 BluetoothChooserDialog dialog = new BluetoothChooserDialog( | 355 BluetoothChooserDialog dialog = new BluetoothChooserDialog( |
333 windowAndroid, origin, securityLevel, nativeBluetoothChooserDial ogPtr); | 356 windowAndroid, origin, securityLevel, nativeBluetoothChooserDial ogPtr); |
334 dialog.show(); | 357 dialog.show(); |
335 return dialog; | 358 return dialog; |
336 } | 359 } |
337 | 360 |
338 @VisibleForTesting | 361 @VisibleForTesting |
339 @CalledByNative | 362 @CalledByNative |
340 void addOrUpdateDevice(String deviceId, String deviceName) { | 363 void addOrUpdateDevice(String deviceId, String deviceName, int signalStrengt hLevel) { |
341 mItemChooserDialog.addOrUpdateItem( | 364 mItemChooserDialog.addOrUpdateItem(new ItemChooserDialog.ItemChooserRow( deviceId, |
342 new ItemChooserDialog.ItemChooserRow(deviceId, deviceName)); | 365 deviceName, |
366 signalStrengthLevel == -1 ? null : SIGNAL_STRENGTH_ICONS[signalS trengthLevel])); | |
juncai
2016/08/26 19:37:48
maybe add some assert to make sure |signalStrength
ortuno
2016/09/12 05:11:27
Done.
| |
343 } | 367 } |
344 | 368 |
345 @VisibleForTesting | 369 @VisibleForTesting |
346 @CalledByNative | 370 @CalledByNative |
347 void closeDialog() { | 371 void closeDialog() { |
348 mNativeBluetoothChooserDialogPtr = 0; | 372 mNativeBluetoothChooserDialogPtr = 0; |
349 mItemChooserDialog.dismiss(); | 373 mItemChooserDialog.dismiss(); |
350 } | 374 } |
351 | 375 |
352 @VisibleForTesting | 376 @VisibleForTesting |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 @VisibleForTesting | 427 @VisibleForTesting |
404 native void nativeRestartSearch(long nativeBluetoothChooserAndroid); | 428 native void nativeRestartSearch(long nativeBluetoothChooserAndroid); |
405 // Help links. | 429 // Help links. |
406 @VisibleForTesting | 430 @VisibleForTesting |
407 native void nativeShowBluetoothOverviewLink(long nativeBluetoothChooserAndro id); | 431 native void nativeShowBluetoothOverviewLink(long nativeBluetoothChooserAndro id); |
408 @VisibleForTesting | 432 @VisibleForTesting |
409 native void nativeShowBluetoothAdapterOffLink(long nativeBluetoothChooserAnd roid); | 433 native void nativeShowBluetoothAdapterOffLink(long nativeBluetoothChooserAnd roid); |
410 @VisibleForTesting | 434 @VisibleForTesting |
411 native void nativeShowNeedLocationPermissionLink(long nativeBluetoothChooser Android); | 435 native void nativeShowNeedLocationPermissionLink(long nativeBluetoothChooser Android); |
412 } | 436 } |
OLD | NEW |