mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-01-03 06:30:07 +02:00
Request notification for Android 13+
This commit is contained in:
parent
20c031f39e
commit
2c48032127
1 changed files with 14 additions and 0 deletions
|
@ -21,6 +21,7 @@ import static app.fedilab.android.helper.Helper.PREF_USER_TOKEN;
|
||||||
import static app.fedilab.android.helper.Helper.displayReleaseNotesIfNeeded;
|
import static app.fedilab.android.helper.Helper.displayReleaseNotesIfNeeded;
|
||||||
import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction;
|
import static app.fedilab.android.ui.drawer.StatusAdapter.sendAction;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
@ -51,12 +52,15 @@ import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.widget.PopupMenu;
|
import androidx.appcompat.widget.PopupMenu;
|
||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
|
import androidx.core.app.ActivityCompat;
|
||||||
import androidx.core.app.ActivityOptionsCompat;
|
import androidx.core.app.ActivityOptionsCompat;
|
||||||
import androidx.core.view.GravityCompat;
|
import androidx.core.view.GravityCompat;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
@ -290,6 +294,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
};
|
};
|
||||||
private NetworkStateReceiver networkStateReceiver;
|
private NetworkStateReceiver networkStateReceiver;
|
||||||
private boolean headerMenuOpen;
|
private boolean headerMenuOpen;
|
||||||
|
private static final int REQUEST_CODE = 5415;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
@ -304,6 +309,15 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt
|
||||||
} else {
|
} else {
|
||||||
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
BaseMainActivity.currentToken = sharedpreferences.getString(Helper.PREF_USER_TOKEN, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
ActivityResultLauncher<String> permissionLauncher = registerForActivityResult(new ActivityResultContracts.RequestPermission(), isGranted -> {
|
||||||
|
if (!isGranted) {
|
||||||
|
ActivityCompat.requestPermissions(BaseMainActivity.this, new String[]{Manifest.permission.POST_NOTIFICATIONS}, REQUEST_CODE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
permissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS);
|
||||||
|
}
|
||||||
filteredAccounts = new ArrayList<>();
|
filteredAccounts = new ArrayList<>();
|
||||||
mamageNewIntent(getIntent());
|
mamageNewIntent(getIntent());
|
||||||
filterFetched = false;
|
filterFetched = false;
|
||||||
|
|
Loading…
Reference in a new issue