[controller] rediseño de botones y lógica en visualización

This commit is contained in:
Luis Guzmán 2026-03-31 18:45:18 -06:00
parent 875df57422
commit c86c17c0be
4 changed files with 777 additions and 723 deletions

View File

@ -85,8 +85,12 @@ public class PortalActivity extends AppCompatActivity {
resetTimer.run(); resetTimer.run();
}); });
Preferences prefs = new Preferences(this);
boolean isVpnActive = prefs.getEnable();
String targetUrl = isVpnActive ? "http://box/" : "http://localhost:8085/home";
btnHome.setOnClickListener(v -> { btnHome.setOnClickListener(v -> {
webView.loadUrl("http://box/"); webView.loadUrl(targetUrl);
resetTimer.run(); resetTimer.run();
}); });
@ -156,31 +160,35 @@ public class PortalActivity extends AppCompatActivity {
webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setDomStorageEnabled(true);
// 2. Port and Mirror logic // 2. Port and Mirror logic
Preferences prefs = new Preferences(this);
int tempPort = prefs.getSocksPort(); int tempPort = prefs.getSocksPort();
if (tempPort <= 0) tempPort = 1080; if (tempPort <= 0) tempPort = 1080;
// Variable safe to read in lambda // Variable safe to read in lambda
final int finalProxyPort = tempPort; final int finalProxyPort = tempPort;
// 3. Proxy block // 3. Proxy block (ONLY IF VPN IS ACTIVE)
if (WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) { if (isVpnActive) {
ProxyConfig proxyConfig = new ProxyConfig.Builder() if (WebViewFeature.isFeatureSupported(WebViewFeature.PROXY_OVERRIDE)) {
.addProxyRule("socks5://127.0.0.1:" + finalProxyPort) ProxyConfig proxyConfig = new ProxyConfig.Builder()
.build(); .addProxyRule("socks5://127.0.0.1:" + finalProxyPort)
.build();
Executor executor = ContextCompat.getMainExecutor(this); Executor executor = ContextCompat.getMainExecutor(this);
ProxyController.getInstance().setProxyOverride(proxyConfig, executor, () -> { ProxyController.getInstance().setProxyOverride(proxyConfig, executor, () -> {
Log.d(TAG, "Proxy configured on port: " + finalProxyPort); Log.d(TAG, "Proxy configured on port: " + finalProxyPort);
// Load HTML only when proxy is ready // Load HTML only when proxy is ready
webView.loadUrl("http://box/"); webView.loadUrl(targetUrl);
}); });
} else {
// Fallback for older devices
Log.w(TAG, "Proxy Override not supported");
webView.loadUrl(targetUrl);
}
} else { } else {
// Fallback for older devices // VPN is OFF. Do NOT use proxy. Just load localhost directly.
Log.w(TAG, "Proxy Override not supported"); webView.loadUrl(targetUrl);
} }
webView.loadUrl("http://box/");
} }
// 4. Cleanup (Important to not leave the proxy active) // 4. Cleanup (Important to not leave the proxy active)

View File

