Skip to content

Commit

Permalink
Use a generic filename for unknown filename links to download
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 13, 2024
1 parent a0acb84 commit 1c26837
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ dependencies {
// Add entry to be able to use androidx.core.content.FileProvider to use Provider for file upload of camera capture on Android >= 30
implementation 'androidx.core:core:1.10.1'

// Add swiper
// Add swiper to allow to refresh of a web page with a screen swipe bottom
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"

// To be able to use CardView so we can add shadow arround images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1956,7 +1956,14 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request
{
String query=Uri.parse(url).getQuery();
if (query != null) {
query = query.replaceAll(".*file=", "").replaceAll("&.*", "").replaceAll(".*/", "");
// Example:
// query=file=myfilename.ext&...&output=file
// query=format=ical&...&output=file
query = query.replaceAll(".*file=", "file=").replaceAll("&.*", "").replaceAll(".*/", "");
if (!query.startsWith("file=")) {
// The parameter file=myfilename.ext was not provided so we use a generic file name
query = "Unknown-filename";
}
}
Log.d(LOG_TAG, "shouldOverrideUrlLoading Start activity to download file="+query);
/*Pattern p = Pattern.compile("file=(.*)\.(pdf|odt|ods)");
Expand Down

0 comments on commit 1c26837

Please sign in to comment.