From 5ca0a0adf2fd8707a5bdb32b6c48a5956e258902 Mon Sep 17 00:00:00 2001 From: Aris Poloway Date: Fri, 6 Apr 2018 17:19:45 -0400 Subject: [PATCH] Open downloads after permission granted --- .../java/org/schabi/newpipe/MainActivity.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/MainActivity.java b/app/src/main/java/org/schabi/newpipe/MainActivity.java index 8285a445e..4b31a1b1f 100644 --- a/app/src/main/java/org/schabi/newpipe/MainActivity.java +++ b/app/src/main/java/org/schabi/newpipe/MainActivity.java @@ -22,11 +22,13 @@ package org.schabi.newpipe; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.PackageManager; import android.net.Uri; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.preference.PreferenceManager; +import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; import android.support.v4.app.Fragment; import android.support.v4.view.GravityCompat; @@ -54,6 +56,7 @@ import org.schabi.newpipe.fragments.list.search.SearchFragment; import org.schabi.newpipe.report.ErrorActivity; import org.schabi.newpipe.util.Constants; import org.schabi.newpipe.util.NavigationHelper; +import org.schabi.newpipe.util.PermissionHelper; import org.schabi.newpipe.util.ServiceHelper; import org.schabi.newpipe.util.StateSaver; import org.schabi.newpipe.util.ThemeHelper; @@ -233,6 +236,19 @@ public class MainActivity extends AppCompatActivity { } else super.onBackPressed(); } + @Override + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + if (requestCode == PermissionHelper.PERMISSION_READ_STORAGE || + requestCode == PermissionHelper.PERMISSION_WRITE_STORAGE){ + for (int i: grantResults){ + if (i == PackageManager.PERMISSION_DENIED){ + return; + } + } + NavigationHelper.openDownloads(this); + } + } + /** * Implement the following diagram behavior for the up button: *