Browse Source

Optimisations diverses

master
Samuel Vermeulen 4 weeks ago
parent
commit
96b1cb52ab
  1. 34
      app/src/main/java/fr/svpro/radiomercure/MainActivity.java
  2. 4
      build.gradle

34
app/src/main/java/fr/svpro/radiomercure/MainActivity.java

@ -1,6 +1,7 @@
package fr.svpro.radiomercure;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.DownloadManager;
import android.content.Intent;
@ -39,6 +40,7 @@ public class MainActivity extends AppCompatActivity {
versionName = BuildConfig.VERSION_NAME;
}
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@ -65,24 +67,20 @@ public class MainActivity extends AppCompatActivity {
web.getSettings().setAllowFileAccessFromFileURLs(true);
}
web.setDownloadListener(new DownloadListener() {
@Override
public void onDownloadStart(String url, String userAgent, String contentDisposition,
String mimeType, long contentLength) {
MainActivity.this.url = url;
MainActivity.this.userAgent = userAgent;
MainActivity.this.contentDisposition = contentDisposition;
MainActivity.this.mimeType = mimeType;
String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
if (ActivityCompat.checkSelfPermission(MainActivity.this, permission)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
WRITE_EXTERNAL_STORAGE_RC);
} else {
TelechargemntPodcast();
}
web.setDownloadListener((url, userAgent, contentDisposition, mimeType, contentLength) -> {
MainActivity.this.url = url;
MainActivity.this.userAgent = userAgent;
MainActivity.this.contentDisposition = contentDisposition;
MainActivity.this.mimeType = mimeType;
String permission = Manifest.permission.WRITE_EXTERNAL_STORAGE;
if (ActivityCompat.checkSelfPermission(MainActivity.this, permission)
!= PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(MainActivity.this,
new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE},
WRITE_EXTERNAL_STORAGE_RC);
} else {
TelechargemntPodcast();
}
});

4
build.gradle

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
}
task clean(type: Delete) {

Loading…
Cancel
Save