11/*
22 * ============================================================================
33 * Name : DashboardManager.java
4- * Author : IIAB Project
5- * Copyright : Copyright (c) 2026 IIAB Project
6- * Description : Initial dasboard status helper
4+ * Author : AppDevForAll
5+ * Copyright : Copyright (c) 2026 AppDevForAll
6+ * Description : Home dashboard status helper: binds the Wi-Fi and Hotspot tiles
7+ * and reflects their OS connectivity state on the LEDs. The legacy
8+ * "tunnel"/ESPW toggle was removed with the dead SOCKS-proxy
9+ * mechanism (ADFA-4553); content is served from the native local
10+ * server, so there is no tunnel state to display.
711 * ============================================================================
812 */
913package org .iiab .controller ;
1014
1115import android .app .Activity ;
1216import android .content .Intent ;
1317import android .provider .Settings ;
14- import android .transition .AutoTransition ;
15- import android .transition .TransitionManager ;
1618import android .view .View ;
17- import android .view .ViewGroup ;
18- import android .widget .LinearLayout ;
1919
2020public class DashboardManager {
2121
2222 private final Activity activity ;
23- private final LinearLayout dashboardContainer ;
2423
25- private final View dashWifi , dashHotspot , dashTunnel ;
26- private final View ledWifi , ledHotspot , ledTunnel ;
27- private final View standaloneEspwButton ;
28- private final View standaloneEspwDescription ;
24+ private final View dashWifi , dashHotspot ;
25+ private final View ledWifi , ledHotspot ;
2926
30- // Memory variables to avoid freezing the screen
31- private boolean lastTunnelState = false ;
32- private boolean lastDegradedState = false ;
33- private boolean isFirstRun = true ;
34-
35- public interface DashboardActionCallback {
36- void onToggleEspwRequested ();
37- }
38-
39- public DashboardManager (Activity activity , View rootView , DashboardActionCallback callback ) {
27+ public DashboardManager (Activity activity , View rootView ) {
4028 this .activity = activity ;
4129
42- // Bind all the views
43- dashboardContainer = (LinearLayout ) rootView .findViewById (R .id .dashboard_container );
4430 dashWifi = rootView .findViewById (R .id .dash_wifi );
4531 dashHotspot = rootView .findViewById (R .id .dash_hotspot );
46- dashTunnel = rootView .findViewById (R .id .dash_tunnel );
47-
4832 ledWifi = rootView .findViewById (R .id .led_wifi );
4933 ledHotspot = rootView .findViewById (R .id .led_hotspot );
50- ledTunnel = rootView .findViewById (R .id .led_tunnel );
51-
52- standaloneEspwButton = rootView .findViewById (R .id .control );
53- standaloneEspwDescription = rootView .findViewById (R .id .control_description );
5434
55- setupListeners (callback );
35+ setupListeners ();
5636 }
5737
58- private void setupListeners (DashboardActionCallback callback ) {
38+ private void setupListeners () {
5939 // Single tap opens Settings directly
6040 dashWifi .setOnClickListener (v -> activity .startActivity (new Intent (Settings .ACTION_WIFI_SETTINGS )));
6141
@@ -68,54 +48,11 @@ private void setupListeners(DashboardActionCallback callback) {
6848 activity .startActivity (new Intent (Settings .ACTION_WIRELESS_SETTINGS ));
6949 }
7050 });
71-
72- // The Tunnel/ESPW toggle logic
73- View .OnClickListener toggleEspw = v -> callback .onToggleEspwRequested ();
74- standaloneEspwButton .setOnClickListener (toggleEspw );
75- dashTunnel .setOnClickListener (toggleEspw );
7651 }
7752
7853 // Updates the LED graphics based on actual OS connectivity states
7954 public void updateConnectivityLeds (boolean isWifiOn , boolean isHotspotOn ) {
8055 ledWifi .setBackgroundResource (isWifiOn ? R .drawable .led_on_green : R .drawable .led_off );
8156 ledHotspot .setBackgroundResource (isHotspotOn ? R .drawable .led_on_green : R .drawable .led_off );
8257 }
83-
84- // The Magic Morphing Animation!
85- public void setTunnelState (boolean isTunnelActive , boolean isDegraded ) {
86- // ANTI-FREEZE SHIELD!
87- // If the state is exactly the same as 3 seconds ago, abort to avoid blocking the UI
88- if (!isFirstRun && lastTunnelState == isTunnelActive && lastDegradedState == isDegraded ) {
89- return ;
90- }
91- isFirstRun = false ;
92- lastTunnelState = isTunnelActive ;
93- lastDegradedState = isDegraded ;
94-
95- // Tells Android to smoothly animate any layout changes we make next
96- TransitionManager .beginDelayedTransition ((ViewGroup ) dashboardContainer .getParent (), new AutoTransition ().setDuration (300 ));
97-
98- if (isTunnelActive ) {
99- // Morph into 33% / 33% / 33% Dashboard mode
100- standaloneEspwButton .setVisibility (View .GONE );
101- standaloneEspwDescription .setVisibility (View .GONE );
102- dashTunnel .setVisibility (View .VISIBLE );
103- ledTunnel .setBackgroundResource (isDegraded ? R .drawable .led_on_orange : R .drawable .led_on_green );
104-
105- // Force recalculate
106- dashboardContainer .setWeightSum (3f );
107- } else {
108- // Morph back into 50% / 50% mode
109- dashTunnel .setVisibility (View .GONE );
110- // TODO: [RESTORE] Uncomment to show ESPW button again
111- // standaloneEspwButton.setVisibility(View.VISIBLE);
112- // standaloneEspwDescription.setVisibility(View.VISIBLE);
113- // The LED turns off implicitly since the whole dash_tunnel hides, but we can enforce it:
114- ledTunnel .setBackgroundResource (R .drawable .led_off );
115- // Force recalculate
116- dashboardContainer .setWeightSum (2f );
117- }
118- // Force recalculate
119- dashboardContainer .requestLayout ();
120- }
12158}
0 commit comments