HotFix https://cau.verdnatura.es/scp/tickets.php?id=75703 . No se podían descargar las facturas

This commit is contained in:
Sergio De la torre 2023-02-21 15:51:59 +01:00
parent 4d81ad2105
commit cf5e7e6d3e
4 changed files with 22 additions and 13 deletions

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="VcsDirectoryMappings"> <component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
<mapping directory="$PROJECT_DIR$" vcs="Git" /> <mapping directory="$PROJECT_DIR$" vcs="Git" />
</component> </component>
</project> </project>

View File

@ -11,9 +11,9 @@ android {
applicationId "com.verdnatura.verdnaturaventas" applicationId "com.verdnatura.verdnaturaventas"
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 33 targetSdkVersion 33
versionCode 106 versionCode 108
versionName "3.0.3" versionName "3.0.4"
//versionName "3.0.2" versionCode 105 //versionName "3.0.4" versionCode 107
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -11,8 +11,8 @@
"type": "SINGLE", "type": "SINGLE",
"filters": [], "filters": [],
"attributes": [], "attributes": [],
"versionCode": 106, "versionCode": 108,
"versionName": "3.0.3", "versionName": "3.0.4",
"outputFile": "app-release.apk" "outputFile": "app-release.apk"
} }
], ],

View File

@ -1,18 +1,17 @@
package com.verdnatura.verdnaturaventas package com.verdnatura.verdnaturaventas
import android.app.DownloadManager
import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Environment
import android.view.View import android.view.View
import android.webkit.WebChromeClient import android.webkit.*
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import android.widget.LinearLayout import android.widget.LinearLayout
import android.window.OnBackInvokedDispatcher import android.window.OnBackInvokedDispatcher
import androidx.activity.OnBackPressedCallback import androidx.activity.OnBackPressedCallback
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
class MainActivity : AppCompatActivity() { class MainActivity : AppCompatActivity() {
private lateinit var webView: WebView private lateinit var webView: WebView
@ -46,7 +45,6 @@ class MainActivity : AppCompatActivity() {
loading = findViewById(R.id.loading) loading = findViewById(R.id.loading)
} }
private fun setWebview() { private fun setWebview() {
webView = findViewById(R.id.webView) webView = findViewById(R.id.webView)
val webSettings = webView.settings val webSettings = webView.settings
@ -75,6 +73,19 @@ class MainActivity : AppCompatActivity() {
loading.visibility = View.GONE 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() { fun loadHome() {
@ -90,7 +101,6 @@ class MainActivity : AppCompatActivity() {
} }
} }
@Suppress("UNUSED_PARAMETER") @Suppress("UNUSED_PARAMETER")
fun backPressed(view: View) { fun backPressed(view: View) {
webView.goBack() webView.goBack()