Skip to content

Commit

Permalink
Merge pull request #50 from AbdurazaaqMohammed/main
Browse files Browse the repository at this point in the history
Only check and request permission when downloading file
  • Loading branch information
prateek-chaubey authored Jul 13, 2024
2 parents 26d11da + cf99f32 commit 97813f6
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ protected void onCreate(Bundle savedInstanceState) {
}
public void load(boolean dl) {
dL=dl;
if (Build.VERSION.SDK_INT > 22 && Build.VERSION.SDK_INT < 28 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
Toast.makeText(getApplicationContext(), getString(R.string.grant_storage), Toast.LENGTH_SHORT).show();
requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
}


web = findViewById(R.id.web);
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setSupportZoom(true);
Expand Down Expand Up @@ -198,6 +194,11 @@ public void onPermissionRequest(final PermissionRequest request) {
}

private void downloadFile(String filename, String url, String mtype) {

if (Build.VERSION.SDK_INT > 22 && Build.VERSION.SDK_INT < 28 && checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) {
runOnUiThread(() -> Toast.makeText(getApplicationContext(), R.string.grant_storage, Toast.LENGTH_SHORT).show());
requestPermissions(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
}
try {
try {
String encodedFileName = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
Expand Down

0 comments on commit 97813f6

Please sign in to comment.