LineageActions: Remove ACCESS_NOTIFICATION_POLICY check

* It is granted at first boot and users cannot revoke
   the permission of a system app anymore since Nougat

Change-Id: Ie736c1620420a51d40062de1f809c78a11741781
This commit is contained in:
Alberto97
2017-10-24 18:32:28 +02:00
committed by therootlord
parent 28bec6a977
commit 6da473545a

View File

@@ -16,25 +16,11 @@
package org.lineageos.settings.device;
import android.app.AlertDialog;
import android.app.NotificationManager;
import android.os.Bundle;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v14.preference.PreferenceFragment;
import android.support.v7.preference.PreferenceCategory;
import android.support.v7.preference.Preference;
import android.support.v7.preference.Preference.OnPreferenceClickListener;
import android.support.v14.preference.SwitchPreference;
import android.view.MenuItem;
public class GestureSettingsFragment extends PreferenceFragment {
private SwitchPreference mFlipPref;
private NotificationManager mNotificationManager;
private boolean mFlipClick = false;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
@@ -44,41 +30,6 @@ public class GestureSettingsFragment extends PreferenceFragment {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.actions_panel);
mNotificationManager = (NotificationManager) getActivity().getSystemService(Context.NOTIFICATION_SERVICE);
mFlipPref = (SwitchPreference) findPreference("gesture_flip_to_mute");
mFlipPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
if (!mNotificationManager.isNotificationPolicyAccessGranted()) {
mFlipPref.setChecked(false);
new AlertDialog.Builder(getActivity())
.setTitle(getString(R.string.flip_to_mute_title))
.setMessage(getString(R.string.dnd_access))
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
mFlipClick = true;
startActivity(new Intent(
android.provider.Settings.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS));
}
}).show();
}
return true;
}
});
//Users may deny DND access after giving it
if (!mNotificationManager.isNotificationPolicyAccessGranted()) {
mFlipPref.setChecked(false);
}
}
@Override
public void onResume() {
super.onResume();
if (mNotificationManager.isNotificationPolicyAccessGranted() && mFlipClick) {
mFlipPref.setChecked(true);
}
}
}