Mercurial > 510Connectbot
diff 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 |
line wrap: on
line diff
--- a/src/com/five_ten_sg/connectbot/HostListActivity.java Wed Jul 30 12:09:51 2014 -0700 +++ b/src/com/five_ten_sg/connectbot/HostListActivity.java Wed Jul 30 14:16:58 2014 -0700 @@ -403,21 +403,30 @@ File.separator + "deployment.connections"; BufferedReader reader = new BufferedReader(new FileReader(fn)); String line = null; + while ((line = reader.readLine()) != null) { if (line.length() == 0) continue; // empty - if (line.substring(0,1).equals("#")) continue; // comment + + if (line.substring(0, 1).equals("#")) continue; // comment + if (!line.contains("://")) continue; // invalid uri + Uri uri = Uri.parse(line); ContentValues values = null; + while ((line = reader.readLine()).length() > 0) { String [] parts = line.split("="); + if (parts.length != 2) continue; + if (values == null) values = new ContentValues(); + values.put(parts[0].trim(), parts[1].trim()); } + if (uri.getScheme().equals("global")) { Editor editor = prefs.edit(); - HashMap<String,String> types = new HashMap<String,String>(); + HashMap<String, String> types = new HashMap<String, String>(); types.put("memkeys", "boolean"); types.put("connPersist", "boolean"); types.put("emulation", "string"); @@ -451,30 +460,38 @@ types.put("upload_dest_prompt", "boolean"); types.put("background_file_transfer", "boolean"); types.put("debug_keycodes", "boolean"); + for (String key : values.keySet()) { if (types.containsKey(key)) { String sv = values.getAsString(key); editor.putString(key, sv); } } + editor.commit(); } else { HostBean host = TransportFactory.findHost(hostdb, uri); + if (host == null) { host = TransportFactory.getTransport(uri.getScheme()).createHost(uri); host.setColor(HostDatabase.COLOR_GRAY); host.setPubkeyId(HostDatabase.PUBKEYID_ANY); hostdb.saveHost(host); } + host = TransportFactory.findHost(hostdb, uri); + if (host == null) continue; + if (values == null) continue; + SQLiteDatabase db = hostdb.getWritableDatabase(); db.update(HostDatabase.TABLE_HOSTS, values, "_id = ?", new String[] { String.valueOf(host.getId()) }); db.close(); } } + reader.close(); (new File(fn)).delete(); }