diff --git a/apk/controller/app/src/main/assets/index.html b/apk/controller/app/src/main/assets/index.html deleted file mode 100644 index 77cf2a7..0000000 --- a/apk/controller/app/src/main/assets/index.html +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - Safe Pocket Web - - - - -
- -

Internet-in-a-Box
on Android

-
- -
-
-
Loading...
-
- - - - - - \ No newline at end of file diff --git a/apk/controller/app/src/main/assets/js/app.js b/apk/controller/app/src/main/assets/js/app.js deleted file mode 100644 index a1521ab..0000000 --- a/apk/controller/app/src/main/assets/js/app.js +++ /dev/null @@ -1,43 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - - // 1. Detect device language - let userLang = (navigator.language || navigator.userLanguage).substring(0, 2).toLowerCase(); - - // Function to detect the user's language - const applyTranslations = () => { - if (!window.i18n) return; // If something went wrong, we return - - // Search for all elements with the data-i18n attribute - const elements = document.querySelectorAll("[data-i18n]"); - - elements.forEach(el => { - const key = el.getAttribute("data-i18n"); - // Si la clave existe en el diccionario, reemplaza el texto - if (window.i18n[key]) { - el.innerText = window.i18n[key]; - } - }); - }; - - // Function to load the .js file of the language - const loadScript = (langCode, isFallback = false) => { - const script = document.createElement("script"); - script.src = `lang/${langCode}.js`; - - // If the file exists, we apply the translations - script.onload = () => applyTranslations(); - - // If the file does NOT exist - script.onerror = () => { - if (!isFallback) { - console.log(`Idioma ${langCode} no encontrado. Cargando inglΓ©s...`); - loadScript("en", true); // Intentamos con el idioma por defecto - } - }; - - document.head.appendChild(script); - }; - - // 2. Start the script loading - loadScript(userLang); -}); diff --git a/apk/controller/app/src/main/assets/lang/en.js b/apk/controller/app/src/main/assets/lang/en.js deleted file mode 100644 index 3e6602e..0000000 --- a/apk/controller/app/src/main/assets/lang/en.js +++ /dev/null @@ -1,7 +0,0 @@ -window.i18n = { - "title": "Choose Content", - "maps": "πŸ—ΊοΈ Maps", - "kolibri": "πŸ“š Kolibri", - "kiwix": "πŸ“– Kiwix", - "books": "πŸ“• Books" -}; diff --git a/apk/controller/app/src/main/assets/lang/es.js b/apk/controller/app/src/main/assets/lang/es.js deleted file mode 100644 index bc7b492..0000000 --- a/apk/controller/app/src/main/assets/lang/es.js +++ /dev/null @@ -1,7 +0,0 @@ -window.i18n = { - "title": "Elige el Contenido", - "maps": "πŸ—ΊοΈ Mapas", - "kolibri": "πŸ“š Kolibri", - "kiwix": "πŸ“– Kiwix", - "books": "πŸ“• Libros" -}; diff --git a/apk/controller/app/src/main/assets/style.css b/apk/controller/app/src/main/assets/style.css deleted file mode 100644 index e69de29..0000000 diff --git a/apk/controller/app/src/main/java/org/iiab/controller/PortalActivity.java b/apk/controller/app/src/main/java/org/iiab/controller/PortalActivity.java index 5104d2c..bdd65e8 100644 --- a/apk/controller/app/src/main/java/org/iiab/controller/PortalActivity.java +++ b/apk/controller/app/src/main/java/org/iiab/controller/PortalActivity.java @@ -41,10 +41,54 @@ public class PortalActivity extends AppCompatActivity { Button btnExit = findViewById(R.id.btnExit); Button btnForward = findViewById(R.id.btnForward); + // --- PREPARE HIDDEN BAR --- + // Wait for Android to draw the screen to determine bar height + // and hide it exactly below the bottom edge. + bottomNav.post(() -> { + bottomNav.setTranslationY(bottomNav.getHeight()); // Move outside the screen + bottomNav.setVisibility(View.VISIBLE); // Remove invisibility + }); + + // --- AUTO-HIDE TIMER --- + Handler hideHandler = new Handler(Looper.getMainLooper()); + + // This is the hiding action packaged for later use + Runnable hideRunnable = () -> { + bottomNav.animate().translationY(bottomNav.getHeight()).setDuration(250); + btnHandle.setVisibility(View.VISIBLE); + btnHandle.animate().alpha(1f).setDuration(150); + }; + + // --- Restart timer --- + Runnable resetTimer = () -> { + hideHandler.removeCallbacks(hideRunnable); + hideHandler.postDelayed(hideRunnable, 5000); // Restarts new 5 sec + }; + + // --- HANDLE LOGIC (Show Bar) --- + btnHandle.setOnClickListener(v -> { + // 1. Animate entry + btnHandle.animate().alpha(0f).setDuration(150).withEndAction(() -> btnHandle.setVisibility(View.GONE)); + bottomNav.animate().translationY(0).setDuration(250); + + // 2. Starts countdown + resetTimer.run(); + }); // Button actions - btnBack.setOnClickListener(v -> { if (webView.canGoBack()) webView.goBack(); }); - btnForward.setOnClickListener(v -> { if (webView.canGoForward()) webView.goForward(); }); - btnHome.setOnClickListener(v -> webView.loadUrl("file:///android_asset/index.html")); + btnBack.setOnClickListener(v -> { + if (webView.canGoBack()) webView.goBack(); + resetTimer.run(); + }); + + btnForward.setOnClickListener(v -> { + if (webView.canGoForward()) webView.goForward(); + resetTimer.run(); + }); + + btnHome.setOnClickListener(v -> { + webView.loadUrl("http://box/"); + resetTimer.run(); + }); // Dual logic: Forced reload or Stop btnReload.setOnClickListener(v -> { @@ -56,6 +100,7 @@ public class PortalActivity extends AppCompatActivity { // 2. Force download from scratch webView.reload(); } + resetTimer.run(); }); // --- NEW: DETECT LOADING TO CHANGE BUTTON TO 'X' --- @@ -65,17 +110,12 @@ public class PortalActivity extends AppCompatActivity { String url = request.getUrl().toString(); String host = request.getUrl().getHost(); - // 1. Local main menu - if (url.startsWith("file://")) { - return false; // return false means: "WebView, handle it yourself" - } - - // 2. Internal server link (Box) + // 1. Internal server link (Box) if (host != null && (host.equals("box") || host.equals("127.0.0.1") || host.equals("localhost"))) { return false; // Remains in our app and travels through the proxy } - // 3. External link (Real Internet) + // 2. External link (Real Internet) try { // Tell Android to find the correct app to open this (Chrome, YouTube, etc.) Intent intent = new Intent(Intent.ACTION_VIEW, request.getUrl()); @@ -104,35 +144,6 @@ public class PortalActivity extends AppCompatActivity { } }); - // --- PREPARE HIDDEN BAR --- - // Wait for Android to draw the screen to determine bar height - // and hide it exactly below the bottom edge. - bottomNav.post(() -> { - bottomNav.setTranslationY(bottomNav.getHeight()); // Move outside the screen - bottomNav.setVisibility(View.VISIBLE); // Remove invisibility - }); - - // --- AUTO-HIDE TIMER --- - Handler hideHandler = new Handler(Looper.getMainLooper()); - - // This is the hiding action packaged for later use - Runnable hideRunnable = () -> { - bottomNav.animate().translationY(bottomNav.getHeight()).setDuration(250); - btnHandle.setVisibility(View.VISIBLE); - btnHandle.animate().alpha(1f).setDuration(150); - }; - - // --- HANDLE LOGIC (Show Bar) --- - btnHandle.setOnClickListener(v -> { - // 1. Animate entry - btnHandle.animate().alpha(0f).setDuration(150).withEndAction(() -> btnHandle.setVisibility(View.GONE)); - bottomNav.animate().translationY(0).setDuration(250); - - // 2. Start 5-second countdown (5000 ms) - hideHandler.removeCallbacks(hideRunnable); // Cancel if there was a previous countdown - hideHandler.postDelayed(hideRunnable, 5000); // Change 5000 to 7000 for 7 seconds - }); - // --- MANUALLY CLOSE BAR LOGIC --- btnHideNav.setOnClickListener(v -> { hideHandler.removeCallbacks(hideRunnable); // Cancel the timer so it doesn't conflict @@ -163,13 +174,13 @@ public class PortalActivity extends AppCompatActivity { ProxyController.getInstance().setProxyOverride(proxyConfig, executor, () -> { Log.d(TAG, "Proxy configured on port: " + finalProxyPort); // Load HTML only when proxy is ready - webView.loadUrl("file:///android_asset/index.html"); + webView.loadUrl("http://box/"); }); } else { // Fallback for older devices Log.w(TAG, "Proxy Override not supported"); } - webView.loadUrl("file:///android_asset/index.html"); + webView.loadUrl("http://box/"); } // 4. Cleanup (Important to not leave the proxy active)