1
1
package com .ichtj .basetools ;
2
2
3
- import android .app .AlertDialog ;
4
- import android .content .Context ;
5
- import android .content .DialogInterface ;
6
3
import android .content .Intent ;;
7
- import android .content .pm .PackageManager ;
8
- import android .content .pm .ResolveInfo ;
9
- import android .database .Cursor ;
10
- import android .graphics .Color ;
11
4
import android .net .Uri ;
12
5
import android .os .Bundle ;
13
6
import android .os .Environment ;
14
7
import android .os .Handler ;
15
- import android .provider .MediaStore ;
16
- import android .util .Log ;
17
8
import android .view .Gravity ;
18
- import android .view .ViewGroup ;
19
- import android .view .WindowManager ;
9
+ import android .view .View ;
20
10
import android .widget .Button ;
21
- import android .widget .LinearLayout ;
22
- import android .widget .RadioButton ;
23
- import android .widget .RadioGroup ;
24
- import android .widget .ScrollView ;
25
- import android .widget .TextView ;
26
11
27
12
import androidx .annotation .Nullable ;
28
- import androidx .core .content .ContextCompat ;
29
13
30
14
import com .alibaba .android .arouter .facade .annotation .Route ;
31
15
import com .chtj .base_framework .FScreentTools ;
39
23
import com .face_chtj .base_iotutils .AudioUtils ;
40
24
import com .face_chtj .base_iotutils .BaseIotUtils ;
41
25
import com .face_chtj .base_iotutils .DeviceUtils ;
42
- import com .face_chtj .base_iotutils .FileUtils ;
43
26
import com .face_chtj .base_iotutils .GlobalDialogUtils ;
44
27
import com .face_chtj .base_iotutils .KLog ;
45
28
import com .face_chtj .base_iotutils .NetUtils ;
46
29
import com .face_chtj .base_iotutils .NotifyUtils ;
47
- import com .face_chtj .base_iotutils .ShellUtils ;
48
30
import com .face_chtj .base_iotutils .TPoolSingleUtils ;
49
31
import com .face_chtj .base_iotutils .TPoolUtils ;
50
32
import com .face_chtj .base_iotutils .ToastUtils ;
75
57
import com .ichtj .basetools .socket .SocketAty ;
76
58
import com .ichtj .basetools .timer .TimerAty ;
77
59
import com .ichtj .basetools .touch .TouchDetectAty ;
60
+ import com .face_chtj .base_iotutils .view .PopupWindowTools ;
78
61
import com .ichtj .basetools .util .CustomButtonGridView ;
79
62
import com .ichtj .basetools .util .FKey ;
80
63
import com .ichtj .basetools .util .JXLExcelUtils ;
87
70
import com .ichtj .basetools .video .VideoPlayAty ;
88
71
import com .ichtj .basetools .webviews .WebViewAty ;
89
72
90
- import java .io .File ;
91
73
import java .io .InputStream ;
92
- import java .util .ArrayList ;
93
74
import java .util .HashMap ;
94
75
import java .util .List ;
95
76
import java .util .Map ;
@@ -184,6 +165,7 @@ public Map<Integer, String> getDisplayBtn() {
184
165
btnList .put (FKey .KEY_TOUCH_DETECT , getString (R .string .main_touch_check ));
185
166
btnList .put (FKey .KEY_MQTT_TEST , getString (R .string .main_test_mqtt ));
186
167
btnList .put (FKey .KEY_WEBVIEW_TEST , getString (R .string .main_test_webview ));
168
+ btnList .put (FKey .KEY_POPWINDOW , getString (R .string .main_popwindow_toast ));
187
169
return btnList ;
188
170
}
189
171
@@ -210,7 +192,6 @@ public void dismiss(boolean dismiss) {
210
192
.setRemarks ("this is a remarks" )
211
193
.exeuNotify ( );
212
194
} else {
213
- //去开启通知
214
195
NotifyUtils .toOpenNotify ( );
215
196
}
216
197
Handler handler = new Handler ( );
@@ -231,19 +212,16 @@ public void run() {
231
212
NotifyUtils .closeNotify ( );
232
213
break ;
233
214
case FKey .KEY_SYS_DIALOG_SHOW :
234
- GlobalDialogUtils .getInstance ( ).show ("hello world" );
215
+ GlobalDialogUtils .getInstance ( ).show (getString ( R . string . app_name ) );
235
216
break ;
236
217
case FKey .KEY_SYS_DIALOG_CLOSE :
237
218
GlobalDialogUtils .getInstance ( ).dismiss ( );
238
219
break ;
239
220
case FKey .KEY_TOAST :
240
- ShellUtils .CommandResult commandResult = ShellUtils .execCommand ("am force-stop " +
241
- "com.face.regularservice" , true );
242
- KLog .d ("result=" + commandResult .result + ",errMeg=" + commandResult .errorMsg );
243
- ToastUtils .showShort ("Hello Worold!" );
221
+ ToastUtils .showShort (getString (R .string .app_name ));
244
222
break ;
245
223
case FKey .KEY_TOAST_BG :
246
- ToastUtils .success ("Hello Worold!" );
224
+ ToastUtils .success (getString ( R . string . app_name ) );
247
225
break ;
248
226
case FKey .KEY_ERR_ANR :
249
227
stopService (new Intent (this , MyService .class ));
@@ -267,7 +245,7 @@ public void deviceInfo(String action, String path, boolean isConn) {
267
245
UsbHubTools .getInstance ( ).unRegisterReceiver ( );
268
246
break ;
269
247
case FKey .KEY_JXL_OPEN :
270
- ToastUtils .info ("请查看日志确定读取结果" );
248
+ ToastUtils .info (getString ( R . string . main_to_search_jxl ) );
271
249
TPoolUtils .newInstance ( ).addExecuteTask (new Runnable ( ) {
272
250
@ Override
273
251
public void run () {
@@ -290,10 +268,10 @@ public void run() {
290
268
case FKey .KEY_JXL_EXPORT :
291
269
//第一种 jxl.jar导出
292
270
JXLExcelUtils .exportExcel ( );
293
- ToastUtils .success ("export successful!" );
271
+ ToastUtils .success (getString ( R . string . main_export_succ ) );
294
272
break ;
295
273
case FKey .KEY_POI_OPEN :
296
- ToastUtils .info ("请查看日志确定读取结果" );
274
+ ToastUtils .info (getString ( R . string . main_to_search_jxl ) );
297
275
TPoolUtils .newInstance ( ).addExecuteTask (new Runnable ( ) {
298
276
@ Override
299
277
public void run () {
@@ -314,7 +292,7 @@ public void run() {
314
292
});
315
293
break ;
316
294
case FKey .KEY_POI_EXPORT :
317
- ToastUtils .info ("请查看日志确定导出结果" );
295
+ ToastUtils .info (getString ( R . string . main_to_search_jxl ) );
318
296
TPoolUtils .newInstance ( ).addExecuteTask (new Runnable ( ) {
319
297
@ Override
320
298
public void run () {
@@ -328,15 +306,15 @@ public void run() {
328
306
Intent intent = new Intent (Intent .ACTION_GET_CONTENT );
329
307
intent .setType ("*/*" );
330
308
intent .addCategory (Intent .CATEGORY_OPENABLE );
331
- startActivityForResult (Intent .createChooser (intent , "请选择文件" ), FILE_SELECT_CODE );
309
+ startActivityForResult (Intent .createChooser (intent , getString ( R . string . main_select_file ) ), FILE_SELECT_CODE );
332
310
break ;
333
311
case FKey .KEY_ASSETS :
334
312
try {
335
313
InputStream input = this .getAssets ( ).open ("table.xls" );
336
314
if (input != null ) {
337
- ToastUtils .success ("found table.xls" );
315
+ ToastUtils .success (getString ( R . string . main_found_table_succ ) );
338
316
} else {
339
- ToastUtils .success ("not found table.xls" );
317
+ ToastUtils .success (getString ( R . string . main_not_found_table_failed ) );
340
318
}
341
319
} catch (Exception e ) {
342
320
e .printStackTrace ( );
@@ -346,7 +324,7 @@ public void run() {
346
324
case FKey .KEY_IP_SET_DHCP :
347
325
CommonValue commonValue2 = FEthTools .setEthDhcp ( );
348
326
if (commonValue2 == CommonValue .EXEU_COMPLETE ) {
349
- ToastUtils .success ("动态IP设置成功!" );
327
+ ToastUtils .success (getString ( R . string . main_set_dhcp_succ ) );
350
328
} else {
351
329
ToastUtils .error ("动态IP设置失败!errMeg=" + commonValue2 .getRemarks ( ));
352
330
}
@@ -355,17 +333,17 @@ public void run() {
355
333
CommonValue commonValue = FEthTools .setStaticIp (new IpConfigInfo ("192.168.1.155" ,
356
334
"8.8.8.8" , "8.8.4.4" , "192.168.1.1" , "255.255.255.0" ));
357
335
if (commonValue == CommonValue .EXEU_COMPLETE ) {
358
- ToastUtils .success ("静态IP设置成功!" );
336
+ ToastUtils .success (getString ( R . string . main_set_static_succ ) );
359
337
} else {
360
338
ToastUtils .error ("静态IP设置失败!errMeg=" + commonValue .getRemarks ( ));
361
339
}
362
340
break ;
363
341
case FKey .KEY_SCREENSHOT :
364
342
String imgPath = FScreentTools .takeScreenshot ("/sdcard/" );
365
343
if (imgPath != null && !imgPath .equals ("" )) {
366
- ToastUtils .success ("截屏成功,位置:/sdcard/目录下" );
344
+ ToastUtils .success (getString ( R . string . main_screenshot_succ_toast ) );
367
345
} else {
368
- ToastUtils .error ("截屏失败!" );
346
+ ToastUtils .error (getString ( R . string . main_screenshot_failed ) );
369
347
}
370
348
break ;
371
349
case FKey .KEY_CRASH :
@@ -449,6 +427,11 @@ public void run() {
449
427
case FKey .KEY_WEBVIEW_TEST :
450
428
startAty (WebViewAty .class );
451
429
break ;
430
+ case FKey .KEY_POPWINDOW :
431
+ PopupWindowTools bubblePopupWindow = new PopupWindowTools (MainActivity .this );
432
+ bubblePopupWindow .setBubbleText ("这是一条气泡消息" );
433
+ bubblePopupWindow .show (customButtonGridView .getSelectButton (), Gravity .TOP );//view的上部展示
434
+ break ;
452
435
}
453
436
}
454
437
@@ -457,7 +440,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
457
440
super .onActivityResult (requestCode , resultCode , data );
458
441
if (data == null ) {
459
442
// 用户未选择任何文件,直接返回
460
- ToastUtils .error ("未选择任何文件!" );
443
+ ToastUtils .error (getString ( R . string . main_no_files_were_selected ) );
461
444
return ;
462
445
}
463
446
if (requestCode == FILE_SELECT_CODE ) {
0 commit comments