From cf5e7e6d3e75fca1187d18f96a321e7f532f1834 Mon Sep 17 00:00:00 2001 From: Sergio De la torre Date: Tue, 21 Feb 2023 15:51:59 +0100 Subject: [PATCH] =?UTF-8?q?HotFix=20https://cau.verdnatura.es/scp/tickets.?= =?UTF-8?q?php=3Fid=3D75703=20.=20No=20se=20pod=C3=ADan=20descargar=20las?= =?UTF-8?q?=20facturas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/vcs.xml | 1 - app/build.gradle | 6 ++--- app/release/output-metadata.json | 4 ++-- .../verdnaturaventas/MainActivity.kt | 24 +++++++++++++------ 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 288b36b..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,7 +1,6 @@ - \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 1a49a10..911291c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -11,9 +11,9 @@ android { applicationId "com.verdnatura.verdnaturaventas" minSdkVersion 16 targetSdkVersion 33 - versionCode 106 - versionName "3.0.3" - //versionName "3.0.2" versionCode 105 + versionCode 108 + versionName "3.0.4" + //versionName "3.0.4" versionCode 107 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 8768e13..8137033 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -11,8 +11,8 @@ "type": "SINGLE", "filters": [], "attributes": [], - "versionCode": 106, - "versionName": "3.0.3", + "versionCode": 108, + "versionName": "3.0.4", "outputFile": "app-release.apk" } ], diff --git a/app/src/main/java/com/verdnatura/verdnaturaventas/MainActivity.kt b/app/src/main/java/com/verdnatura/verdnaturaventas/MainActivity.kt index 27fe3c4..4e70cc7 100644 --- a/app/src/main/java/com/verdnatura/verdnaturaventas/MainActivity.kt +++ b/app/src/main/java/com/verdnatura/verdnaturaventas/MainActivity.kt @@ -1,18 +1,17 @@ package com.verdnatura.verdnaturaventas +import android.app.DownloadManager +import android.net.Uri import android.os.Build import android.os.Bundle +import android.os.Environment import android.view.View -import android.webkit.WebChromeClient -import android.webkit.WebResourceRequest -import android.webkit.WebView -import android.webkit.WebViewClient +import android.webkit.* import android.widget.LinearLayout import android.window.OnBackInvokedDispatcher import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity - class MainActivity : AppCompatActivity() { private lateinit var webView: WebView @@ -46,7 +45,6 @@ class MainActivity : AppCompatActivity() { loading = findViewById(R.id.loading) } - private fun setWebview() { webView = findViewById(R.id.webView) val webSettings = webView.settings @@ -75,6 +73,19 @@ class MainActivity : AppCompatActivity() { loading.visibility = View.GONE } } + webView.setDownloadListener { url, _, contentDisposition, mimetype, _ -> + val request = DownloadManager.Request( + Uri.parse(url) + ) + request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED) + request.setDestinationInExternalPublicDir( + Environment.DIRECTORY_DOWNLOADS, + URLUtil.guessFileName(url, contentDisposition, mimetype) + ) + val dm = getSystemService(DOWNLOAD_SERVICE) as DownloadManager + dm.enqueue(request) + } + } fun loadHome() { @@ -90,7 +101,6 @@ class MainActivity : AppCompatActivity() { } } - @Suppress("UNUSED_PARAMETER") fun backPressed(view: View) { webView.goBack()