Add permissions checks to SettingsPage - 1.172 🚀

Related to #177
This commit is contained in:
Brandon Presley 2023-11-10 12:52:24 +13:00
parent 8988e584ae
commit 813928bdd3
4 changed files with 29 additions and 5 deletions

View File

@ -20,6 +20,7 @@ import { darkOptions, lightOptions, themeOptions } from "./options";
import Settings, { settingsUpdated } from "./settings";
import { toast } from "./toast";
import { useTheme } from "./use-theme";
import { check, PERMISSIONS, RESULTS, request } from "react-native-permissions";
const twelveHours = [
"dd/LL/yyyy",
@ -126,6 +127,9 @@ export default function SettingsPage() {
case "alarm":
if (value) toast("Timers will now run after each set.");
else toast("Stopped timers running after each set.");
const canNotify = await check(PERMISSIONS.ANDROID.POST_NOTIFICATIONS);
if (canNotify === RESULTS.DENIED || canNotify === RESULTS.BLOCKED)
await request(PERMISSIONS.ANDROID.POST_NOTIFICATIONS);
if (value && !ignoring) NativeModules.SettingsModule.ignoreBattery();
return;
case "vibrate":
@ -290,6 +294,9 @@ export default function SettingsPage() {
}, [reset, update]);
const exportDatabase = useCallback(async () => {
const result = await check(PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
if (result === RESULTS.DENIED || result === RESULTS.BLOCKED)
await request(PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
const path = Dirs.DatabaseDir + "/massive.db";
await FileSystem.cpExternal(path, "massive.db", "downloads");
toast("Database exported. Check downloads.");

View File

@ -85,8 +85,8 @@ android {
applicationId "com.massive"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 36197
versionName "1.171"
versionCode 36198
versionName "1.172"
}
signingConfigs {
release {

20
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "massive",
"version": "1.169",
"version": "1.171",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "massive",
"version": "1.169",
"version": "1.171",
"license": "GPL-3.0-only",
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.18.6",
@ -37,6 +37,7 @@
"react-native-linear-gradient": "^2.7.3",
"react-native-pager-view": "^6.2.0",
"react-native-paper": "^5.9.1",
"react-native-permissions": "^3.10.1",
"react-native-reanimated": "^3.3.0",
"react-native-reorderable-list": "^0.4.0",
"react-native-safe-area-context": "^4.7.1",
@ -9896,6 +9897,21 @@
"color-string": "^1.6.0"
}
},
"node_modules/react-native-permissions": {
"version": "3.10.1",
"resolved": "https://registry.npmjs.org/react-native-permissions/-/react-native-permissions-3.10.1.tgz",
"integrity": "sha512-Gc5BxxpjZn4QNUDiVeHOO0vXh3AH7ToolmwTJozqC6DsxV7NAf3ttap+8BSmzDR8WxuAM3Cror+YNiBhHJx7/w==",
"peerDependencies": {
"react": ">=16.13.1",
"react-native": ">=0.63.3",
"react-native-windows": ">=0.62.0"
},
"peerDependenciesMeta": {
"react-native-windows": {
"optional": true
}
}
},
"node_modules/react-native-reanimated": {
"version": "3.3.0",
"license": "MIT",

View File

@ -1,6 +1,6 @@
{
"name": "massive",
"version": "1.171",
"version": "1.172",
"private": true,
"license": "GPL-3.0-only",
"scripts": {
@ -40,6 +40,7 @@
"react-native-linear-gradient": "^2.7.3",
"react-native-pager-view": "^6.2.0",
"react-native-paper": "^5.9.1",
"react-native-permissions": "^3.10.1",
"react-native-reanimated": "^3.3.0",
"react-native-reorderable-list": "^0.4.0",
"react-native-safe-area-context": "^4.7.1",