[controller] replace icon and add snackbar on disabled buttons

This commit is contained in:
Luis Guzmán 2026-04-04 12:45:21 -06:00
parent a041c433f9
commit b7d8cbda2a
5 changed files with 20 additions and 8 deletions

View File

@ -314,7 +314,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
addToLog("Warning: Server state transition timed out.");
}
};
timeoutHandler.postDelayed(timeoutRunnable, 45000);
timeoutHandler.postDelayed(timeoutRunnable, getResources().getInteger(R.integer.server_cool_off_duration_ms));
// Execute the corresponding script command
if (!isServerAlive) {
@ -331,6 +331,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Logic to open the WebView (PortalActivity)
button_browse_content.setOnClickListener(v -> {
if (!isServerAlive) {
Snackbar.make(v, R.string.qr_error_no_server, Snackbar.LENGTH_LONG).show();
return;
}
if (currentTargetUrl != null) {
Intent intent = new Intent(MainActivity.this, PortalActivity.class);
intent.putExtra("TARGET_URL", currentTargetUrl);
@ -725,6 +729,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
private void handleControlClick() {
if (!isServerAlive) {
Snackbar.make(findViewById(android.R.id.content), R.string.qr_error_no_server, Snackbar.LENGTH_LONG).show();
return;
}
if (prefs.getEnable()) {
BiometricHelper.prompt(this,
getString(R.string.auth_required_title),
@ -864,7 +872,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
// Draw main VPN button (ESPW)
if (!isServerAlive) {
// Lock and dim the VPN button if there is no server to connect to
button_control.setEnabled(false);
if (isVpnActive) {
button_control.setText(R.string.control_disable);
button_control.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.btn_vpn_on_dim));
@ -891,7 +898,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
if (!isServerAlive) {
// State 1: Stopped (Greyed out)
stopExplorePulse();
button_browse_content.setEnabled(false);
button_browse_content.setEnabled(true);
button_browse_content.setBackgroundTintList(ContextCompat.getColorStateList(this, R.color.btn_explore_disabled));
button_browse_content.setAlpha(1.0f);
button_browse_content.setTextColor(Color.parseColor("#888888"));
@ -1016,8 +1023,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
Intent intent = new Intent();
intent.setClassName("com.termux", "com.termux.app.RunCommandService");
intent.setAction("com.termux.RUN_COMMAND");
intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/usr/bin/iiab-termux");
intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{actionFlag});
intent.putExtra("com.termux.RUN_COMMAND_WORKDIR", "/data/data/com.termux/files/home");
intent.putExtra("com.termux.RUN_COMMAND_PATH", "/data/data/com.termux/files/usr/bin/env");
intent.putExtra("com.termux.RUN_COMMAND_ARGUMENTS", new String[]{
@ -1027,6 +1033,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
actionFlag
});
intent.putExtra("com.termux.RUN_COMMAND_BACKGROUND", false);
try {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent);

View File

@ -121,7 +121,7 @@ public class QrActivity extends AppCompatActivity {
String title = showingWifi ? getString(R.string.qr_title_wifi) : getString(R.string.qr_title_hotspot);
// 8085 is the default port for the IIAB interface
String url = "http://" + currentIp + ":8085";
String url = "http://" + currentIp + ":8085/home";
titleText.setText(title);
ipText.setText(url);

View File

@ -0,0 +1,5 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
<path android:fillColor="@android:color/white" android:pathData="M12,8c-2.21,0 -4,1.79 -4,4s1.79,4 4,4 4,-1.79 4,-4 -1.79,-4 -4,-4zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2v4h2L5,5zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4z"/>
</vector>

View File

@ -38,7 +38,7 @@
android:layout_toStartOf="@id/btn_settings"
android:layout_centerVertical="true"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:src="@android:drawable/ic_menu_share"
android:src="@drawable/ic_center_focus_strong"
android:contentDescription="Share via QR"
android:padding="12dp"
android:scaleType="fitCenter"

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer name="server_cool_off_duration_ms">15000</integer>
<integer name="server_cool_off_duration_ms">60000</integer>
</resources>