diff app/src/main/java/com/five_ten_sg/connectbot/HostListActivity.java @ 466:12e2d9dd95df stable-1.9.3-6

add delete_deployment and autolaunch keys to the deployment.connections file
author Carl Byington <carl@five-ten-sg.com>
date Thu, 05 Sep 2019 09:24:55 -0700
parents 7c8aebcc882a
children 74b507d491c9
line wrap: on
line diff
--- 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<String, String> types = new HashMap<String, String>();
                     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() {