shithub: drawterm-fdroid

Download patch

ref: 93287184eea7bcdce590ac8cbb2c211a9e2c5e68
parent: cce4ca5a6c55eb6fff53f9b7092e2518185a984c
author: Eli Cohen <echoline@gmail.com>
date: Sun Jan 30 20:40:33 EST 2022

android checkboxes for some of the flags

--- a/gui-android/java/org/echoline/drawterm/MainActivity.java
+++ b/gui-android/java/org/echoline/drawterm/MainActivity.java
@@ -30,6 +30,7 @@
 import android.widget.LinearLayout;
 import android.widget.ListView;
 import android.widget.TextView;
+import android.widget.CheckBox;
 import android.content.ClipData;
 import android.content.ClipboardManager;
 import android.hardware.camera2.CameraManager;
@@ -50,6 +51,7 @@
 import java.nio.ByteBuffer;
 import java.util.List;
 import java.util.ArrayList;
+import java.util.Arrays;
 
 public class MainActivity extends Activity {
 	private Map<String, ?> map;
@@ -172,8 +174,11 @@
 		((EditText)findViewById(R.id.cpuServer)).setText((String)a[0]);
 		((EditText)findViewById(R.id.authServer)).setText((String)a[1]);
 		((EditText)findViewById(R.id.userName)).setText((String)a[2]);
-		if (a.length > 3)
-			((EditText)findViewById(R.id.passWord)).setText((String)a[3]);
+		((EditText)findViewById(R.id.passWord)).setText((String)a[3]);
+
+		((CheckBox)findViewById(R.id.aan)).setChecked(((String)a[4]).equals("true") ? true : false);
+		((CheckBox)findViewById(R.id.cmd)).setChecked(((String)a[5]).equals("true") ? true : false);
+		((CheckBox)findViewById(R.id.root)).setChecked(((String)a[6]).equals("true") ? true : false);
 	}
 
 	public void populateServers(Context context) {
@@ -253,10 +258,13 @@
 				String auth = ((EditText)findViewById(R.id.authServer)).getText().toString();
 				String user = ((EditText)findViewById(R.id.userName)).getText().toString();
 				String pass = ((EditText)findViewById(R.id.passWord)).getText().toString();
+				String aan = ((CheckBox)findViewById(R.id.aan)).isChecked() ? "true" : "false";
+				String cmd = ((CheckBox)findViewById(R.id.cmd)).isChecked() ? "true" : "false";
+				String root = ((CheckBox)findViewById(R.id.root)).isChecked() ? "true" : "false";
 
 				SharedPreferences settings = getSharedPreferences("DrawtermPrefs", 0);
 				SharedPreferences.Editor editor = settings.edit();
-				editor.putString(user + "@" + cpu + " (auth="  + auth + ")", cpu + "\007" + auth + "\007" + user + "\007" + pass);
+				editor.putString(user + "@" + cpu + " (auth="  + auth + ")", cpu + "\007" + auth + "\007" + user + "\007" + pass + "\007" + aan + "\007" + cmd + "\007" + root);
 				editor.commit();
 			}
 		});
@@ -263,6 +271,12 @@
 
 		button = (Button) findViewById(R.id.connect);
 		button.setOnClickListener(new View.OnClickListener() {
+			private String[] appendString(String []args, String s) {
+				String ret[] = Arrays.copyOf(args, args.length + 1);
+				ret[ret.length - 1] = s;
+				return ret;
+			}
+
 			@Override
 			public void onClick(final View view) {
 				String cpu = ((EditText)findViewById(R.id.cpuServer)).getText().toString();
@@ -270,7 +284,13 @@
 				String user = ((EditText)findViewById(R.id.userName)).getText().toString();
 				String pass = ((EditText)findViewById(R.id.passWord)).getText().toString();
 
-				String args[] = {"drawterm", "-p", "-h", cpu, "-a", auth, "-u", user};
+				String args[] = {"drawterm", "-h", cpu, "-a", auth, "-u", user};
+				if (((CheckBox)findViewById(R.id.aan)).isChecked())
+					args = appendString(args, "-p");
+				if (!((CheckBox)findViewById(R.id.cmd)).isChecked())
+					args = appendString(args, "-C");
+				if (!((CheckBox)findViewById(R.id.root)).isChecked())
+					args = appendString(args, "-R");
 				runDrawterm(args, pass);
 			}
 		});
--- a/gui-android/res/layout/server_main.xml
+++ b/gui-android/res/layout/server_main.xml
@@ -39,6 +39,27 @@
             android:password="true"
             android:hint="Password"/>
 
+        <CheckBox android:id="@+id/aan"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ems="10"
+            android:checked="true"
+            android:text="AAN" />
+
+        <CheckBox android:id="@+id/root"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ems="10"
+            android:checked="true"
+            android:text="Local Files" />
+
+        <CheckBox android:id="@+id/cmd"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            android:ems="10"
+            android:checked="true"
+            android:text="Local Commands" />
+
         <Button
             android:id="@+id/save"
             android:layout_width="match_parent"