# HG changeset patch # User Carl Byington # Date 1567700695 25200 # Node ID 12e2d9dd95df7a0fb48667dc195f9bb65cf20544 # Parent 7c8aebcc882a78ea06d5776d970b0107df450748 add delete_deployment and autolaunch keys to the deployment.connections file diff -r 7c8aebcc882a -r 12e2d9dd95df app/src/main/AndroidManifest.xml --- a/app/src/main/AndroidManifest.xml Mon Aug 19 11:12:40 2019 -0700 +++ b/app/src/main/AndroidManifest.xml Thu Sep 05 09:24:55 2019 -0700 @@ -17,8 +17,8 @@ --> diff -r 7c8aebcc882a -r 12e2d9dd95df app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java --- a/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Mon Aug 19 11:12:40 2019 -0700 +++ b/app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java Thu Sep 05 09:24:55 2019 -0700 @@ -198,7 +198,8 @@ // connect with hosts database, read deployment file, and populate list hostdb = new HostDatabase(this); - createDeploymentHosts(); // build hosts from a deployment text file + // build hosts from a deployment text file + Uri launch = createDeploymentHosts(); updateList(); // check for eula agreement, which might be set from the deployment file @@ -264,6 +265,12 @@ }); transportSpinner.setAdapter(transportSelection); this.inflater = LayoutInflater.from(this); + + if (launch != null) { + Intent contents = new Intent(Intent.ACTION_VIEW, launch); + contents.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(contents); + } } public void checkp(String [] perms) { @@ -423,8 +430,10 @@ return true; } - private void createDeploymentHosts() { + private Uri createDeploymentHosts() { + Uri launch = null; try { + boolean del = true; String fn = Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "deployment.connections"; BufferedReader reader = new BufferedReader(new FileReader(fn)); @@ -451,6 +460,11 @@ } if (uri.getScheme().equals("global")) { + String dd = "delete_deployment"; + if (values.containsKey(dd)) { + String sv = values.getAsString(dd); + del = Boolean.parseBoolean(sv); + } Editor editor = prefs.edit(); HashMap types = new HashMap(); types.put("memkeys", "boolean"); @@ -522,6 +536,13 @@ if (values == null) continue; + String key = "autolaunch"; + if (values.containsKey(key)) { + String sv = values.getAsString(key); + if (Boolean.parseBoolean(sv)) launch = uri; + values.remove(key); + } + SQLiteDatabase db = hostdb.getWritableDatabase(); db.update(HostDatabase.TABLE_HOSTS, values, "_id = ?", new String[] { String.valueOf(host.getId()) }); db.close(); @@ -529,11 +550,12 @@ } reader.close(); - (new File(fn)).delete(); + if (del) (new File(fn)).delete(); } catch (Exception e) { Log.d(TAG, "Deployment scan failed."); } + return launch; } protected void updateList() { diff -r 7c8aebcc882a -r 12e2d9dd95df xml/510connectbot.in --- a/xml/510connectbot.in Mon Aug 19 11:12:40 2019 -0700 +++ b/xml/510connectbot.in Thu Sep 05 09:24:55 2019 -0700 @@ -357,10 +357,16 @@ file is below. If this file exists at the top level of the external storage (as returned by Environment.getExternalStorageDirectory().getAbsolutePath()), - it is read, parsed, and deleted. Comments start with # + it is read, parsed, and optionally deleted. Comments start with # and extend to the end of the line. + + The deployment file is deleted unless it contains "delete_deployment=false" + in the global options section. In that case, the file remains, and + it is read and parsed every time the app is launched. + +