Notifications are no longer requested again after rotating the phone
This commit is contained in:
parent
06036a035a
commit
90d7cc8fa6
2 changed files with 16 additions and 3 deletions
|
|
@ -66,12 +66,21 @@ public class App extends Application {
|
||||||
|
|
||||||
private boolean isFirstRun = false;
|
private boolean isFirstRun = false;
|
||||||
private static App app;
|
private static App app;
|
||||||
|
private boolean notificationsRequested = false;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static App getApp() {
|
public static App getApp() {
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getNotificationsRequested() {
|
||||||
|
return notificationsRequested;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNotificationsRequested() {
|
||||||
|
notificationsRequested = true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(final Context base) {
|
protected void attachBaseContext(final Context base) {
|
||||||
super.attachBaseContext(base);
|
super.attachBaseContext(base);
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.core.app.ActivityCompat;
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.App;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.settings.NewPipeSettings;
|
import org.schabi.newpipe.settings.NewPipeSettings;
|
||||||
|
|
||||||
|
|
@ -89,9 +90,12 @@ public final class PermissionHelper {
|
||||||
&& ContextCompat.checkSelfPermission(activity,
|
&& ContextCompat.checkSelfPermission(activity,
|
||||||
Manifest.permission.POST_NOTIFICATIONS)
|
Manifest.permission.POST_NOTIFICATIONS)
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
ActivityCompat.requestPermissions(activity,
|
if (!App.getApp().getNotificationsRequested()) {
|
||||||
new String[] {Manifest.permission.POST_NOTIFICATIONS}, requestCode);
|
ActivityCompat.requestPermissions(activity,
|
||||||
return false;
|
new String[]{Manifest.permission.POST_NOTIFICATIONS}, requestCode);
|
||||||
|
App.getApp().setNotificationsRequested();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue