Revision 5debefcb app/src/org/storymaker/app/BaseActivity.java
| app/src/org/storymaker/app/BaseActivity.java | ||
|---|---|---|
| 1 | 1 |
package org.storymaker.app; |
| 2 | 2 |
|
| 3 |
import android.Manifest; |
|
| 3 | 4 |
import android.app.Activity; |
| 4 | 5 |
import android.app.Notification; |
| 5 | 6 |
import android.content.Context; |
| ... | ... | |
| 14 | 15 |
import android.os.Bundle; |
| 15 | 16 |
import android.preference.PreferenceManager; |
| 16 | 17 |
import android.support.v4.app.ActionBarDrawerToggle; |
| 18 |
import android.support.v4.app.ActivityCompat; |
|
| 17 | 19 |
import android.support.v4.app.FragmentActivity; |
| 18 | 20 |
import android.support.v4.app.NotificationCompat; |
| 19 | 21 |
import android.support.v4.widget.DrawerLayout; |
| ... | ... | |
| 35 | 37 |
|
| 36 | 38 |
import java.io.IOException; |
| 37 | 39 |
import java.io.InputStream; |
| 40 |
import java.util.ArrayList; |
|
| 38 | 41 |
|
| 39 | 42 |
import info.guardianproject.cacheword.CacheWordHandler; |
| 40 | 43 |
import info.guardianproject.cacheword.ICacheWordSubscriber; |
| ... | ... | |
| 428 | 431 |
if (mDrawerOpen) mDrawerLayout.closeDrawer(mDrawerContainer); |
| 429 | 432 |
else mDrawerLayout.openDrawer(mDrawerContainer); |
| 430 | 433 |
} |
| 434 |
|
|
| 435 |
// force permissions we require |
|
| 436 |
protected void checkAndEnforcePermissions() {
|
|
| 437 |
ArrayList<String> perms = new ArrayList<>(); |
|
| 438 |
|
|
| 439 |
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
| 440 |
perms.add(Manifest.permission.READ_EXTERNAL_STORAGE); |
|
| 441 |
} |
|
| 442 |
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
|
| 443 |
perms.add(Manifest.permission.WRITE_EXTERNAL_STORAGE); |
|
| 444 |
} |
|
| 445 |
if (perms.size() > 0) {
|
|
| 446 |
ActivityCompat.requestPermissions(this, perms.toArray(new String[0]), Constants.PERMS_REQ_ALL); |
|
| 447 |
} |
|
| 448 |
} |
|
| 431 | 449 |
} |
Also available in: Unified diff