aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main/java/github')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java25
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java2
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Util.java12
3 files changed, 33 insertions, 6 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
index ab846ba0..d987f403 100644
--- a/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
+++ b/app/src/main/java/github/daneren2005/dsub/activity/SubsonicActivity.java
@@ -32,12 +32,15 @@ import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.design.widget.NavigationView;
+import android.support.v4.app.ActivityCompat;
+import android.support.v4.content.ContextCompat;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
+import android.support.v7.app.AppCompatDelegate;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.KeyEvent;
@@ -81,6 +84,8 @@ import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.view.UpdateView;
import github.daneren2005.dsub.util.UserUtil;
+import static android.Manifest.*;
+
public class SubsonicActivity extends AppCompatActivity implements OnItemSelectedListener {
private static final String TAG = SubsonicActivity.class.getSimpleName();
private static ImageLoader IMAGE_LOADER;
@@ -89,6 +94,7 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
protected static boolean actionbarColored;
private static final int MENU_GROUP_SERVER = 10;
private static final int MENU_ITEM_SERVER_BASE = 100;
+ private static final int PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE = 1;
private final List<Runnable> afterServiceAvailable = new ArrayList<>();
private boolean drawerIdle = true;
@@ -165,6 +171,25 @@ public class SubsonicActivity extends AppCompatActivity implements OnItemSelecte
};
Util.getPreferences(this).registerOnSharedPreferenceChangeListener(preferencesListener);
}
+
+ if (ContextCompat.checkSelfPermission(this, permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
+ ActivityCompat.requestPermissions(this, new String[]{ permission.WRITE_EXTERNAL_STORAGE }, PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE);
+ }
+ }
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
+ switch (requestCode) {
+ case PERMISSIONS_REQUEST_WRITE_EXTERNAL_STORAGE: {
+ // If request is cancelled, the result arrays are empty.
+ if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
+
+ } else {
+ Util.toast(this, R.string.permission_external_storage_failed);
+ finish();
+ }
+ }
+ }
}
@Override
diff --git a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index f8272356..726840b2 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -155,6 +155,8 @@ public class DownloadServiceLifecycleSupport {
// Pause temporarily on incoming phone calls.
phoneStateListener = new MyPhoneStateListener();
+
+ // Android 6.0 removes requirement for android.Manifest.permission.READ_PHONE_STATE;
TelephonyManager telephonyManager = (TelephonyManager) downloadService.getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
diff --git a/app/src/main/java/github/daneren2005/dsub/util/Util.java b/app/src/main/java/github/daneren2005/dsub/util/Util.java
index fc7292f6..759c6799 100644
--- a/app/src/main/java/github/daneren2005/dsub/util/Util.java
+++ b/app/src/main/java/github/daneren2005/dsub/util/Util.java
@@ -1198,22 +1198,22 @@ public final class Util {
showDialog(context, android.R.drawable.ic_dialog_info, title, message, linkify);
}
- private static void showDialog(Context context, int icon, int titleId, int messageId) {
+ public static void showDialog(Context context, int icon, int titleId, int messageId) {
showDialog(context, icon, titleId, messageId, true);
}
- private static void showDialog(Context context, int icon, int titleId, String message) {
+ public static void showDialog(Context context, int icon, int titleId, String message) {
showDialog(context, icon, titleId, message, true);
}
- private static void showDialog(Context context, int icon, String title, String message) {
+ public static void showDialog(Context context, int icon, String title, String message) {
showDialog(context, icon, title, message, true);
}
- private static void showDialog(Context context, int icon, int titleId, int messageId, boolean linkify) {
+ public static void showDialog(Context context, int icon, int titleId, int messageId, boolean linkify) {
showDialog(context, icon, context.getResources().getString(titleId), context.getResources().getString(messageId), linkify);
}
- private static void showDialog(Context context, int icon, int titleId, String message, boolean linkify) {
+ public static void showDialog(Context context, int icon, int titleId, String message, boolean linkify) {
showDialog(context, icon, context.getResources().getString(titleId), message, linkify);
}
- private static void showDialog(Context context, int icon, String title, String message, boolean linkify) {
+ public static void showDialog(Context context, int icon, String title, String message, boolean linkify) {
SpannableString ss = new SpannableString(message);
if(linkify) {
Linkify.addLinks(ss, Linkify.ALL);