comparison src/com/five_ten_sg/connectbot/HostListActivity.java @ 307:071eccdff8ea ganymed

fix java formatting
author Carl Byington <carl@five-ten-sg.com>
date Wed, 30 Jul 2014 14:16:58 -0700
parents 32737a428805
children 93621e963303
comparison
equal deleted inserted replaced
305:d2b303406d63 307:071eccdff8ea
401 try { 401 try {
402 String fn = Environment.getExternalStorageDirectory().getAbsolutePath() + 402 String fn = Environment.getExternalStorageDirectory().getAbsolutePath() +
403 File.separator + "deployment.connections"; 403 File.separator + "deployment.connections";
404 BufferedReader reader = new BufferedReader(new FileReader(fn)); 404 BufferedReader reader = new BufferedReader(new FileReader(fn));
405 String line = null; 405 String line = null;
406
406 while ((line = reader.readLine()) != null) { 407 while ((line = reader.readLine()) != null) {
407 if (line.length() == 0) continue; // empty 408 if (line.length() == 0) continue; // empty
408 if (line.substring(0,1).equals("#")) continue; // comment 409
410 if (line.substring(0, 1).equals("#")) continue; // comment
411
409 if (!line.contains("://")) continue; // invalid uri 412 if (!line.contains("://")) continue; // invalid uri
413
410 Uri uri = Uri.parse(line); 414 Uri uri = Uri.parse(line);
411 ContentValues values = null; 415 ContentValues values = null;
416
412 while ((line = reader.readLine()).length() > 0) { 417 while ((line = reader.readLine()).length() > 0) {
413 String [] parts = line.split("="); 418 String [] parts = line.split("=");
419
414 if (parts.length != 2) continue; 420 if (parts.length != 2) continue;
421
415 if (values == null) values = new ContentValues(); 422 if (values == null) values = new ContentValues();
423
416 values.put(parts[0].trim(), parts[1].trim()); 424 values.put(parts[0].trim(), parts[1].trim());
417 } 425 }
426
418 if (uri.getScheme().equals("global")) { 427 if (uri.getScheme().equals("global")) {
419 Editor editor = prefs.edit(); 428 Editor editor = prefs.edit();
420 HashMap<String,String> types = new HashMap<String,String>(); 429 HashMap<String, String> types = new HashMap<String, String>();
421 types.put("memkeys", "boolean"); 430 types.put("memkeys", "boolean");
422 types.put("connPersist", "boolean"); 431 types.put("connPersist", "boolean");
423 types.put("emulation", "string"); 432 types.put("emulation", "string");
424 types.put("scrollback", "integer"); 433 types.put("scrollback", "integer");
425 types.put("rotation", "string"); 434 types.put("rotation", "string");
449 types.put("download_folder", "string"); 458 types.put("download_folder", "string");
450 types.put("remote_upload_folder", "string"); 459 types.put("remote_upload_folder", "string");
451 types.put("upload_dest_prompt", "boolean"); 460 types.put("upload_dest_prompt", "boolean");
452 types.put("background_file_transfer", "boolean"); 461 types.put("background_file_transfer", "boolean");
453 types.put("debug_keycodes", "boolean"); 462 types.put("debug_keycodes", "boolean");
463
454 for (String key : values.keySet()) { 464 for (String key : values.keySet()) {
455 if (types.containsKey(key)) { 465 if (types.containsKey(key)) {
456 String sv = values.getAsString(key); 466 String sv = values.getAsString(key);
457 editor.putString(key, sv); 467 editor.putString(key, sv);
458 } 468 }
459 } 469 }
470
460 editor.commit(); 471 editor.commit();
461 } 472 }
462 else { 473 else {
463 HostBean host = TransportFactory.findHost(hostdb, uri); 474 HostBean host = TransportFactory.findHost(hostdb, uri);
475
464 if (host == null) { 476 if (host == null) {
465 host = TransportFactory.getTransport(uri.getScheme()).createHost(uri); 477 host = TransportFactory.getTransport(uri.getScheme()).createHost(uri);
466 host.setColor(HostDatabase.COLOR_GRAY); 478 host.setColor(HostDatabase.COLOR_GRAY);
467 host.setPubkeyId(HostDatabase.PUBKEYID_ANY); 479 host.setPubkeyId(HostDatabase.PUBKEYID_ANY);
468 hostdb.saveHost(host); 480 hostdb.saveHost(host);
469 } 481 }
482
470 host = TransportFactory.findHost(hostdb, uri); 483 host = TransportFactory.findHost(hostdb, uri);
484
471 if (host == null) continue; 485 if (host == null) continue;
486
472 if (values == null) continue; 487 if (values == null) continue;
488
473 SQLiteDatabase db = hostdb.getWritableDatabase(); 489 SQLiteDatabase db = hostdb.getWritableDatabase();
474 db.update(HostDatabase.TABLE_HOSTS, values, "_id = ?", new String[] { String.valueOf(host.getId()) }); 490 db.update(HostDatabase.TABLE_HOSTS, values, "_id = ?", new String[] { String.valueOf(host.getId()) });
475 db.close(); 491 db.close();
476 } 492 }
477 } 493 }
494
478 reader.close(); 495 reader.close();
479 (new File(fn)).delete(); 496 (new File(fn)).delete();
480 } 497 }
481 catch (Exception e) { 498 catch (Exception e) {
482 Log.d(TAG, "Deployment scan failed.", e); 499 Log.d(TAG, "Deployment scan failed.", e);