1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-18 11:00:09 +02:00

Made sure to check notification listener access even after first launch because not having it can cause issues

This commit is contained in:
TaaviE 2020-07-27 19:42:36 +03:00
parent d2a6353e8d
commit bb1b31bcb4

View File

@ -40,6 +40,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.appcompat.widget.Toolbar;
import androidx.core.app.ActivityCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.core.content.ContextCompat;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
@ -195,11 +196,13 @@ public class ControlCenterv2 extends AppCompatActivity
* Ask for permission to intercept notifications on first run.
*/
Prefs prefs = GBApplication.getPrefs();
if (prefs.getBoolean("firstrun", true)) {
prefs.getPreferences().edit().putBoolean("firstrun", false).apply();
Set<String> set = NotificationManagerCompat.getEnabledListenerPackages(this);
if (!set.contains(this.getPackageName())) { // If notification listener access hasn't been granted
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(enableIntent);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkAndRequestPermissions();
}