mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2026-07-31 07:44:24 +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:
+5
-2
@@ -40,6 +40,7 @@ import androidx.appcompat.app.AppCompatActivity;
|
|||||||
import androidx.appcompat.app.AppCompatDelegate;
|
import androidx.appcompat.app.AppCompatDelegate;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
|
import androidx.core.app.NotificationManagerCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.drawerlayout.widget.DrawerLayout;
|
import androidx.drawerlayout.widget.DrawerLayout;
|
||||||
@@ -195,11 +196,13 @@ public class ControlCenterv2 extends AppCompatActivity
|
|||||||
* Ask for permission to intercept notifications on first run.
|
* Ask for permission to intercept notifications on first run.
|
||||||
*/
|
*/
|
||||||
Prefs prefs = GBApplication.getPrefs();
|
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");
|
Intent enableIntent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
|
||||||
startActivity(enableIntent);
|
startActivity(enableIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
checkAndRequestPermissions();
|
checkAndRequestPermissions();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user