Commit 0e9d42de474d84c54959b8cbe8905c2825eea23a
1 parent
f2ef1fe4
畅游通核销app: 1.修复上次提交的功能bug
Showing
1 changed file
with
712 additions
and
701 deletions
src/com/ectrip/cyt/ui/SettingsActivity.java
| ... | ... | @@ -37,6 +37,7 @@ import android.widget.RadioGroup.OnCheckedChangeListener; |
| 37 | 37 | import android.widget.RelativeLayout; |
| 38 | 38 | import android.widget.TextView; |
| 39 | 39 | import android.widget.Toast; |
| 40 | + | |
| 40 | 41 | import antistatic.spinnerwheel.AbstractWheel; |
| 41 | 42 | |
| 42 | 43 | import com.ectrip.cyt.bean.ConfigBean; |
| ... | ... | @@ -57,704 +58,714 @@ import com.ectrip.trips.check.R; |
| 57 | 58 | * 设置Activity |
| 58 | 59 | */ |
| 59 | 60 | public class SettingsActivity extends BaseActivity implements OnClickListener, |
| 60 | - OnCheckedChangeListener { | |
| 61 | - //返回相应码 | |
| 62 | - private final int SETTING_REQUESTCODE = 1; | |
| 63 | - // 机器码,服务地址,系统密码,企业标识,企业编码 | |
| 64 | - private EditText machineCodeEdit, serviceIpEdit, systemPwdEdit, | |
| 65 | - identityEdit, encodeEdit; | |
| 66 | - // 打印选项组,调试选项组,打印加密选项组 | |
| 67 | - private RelativeLayout printGroup, reprintEncryptGroup; | |
| 68 | - private RadioGroup testGroup; | |
| 69 | - // 调试开关选项,是否打印选项,是否加密打印 | |
| 70 | - private RadioButton testNoRadioBtn, testYesRadioBtn; | |
| 71 | - // 确认按钮 | |
| 72 | - private Button confirmBtn, updateBtn; | |
| 73 | - private View testlayout; | |
| 74 | - // 是否调试模式,密码弹框 | |
| 75 | - private Dialog testDialog, pwdDialog; | |
| 76 | - // 打印次数,标题,版本, | |
| 77 | - private TextView printNumText, titleText, versionText; | |
| 78 | - | |
| 79 | - private String mode; | |
| 80 | - private int isprint = 0; | |
| 81 | - private NetworkConnectChangedReceiver receiver = null; | |
| 82 | - // 打印次数 | |
| 83 | - private Integer pnum = null; | |
| 84 | - // 调试模式 | |
| 85 | - private Boolean testMOdel; | |
| 86 | - // 是否加密 | |
| 87 | - private Boolean isEncrypt; | |
| 88 | - //退出应用次数 | |
| 89 | - private long firstTime = 0; | |
| 90 | - private int num = 0; | |
| 91 | - private RelativeLayout scanGroup; | |
| 92 | - private ImageView isreprint,scanEncrypt,reprntEncrypt; | |
| 93 | - private Boolean scanBack; | |
| 94 | - private LinearLayout lv_printNum; | |
| 95 | - | |
| 96 | - @Override | |
| 97 | - protected void onCreate(Bundle savedInstanceState) { | |
| 98 | - super.onCreate(savedInstanceState); | |
| 99 | - setContentView(R.layout.app_settings); | |
| 100 | - init(); | |
| 101 | - initConfig(); | |
| 102 | - initView(); | |
| 103 | - initListen(); | |
| 104 | - initData(); | |
| 105 | - initRegist(); | |
| 106 | - } | |
| 107 | - | |
| 108 | - private void init() { | |
| 109 | - pnum = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 110 | - .setName("MachineType").getObject("printNum", Integer.class); | |
| 111 | - | |
| 112 | - if (pnum == null) { | |
| 113 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 114 | - .setName("MachineType").setObject("printNum", 2); | |
| 115 | - } else { | |
| 116 | - if (pnum > 3) { | |
| 117 | - pnum = 3; | |
| 118 | - } | |
| 119 | - } | |
| 120 | - | |
| 121 | - testMOdel = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 122 | - .setName("config").getObject("testMOdel", Boolean.class); | |
| 123 | - isEncrypt = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 124 | - .setName("config").getObject("isEncrypt", Boolean.class); | |
| 125 | - } | |
| 126 | - | |
| 127 | - private void initRegist() { | |
| 128 | - if (receiver == null) { | |
| 129 | - receiver = new NetworkConnectChangedReceiver(); | |
| 130 | - } | |
| 131 | - IntentFilter filter = new IntentFilter(); | |
| 132 | - filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); | |
| 133 | - filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); | |
| 134 | - registerReceiver(receiver, filter); | |
| 135 | - } | |
| 136 | - | |
| 137 | - private void initView() { | |
| 138 | - lv_printNum = (LinearLayout) findViewById(R.id.lv_printNum); | |
| 139 | - printNumText = (TextView) findViewById(R.id.printNum); | |
| 140 | - machineCodeEdit = (EditText) findViewById(R.id.machineCodeEdit); | |
| 141 | - systemPwdEdit = (EditText) findViewById(R.id.systemPwdEdit); | |
| 142 | - serviceIpEdit = (EditText) findViewById(R.id.serviceIpEdit); | |
| 143 | - identityEdit = (EditText) findViewById(R.id.identityEdit); | |
| 144 | - encodeEdit = (EditText) findViewById(R.id.encodeEdit); | |
| 145 | - printGroup = (RelativeLayout) this.findViewById(R.id.printGroup); | |
| 146 | - testGroup = (RadioGroup) findViewById(R.id.testGroup); | |
| 147 | - scanGroup = (RelativeLayout) findViewById(R.id.scanEncryptGroup); | |
| 148 | - reprintEncryptGroup = (RelativeLayout) findViewById(R.id.reprintEncryptGroup); | |
| 149 | - testlayout = findViewById(R.id.testlayout);// 调节模式 | |
| 150 | - versionText = (TextView) findViewById(R.id.version); | |
| 151 | - confirmBtn = (Button) findViewById(R.id.set_saveBtn);//确认按钮 | |
| 152 | - updateBtn = (Button) findViewById(R.id.update); | |
| 153 | - titleText = (TextView) findViewById(R.id.title); | |
| 154 | - | |
| 155 | - isreprint = (ImageView) findViewById(R.id.iv_isreprint); | |
| 156 | - reprntEncrypt = (ImageView) findViewById(R.id.iv_reprintEncrypt); | |
| 157 | - scanEncrypt = (ImageView) findViewById(R.id.iv_scanEncrypt); | |
| 158 | - | |
| 159 | - // 显示版本号 | |
| 160 | - String versionName = MyApp.getInstance().getVersionName(); | |
| 161 | - versionText.setText(versionName); | |
| 162 | - confirmBtn.setVisibility(View.VISIBLE); | |
| 163 | - updateBtn.setVisibility(View.VISIBLE); | |
| 164 | - //findViewById(R.id.saveBtn).setVisibility(View.VISIBLE); | |
| 165 | - if (testMOdel != null && testMOdel) { // 是否隐藏 | |
| 166 | - testlayout.setVisibility(View.VISIBLE); | |
| 167 | - } else if (testMOdel != null && !testMOdel) { | |
| 168 | - testlayout.setVisibility(View.GONE); | |
| 169 | - } | |
| 170 | - titleText.setVisibility(View.VISIBLE); | |
| 171 | - titleText.setText(R.string.setting); | |
| 172 | - if (pnum != null) { | |
| 173 | - printNumText.setText(pnum +""); | |
| 174 | - } | |
| 175 | - if (isEncrypt != null && isEncrypt) { // 是否隐藏 | |
| 176 | - reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 177 | - } else if (testMOdel != null && !testMOdel) { | |
| 178 | - reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 179 | - } | |
| 180 | - } | |
| 181 | - | |
| 182 | - private void initListen() { | |
| 183 | - versionText.setOnClickListener(this); | |
| 184 | - updateBtn.setOnClickListener(this); | |
| 185 | - titleText.setOnClickListener(this); | |
| 186 | - reprintEncryptGroup.setOnClickListener(this); | |
| 187 | - lv_printNum.setOnClickListener(this); | |
| 188 | - printGroup.setOnClickListener(this); | |
| 189 | - testGroup.setOnClickListener(this); | |
| 190 | - scanGroup.setOnClickListener(this); | |
| 191 | - confirmBtn.setOnClickListener(this); | |
| 192 | - } | |
| 193 | - | |
| 194 | - /*************************************** 退出应用****************************/ | |
| 195 | - private void closeApp() { | |
| 196 | - if (num < 5) { | |
| 197 | - long secondTime = System.currentTimeMillis(); | |
| 198 | - if (secondTime - firstTime > 4000) { // 如果两次按键时间间隔大于2秒,则不退出 | |
| 199 | - if (num == 1) { | |
| 200 | - firstTime = secondTime;// 更新firstTime | |
| 201 | - } | |
| 202 | - } | |
| 203 | - num++; | |
| 204 | - } else { | |
| 205 | - num = 0; | |
| 206 | - exitApp(); | |
| 207 | - } | |
| 208 | - } | |
| 209 | - | |
| 210 | - /*******************************调试模式*********************************************/ | |
| 211 | - private void testApp() { | |
| 212 | - if (num < 5) { | |
| 213 | - long secondTime = System.currentTimeMillis(); | |
| 214 | - if (secondTime - firstTime > 4000) { // 如果两次按键时间间隔大于2秒,则不退出 | |
| 215 | - if (num == 1) { | |
| 216 | - firstTime = secondTime;// 更新firstTime | |
| 217 | - } | |
| 218 | - } | |
| 219 | - num++; | |
| 220 | - } else { | |
| 221 | - num = 0; | |
| 222 | - testDialog(); | |
| 223 | - } | |
| 224 | - } | |
| 225 | - | |
| 226 | - /******************************* 调试弹框****************************************/ | |
| 227 | - private void testDialog() { | |
| 228 | - if (testDialog == null) { | |
| 229 | - final EditText inputpress = new EditText(this); | |
| 230 | - inputpress.setInputType(InputType.TYPE_CLASS_TEXT | |
| 231 | - | InputType.TYPE_TEXT_VARIATION_PASSWORD); | |
| 232 | - Builder builder = new AlertDialog.Builder(this); | |
| 233 | - builder.setTitle(R.string.input_pwd_debug); | |
| 234 | - builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 235 | - builder.setView(inputpress).setPositiveButton(R.string.btn_ok, | |
| 236 | - new DialogInterface.OnClickListener() { | |
| 237 | - | |
| 238 | - @Override | |
| 239 | - public void onClick(DialogInterface dialog, int which) { | |
| 240 | - String password = inputpress.getText().toString(); | |
| 241 | - if (password.equals(constant.exitPwd)) { | |
| 242 | - LogUtil.isDebug = false; | |
| 243 | - testlayout.setVisibility(View.VISIBLE); | |
| 244 | - SharedPreferences2Obj | |
| 245 | - .getInstance(SettingsActivity.this) | |
| 246 | - .setName("config") | |
| 247 | - .setObject("testMOdel", true); | |
| 248 | - testYesRadioBtn.setChecked(true); | |
| 249 | - testNoRadioBtn.setChecked(false); | |
| 250 | - } else { | |
| 251 | - MToast(SettingsActivity.this, | |
| 252 | - getString(R.string.pwd_error_noexit), | |
| 253 | - MToast.LENGTH_SHORT); | |
| 254 | - } | |
| 255 | - } | |
| 256 | - }); | |
| 257 | - | |
| 258 | - builder.setNegativeButton(R.string.btn_cancel, null); | |
| 259 | - AlertDialog dialog = builder.create(); | |
| 260 | - if (MyApp.getInstance().isHandset) { | |
| 261 | - dialog.getWindow().setType( | |
| 262 | - WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); | |
| 263 | - } | |
| 264 | - dialog.setCanceledOnTouchOutside(false); | |
| 265 | - dialog.show(); | |
| 266 | - } | |
| 267 | - } | |
| 268 | - | |
| 269 | - /******************************** 退出手持机的方法******************************/ | |
| 270 | - private void exitApp() { | |
| 271 | - if (pwdDialog == null) { | |
| 272 | - final EditText inputpress = new EditText(this); | |
| 273 | - inputpress.setInputType(InputType.TYPE_CLASS_TEXT | |
| 274 | - | InputType.TYPE_TEXT_VARIATION_PASSWORD); | |
| 275 | - Builder builder = new AlertDialog.Builder(this); | |
| 276 | - builder.setTitle(R.string.input_exit_pwd); | |
| 277 | - builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 278 | - builder.setView(inputpress).setPositiveButton(R.string.btn_ok, | |
| 279 | - new DialogInterface.OnClickListener() { | |
| 280 | - | |
| 281 | - @Override | |
| 282 | - public void onClick(DialogInterface dialog, int which) { | |
| 283 | - String password = inputpress.getText().toString(); | |
| 284 | - if (password.equals(constant.exitPwd)) { | |
| 285 | - MyApp.getInstance().exit(); | |
| 286 | - } else { | |
| 287 | - MToast(SettingsActivity.this, | |
| 288 | - getString(R.string.pwd_error_noexit), | |
| 289 | - MToast.LENGTH_SHORT); | |
| 290 | - } | |
| 291 | - } | |
| 292 | - }); | |
| 293 | - | |
| 294 | - builder.setNegativeButton(getString(R.string.cancle_label), null); | |
| 295 | - AlertDialog dialog = builder.create(); | |
| 296 | - if (MyApp.getInstance().isHandset) { | |
| 297 | - dialog.getWindow().setType( | |
| 298 | - WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); | |
| 299 | - } | |
| 300 | - dialog.setCanceledOnTouchOutside(false); | |
| 301 | - dialog.show(); | |
| 302 | - } | |
| 303 | - } | |
| 304 | - | |
| 305 | - private void initData() { | |
| 306 | - | |
| 307 | - ArrayList<ConfigBean> beans = DbManager.GetConfigs(); | |
| 308 | - | |
| 309 | - if (beans != null && beans.size() > 0) { | |
| 310 | - serviceIpEdit.setText(beans.get(0).getEc_ip()); | |
| 311 | - if(TextUtils.isEmpty(beans.get(0).getEc_mac())){ | |
| 312 | - machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 313 | - }else { | |
| 314 | - machineCodeEdit.setText(beans.get(0).getEc_mac()); | |
| 315 | - } | |
| 316 | - systemPwdEdit.setText(beans.get(0).getEc_passwd()); | |
| 317 | - encodeEdit.setText(beans.get(0).getEc_identity()); | |
| 318 | - try { | |
| 319 | - String ec_name = AESEncryptor.decrypt(constant.decrypt, beans | |
| 320 | - .get(0).getEc_signkey()); | |
| 321 | - identityEdit.setText(ec_name); | |
| 322 | - } catch (Exception e) { | |
| 323 | - e.printStackTrace(); | |
| 324 | - } | |
| 325 | - if (1 == beans.get(0).getEc_isPrint()) { | |
| 326 | - isprint =1; | |
| 327 | - isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 328 | - } else if (0 == beans.get(0).getEc_isPrint()) { | |
| 329 | - isprint =0; | |
| 330 | - isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 331 | - } | |
| 332 | - } else { | |
| 333 | - | |
| 334 | - serviceIpEdit.setText(""); | |
| 335 | - machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 336 | - systemPwdEdit.setText(constant.pwd); | |
| 337 | - encodeEdit.setText(""); | |
| 338 | - identityEdit.setText(""); | |
| 339 | - MToast(SettingsActivity.this, getString(R.string.init_setting), | |
| 340 | - MToast.LENGTH_SHORT); | |
| 341 | - } | |
| 342 | - | |
| 343 | - scanBack = SharedPreferences2Obj.getInstance(this).setName("config").getObject("scanBack", Boolean.class); | |
| 344 | - if (scanBack !=null){ | |
| 345 | - if (scanBack){ | |
| 346 | - | |
| 347 | - scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 348 | - }else { | |
| 349 | - scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 350 | - } | |
| 351 | - }else { | |
| 352 | - scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 353 | - } | |
| 354 | - } | |
| 355 | - | |
| 356 | - | |
| 357 | - | |
| 358 | - public class NetworkConnectChangedReceiver extends BroadcastReceiver { | |
| 359 | - @Override | |
| 360 | - public void onReceive(Context context, Intent intent) { | |
| 361 | - if (WifiManager.WIFI_STATE_CHANGED_ACTION | |
| 362 | - .equals(intent.getAction())) {// 这个监听wifi的打开与关闭,与wifi的连接无关 | |
| 363 | - int wifiState = intent.getIntExtra( | |
| 364 | - WifiManager.EXTRA_WIFI_STATE, 0); | |
| 365 | - LogUtil.e("H3c", "wifiState" + wifiState); | |
| 366 | - switch (wifiState) { | |
| 367 | - case WifiManager.WIFI_STATE_ENABLED: | |
| 368 | - if (machineCodeEdit != null) { | |
| 369 | - machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 370 | - } | |
| 371 | - break; | |
| 372 | - } | |
| 373 | - } | |
| 374 | - } | |
| 375 | - } | |
| 376 | - | |
| 377 | - private void initConfig() { | |
| 378 | - mode = getIntent().getStringExtra("mode"); | |
| 379 | - findViewById(R.id.topBack).setOnClickListener(new OnClickListener() { | |
| 380 | - @Override | |
| 381 | - public void onClick(View arg0) { | |
| 382 | - finish(); | |
| 383 | - } | |
| 384 | - }); | |
| 385 | - } | |
| 386 | - | |
| 387 | - /************************** 下面是打印次数的弹框 ***********************************/ | |
| 388 | - private LayoutInflater inflater; | |
| 389 | - private View layout2; | |
| 390 | - | |
| 391 | - private AlertDialog dialog2; // 部分检票弹框 | |
| 392 | - private AbstractWheel wheel;// 部分检票滚轮 | |
| 393 | - private Button reduce;// 部分检票减按钮 | |
| 394 | - private Button plus;// 部分检票加按钮 | |
| 395 | - | |
| 396 | - @SuppressLint("InflateParams") | |
| 397 | - public void dialog(int num) { | |
| 398 | - if (dialog2 == null) { | |
| 399 | - inflater = LayoutInflater.from(SettingsActivity.this); | |
| 400 | - layout2 = inflater.inflate(R.layout.consume_dialog, null); | |
| 401 | - Builder builder = new AlertDialog.Builder(SettingsActivity.this); | |
| 402 | - builder.setTitle(R.string.print_number); | |
| 403 | - builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 404 | - builder.setView(layout2).setPositiveButton(R.string.btn_ok, | |
| 405 | - new DialogInterface.OnClickListener() { | |
| 406 | - @Override | |
| 407 | - public void onClick(DialogInterface dialog, int which) { | |
| 408 | - printNumText.setText(wheel.getCurrentItem() + 1 | |
| 409 | - + ""); | |
| 410 | - SharedPreferences2Obj | |
| 411 | - .getInstance(SettingsActivity.this) | |
| 412 | - .setName("MachineType") | |
| 413 | - .setObject("printNum", | |
| 414 | - wheel.getCurrentItem() + 1); | |
| 415 | - } | |
| 416 | - }); | |
| 417 | - builder.setNegativeButton(R.string.btn_cancel, | |
| 418 | - new DialogInterface.OnClickListener() { | |
| 419 | - @Override | |
| 420 | - public void onClick(DialogInterface dialog, int which) { | |
| 421 | - if (dialog != null) { | |
| 422 | - try { | |
| 423 | - dialog.dismiss(); | |
| 424 | - } catch (Exception e) { | |
| 425 | - e.printStackTrace(); | |
| 426 | - } catch (Throwable e) { | |
| 427 | - e.printStackTrace(); | |
| 428 | - } | |
| 429 | - } | |
| 430 | - } | |
| 431 | - }); | |
| 432 | - dialog2 = builder.create(); | |
| 433 | - } | |
| 434 | - | |
| 435 | - initWheel(layout2, R.id.wheelView, num); | |
| 436 | - | |
| 437 | - if (MyApp.getInstance().isHandset) { | |
| 438 | - dialog2.getWindow().setType( | |
| 439 | - WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); | |
| 440 | - } | |
| 441 | - dialog2.show(); | |
| 442 | - } | |
| 443 | - | |
| 444 | - private void initWheel(View view, int id, final int num) { | |
| 445 | - wheel = (AbstractWheel) view.findViewById(id); | |
| 446 | - wheel.setViewAdapter(new NumericWheelAdapter(SettingsActivity.this, 1, | |
| 447 | - num)); | |
| 448 | - wheel.setCyclic(true); | |
| 449 | - wheel.setInterpolator(new AnticipateOvershootInterpolator()); | |
| 450 | - reduce = (Button) view.findViewById(R.id.reduce); | |
| 451 | - reduce.setOnClickListener(new OnClickListener() { | |
| 452 | - @Override | |
| 453 | - public void onClick(View v) { | |
| 454 | - int current = wheel.getCurrentItem() - 1; | |
| 455 | - if (current < 0) { | |
| 456 | - return; | |
| 457 | - } | |
| 458 | - wheel.setCurrentItem(current); | |
| 459 | - } | |
| 460 | - }); | |
| 461 | - | |
| 462 | - plus = (Button) view.findViewById(R.id.plus); | |
| 463 | - plus.setOnClickListener(new OnClickListener() { | |
| 464 | - @Override | |
| 465 | - public void onClick(View v) { | |
| 466 | - int current = wheel.getCurrentItem() + 1; | |
| 467 | - if (num == current) { | |
| 468 | - return; | |
| 469 | - } | |
| 470 | - wheel.setCurrentItem(current); | |
| 471 | - } | |
| 472 | - }); | |
| 473 | - } | |
| 474 | - | |
| 475 | - @Override | |
| 476 | - public boolean onKeyDown(int keyCode, KeyEvent event) { | |
| 477 | - if (keyCode == KeyEvent.KEYCODE_BACK) { | |
| 478 | - try { | |
| 479 | - CommetryUtils.releaseCommery(this); | |
| 480 | - } catch (Exception e) { | |
| 481 | - e.printStackTrace(); | |
| 482 | - } | |
| 483 | - finish(); | |
| 484 | - } | |
| 485 | - return false; | |
| 486 | - } | |
| 487 | - | |
| 488 | - @Override | |
| 489 | - protected void onDestroy() { | |
| 490 | - if (receiver != null) { | |
| 491 | - unregisterReceiver(receiver); | |
| 492 | - } | |
| 493 | - super.onDestroy(); | |
| 494 | - } | |
| 495 | - | |
| 496 | - /************************* 失去焦点的时候,隐藏键盘 *********************************/ | |
| 497 | - /** | |
| 498 | - * 隐藏软键盘 | |
| 499 | - */ | |
| 500 | - @Override | |
| 501 | - public boolean dispatchTouchEvent(MotionEvent ev) { | |
| 502 | - // TODO Auto-generated method stub | |
| 503 | - if (ev.getAction() == MotionEvent.ACTION_DOWN) { | |
| 504 | - | |
| 505 | - // 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点) | |
| 506 | - View v = getCurrentFocus(); | |
| 507 | - | |
| 508 | - if (isShouldHideInput(v, ev)) { | |
| 509 | - InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | |
| 510 | - hideSoftInput(v.getWindowToken(), im); | |
| 511 | - } | |
| 512 | - } | |
| 513 | - return super.dispatchTouchEvent(ev); | |
| 514 | - } | |
| 515 | - | |
| 516 | - /** | |
| 517 | - * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时没必要隐藏 | |
| 518 | - * | |
| 519 | - * @param v | |
| 520 | - * @param event | |
| 521 | - * @return | |
| 522 | - */ | |
| 523 | - public boolean isShouldHideInput(View v, MotionEvent event) { | |
| 524 | - if (v != null && (v instanceof EditText)) { | |
| 525 | - int[] l = { 0, 0 }; | |
| 526 | - v.getLocationInWindow(l); | |
| 527 | - int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left | |
| 528 | - + v.getWidth(); | |
| 529 | - if (event.getX() > left && event.getX() < right | |
| 530 | - && event.getY() > top && event.getY() < bottom) { | |
| 531 | - // 点击EditText的事件,忽略它。 | |
| 532 | - return false; | |
| 533 | - } else { | |
| 534 | - return true; | |
| 535 | - } | |
| 536 | - } | |
| 537 | - // 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditView上,和用户用轨迹球选择其他的焦点 | |
| 538 | - return false; | |
| 539 | - } | |
| 540 | - | |
| 541 | - /** | |
| 542 | - * 多种隐藏软件盘方法的其中一种 | |
| 543 | - * | |
| 544 | - * @param token | |
| 545 | - */ | |
| 546 | - public void hideSoftInput(IBinder token, InputMethodManager im) { | |
| 547 | - if (token != null) { | |
| 548 | - im.hideSoftInputFromWindow(token, | |
| 549 | - InputMethodManager.HIDE_NOT_ALWAYS); | |
| 550 | - } | |
| 551 | - } | |
| 552 | - /********************************监听事件***************************/ | |
| 553 | - | |
| 554 | - @SuppressLint("DefaultLocale") | |
| 555 | - @Override | |
| 556 | - public void onClick(View arg0) { | |
| 557 | - | |
| 558 | - switch (arg0.getId()) { | |
| 559 | - case R.id.lv_printNum: | |
| 560 | - dialog(3); | |
| 561 | - break; | |
| 562 | - case R.id.version: // 调试模式 | |
| 563 | - testApp(); | |
| 564 | - break; | |
| 565 | - case R.id.update: | |
| 566 | - if (serviceIpEdit.getText() == null | |
| 567 | - || serviceIpEdit.getText().toString() == null | |
| 568 | - || serviceIpEdit.getText().toString().trim().equals("")) { | |
| 569 | - Toast.makeText(SettingsActivity.this, | |
| 570 | - getString(R.string.fill_in_server_ip), | |
| 571 | - Toast.LENGTH_SHORT).show(); | |
| 572 | - return; | |
| 573 | - } | |
| 574 | - if (encodeEdit.getText() == null | |
| 575 | - || encodeEdit.getText().toString() == null | |
| 576 | - || encodeEdit.getText().toString().trim().equals("")) { | |
| 577 | - Toast.makeText(SettingsActivity.this, | |
| 578 | - getString(R.string.fil_in_connkey), Toast.LENGTH_SHORT) | |
| 579 | - .show(); | |
| 580 | - return; | |
| 581 | - } | |
| 582 | - if (identityEdit.getText() == null | |
| 583 | - || identityEdit.getText().toString() == null | |
| 584 | - || identityEdit.getText().toString().trim().equals("")) { | |
| 585 | - Toast.makeText(SettingsActivity.this, R.string.fil_in_qiye_key, | |
| 586 | - Toast.LENGTH_SHORT).show(); | |
| 587 | - return; | |
| 588 | - } | |
| 589 | - try { | |
| 590 | - UpdateManager.getUpdateManager().checkAppUpdate( | |
| 591 | - SettingsActivity.this, | |
| 592 | - serviceIpEdit.getText().toString().trim(), | |
| 593 | - identityEdit.getText().toString().trim(), | |
| 594 | - encodeEdit.getText().toString().trim()); | |
| 595 | - // 并保存信息 | |
| 596 | - try { | |
| 597 | - ConfigBean bean = new ConfigBean(); | |
| 598 | - String mac = machineCodeEdit.getText().toString().trim(); | |
| 599 | - bean.setEc_id(0 + ""); | |
| 600 | - bean.setEc_ip(serviceIpEdit.getText().toString().trim()); | |
| 601 | - bean.setEc_identity(encodeEdit.getText().toString().trim()); | |
| 602 | - bean.setEc_mac(mac.toUpperCase()); | |
| 603 | - bean.setEc_passwd(systemPwdEdit.getText().toString().trim()); | |
| 604 | - String signkey = AESEncryptor.encrypt(constant.decrypt, | |
| 605 | - identityEdit.getText().toString().trim()); | |
| 606 | - bean.setEc_signkey(signkey); | |
| 607 | - bean.setEc_isPrint(isprint); | |
| 608 | - if ("0".equals(mode)) { | |
| 609 | - DbManager.ClearConfig(); | |
| 610 | - DbManager.InsertConfig(bean); | |
| 611 | - } else { | |
| 612 | - DbManager.ModifyConfig(bean); | |
| 613 | - } | |
| 614 | - } catch (Exception e) { | |
| 615 | - e.printStackTrace(); | |
| 616 | - } | |
| 617 | - // } | |
| 618 | - } catch (Exception e) { | |
| 619 | - e.printStackTrace(); | |
| 620 | - } | |
| 621 | - break; | |
| 622 | - case R.id.set_saveBtn: | |
| 623 | - String ec_name = identityEdit.getText().toString().trim(); | |
| 624 | - if (!ec_name.equals("")) { | |
| 625 | - try { | |
| 626 | - ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name); | |
| 627 | - LogUtil.d(getString(R.string.enterprise_communication_identifier) | |
| 628 | - + ec_name); | |
| 629 | - ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name); | |
| 630 | - } catch (Exception ex) { | |
| 631 | - try { | |
| 632 | - ec_name = AESEncryptor.encrypt(constant.decrypt, | |
| 633 | - ec_name); | |
| 634 | - LogUtil.d(getString(R.string.not_successfully_decrypt) | |
| 635 | - + ec_name); | |
| 636 | - } catch (Exception e) { | |
| 637 | - e.printStackTrace(); | |
| 638 | - MToast(SettingsActivity.this, | |
| 639 | - getString(R.string.communication_id_error), | |
| 640 | - MToast.LENGTH_SHORT); | |
| 641 | - ec_name = ""; | |
| 642 | - identityEdit.setText(""); | |
| 643 | - return; | |
| 644 | - } | |
| 645 | - } | |
| 646 | - if ("".equals(serviceIpEdit.getText().toString().trim())) { | |
| 647 | - | |
| 648 | - MToast(SettingsActivity.this, | |
| 649 | - getString(R.string.server_ip_notnull), | |
| 650 | - MToast.LENGTH_SHORT); | |
| 651 | - return; | |
| 652 | - } else if ("".equals(systemPwdEdit.getText().toString().trim())) { | |
| 653 | - MToast(SettingsActivity.this, | |
| 654 | - getString(R.string.pwd_notnull), | |
| 655 | - MToast.LENGTH_SHORT); | |
| 656 | - return; | |
| 657 | - } else if ("".equals(encodeEdit.getText().toString().trim())) { | |
| 658 | - MToast(SettingsActivity.this, | |
| 659 | - getString(R.string.connkey_notnull), | |
| 660 | - MToast.LENGTH_SHORT); | |
| 661 | - return; | |
| 662 | - } else if ("".equals(ec_name)) { | |
| 663 | - MToast(SettingsActivity.this, | |
| 664 | - getString(R.string.communication_id_notnull), | |
| 665 | - MToast.LENGTH_SHORT); | |
| 666 | - return; | |
| 667 | - } else { | |
| 668 | - | |
| 669 | - ConfigBean bean = new ConfigBean(); | |
| 670 | - String mac = machineCodeEdit.getText().toString().trim(); | |
| 671 | - bean.setEc_id(0 + ""); | |
| 672 | - bean.setEc_ip(serviceIpEdit.getText().toString().trim()); | |
| 673 | - bean.setEc_identity(encodeEdit.getText().toString().trim()); | |
| 674 | - bean.setEc_mac(mac.toUpperCase()); | |
| 675 | - bean.setEc_passwd(systemPwdEdit.getText().toString().trim()); | |
| 676 | - bean.setEc_signkey(ec_name); | |
| 677 | - bean.setEc_isPrint(isprint); | |
| 678 | - if ("0".equals(mode)) { | |
| 679 | - DbManager.ClearConfig(); | |
| 680 | - DbManager.InsertConfig(bean); | |
| 681 | - } else { | |
| 682 | - DbManager.ModifyConfig(bean); | |
| 683 | - } | |
| 684 | - | |
| 685 | - Intent intent = new Intent(); | |
| 686 | - setResult(SETTING_REQUESTCODE, intent); | |
| 687 | - finish(); | |
| 688 | - } | |
| 689 | - } else { | |
| 690 | - MToast(SettingsActivity.this, | |
| 691 | - getString(R.string.communication_id_notnull), | |
| 692 | - MToast.LENGTH_SHORT); | |
| 693 | - } | |
| 694 | - break; | |
| 695 | - case R.id.title: | |
| 696 | - closeApp(); | |
| 697 | - break; | |
| 698 | - case R.id.printGroup: | |
| 699 | - if (isprint == 1){ | |
| 700 | - isprint = 0; | |
| 701 | - isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 702 | - }else if (isprint == 0){ | |
| 703 | - isprint =1; | |
| 704 | - isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 705 | - } | |
| 706 | - break; | |
| 707 | - case R.id.reprintEncryptGroup: | |
| 708 | - if (isEncrypt != null && isEncrypt) { // 是否隐藏 | |
| 709 | - isEncrypt = false; | |
| 710 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 711 | - .setName("config").setObject("isEncrypt", false); | |
| 712 | - reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 713 | - } else { | |
| 714 | - isEncrypt = true; | |
| 715 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 716 | - .setName("config").setObject("isEncrypt", true); | |
| 717 | - reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 718 | - } | |
| 719 | - break; | |
| 720 | - case R.id.scanEncryptGroup: | |
| 721 | - if (scanBack != null && scanBack) { | |
| 722 | - scanBack = false; | |
| 723 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 724 | - .setName("config").setObject("scanBack", false); | |
| 725 | - scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 726 | - }else { | |
| 727 | - scanBack = true; | |
| 728 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 729 | - .setName("config").setObject("scanBack", true); | |
| 730 | - scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 731 | - } | |
| 732 | - break; | |
| 733 | - } | |
| 734 | - } | |
| 735 | - | |
| 736 | - @Override | |
| 737 | - public void onCheckedChanged(RadioGroup group, int checkedId) { | |
| 738 | - switch (group.getId()) { | |
| 739 | - | |
| 740 | - case R.id.testGroup: | |
| 741 | - // 获取变更后的选中项的ID | |
| 742 | - if (checkedId == testYesRadioBtn.getId()) { | |
| 743 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 744 | - .setName("config").setObject("testMOdel", true); | |
| 745 | - testYesRadioBtn.setChecked(true); | |
| 746 | - testNoRadioBtn.setChecked(false); | |
| 747 | - } else if (checkedId == testNoRadioBtn.getId()) { | |
| 748 | - SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 749 | - .setName("config").setObject("testMOdel", false); | |
| 750 | - testlayout.setVisibility(View.GONE); | |
| 751 | - testYesRadioBtn.setChecked(false); | |
| 752 | - testNoRadioBtn.setChecked(true); | |
| 753 | - } | |
| 754 | - break; | |
| 755 | - | |
| 756 | - default: | |
| 757 | - break; | |
| 758 | - } | |
| 759 | - } | |
| 760 | -} | |
| 61 | + OnCheckedChangeListener { | |
| 62 | + //返回相应码 | |
| 63 | + private final int SETTING_REQUESTCODE = 1; | |
| 64 | + // 机器码,服务地址,系统密码,企业标识,企业编码 | |
| 65 | + private EditText machineCodeEdit, serviceIpEdit, systemPwdEdit, | |
| 66 | + identityEdit, encodeEdit; | |
| 67 | + // 打印选项组,调试选项组,打印加密选项组 | |
| 68 | + private RelativeLayout printGroup, reprintEncryptGroup; | |
| 69 | + private RadioGroup testGroup; | |
| 70 | + // 调试开关选项,是否打印选项,是否加密打印 | |
| 71 | + private RadioButton testNoRadioBtn, testYesRadioBtn; | |
| 72 | + // 确认按钮 | |
| 73 | + private Button confirmBtn, updateBtn; | |
| 74 | + private View testlayout; | |
| 75 | + // 是否调试模式,密码弹框 | |
| 76 | + private Dialog testDialog, pwdDialog; | |
| 77 | + // 打印次数,标题,版本, | |
| 78 | + private TextView printNumText, titleText, versionText; | |
| 79 | + | |
| 80 | + private String mode; | |
| 81 | + private int isprint = 0; | |
| 82 | + private NetworkConnectChangedReceiver receiver = null; | |
| 83 | + // 打印次数 | |
| 84 | + private Integer pnum = null; | |
| 85 | + // 调试模式 | |
| 86 | + private Boolean testMOdel; | |
| 87 | + // 是否加密 | |
| 88 | + private Boolean isEncrypt; | |
| 89 | + //退出应用次数 | |
| 90 | + private long firstTime = 0; | |
| 91 | + private int num = 0; | |
| 92 | + private RelativeLayout scanGroup; | |
| 93 | + private ImageView isreprint, scanEncrypt, reprntEncrypt; | |
| 94 | + private Boolean scanBack; | |
| 95 | + private LinearLayout lv_printNum; | |
| 96 | + private ArrayList<ConfigBean> beans; | |
| 97 | + | |
| 98 | + @Override | |
| 99 | + protected void onCreate(Bundle savedInstanceState) { | |
| 100 | + super.onCreate(savedInstanceState); | |
| 101 | + setContentView(R.layout.app_settings); | |
| 102 | + init(); | |
| 103 | + initConfig(); | |
| 104 | + initView(); | |
| 105 | + initListen(); | |
| 106 | + initData(); | |
| 107 | + initRegist(); | |
| 108 | + } | |
| 109 | + | |
| 110 | + private void init() { | |
| 111 | + pnum = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 112 | + .setName("MachineType").getObject("printNum", Integer.class); | |
| 113 | + | |
| 114 | + if (pnum == null) { | |
| 115 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 116 | + .setName("MachineType").setObject("printNum", 2); | |
| 117 | + } else { | |
| 118 | + if (pnum > 3) { | |
| 119 | + pnum = 3; | |
| 120 | + } | |
| 121 | + } | |
| 122 | + | |
| 123 | + testMOdel = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 124 | + .setName("config").getObject("testMOdel", Boolean.class); | |
| 125 | + isEncrypt = SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 126 | + .setName("config").getObject("isEncrypt", Boolean.class); | |
| 127 | + } | |
| 128 | + | |
| 129 | + private void initRegist() { | |
| 130 | + if (receiver == null) { | |
| 131 | + receiver = new NetworkConnectChangedReceiver(); | |
| 132 | + } | |
| 133 | + IntentFilter filter = new IntentFilter(); | |
| 134 | + filter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); | |
| 135 | + filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); | |
| 136 | + registerReceiver(receiver, filter); | |
| 137 | + } | |
| 138 | + | |
| 139 | + private void initView() { | |
| 140 | + lv_printNum = (LinearLayout) findViewById(R.id.lv_printNum); | |
| 141 | + printNumText = (TextView) findViewById(R.id.printNum); | |
| 142 | + machineCodeEdit = (EditText) findViewById(R.id.machineCodeEdit); | |
| 143 | + systemPwdEdit = (EditText) findViewById(R.id.systemPwdEdit); | |
| 144 | + serviceIpEdit = (EditText) findViewById(R.id.serviceIpEdit); | |
| 145 | + identityEdit = (EditText) findViewById(R.id.identityEdit); | |
| 146 | + encodeEdit = (EditText) findViewById(R.id.encodeEdit); | |
| 147 | + printGroup = (RelativeLayout) this.findViewById(R.id.printGroup); | |
| 148 | + testGroup = (RadioGroup) findViewById(R.id.testGroup); | |
| 149 | + scanGroup = (RelativeLayout) findViewById(R.id.scanEncryptGroup); | |
| 150 | + reprintEncryptGroup = (RelativeLayout) findViewById(R.id.reprintEncryptGroup); | |
| 151 | + testlayout = findViewById(R.id.testlayout);// 调节模式 | |
| 152 | + versionText = (TextView) findViewById(R.id.version); | |
| 153 | + confirmBtn = (Button) findViewById(R.id.set_saveBtn);//确认按钮 | |
| 154 | + updateBtn = (Button) findViewById(R.id.update); | |
| 155 | + titleText = (TextView) findViewById(R.id.title); | |
| 156 | + | |
| 157 | + isreprint = (ImageView) findViewById(R.id.iv_isreprint); | |
| 158 | + reprntEncrypt = (ImageView) findViewById(R.id.iv_reprintEncrypt); | |
| 159 | + scanEncrypt = (ImageView) findViewById(R.id.iv_scanEncrypt); | |
| 160 | + | |
| 161 | + // 显示版本号 | |
| 162 | + String versionName = MyApp.getInstance().getVersionName(); | |
| 163 | + versionText.setText(versionName); | |
| 164 | + confirmBtn.setVisibility(View.VISIBLE); | |
| 165 | + updateBtn.setVisibility(View.VISIBLE); | |
| 166 | + //findViewById(R.id.saveBtn).setVisibility(View.VISIBLE); | |
| 167 | + if (testMOdel != null && testMOdel) { // 是否隐藏 | |
| 168 | + testlayout.setVisibility(View.VISIBLE); | |
| 169 | + } else if (testMOdel != null && !testMOdel) { | |
| 170 | + testlayout.setVisibility(View.GONE); | |
| 171 | + } | |
| 172 | + titleText.setVisibility(View.VISIBLE); | |
| 173 | + titleText.setText(R.string.setting); | |
| 174 | + if (pnum != null) { | |
| 175 | + printNumText.setText(pnum + ""); | |
| 176 | + } | |
| 177 | + if (isEncrypt != null && isEncrypt) { // 是否隐藏 | |
| 178 | + reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 179 | + } else if (testMOdel != null && !testMOdel) { | |
| 180 | + reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 181 | + } | |
| 182 | + } | |
| 183 | + | |
| 184 | + private void initListen() { | |
| 185 | + versionText.setOnClickListener(this); | |
| 186 | + updateBtn.setOnClickListener(this); | |
| 187 | + titleText.setOnClickListener(this); | |
| 188 | + reprintEncryptGroup.setOnClickListener(this); | |
| 189 | + lv_printNum.setOnClickListener(this); | |
| 190 | + printGroup.setOnClickListener(this); | |
| 191 | + testGroup.setOnClickListener(this); | |
| 192 | + scanGroup.setOnClickListener(this); | |
| 193 | + confirmBtn.setOnClickListener(this); | |
| 194 | + } | |
| 195 | + | |
| 196 | + /*************************************** 退出应用****************************/ | |
| 197 | + private void closeApp() { | |
| 198 | + if (num < 5) { | |
| 199 | + long secondTime = System.currentTimeMillis(); | |
| 200 | + if (secondTime - firstTime > 4000) { // 如果两次按键时间间隔大于2秒,则不退出 | |
| 201 | + if (num == 1) { | |
| 202 | + firstTime = secondTime;// 更新firstTime | |
| 203 | + } | |
| 204 | + } | |
| 205 | + num++; | |
| 206 | + } else { | |
| 207 | + num = 0; | |
| 208 | + exitApp(); | |
| 209 | + } | |
| 210 | + } | |
| 211 | + | |
| 212 | + /*******************************调试模式*********************************************/ | |
| 213 | + private void testApp() { | |
| 214 | + if (num < 5) { | |
| 215 | + long secondTime = System.currentTimeMillis(); | |
| 216 | + if (secondTime - firstTime > 4000) { // 如果两次按键时间间隔大于2秒,则不退出 | |
| 217 | + if (num == 1) { | |
| 218 | + firstTime = secondTime;// 更新firstTime | |
| 219 | + } | |
| 220 | + } | |
| 221 | + num++; | |
| 222 | + } else { | |
| 223 | + num = 0; | |
| 224 | + testDialog(); | |
| 225 | + } | |
| 226 | + } | |
| 227 | + | |
| 228 | + /******************************* 调试弹框****************************************/ | |
| 229 | + private void testDialog() { | |
| 230 | + if (testDialog == null) { | |
| 231 | + final EditText inputpress = new EditText(this); | |
| 232 | + inputpress.setInputType(InputType.TYPE_CLASS_TEXT | |
| 233 | + | InputType.TYPE_TEXT_VARIATION_PASSWORD); | |
| 234 | + Builder builder = new AlertDialog.Builder(this); | |
| 235 | + builder.setTitle(R.string.input_pwd_debug); | |
| 236 | + builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 237 | + builder.setView(inputpress).setPositiveButton(R.string.btn_ok, | |
| 238 | + new DialogInterface.OnClickListener() { | |
| 239 | + | |
| 240 | + @Override | |
| 241 | + public void onClick(DialogInterface dialog, int which) { | |
| 242 | + String password = inputpress.getText().toString(); | |
| 243 | + if (password.equals(constant.exitPwd)) { | |
| 244 | + LogUtil.isDebug = false; | |
| 245 | + testlayout.setVisibility(View.VISIBLE); | |
| 246 | + SharedPreferences2Obj | |
| 247 | + .getInstance(SettingsActivity.this) | |
| 248 | + .setName("config") | |
| 249 | + .setObject("testMOdel", true); | |
| 250 | + testYesRadioBtn.setChecked(true); | |
| 251 | + testNoRadioBtn.setChecked(false); | |
| 252 | + } else { | |
| 253 | + MToast(SettingsActivity.this, | |
| 254 | + getString(R.string.pwd_error_noexit), | |
| 255 | + MToast.LENGTH_SHORT); | |
| 256 | + } | |
| 257 | + } | |
| 258 | + }); | |
| 259 | + | |
| 260 | + builder.setNegativeButton(R.string.btn_cancel, null); | |
| 261 | + AlertDialog dialog = builder.create(); | |
| 262 | + if (MyApp.getInstance().isHandset) { | |
| 263 | + dialog.getWindow().setType( | |
| 264 | + WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); | |
| 265 | + } | |
| 266 | + dialog.setCanceledOnTouchOutside(false); | |
| 267 | + dialog.show(); | |
| 268 | + } | |
| 269 | + } | |
| 270 | + | |
| 271 | + /******************************** 退出手持机的方法******************************/ | |
| 272 | + private void exitApp() { | |
| 273 | + if (pwdDialog == null) { | |
| 274 | + final EditText inputpress = new EditText(this); | |
| 275 | + inputpress.setInputType(InputType.TYPE_CLASS_TEXT | |
| 276 | + | InputType.TYPE_TEXT_VARIATION_PASSWORD); | |
| 277 | + Builder builder = new AlertDialog.Builder(this); | |
| 278 | + builder.setTitle(R.string.input_exit_pwd); | |
| 279 | + builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 280 | + builder.setView(inputpress).setPositiveButton(R.string.btn_ok, | |
| 281 | + new DialogInterface.OnClickListener() { | |
| 282 | + | |
| 283 | + @Override | |
| 284 | + public void onClick(DialogInterface dialog, int which) { | |
| 285 | + String password = inputpress.getText().toString(); | |
| 286 | + if (password.equals(constant.exitPwd)) { | |
| 287 | + MyApp.getInstance().exit(); | |
| 288 | + } else { | |
| 289 | + MToast(SettingsActivity.this, | |
| 290 | + getString(R.string.pwd_error_noexit), | |
| 291 | + MToast.LENGTH_SHORT); | |
| 292 | + } | |
| 293 | + } | |
| 294 | + }); | |
| 295 | + | |
| 296 | + builder.setNegativeButton(getString(R.string.cancle_label), null); | |
| 297 | + AlertDialog dialog = builder.create(); | |
| 298 | + if (MyApp.getInstance().isHandset) { | |
| 299 | + dialog.getWindow().setType( | |
| 300 | + WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); | |
| 301 | + } | |
| 302 | + dialog.setCanceledOnTouchOutside(false); | |
| 303 | + dialog.show(); | |
| 304 | + } | |
| 305 | + } | |
| 306 | + | |
| 307 | + private void initData() { | |
| 308 | + | |
| 309 | + beans = DbManager.GetConfigs(); | |
| 310 | + | |
| 311 | + if (beans != null && beans.size() > 0) { | |
| 312 | + serviceIpEdit.setText(beans.get(0).getEc_ip()); | |
| 313 | + if (TextUtils.isEmpty(beans.get(0).getEc_mac())) { | |
| 314 | + machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 315 | + } else { | |
| 316 | + machineCodeEdit.setText(beans.get(0).getEc_mac()); | |
| 317 | + } | |
| 318 | + systemPwdEdit.setText(beans.get(0).getEc_passwd()); | |
| 319 | + encodeEdit.setText(beans.get(0).getEc_identity()); | |
| 320 | + try { | |
| 321 | + String ec_name = AESEncryptor.decrypt(constant.decrypt, beans | |
| 322 | + .get(0).getEc_signkey()); | |
| 323 | + identityEdit.setText(ec_name); | |
| 324 | + } catch (Exception e) { | |
| 325 | + e.printStackTrace(); | |
| 326 | + } | |
| 327 | + if (1 == beans.get(0).getEc_isPrint()) { | |
| 328 | + isprint = 1; | |
| 329 | + isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 330 | + } else if (0 == beans.get(0).getEc_isPrint()) { | |
| 331 | + isprint = 0; | |
| 332 | + isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 333 | + } | |
| 334 | + } else { | |
| 335 | + | |
| 336 | + serviceIpEdit.setText(""); | |
| 337 | + machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 338 | + systemPwdEdit.setText(constant.pwd); | |
| 339 | + encodeEdit.setText(""); | |
| 340 | + identityEdit.setText(""); | |
| 341 | + MToast(SettingsActivity.this, getString(R.string.init_setting), | |
| 342 | + MToast.LENGTH_SHORT); | |
| 343 | + } | |
| 344 | + | |
| 345 | + scanBack = SharedPreferences2Obj.getInstance(this).setName("config").getObject("scanBack", Boolean.class); | |
| 346 | + if (scanBack != null) { | |
| 347 | + if (scanBack) { | |
| 348 | + | |
| 349 | + scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 350 | + } else { | |
| 351 | + scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 352 | + } | |
| 353 | + } else { | |
| 354 | + scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 355 | + } | |
| 356 | + } | |
| 357 | + | |
| 358 | + | |
| 359 | + public class NetworkConnectChangedReceiver extends BroadcastReceiver { | |
| 360 | + @Override | |
| 361 | + public void onReceive(Context context, Intent intent) { | |
| 362 | + if (WifiManager.WIFI_STATE_CHANGED_ACTION | |
| 363 | + .equals(intent.getAction())) {// 这个监听wifi的打开与关闭,与wifi的连接无关 | |
| 364 | + int wifiState = intent.getIntExtra( | |
| 365 | + WifiManager.EXTRA_WIFI_STATE, 0); | |
| 366 | + LogUtil.e("H3c", "wifiState" + wifiState); | |
| 367 | + switch (wifiState) { | |
| 368 | + case WifiManager.WIFI_STATE_ENABLED: | |
| 369 | + if (machineCodeEdit != null) { | |
| 370 | + | |
| 371 | + if (beans != null && beans.size() > 0) { | |
| 372 | + if (TextUtils.isEmpty(beans.get(0).getEc_mac())) { | |
| 373 | + machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 374 | + } else { | |
| 375 | + machineCodeEdit.setText(beans.get(0).getEc_mac()); | |
| 376 | + } | |
| 377 | + }else{ | |
| 378 | + machineCodeEdit.setText(DevicTool.getInstance().getDevId()); | |
| 379 | + } | |
| 380 | + } | |
| 381 | + break; | |
| 382 | + } | |
| 383 | + } | |
| 384 | + } | |
| 385 | + } | |
| 386 | + | |
| 387 | + private void initConfig() { | |
| 388 | + mode = getIntent().getStringExtra("mode"); | |
| 389 | + findViewById(R.id.topBack).setOnClickListener(new OnClickListener() { | |
| 390 | + @Override | |
| 391 | + public void onClick(View arg0) { | |
| 392 | + finish(); | |
| 393 | + } | |
| 394 | + }); | |
| 395 | + } | |
| 396 | + | |
| 397 | + /************************** 下面是打印次数的弹框 ***********************************/ | |
| 398 | + private LayoutInflater inflater; | |
| 399 | + private View layout2; | |
| 400 | + | |
| 401 | + private AlertDialog dialog2; // 部分检票弹框 | |
| 402 | + private AbstractWheel wheel;// 部分检票滚轮 | |
| 403 | + private Button reduce;// 部分检票减按钮 | |
| 404 | + private Button plus;// 部分检票加按钮 | |
| 405 | + | |
| 406 | + @SuppressLint("InflateParams") | |
| 407 | + public void dialog(int num) { | |
| 408 | + if (dialog2 == null) { | |
| 409 | + inflater = LayoutInflater.from(SettingsActivity.this); | |
| 410 | + layout2 = inflater.inflate(R.layout.consume_dialog, null); | |
| 411 | + Builder builder = new AlertDialog.Builder(SettingsActivity.this); | |
| 412 | + builder.setTitle(R.string.print_number); | |
| 413 | + builder.setIcon(android.R.drawable.ic_dialog_info); | |
| 414 | + builder.setView(layout2).setPositiveButton(R.string.btn_ok, | |
| 415 | + new DialogInterface.OnClickListener() { | |
| 416 | + @Override | |
| 417 | + public void onClick(DialogInterface dialog, int which) { | |
| 418 | + printNumText.setText(wheel.getCurrentItem() + 1 | |
| 419 | + + ""); | |
| 420 | + SharedPreferences2Obj | |
| 421 | + .getInstance(SettingsActivity.this) | |
| 422 | + .setName("MachineType") | |
| 423 | + .setObject("printNum", | |
| 424 | + wheel.getCurrentItem() + 1); | |
| 425 | + } | |
| 426 | + }); | |
| 427 | + builder.setNegativeButton(R.string.btn_cancel, | |
| 428 | + new DialogInterface.OnClickListener() { | |
| 429 | + @Override | |
| 430 | + public void onClick(DialogInterface dialog, int which) { | |
| 431 | + if (dialog != null) { | |
| 432 | + try { | |
| 433 | + dialog.dismiss(); | |
| 434 | + } catch (Exception e) { | |
| 435 | + e.printStackTrace(); | |
| 436 | + } catch (Throwable e) { | |
| 437 | + e.printStackTrace(); | |
| 438 | + } | |
| 439 | + } | |
| 440 | + } | |
| 441 | + }); | |
| 442 | + dialog2 = builder.create(); | |
| 443 | + } | |
| 444 | + | |
| 445 | + initWheel(layout2, R.id.wheelView, num); | |
| 446 | + | |
| 447 | + if (MyApp.getInstance().isHandset) { | |
| 448 | + dialog2.getWindow().setType( | |
| 449 | + WindowManager.LayoutParams.TYPE_SYSTEM_ERROR); | |
| 450 | + } | |
| 451 | + dialog2.show(); | |
| 452 | + } | |
| 453 | + | |
| 454 | + private void initWheel(View view, int id, final int num) { | |
| 455 | + wheel = (AbstractWheel) view.findViewById(id); | |
| 456 | + wheel.setViewAdapter(new NumericWheelAdapter(SettingsActivity.this, 1, | |
| 457 | + num)); | |
| 458 | + wheel.setCyclic(true); | |
| 459 | + wheel.setInterpolator(new AnticipateOvershootInterpolator()); | |
| 460 | + reduce = (Button) view.findViewById(R.id.reduce); | |
| 461 | + reduce.setOnClickListener(new OnClickListener() { | |
| 462 | + @Override | |
| 463 | + public void onClick(View v) { | |
| 464 | + int current = wheel.getCurrentItem() - 1; | |
| 465 | + if (current < 0) { | |
| 466 | + return; | |
| 467 | + } | |
| 468 | + wheel.setCurrentItem(current); | |
| 469 | + } | |
| 470 | + }); | |
| 471 | + | |
| 472 | + plus = (Button) view.findViewById(R.id.plus); | |
| 473 | + plus.setOnClickListener(new OnClickListener() { | |
| 474 | + @Override | |
| 475 | + public void onClick(View v) { | |
| 476 | + int current = wheel.getCurrentItem() + 1; | |
| 477 | + if (num == current) { | |
| 478 | + return; | |
| 479 | + } | |
| 480 | + wheel.setCurrentItem(current); | |
| 481 | + } | |
| 482 | + }); | |
| 483 | + } | |
| 484 | + | |
| 485 | + @Override | |
| 486 | + public boolean onKeyDown(int keyCode, KeyEvent event) { | |
| 487 | + if (keyCode == KeyEvent.KEYCODE_BACK) { | |
| 488 | + try { | |
| 489 | + CommetryUtils.releaseCommery(this); | |
| 490 | + } catch (Exception e) { | |
| 491 | + e.printStackTrace(); | |
| 492 | + } | |
| 493 | + finish(); | |
| 494 | + } | |
| 495 | + return false; | |
| 496 | + } | |
| 497 | + | |
| 498 | + @Override | |
| 499 | + protected void onDestroy() { | |
| 500 | + if (receiver != null) { | |
| 501 | + unregisterReceiver(receiver); | |
| 502 | + } | |
| 503 | + super.onDestroy(); | |
| 504 | + } | |
| 505 | + | |
| 506 | + /************************* 失去焦点的时候,隐藏键盘 *********************************/ | |
| 507 | + /** | |
| 508 | + * 隐藏软键盘 | |
| 509 | + */ | |
| 510 | + @Override | |
| 511 | + public boolean dispatchTouchEvent(MotionEvent ev) { | |
| 512 | + // TODO Auto-generated method stub | |
| 513 | + if (ev.getAction() == MotionEvent.ACTION_DOWN) { | |
| 514 | + | |
| 515 | + // 获得当前得到焦点的View,一般情况下就是EditText(特殊情况就是轨迹求或者实体案件会移动焦点) | |
| 516 | + View v = getCurrentFocus(); | |
| 517 | + | |
| 518 | + if (isShouldHideInput(v, ev)) { | |
| 519 | + InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); | |
| 520 | + hideSoftInput(v.getWindowToken(), im); | |
| 521 | + } | |
| 522 | + } | |
| 523 | + return super.dispatchTouchEvent(ev); | |
| 524 | + } | |
| 525 | + | |
| 526 | + /** | |
| 527 | + * 根据EditText所在坐标和用户点击的坐标相对比,来判断是否隐藏键盘,因为当用户点击EditText时没必要隐藏 | |
| 528 | + * | |
| 529 | + * @param v | |
| 530 | + * @param event | |
| 531 | + * @return | |
| 532 | + */ | |
| 533 | + public boolean isShouldHideInput(View v, MotionEvent event) { | |
| 534 | + if (v != null && (v instanceof EditText)) { | |
| 535 | + int[] l = {0, 0}; | |
| 536 | + v.getLocationInWindow(l); | |
| 537 | + int left = l[0], top = l[1], bottom = top + v.getHeight(), right = left | |
| 538 | + + v.getWidth(); | |
| 539 | + if (event.getX() > left && event.getX() < right | |
| 540 | + && event.getY() > top && event.getY() < bottom) { | |
| 541 | + // 点击EditText的事件,忽略它。 | |
| 542 | + return false; | |
| 543 | + } else { | |
| 544 | + return true; | |
| 545 | + } | |
| 546 | + } | |
| 547 | + // 如果焦点不是EditText则忽略,这个发生在视图刚绘制完,第一个焦点不在EditView上,和用户用轨迹球选择其他的焦点 | |
| 548 | + return false; | |
| 549 | + } | |
| 550 | + | |
| 551 | + /** | |
| 552 | + * 多种隐藏软件盘方法的其中一种 | |
| 553 | + * | |
| 554 | + * @param token | |
| 555 | + */ | |
| 556 | + public void hideSoftInput(IBinder token, InputMethodManager im) { | |
| 557 | + if (token != null) { | |
| 558 | + im.hideSoftInputFromWindow(token, | |
| 559 | + InputMethodManager.HIDE_NOT_ALWAYS); | |
| 560 | + } | |
| 561 | + } | |
| 562 | + | |
| 563 | + /********************************监听事件***************************/ | |
| 564 | + | |
| 565 | + @SuppressLint("DefaultLocale") | |
| 566 | + @Override | |
| 567 | + public void onClick(View arg0) { | |
| 568 | + | |
| 569 | + switch (arg0.getId()) { | |
| 570 | + case R.id.lv_printNum: | |
| 571 | + dialog(3); | |
| 572 | + break; | |
| 573 | + case R.id.version: // 调试模式 | |
| 574 | + testApp(); | |
| 575 | + break; | |
| 576 | + case R.id.update: | |
| 577 | + if (serviceIpEdit.getText() == null | |
| 578 | + || serviceIpEdit.getText().toString() == null | |
| 579 | + || serviceIpEdit.getText().toString().trim().equals("")) { | |
| 580 | + Toast.makeText(SettingsActivity.this, | |
| 581 | + getString(R.string.fill_in_server_ip), | |
| 582 | + Toast.LENGTH_SHORT).show(); | |
| 583 | + return; | |
| 584 | + } | |
| 585 | + if (encodeEdit.getText() == null | |
| 586 | + || encodeEdit.getText().toString() == null | |
| 587 | + || encodeEdit.getText().toString().trim().equals("")) { | |
| 588 | + Toast.makeText(SettingsActivity.this, | |
| 589 | + getString(R.string.fil_in_connkey), Toast.LENGTH_SHORT) | |
| 590 | + .show(); | |
| 591 | + return; | |
| 592 | + } | |
| 593 | + if (identityEdit.getText() == null | |
| 594 | + || identityEdit.getText().toString() == null | |
| 595 | + || identityEdit.getText().toString().trim().equals("")) { | |
| 596 | + Toast.makeText(SettingsActivity.this, R.string.fil_in_qiye_key, | |
| 597 | + Toast.LENGTH_SHORT).show(); | |
| 598 | + return; | |
| 599 | + } | |
| 600 | + try { | |
| 601 | + UpdateManager.getUpdateManager().checkAppUpdate( | |
| 602 | + SettingsActivity.this, | |
| 603 | + serviceIpEdit.getText().toString().trim(), | |
| 604 | + identityEdit.getText().toString().trim(), | |
| 605 | + encodeEdit.getText().toString().trim()); | |
| 606 | + // 并保存信息 | |
| 607 | + try { | |
| 608 | + ConfigBean bean = new ConfigBean(); | |
| 609 | + String mac = machineCodeEdit.getText().toString().trim(); | |
| 610 | + bean.setEc_id(0 + ""); | |
| 611 | + bean.setEc_ip(serviceIpEdit.getText().toString().trim()); | |
| 612 | + bean.setEc_identity(encodeEdit.getText().toString().trim()); | |
| 613 | + bean.setEc_mac(mac.toUpperCase()); | |
| 614 | + bean.setEc_passwd(systemPwdEdit.getText().toString().trim()); | |
| 615 | + String signkey = AESEncryptor.encrypt(constant.decrypt, | |
| 616 | + identityEdit.getText().toString().trim()); | |
| 617 | + bean.setEc_signkey(signkey); | |
| 618 | + bean.setEc_isPrint(isprint); | |
| 619 | + if ("0".equals(mode)) { | |
| 620 | + DbManager.ClearConfig(); | |
| 621 | + DbManager.InsertConfig(bean); | |
| 622 | + } else { | |
| 623 | + DbManager.ModifyConfig(bean); | |
| 624 | + } | |
| 625 | + } catch (Exception e) { | |
| 626 | + e.printStackTrace(); | |
| 627 | + } | |
| 628 | + // } | |
| 629 | + } catch (Exception e) { | |
| 630 | + e.printStackTrace(); | |
| 631 | + } | |
| 632 | + break; | |
| 633 | + case R.id.set_saveBtn: | |
| 634 | + String ec_name = identityEdit.getText().toString().trim(); | |
| 635 | + if (!ec_name.equals("")) { | |
| 636 | + try { | |
| 637 | + ec_name = AESEncryptor.decrypt(constant.decrypt, ec_name); | |
| 638 | + LogUtil.d(getString(R.string.enterprise_communication_identifier) | |
| 639 | + + ec_name); | |
| 640 | + ec_name = AESEncryptor.encrypt(constant.decrypt, ec_name); | |
| 641 | + } catch (Exception ex) { | |
| 642 | + try { | |
| 643 | + ec_name = AESEncryptor.encrypt(constant.decrypt, | |
| 644 | + ec_name); | |
| 645 | + LogUtil.d(getString(R.string.not_successfully_decrypt) | |
| 646 | + + ec_name); | |
| 647 | + } catch (Exception e) { | |
| 648 | + e.printStackTrace(); | |
| 649 | + MToast(SettingsActivity.this, | |
| 650 | + getString(R.string.communication_id_error), | |
| 651 | + MToast.LENGTH_SHORT); | |
| 652 | + ec_name = ""; | |
| 653 | + identityEdit.setText(""); | |
| 654 | + return; | |
| 655 | + } | |
| 656 | + } | |
| 657 | + if ("".equals(serviceIpEdit.getText().toString().trim())) { | |
| 658 | + | |
| 659 | + MToast(SettingsActivity.this, | |
| 660 | + getString(R.string.server_ip_notnull), | |
| 661 | + MToast.LENGTH_SHORT); | |
| 662 | + return; | |
| 663 | + } else if ("".equals(systemPwdEdit.getText().toString().trim())) { | |
| 664 | + MToast(SettingsActivity.this, | |
| 665 | + getString(R.string.pwd_notnull), | |
| 666 | + MToast.LENGTH_SHORT); | |
| 667 | + return; | |
| 668 | + } else if ("".equals(encodeEdit.getText().toString().trim())) { | |
| 669 | + MToast(SettingsActivity.this, | |
| 670 | + getString(R.string.connkey_notnull), | |
| 671 | + MToast.LENGTH_SHORT); | |
| 672 | + return; | |
| 673 | + } else if ("".equals(ec_name)) { | |
| 674 | + MToast(SettingsActivity.this, | |
| 675 | + getString(R.string.communication_id_notnull), | |
| 676 | + MToast.LENGTH_SHORT); | |
| 677 | + return; | |
| 678 | + } else { | |
| 679 | + | |
| 680 | + ConfigBean bean = new ConfigBean(); | |
| 681 | + String mac = machineCodeEdit.getText().toString().trim(); | |
| 682 | + bean.setEc_id(0 + ""); | |
| 683 | + bean.setEc_ip(serviceIpEdit.getText().toString().trim()); | |
| 684 | + bean.setEc_identity(encodeEdit.getText().toString().trim()); | |
| 685 | + bean.setEc_mac(mac.toUpperCase()); | |
| 686 | + bean.setEc_passwd(systemPwdEdit.getText().toString().trim()); | |
| 687 | + bean.setEc_signkey(ec_name); | |
| 688 | + bean.setEc_isPrint(isprint); | |
| 689 | + if ("0".equals(mode)) { | |
| 690 | + DbManager.ClearConfig(); | |
| 691 | + DbManager.InsertConfig(bean); | |
| 692 | + } else { | |
| 693 | + DbManager.ModifyConfig(bean); | |
| 694 | + } | |
| 695 | + | |
| 696 | + Intent intent = new Intent(); | |
| 697 | + setResult(SETTING_REQUESTCODE, intent); | |
| 698 | + finish(); | |
| 699 | + } | |
| 700 | + } else { | |
| 701 | + MToast(SettingsActivity.this, | |
| 702 | + getString(R.string.communication_id_notnull), | |
| 703 | + MToast.LENGTH_SHORT); | |
| 704 | + } | |
| 705 | + break; | |
| 706 | + case R.id.title: | |
| 707 | + closeApp(); | |
| 708 | + break; | |
| 709 | + case R.id.printGroup: | |
| 710 | + if (isprint == 1) { | |
| 711 | + isprint = 0; | |
| 712 | + isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 713 | + } else if (isprint == 0) { | |
| 714 | + isprint = 1; | |
| 715 | + isreprint.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 716 | + } | |
| 717 | + break; | |
| 718 | + case R.id.reprintEncryptGroup: | |
| 719 | + if (isEncrypt != null && isEncrypt) { // 是否隐藏 | |
| 720 | + isEncrypt = false; | |
| 721 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 722 | + .setName("config").setObject("isEncrypt", false); | |
| 723 | + reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 724 | + } else { | |
| 725 | + isEncrypt = true; | |
| 726 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 727 | + .setName("config").setObject("isEncrypt", true); | |
| 728 | + reprntEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 729 | + } | |
| 730 | + break; | |
| 731 | + case R.id.scanEncryptGroup: | |
| 732 | + if (scanBack != null && scanBack) { | |
| 733 | + scanBack = false; | |
| 734 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 735 | + .setName("config").setObject("scanBack", false); | |
| 736 | + scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_gray)); | |
| 737 | + } else { | |
| 738 | + scanBack = true; | |
| 739 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 740 | + .setName("config").setObject("scanBack", true); | |
| 741 | + scanEncrypt.setImageDrawable(getResources().getDrawable(R.drawable.set_choice_blue)); | |
| 742 | + } | |
| 743 | + break; | |
| 744 | + } | |
| 745 | + } | |
| 746 | + | |
| 747 | + @Override | |
| 748 | + public void onCheckedChanged(RadioGroup group, int checkedId) { | |
| 749 | + switch (group.getId()) { | |
| 750 | + | |
| 751 | + case R.id.testGroup: | |
| 752 | + // 获取变更后的选中项的ID | |
| 753 | + if (checkedId == testYesRadioBtn.getId()) { | |
| 754 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 755 | + .setName("config").setObject("testMOdel", true); | |
| 756 | + testYesRadioBtn.setChecked(true); | |
| 757 | + testNoRadioBtn.setChecked(false); | |
| 758 | + } else if (checkedId == testNoRadioBtn.getId()) { | |
| 759 | + SharedPreferences2Obj.getInstance(SettingsActivity.this) | |
| 760 | + .setName("config").setObject("testMOdel", false); | |
| 761 | + testlayout.setVisibility(View.GONE); | |
| 762 | + testYesRadioBtn.setChecked(false); | |
| 763 | + testNoRadioBtn.setChecked(true); | |
| 764 | + } | |
| 765 | + break; | |
| 766 | + | |
| 767 | + default: | |
| 768 | + break; | |
| 769 | + } | |
| 770 | + } | |
| 771 | + } | ... | ... |