Ask for external storage permissions on Marshmallow. Fixes #76 and #36

This commit is contained in:
inorichi 2016-01-31 22:38:54 +01:00
parent d799ae5d72
commit ad953b7bf6

View file

@ -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<MangaPresenter> {
isOnline = intent.getBooleanExtra(MANGA_ONLINE, false);
setupViewPager();
requestPermissionsOnMarshmallow();
}
private void setupViewPager() {
@ -83,6 +90,21 @@ public class MangaActivity extends BaseRxActivity<MangaPresenter> {
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;