@ -57,7 +57,7 @@
android:padding="16dp"> android:padding="16dp">
<!-- HR below Watchdog --> <!-- HR below Watchdog -->
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#444444" android:layout_marginBottom="20dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider_color" android:layout_marginBottom="20dp"/>
<!-- VPN Control Section --> <!-- VPN Control Section -->
<Button <Button
@ -69,7 +69,7 @@
android:textStyle="bold" android:textStyle="bold"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:background="@drawable/rounded_button" android:background="@drawable/rounded_button"
android:backgroundTint="#2E7D32" android:backgroundTint="@color/btn_vpn_off"
android:textAllCaps="false"/> android:textAllCaps="false"/>
<TextView <TextView
@ -94,7 +94,7 @@
android:textStyle="bold" android:textStyle="bold"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:background="@drawable/rounded_button" android:background="@drawable/rounded_button"
android:backgroundTint="#F57C00" android:backgroundTint="@color/btn_explore_disabled"
android:textAllCaps="false" android:textAllCaps="false"
android:elevation="4dp" android:elevation="4dp"
android:visibility="gone" /> android:visibility="gone" />
@ -235,7 +235,7 @@
</LinearLayout> </LinearLayout>
<!-- HR above Watchdog --> <!-- HR above Watchdog -->
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#444444" android:layout_marginBottom="16dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider_color" android:layout_marginBottom="16dp"/>
<!-- Watchdog Control Section --> <!-- Watchdog Control Section -->
<Button <Button
@ -247,7 +247,7 @@
android:textStyle="bold" android:textStyle="bold"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:background="@drawable/rounded_button" android:background="@drawable/rounded_button"
android:backgroundTint="#1976D2" android:backgroundTint="@color/btn_watchdog_off"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
android:textAllCaps="false"/> android:textAllCaps="false"/>
@ -260,7 +260,7 @@
android:textColor="?android:attr/textColorSecondary" android:textColor="?android:attr/textColorSecondary"
android:layout_marginBottom="16dp"/> android:layout_marginBottom="16dp"/>
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#444444" android:layout_marginVertical="20dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider_color" android:layout_marginVertical="20dp"/>
<!-- Log Section (Collapsible) --> <!-- Log Section (Collapsible) -->
<TextView <TextView
@ -280,7 +280,7 @@
android:id="@+id/log_warning_text" android:id="@+id/log_warning_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textColor="#FF9800" android:textColor="@color/text_warning"
android:textSize="11sp" android:textSize="11sp"
android:textStyle="italic" android:textStyle="italic"
android:padding="4dp" android:padding="4dp"
@ -340,7 +340,7 @@
android:layout_weight="1" android:layout_weight="1"
android:text="@string/reset_log" android:text="@string/reset_log"
android:textSize="12sp" android:textSize="12sp"
android:backgroundTint="#D32F2F" android:backgroundTint="@color/btn_danger"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textAllCaps="false" android:textAllCaps="false"
android:layout_marginEnd="4dp"/> android:layout_marginEnd="4dp"/>
@ -352,21 +352,21 @@
android:layout_weight="1" android:layout_weight="1"
android:text="@string/copy_all" android:text="@string/copy_all"
android:textSize="12sp" android:textSize="12sp"
android:backgroundTint="#388E3C" android:backgroundTint="@color/btn_success"
android:textColor="#FFFFFF" android:textColor="#FFFFFF"
android:textAllCaps="false" android:textAllCaps="false"
android:layout_marginStart="4dp"/> android:layout_marginStart="4dp"/>
</LinearLayout> </LinearLayout>
<!-- Version Footer --> <!-- Version Footer -->
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="#444444" android:layout_marginTop="32dp" android:layout_marginBottom="8dp"/> <View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/divider_color" android:layout_marginTop="32dp" android:layout_marginBottom="8dp"/>
<TextView <TextView
android:id="@+id/version_text" android:id="@+id/version_text"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:gravity="center"
android:text="v0.1.17alpha" android:text="v0.1.17alpha"
android:textColor="#888888" android:textColor="@color/text_muted"
android:textSize="10sp" android:textSize="10sp"
android:paddingBottom="16dp"/> android:paddingBottom="16dp"/>

View File

@ -13,9 +13,19 @@
<color name="btn_watchdog_off">#1976D2</color> <!-- Material Blue --> <color name="btn_watchdog_off">#1976D2</color> <!-- Material Blue -->
<color name="btn_vpn_on">#C62828</color> <!-- Dark Red --> <color name="btn_vpn_on">#C62828</color> <!-- Dark Red -->
<color name="btn_vpn_off">#2E7D32</color> <!-- Material Green --> <color name="btn_vpn_off">#2E7D32</color> <!-- Material Green -->
<color name="btn_explore_ready">#F57C00</color>
<color name="btn_explore_disabled">#9E9E9E</color>
<color name="btn_vpn_on_dim">#EF9A9A</color>
<color name="btn_vpn_off_dim">#A5D6A7</color>
<!-- Secciones --> <!-- Secciones -->
<color name="section_header_bg">#333333</color> <color name="section_header_bg">#333333</color>
<color name="section_body_bg_light">#F5F5F5</color> <color name="section_body_bg_light">#F5F5F5</color>
<color name="section_body_bg_dark">#1A1A1A</color> <color name="section_body_bg_dark">#1A1A1A</color>
<color name="text_warning">#FF9800</color>
<color name="text_muted">#888888</color>
<color name="divider_color">#444444</color>
<color name="btn_danger">#D32F2F</color>
<color name="btn_success">#388E3C</color>
</resources> </resources>