diff --git a/app/src/main/java/mx/joykoo/scanner/MainActivity.kt b/app/src/main/java/mx/joykoo/scanner/MainActivity.kt index 8d1ddb1..0ab4c81 100644 --- a/app/src/main/java/mx/joykoo/scanner/MainActivity.kt +++ b/app/src/main/java/mx/joykoo/scanner/MainActivity.kt @@ -9,16 +9,20 @@ import android.net.NetworkCapabilities import android.net.Uri import android.os.Build import android.os.Bundle +import android.util.Log import android.view.MotionEvent import android.view.View import android.view.WindowInsets import android.view.WindowInsetsController import android.view.WindowManager +import android.webkit.ConsoleMessage import android.webkit.CookieManager +import android.webkit.SslErrorHandler import android.webkit.ValueCallback import android.webkit.WebChromeClient import android.webkit.WebResourceError import android.webkit.WebResourceRequest +import android.webkit.WebResourceResponse import android.webkit.WebSettings import android.webkit.WebView import android.webkit.WebViewClient @@ -98,9 +102,7 @@ class MainActivity : AppCompatActivity() { domStorageEnabled = true databaseEnabled = true - // Allow mixed content only if absolutely necessary for the target site. - // Default to the safest option. - mixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW + mixedContentMode = WebSettings.MIXED_CONTENT_COMPATIBILITY_MODE // Cache and storage for session persistence cacheMode = WebSettings.LOAD_DEFAULT @@ -129,6 +131,8 @@ class MainActivity : AppCompatActivity() { setAcceptThirdPartyCookies(webView, true) } + WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG) + webView.webViewClient = ScannerWebViewClient() webView.webChromeClient = ScannerWebChromeClient() } @@ -315,21 +319,44 @@ class MainActivity : AppCompatActivity() { request: WebResourceRequest, error: WebResourceError ) { - // Only show error overlay for main-frame navigation failures if (request.isForMainFrame) { + Log.e(TAG, "WebView error: ${error.description} (${error.errorCode})") showError() } } - // Do NOT override onReceivedSslError to proceed — let TLS - // errors fail as they should for security. + override fun onReceivedHttpError( + view: WebView, + request: WebResourceRequest, + errorResponse: WebResourceResponse + ) { + if (request.isForMainFrame) { + Log.e(TAG, "HTTP error ${errorResponse.statusCode} for ${request.url}") + showError() + } + } + + override fun onReceivedSslError( + view: WebView, + handler: SslErrorHandler, + error: android.net.http.SslError + ) { + Log.e(TAG, "SSL error: ${error.primaryError} for ${error.url}") + handler.cancel() + showError() + } } // ── WebChromeClient ───────────────────────────────────────────────── private inner class ScannerWebChromeClient : WebChromeClient() { - // File upload support: in the webpage + override fun onConsoleMessage(consoleMessage: ConsoleMessage): Boolean { + Log.d(TAG, "JS [${consoleMessage.messageLevel()}] ${consoleMessage.message()} " + + "(${consoleMessage.sourceId()}:${consoleMessage.lineNumber()})") + return true + } + override fun onShowFileChooser( webView: WebView, filePathCallback: ValueCallback>, @@ -366,6 +393,7 @@ class MainActivity : AppCompatActivity() { } companion object { + private const val TAG = "JoykooScanner" private const val FILE_CHOOSER_REQUEST = 1001 } } diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml index bf081ba..b5cd46e 100644 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -5,6 +5,6 @@ android:viewportWidth="108" android:viewportHeight="108"> diff --git a/app/src/main/res/drawable/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml deleted file mode 100644 index 7d3fa1a..0000000 --- a/app/src/main/res/drawable/ic_launcher_foreground.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/drawable/ic_launcher_legacy.xml b/app/src/main/res/drawable/ic_launcher_legacy.xml deleted file mode 100644 index 8d0a890..0000000 --- a/app/src/main/res/drawable/ic_launcher_legacy.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index 6b78462..3ba4e35 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - + diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png index 83b38d0..013d27e 100644 Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6a831a6 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png index 923259d..751a9b0 100644 Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..4467184 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png index fea21c4..c7c73a0 100644 Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..f8668bc Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index fc7ac09..66c13a2 100644 Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..6875752 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index a137e73..b59cf31 100644 Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png new file mode 100644 index 0000000..fa20e06 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png differ