diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java index 7a550b536d..554db50a97 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaActivity.java @@ -1,12 +1,17 @@ package eu.kanade.tachiyomi.ui.manga; +import android.Manifest; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.support.design.widget.TabLayout; +import android.support.v4.app.ActivityCompat; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; +import android.support.v4.content.ContextCompat; import android.support.v4.view.ViewPager; import android.support.v7.widget.Toolbar; @@ -63,6 +68,8 @@ public class MangaActivity extends BaseRxActivity { isOnline = intent.getBooleanExtra(MANGA_ONLINE, false); setupViewPager(); + + requestPermissionsOnMarshmallow(); } private void setupViewPager() { @@ -83,6 +90,21 @@ public class MangaActivity extends BaseRxActivity { return isOnline; } + private void requestPermissionsOnMarshmallow() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + if (ContextCompat.checkSelfPermission(this, + Manifest.permission.WRITE_EXTERNAL_STORAGE) + != PackageManager.PERMISSION_GRANTED) { + + ActivityCompat.requestPermissions(this, + new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, + Manifest.permission.READ_EXTERNAL_STORAGE}, + 1); + + } + } + } + class MangaDetailAdapter extends FragmentPagerAdapter { private int pageCount;