@@ -313,13 +313,24 @@ public void setupTable() {
313
313
table .setDoubleClickListener ((row , column , e ) -> {
314
314
if (column == DeviceTableModel .Columns .CUSTOM1 .ordinal ()) {
315
315
// edit custom 1 field
316
- handleSetProperty (1 );
316
+ handleSetProperty (Device .CUSTOM_PROP_X + 1 , DeviceTableModel .Columns .CUSTOM1 .toString ());
317
+ return ;
317
318
} else if (column == DeviceTableModel .Columns .CUSTOM2 .ordinal ()) {
318
319
// edit custom 1 field
319
- handleSetProperty (2 );
320
- } else {
321
- handleMirrorCommand ();
320
+ handleSetProperty (Device .CUSTOM_PROP_X + 2 , DeviceTableModel .Columns .CUSTOM2 .toString ());
321
+ return ;
322
+ } else if (column == DeviceTableModel .Columns .PHONE .ordinal ()) {
323
+ Device device = getFirstSelectedDevice ();
324
+ if (device != null ) {
325
+ if (TextUtils .isEmpty (device .phone )) {
326
+ // edit phone number field
327
+ handleSetProperty (Device .CUST_PROP_PHONE , "Device Phone Number" );
328
+ return ;
329
+ }
330
+ }
322
331
}
332
+ // default double-click action
333
+ handleMirrorCommand ();
323
334
});
324
335
325
336
// support drag and drop of files IN TO deviceView
@@ -405,6 +416,18 @@ private JPopupMenu getPopupMenu(int row, int column) {
405
416
JPopupMenu popupMenu = new JPopupMenu ();
406
417
407
418
if (device .isOnline ) {
419
+ DeviceTableModel .Columns columnType = model .getColumnType (column );
420
+ if (columnType == DeviceTableModel .Columns .CUSTOM1 ) {
421
+ UiUtils .addPopupMenuItem (popupMenu , "Edit Custom Field 1..." , actionEvent -> handleSetProperty (Device .CUSTOM_PROP_X + 1 , DeviceTableModel .Columns .CUSTOM1 .toString ()));
422
+ popupMenu .addSeparator ();
423
+ } else if (columnType == DeviceTableModel .Columns .CUSTOM2 ) {
424
+ UiUtils .addPopupMenuItem (popupMenu , "Edit Custom Field 2..." , actionEvent -> handleSetProperty (Device .CUSTOM_PROP_X + 2 , DeviceTableModel .Columns .CUSTOM2 .toString ()));
425
+ popupMenu .addSeparator ();
426
+ } else if (columnType == DeviceTableModel .Columns .PHONE ) {
427
+ UiUtils .addPopupMenuItem (popupMenu , "Edit Phone Number..." , actionEvent -> handleSetProperty (Device .CUST_PROP_PHONE , "Device Phone Number" ));
428
+ popupMenu .addSeparator ();
429
+ }
430
+
408
431
UiUtils .addPopupMenuItem (popupMenu , "Copy Field to Clipboard" , actionEvent -> handleCopyClipboardFieldCommand ());
409
432
UiUtils .addPopupMenuItem (popupMenu , "Copy Line to Clipboard" , actionEvent -> handleCopyClipboardCommand ());
410
433
popupMenu .addSeparator ();
@@ -414,8 +437,6 @@ private JPopupMenu getPopupMenu(int row, int column) {
414
437
UiUtils .addPopupMenuItem (popupMenu , "Capture Screenshot" , actionEvent -> handleScreenshotCommand ());
415
438
UiUtils .addPopupMenuItem (popupMenu , "Restart Device" , actionEvent -> handleRestartCommand ());
416
439
UiUtils .addPopupMenuItem (popupMenu , "Open Terminal" , actionEvent -> handleTermCommand ());
417
- UiUtils .addPopupMenuItem (popupMenu , "Edit Custom Field 1..." , actionEvent -> handleSetProperty (1 ));
418
- UiUtils .addPopupMenuItem (popupMenu , "Edit Custom Field 2..." , actionEvent -> handleSetProperty (2 ));
419
440
420
441
if (device .isWireless ()) {
421
442
popupMenu .addSeparator ();
@@ -787,30 +808,27 @@ private void installFiles(List<Device> selectedDeviceList, List<File> apkList) {
787
808
* set device property
788
809
* uses "persist.dm.custom[number]" for key and prompts user for value
789
810
*/
790
- private void handleSetProperty (int number ) {
811
+ private void handleSetProperty (String property , String description ) {
791
812
List <Device > selectedDeviceList = getSelectedDevices (true );
792
813
if (selectedDeviceList .isEmpty ()) return ;
793
814
String customValue = "" ;
794
815
String message ;
795
816
if (selectedDeviceList .size () == 1 ) {
796
817
Device device = selectedDeviceList .get (0 );
797
- customValue = device .getCustomProperty (Device . CUSTOM_PROP_X + number );
798
- message = "Enter Custom Note" ;
818
+ customValue = device .getCustomProperty (property );
819
+ message = "Enter " + description ;
799
820
} else {
800
- message = "Enter Custom Note for " + selectedDeviceList .size () + " devices" ;
821
+ message = "Enter " + description + " for " + selectedDeviceList .size () + " devices" ;
801
822
}
802
823
803
- String result = DialogHelper .showInputDialog (this , "Custom Note (" + number + ")" , message , customValue );
824
+ String result = DialogHelper .showInputDialog (this , description , message , customValue );
804
825
// allow empty input to go through (clear current value)
805
826
if (result == null ) return ;
806
827
807
828
for (Device device : selectedDeviceList ) {
808
- String prop = "custom" + number ;
809
- DeviceManager .getInstance ().setProperty (device , prop , result , (isSuccess , error ) -> {
829
+ DeviceManager .getInstance ().setProperty (device , property , result , (isSuccess , error ) -> {
810
830
811
831
});
812
- device .setCustomProperty (Device .CUSTOM_PROP_X + number , result );
813
- model .updateDevice (device );
814
832
}
815
833
}
816
834
0 commit comments