feat: settings hosts watch link / Hermes / FRP tunnel / Harness web / API key; allow cleartext http for WebView
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<application
|
<application
|
||||||
|
android:usesCleartextTraffic="true"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:theme="@style/Theme.DSHWatch">
|
android:theme="@style/Theme.DSHWatch">
|
||||||
|
|||||||
@@ -15,6 +15,10 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
private EditText userId;
|
private EditText userId;
|
||||||
private EditText token;
|
private EditText token;
|
||||||
private EditText web;
|
private EditText web;
|
||||||
|
private EditText frp;
|
||||||
|
private EditText hermesUrl;
|
||||||
|
private EditText hermesKey;
|
||||||
|
private EditText apiKey;
|
||||||
private TextView watchStatus;
|
private TextView watchStatus;
|
||||||
private TextView hermesStatus;
|
private TextView hermesStatus;
|
||||||
private WatchBridge watchBridge;
|
private WatchBridge watchBridge;
|
||||||
@@ -28,6 +32,10 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
userId = findViewById(R.id.input_user);
|
userId = findViewById(R.id.input_user);
|
||||||
token = findViewById(R.id.input_token);
|
token = findViewById(R.id.input_token);
|
||||||
web = findViewById(R.id.input_web);
|
web = findViewById(R.id.input_web);
|
||||||
|
frp = findViewById(R.id.input_frp);
|
||||||
|
hermesUrl = findViewById(R.id.input_hermes_url);
|
||||||
|
hermesKey = findViewById(R.id.input_hermes_key);
|
||||||
|
apiKey = findViewById(R.id.input_apikey);
|
||||||
watchStatus = findViewById(R.id.watch_status);
|
watchStatus = findViewById(R.id.watch_status);
|
||||||
hermesStatus = findViewById(R.id.hermes_status);
|
hermesStatus = findViewById(R.id.hermes_status);
|
||||||
|
|
||||||
@@ -35,6 +43,10 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
userId.setText(SettingsStore.userId(this));
|
userId.setText(SettingsStore.userId(this));
|
||||||
token.setText(SettingsStore.token(this));
|
token.setText(SettingsStore.token(this));
|
||||||
web.setText(SettingsStore.webUrl(this));
|
web.setText(SettingsStore.webUrl(this));
|
||||||
|
frp.setText(SettingsStore.frpAddress(this));
|
||||||
|
hermesUrl.setText(SettingsStore.hermesUrl(this));
|
||||||
|
hermesKey.setText(SettingsStore.hermesKey(this));
|
||||||
|
apiKey.setText(SettingsStore.apiKey(this));
|
||||||
|
|
||||||
Button save = findViewById(R.id.btn_save);
|
Button save = findViewById(R.id.btn_save);
|
||||||
save.setOnClickListener(new View.OnClickListener() {
|
save.setOnClickListener(new View.OnClickListener() {
|
||||||
@@ -46,6 +58,9 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
userId.getText().toString().trim(),
|
userId.getText().toString().trim(),
|
||||||
token.getText().toString().trim());
|
token.getText().toString().trim());
|
||||||
SettingsStore.saveWebUrl(SettingsActivity.this, web.getText().toString().trim());
|
SettingsStore.saveWebUrl(SettingsActivity.this, web.getText().toString().trim());
|
||||||
|
SettingsStore.saveFrp(SettingsActivity.this, frp.getText().toString().trim());
|
||||||
|
SettingsStore.saveHermes(SettingsActivity.this, hermesUrl.getText().toString().trim(), hermesKey.getText().toString().trim());
|
||||||
|
SettingsStore.saveApiKey(SettingsActivity.this, apiKey.getText().toString().trim());
|
||||||
Toast.makeText(SettingsActivity.this, "已保存", Toast.LENGTH_SHORT).show();
|
Toast.makeText(SettingsActivity.this, "已保存", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ public class SettingsStore {
|
|||||||
private static final String KEY_USER = "userId";
|
private static final String KEY_USER = "userId";
|
||||||
private static final String KEY_TOKEN = "token";
|
private static final String KEY_TOKEN = "token";
|
||||||
private static final String KEY_WEB = "webUrl";
|
private static final String KEY_WEB = "webUrl";
|
||||||
|
private static final String KEY_FRP = "frpAddress";
|
||||||
|
private static final String KEY_HERMES_URL = "hermesUrl";
|
||||||
|
private static final String KEY_HERMES_KEY = "hermesKey";
|
||||||
|
private static final String KEY_APIKEY = "apiKey";
|
||||||
|
|
||||||
public static void save(Context c, String serverUrl, String userId, String token) {
|
public static void save(Context c, String serverUrl, String userId, String token) {
|
||||||
SharedPreferences p = c.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
|
SharedPreferences p = c.getSharedPreferences(PREFS, Context.MODE_PRIVATE);
|
||||||
@@ -38,4 +42,28 @@ public class SettingsStore {
|
|||||||
public static void saveWebUrl(Context c, String url) {
|
public static void saveWebUrl(Context c, String url) {
|
||||||
c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY_WEB, url == null ? "" : url).apply();
|
c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY_WEB, url == null ? "" : url).apply();
|
||||||
}
|
}
|
||||||
|
public static String frpAddress(Context c) {
|
||||||
|
return c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY_FRP, "");
|
||||||
|
}
|
||||||
|
public static void saveFrp(Context c, String v) {
|
||||||
|
c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY_FRP, v == null ? "" : v).apply();
|
||||||
|
}
|
||||||
|
public static String hermesUrl(Context c) {
|
||||||
|
return c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY_HERMES_URL, "");
|
||||||
|
}
|
||||||
|
public static String hermesKey(Context c) {
|
||||||
|
return c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY_HERMES_KEY, "");
|
||||||
|
}
|
||||||
|
public static void saveHermes(Context c, String url, String key) {
|
||||||
|
c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit()
|
||||||
|
.putString(KEY_HERMES_URL, url == null ? "" : url)
|
||||||
|
.putString(KEY_HERMES_KEY, key == null ? "" : key)
|
||||||
|
.apply();
|
||||||
|
}
|
||||||
|
public static String apiKey(Context c) {
|
||||||
|
return c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).getString(KEY_APIKEY, "");
|
||||||
|
}
|
||||||
|
public static void saveApiKey(Context c, String v) {
|
||||||
|
c.getSharedPreferences(PREFS, Context.MODE_PRIVATE).edit().putString(KEY_APIKEY, v == null ? "" : v).apply();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,6 +76,68 @@
|
|||||||
android:textColor="@color/white"
|
android:textColor="@color/white"
|
||||||
android:textColorHint="@color/light_blue" />
|
android:textColorHint="@color/light_blue" />
|
||||||
|
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="内网穿透/FRP 地址(可选,如 ws://frp-host:18321)"
|
||||||
|
android:textColor="@color/light_blue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/input_frp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="ws://frp-host:18321"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="@color/light_blue" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Hermès 地址"
|
||||||
|
android:textColor="@color/light_blue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/input_hermes_url"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="https://hermes-host:port"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="@color/light_blue" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="Hermès Key"
|
||||||
|
android:textColor="@color/light_blue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/input_hermes_key"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="hermes key"
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="@color/light_blue" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="DeepSeek API Key(K)"
|
||||||
|
android:textColor="@color/light_blue" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/input_apikey"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="sk-..."
|
||||||
|
android:inputType="textPassword"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textColorHint="@color/light_blue" />
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user