From 69815e16f225767be8926650bdcecf1fa88d3e2e Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sat, 16 Aug 2025 22:20:30 +0530 Subject: [PATCH 1/7] made the permission changes --- .gitignore | 2 +- android/app/src/main/AndroidManifest.xml | 3 ++- android/build.gradle | 2 +- src/components/GlobalRegisterSelector.tsx | 0 src/utils/exportSchedule.ts | 23 ++++------------------- src/utils/storage-permissions.ts | 6 ++++++ 6 files changed, 14 insertions(+), 22 deletions(-) create mode 100644 src/components/GlobalRegisterSelector.tsx create mode 100644 src/utils/storage-permissions.ts diff --git a/.gitignore b/.gitignore index f045abd..eff32d4 100644 --- a/.gitignore +++ b/.gitignore @@ -57,7 +57,7 @@ android/app/release/ node_modules/ npm-debug.log yarn-error.log -# package-lock.json +package-lock.json android/app/google-services.json android/keystore.properties diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 7bbaa5b..aa96fd7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ - + + { - if (Platform.OS === 'android') { - try { - const granted = await PermissionsAndroid.request( - PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, - { - title: 'Storage Permission', - message: 'App needs access to storage to save CSV files', - buttonNeutral: 'Ask Me Later', - buttonNegative: 'Cancel', - buttonPositive: 'OK', - } - ); - return granted === PermissionsAndroid.RESULTS.GRANTED; - } catch (err) { - console.warn(err); - return false; - } - } - return true; // iOS doesn't need explicit storage permission for app documents + // Use PermissionsHelper for consistent permission logic + const result = await PermissionsHelper.requestStoragePermission(); + return result.granted; } private getAllRegisterIds(): number[] { diff --git a/src/utils/storage-permissions.ts b/src/utils/storage-permissions.ts new file mode 100644 index 0000000..97b55b7 --- /dev/null +++ b/src/utils/storage-permissions.ts @@ -0,0 +1,6 @@ +import { PermissionsHelper } from './permissions'; + +export const requestStoragePermission = async (): Promise => { + const result = await PermissionsHelper.requestStoragePermission(); + return result.granted; +}; From 3ef2c5c58b61d914faa0a961cb0ad4827efbda45 Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sat, 16 Aug 2025 22:23:43 +0530 Subject: [PATCH 2/7] made the permission chages --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 18b149e..da654c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ buildscript { minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 - ndkVersion = "26.3.11579264" + ndkVersion = "27.1.12297006" kotlinVersion = "2.0.21" } repositories { From d6150e303e57f74bcdf19080800c75771d8e5973 Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sat, 16 Aug 2025 22:57:25 +0530 Subject: [PATCH 3/7] enhanced the changes --- App.tsx | 45 ++++++++++++++-- android/app/src/main/AndroidManifest.xml | 67 ++++++++++++++---------- src/utils/exportSchedule.ts | 26 +++++++++ 3 files changed, 108 insertions(+), 30 deletions(-) diff --git a/App.tsx b/App.tsx index 6cce5e7..3088b2b 100644 --- a/App.tsx +++ b/App.tsx @@ -1,7 +1,10 @@ import React, {useEffect} from 'react'; -// import 'react-native-reanimated'; - -import {StatusBar, StyleSheet} from 'react-native'; +import { + StatusBar, + StyleSheet, + PermissionsAndroid, + Platform, +} from 'react-native'; import {SafeAreaProvider, SafeAreaView} from 'react-native-safe-area-context'; import Toast from 'react-native-toast-message'; import MainApp from './src/main'; @@ -14,8 +17,43 @@ enableScreens(); function App(): React.JSX.Element { useEffect(() => { SplashScreen.hide(); + requestStoragePermission(); }, []); + const requestStoragePermission = async () => { + try { + if (Platform.OS === 'android') { + if (Platform.Version >= 33) { + // Android 13+ (Images, Video, Audio separately) + const result = await PermissionsAndroid.requestMultiple([ + PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES, + PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO, + PermissionsAndroid.PERMISSIONS.READ_MEDIA_AUDIO, + ]); + console.log('Android 13+ permission result:', result); + } else { + // Android 12 and below + const granted = await PermissionsAndroid.request( + PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, + { + title: 'Storage Permission Required', + message: + 'ScheduleX needs access to your storage to function properly.', + buttonPositive: 'OK', + }, + ); + if (granted === PermissionsAndroid.RESULTS.GRANTED) { + console.log('Storage permission granted'); + } else { + console.log('Storage permission denied'); + } + } + } + } catch (err) { + console.warn(err); + } + }; + return ( @@ -44,4 +82,5 @@ const styles = StyleSheet.create({ backgroundColor: '#18181B', }, }); + export default App; diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index aa96fd7..cd6b40b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,32 +1,45 @@ - + - - + + + + + + + + + + + + + + - - - - - - - - - + android:icon="@mipmap/ic_launcher" + android:roundIcon="@mipmap/ic_launcher_round" + android:allowBackup="false" + android:theme="@style/AppTheme" + android:supportsRtl="true"> - \ No newline at end of file + + + + + + + + + + diff --git a/src/utils/exportSchedule.ts b/src/utils/exportSchedule.ts index ceeeb78..ff00448 100644 --- a/src/utils/exportSchedule.ts +++ b/src/utils/exportSchedule.ts @@ -1,3 +1,29 @@ +/** + * Rename an exported CSV file in the Downloads directory. + * @param oldName The current filename (with .csv) + * @param newName The new filename (without .csv or with .csv) + * @returns Promise true if successful, false otherwise + */ +export async function renameExportedCSV(oldName: string, newName: string): Promise { + try { + const downloadsDir = RNFS.DownloadDirectoryPath; + const oldPath = `${downloadsDir}/${oldName}`; + let newFileName = newName.endsWith('.csv') ? newName : `${newName}.csv`; + const newPath = `${downloadsDir}/${newFileName}`; + const exists = await RNFS.exists(oldPath); + if (!exists) { + Alert.alert('Rename Failed', `File ${oldName} does not exist.`); + return false; + } + await RNFS.moveFile(oldPath, newPath); + ToastAndroid.show(`Renamed to ${newFileName}`, ToastAndroid.SHORT); + return true; + } catch (e) { + console.error('Rename error:', e); + Alert.alert('Rename Failed', `Could not rename file: ${e instanceof Error ? e.message : 'Unknown error'}`); + return false; + } +} import RNFS from 'react-native-fs'; import { Alert, ToastAndroid, Platform, PermissionsAndroid } from 'react-native'; import Share from 'react-native-share'; From ad513b9b3df316aeeb0332cd80e81cbf1c188259 Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sat, 16 Aug 2025 23:56:54 +0530 Subject: [PATCH 4/7] sucessfully made the permission settings --- android/app/src/main/AndroidManifest.xml | 19 +- android/app/src/main/res/xml/file_paths.xml | 4 + android/build.gradle | 2 +- package.json | 1 + src/utils/exportSchedule.ts | 26 -- src/utils/permissions.ts | 286 ++++++++++++++------ yarn.lock | 7 +- 7 files changed, 228 insertions(+), 117 deletions(-) create mode 100644 android/app/src/main/res/xml/file_paths.xml diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index cd6b40b..8ee462b 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -4,17 +4,13 @@ - - - - - - + + + + + + + diff --git a/android/app/src/main/res/xml/file_paths.xml b/android/app/src/main/res/xml/file_paths.xml new file mode 100644 index 0000000..a6ce6d3 --- /dev/null +++ b/android/app/src/main/res/xml/file_paths.xml @@ -0,0 +1,4 @@ + + + + diff --git a/android/build.gradle b/android/build.gradle index da654c3..18b149e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ buildscript { minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 - ndkVersion = "27.1.12297006" + ndkVersion = "26.3.11579264" kotlinVersion = "2.0.21" } repositories { diff --git a/package.json b/package.json index d6cfb42..fb28402 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "react-native-linear-gradient": "^2.8.3", "react-native-multiple-select": "^0.5.12", "react-native-pager-view": "^6.8.1", + "react-native-permissions": "^5.4.2", "react-native-safe-area-context": "^5.0.0", "react-native-screens": "^4.3.0", "react-native-share": "^12.1.0", diff --git a/src/utils/exportSchedule.ts b/src/utils/exportSchedule.ts index ff00448..ceeeb78 100644 --- a/src/utils/exportSchedule.ts +++ b/src/utils/exportSchedule.ts @@ -1,29 +1,3 @@ -/** - * Rename an exported CSV file in the Downloads directory. - * @param oldName The current filename (with .csv) - * @param newName The new filename (without .csv or with .csv) - * @returns Promise true if successful, false otherwise - */ -export async function renameExportedCSV(oldName: string, newName: string): Promise { - try { - const downloadsDir = RNFS.DownloadDirectoryPath; - const oldPath = `${downloadsDir}/${oldName}`; - let newFileName = newName.endsWith('.csv') ? newName : `${newName}.csv`; - const newPath = `${downloadsDir}/${newFileName}`; - const exists = await RNFS.exists(oldPath); - if (!exists) { - Alert.alert('Rename Failed', `File ${oldName} does not exist.`); - return false; - } - await RNFS.moveFile(oldPath, newPath); - ToastAndroid.show(`Renamed to ${newFileName}`, ToastAndroid.SHORT); - return true; - } catch (e) { - console.error('Rename error:', e); - Alert.alert('Rename Failed', `Could not rename file: ${e instanceof Error ? e.message : 'Unknown error'}`); - return false; - } -} import RNFS from 'react-native-fs'; import { Alert, ToastAndroid, Platform, PermissionsAndroid } from 'react-native'; import Share from 'react-native-share'; diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index 7ff25dd..e6e6238 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -1,4 +1,136 @@ -import { Platform, PermissionsAndroid, Alert } from 'react-native'; +// import { Platform, Alert } from 'react-native'; +// import { check, request, PERMISSIONS, RESULTS, openSettings } from 'react-native-permissions'; + +// export interface PermissionResult { +// granted: boolean; +// canRequestAgain: boolean; +// } + +// export class PermissionsHelper { + +// /** +// * Check if we need to request storage permissions based on Android version +// * Android 11+ (API 30+) uses scoped storage, so we don't need WRITE_EXTERNAL_STORAGE +// * for app-specific directories +// */ +// static needsStoragePermission(): boolean { +// return Platform.OS === 'android'; +// } + +// /** +// * Request storage permissions for Android +// */ +// static async requestStoragePermission(): Promise { +// if (Platform.OS === 'android') { +// const permission = PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE; +// try { +// const result = await request(permission); +// if (result === RESULTS.GRANTED) { +// return { granted: true, canRequestAgain: false }; +// } else if (result === RESULTS.BLOCKED) { +// return { granted: false, canRequestAgain: false }; +// } else { +// return { granted: false, canRequestAgain: true }; +// } +// } catch (error) { +// console.warn('Permission request error:', error); +// return { granted: false, canRequestAgain: true }; +// } +// } else if (Platform.OS === 'ios') { +// const permission = PERMISSIONS.IOS.PHOTO_LIBRARY; +// try { +// const result = await request(permission); +// if (result === RESULTS.GRANTED) { +// return { granted: true, canRequestAgain: false }; +// } else if (result === RESULTS.BLOCKED) { +// return { granted: false, canRequestAgain: false }; +// } else { +// return { granted: false, canRequestAgain: true }; +// } +// } catch (error) { +// console.warn('Permission request error:', error); +// return { granted: false, canRequestAgain: true }; +// } +// } +// return { granted: true, canRequestAgain: false }; +// } + +// /** +// * Check if storage permissions are currently granted +// */ +// static async checkStoragePermission(): Promise { +// if (Platform.OS === 'android') { +// const permission = PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE; +// try { +// const result = await check(permission); +// return result === RESULTS.GRANTED; +// } catch (error) { +// console.warn('Permission check error:', error); +// return false; +// } +// } else if (Platform.OS === 'ios') { +// const permission = PERMISSIONS.IOS.PHOTO_LIBRARY; +// try { +// const result = await check(permission); +// return result === RESULTS.GRANTED; +// } catch (error) { +// console.warn('Permission check error:', error); +// return false; +// } +// } +// return true; +// } + +// /** +// * Show permission explanation dialog +// */ +// static showPermissionExplanation(onRetry: () => void, onCancel: () => void) { +// Alert.alert( +// 'Storage Permission Required', +// 'This app needs storage permission to save CSV files to your device. You can still use the share feature without this permission.', +// [ +// { +// text: 'Cancel', +// style: 'cancel', +// onPress: onCancel, +// }, +// { +// text: 'Grant Permission', +// onPress: onRetry, +// }, +// ] +// ); +// } + +// /** +// * Show permission denied dialog +// */ +// static showPermissionDenied(onUseAppStorage: () => void) { +// Alert.alert( +// 'Permission Denied', +// 'Storage permission was denied. You can either:\n\n1. Enable it in Settings\n2. Use app storage (files will be saved in app folder)', +// [ +// { +// text: 'Use App Storage', +// onPress: onUseAppStorage, +// }, +// { +// text: 'Open Settings', +// onPress: () => openSettings(), +// }, +// ] +// ); +// } +// } + +import { Platform, Alert } from "react-native"; +import { + check, + request, + PERMISSIONS, + RESULTS, + openSettings, +} from "react-native-permissions"; export interface PermissionResult { granted: boolean; @@ -6,96 +138,84 @@ export interface PermissionResult { } export class PermissionsHelper { - /** * Check if we need to request storage permissions based on Android version - * Android 11+ (API 30+) uses scoped storage, so we don't need WRITE_EXTERNAL_STORAGE - * for app-specific directories */ static needsStoragePermission(): boolean { - if (Platform.OS !== 'android') return false; - - // For Android 11+ (API 30+), we use app-scoped storage which doesn't require permissions - const androidVersion = Platform.Version as number; - return androidVersion < 30; + return Platform.OS === "android"; } /** - * Request storage permissions for Android + * Request storage permissions for Android & iOS */ - static async requestStoragePermission(forPublicStorage: boolean = false): Promise { - if (Platform.OS !== 'android') { - return { granted: true, canRequestAgain: false }; - } + static async requestStoragePermission(): Promise { + if (Platform.OS === "android") { + // For Android 11+, rely on Document Picker instead of MANAGE_EXTERNAL_STORAGE + const permission = + Platform.Version >= 30 + ? PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE + : PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE; - // Android 11+ doesn't need storage permissions for app-scoped directories - if (!this.needsStoragePermission() && !forPublicStorage) { - return { granted: true, canRequestAgain: false }; - } - - try { - // For Android 10 and below, or if explicitly requesting public storage - if (this.needsStoragePermission() || forPublicStorage) { - const writeResult = await PermissionsAndroid.request( - PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, - { - title: 'Storage Permission', - message: 'App needs storage permission to save CSV files', - buttonNeutral: 'Ask Me Later', - buttonNegative: 'Cancel', - buttonPositive: 'OK', - } - ); - - const readResult = await PermissionsAndroid.request( - PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, - { - title: 'Storage Permission', - message: 'App needs storage permission to access files', - buttonNeutral: 'Ask Me Later', - buttonNegative: 'Cancel', - buttonPositive: 'OK', - } - ); - - const allGranted = writeResult === PermissionsAndroid.RESULTS.GRANTED && - readResult === PermissionsAndroid.RESULTS.GRANTED; - - const canRequestAgain = writeResult !== PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN && - readResult !== PermissionsAndroid.RESULTS.NEVER_ASK_AGAIN; - - return { - granted: allGranted, - canRequestAgain - }; + try { + const result = await request(permission); + if (result === RESULTS.GRANTED) { + return { granted: true, canRequestAgain: false }; + } else if (result === RESULTS.BLOCKED) { + return { granted: false, canRequestAgain: false }; + } else { + return { granted: false, canRequestAgain: true }; + } + } catch (error) { + console.warn("Permission request error:", error); + return { granted: false, canRequestAgain: true }; + } + } else if (Platform.OS === "ios") { + const permission = PERMISSIONS.IOS.PHOTO_LIBRARY_ADD_ONLY; + try { + const result = await request(permission); + if (result === RESULTS.GRANTED) { + return { granted: true, canRequestAgain: false }; + } else if (result === RESULTS.BLOCKED) { + return { granted: false, canRequestAgain: false }; + } else { + return { granted: false, canRequestAgain: true }; + } + } catch (error) { + console.warn("Permission request error:", error); + return { granted: false, canRequestAgain: true }; } - - return { granted: true, canRequestAgain: false }; - - } catch (error) { - console.warn('Permission request error:', error); - return { granted: false, canRequestAgain: true }; } + return { granted: true, canRequestAgain: false }; } /** * Check if storage permissions are currently granted */ static async checkStoragePermission(): Promise { - if (Platform.OS !== 'android') return true; - - if (!this.needsStoragePermission()) return true; + if (Platform.OS === "android") { + const permission = + Platform.Version >= 30 + ? PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE + : PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE; - try { - const writePermission = await PermissionsAndroid.check( - PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE - ); - - return writePermission; - } catch (error) { - console.warn('Permission check error:', error); - return false; + try { + const result = await check(permission); + return result === RESULTS.GRANTED; + } catch (error) { + console.warn("Permission check error:", error); + return false; + } + } else if (Platform.OS === "ios") { + const permission = PERMISSIONS.IOS.PHOTO_LIBRARY_ADD_ONLY; + try { + const result = await check(permission); + return result === RESULTS.GRANTED; + } catch (error) { + console.warn("Permission check error:", error); + return false; + } } + return true; } /** @@ -103,16 +223,16 @@ export class PermissionsHelper { */ static showPermissionExplanation(onRetry: () => void, onCancel: () => void) { Alert.alert( - 'Storage Permission Required', - 'This app needs storage permission to save CSV files to your device. You can still use the share feature without this permission.', + "Storage Permission Required", + "This app needs storage permission to save CSV files to your device. You can still use the share feature without this permission.", [ { - text: 'Cancel', - style: 'cancel', + text: "Cancel", + style: "cancel", onPress: onCancel, }, { - text: 'Grant Permission', + text: "Grant Permission", onPress: onRetry, }, ] @@ -122,18 +242,18 @@ export class PermissionsHelper { /** * Show permission denied dialog */ - static showPermissionDenied(onOpenSettings: () => void, onUseAppStorage: () => void) { + static showPermissionDenied(onUseAppStorage: () => void) { Alert.alert( - 'Permission Denied', - 'Storage permission was denied. You can either:\n\n1. Enable it in Settings\n2. Use app storage (files will be saved in app folder)', + "Permission Denied", + "Storage permission was denied. You can either:\n\n1. Enable it in Settings\n2. Use app storage (files will be saved in app folder)", [ { - text: 'Use App Storage', + text: "Use App Storage", onPress: onUseAppStorage, }, { - text: 'Open Settings', - onPress: onOpenSettings, + text: "Open Settings", + onPress: () => openSettings(), }, ] ); diff --git a/yarn.lock b/yarn.lock index 5a0104d..f6c30e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6778,7 +6778,7 @@ react-native-dotenv@^3.4.11: react-native-fs@^2.20.0: version "2.20.0" - resolved "https://registry.npmjs.org/react-native-fs/-/react-native-fs-2.20.0.tgz" + resolved "https://registry.yarnpkg.com/react-native-fs/-/react-native-fs-2.20.0.tgz#05a9362b473bfc0910772c0acbb73a78dbc810f6" integrity sha512-VkTBzs7fIDUiy/XajOSNk0XazFE9l+QlMAce7lGuebZcag5CnjszB+u4BdqzwaQOdcYb5wsJIsqq4kxInIRpJQ== dependencies: base-64 "^0.1.0" @@ -6830,6 +6830,11 @@ react-native-pager-view@^6.8.1: resolved "https://registry.npmjs.org/react-native-pager-view/-/react-native-pager-view-6.8.1.tgz" integrity sha512-XIyVEMhwq7sZqM7GobOJZXxFCfdFgVNq/CFB2rZIRNRSVPJqE1k1fsc8xfQKfdzsp6Rpt6I7VOIvhmP7/YHdVg== +react-native-permissions@^5.4.2: + version "5.4.2" + resolved "https://registry.yarnpkg.com/react-native-permissions/-/react-native-permissions-5.4.2.tgz#206c0e440cff2ce047514995457bd73a9924fd8b" + integrity sha512-XNMoG1fxrB9q73MLn/ZfTaP7pS8qPu0KWypbeFKVTvoR+JJ3O7uedMOTH/mts9bTG+GKhShOoZ+k0CR63q9jwA== + react-native-safe-area-context@^5.0.0: version "5.5.2" resolved "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-5.5.2.tgz" From 41d7ac665d9804a7e102c7180066a29c077c8716 Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sun, 17 Aug 2025 00:09:13 +0530 Subject: [PATCH 5/7] made minor changes --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 18b149e..da654c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ buildscript { minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 - ndkVersion = "26.3.11579264" + ndkVersion = "27.1.12297006" kotlinVersion = "2.0.21" } repositories { From 511261667ad1d1df0831a82ca6eaa9fec62a57ee Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sun, 17 Aug 2025 01:01:40 +0530 Subject: [PATCH 6/7] made the changes for permission --- android/build.gradle | 2 +- src/utils/permissions.ts | 125 --------------------------------------- 2 files changed, 1 insertion(+), 126 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index da654c3..18b149e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ buildscript { minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 - ndkVersion = "27.1.12297006" + ndkVersion = "26.3.11579264" kotlinVersion = "2.0.21" } repositories { diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index e6e6238..e0b8abc 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -1,128 +1,3 @@ -// import { Platform, Alert } from 'react-native'; -// import { check, request, PERMISSIONS, RESULTS, openSettings } from 'react-native-permissions'; - -// export interface PermissionResult { -// granted: boolean; -// canRequestAgain: boolean; -// } - -// export class PermissionsHelper { - -// /** -// * Check if we need to request storage permissions based on Android version -// * Android 11+ (API 30+) uses scoped storage, so we don't need WRITE_EXTERNAL_STORAGE -// * for app-specific directories -// */ -// static needsStoragePermission(): boolean { -// return Platform.OS === 'android'; -// } - -// /** -// * Request storage permissions for Android -// */ -// static async requestStoragePermission(): Promise { -// if (Platform.OS === 'android') { -// const permission = PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE; -// try { -// const result = await request(permission); -// if (result === RESULTS.GRANTED) { -// return { granted: true, canRequestAgain: false }; -// } else if (result === RESULTS.BLOCKED) { -// return { granted: false, canRequestAgain: false }; -// } else { -// return { granted: false, canRequestAgain: true }; -// } -// } catch (error) { -// console.warn('Permission request error:', error); -// return { granted: false, canRequestAgain: true }; -// } -// } else if (Platform.OS === 'ios') { -// const permission = PERMISSIONS.IOS.PHOTO_LIBRARY; -// try { -// const result = await request(permission); -// if (result === RESULTS.GRANTED) { -// return { granted: true, canRequestAgain: false }; -// } else if (result === RESULTS.BLOCKED) { -// return { granted: false, canRequestAgain: false }; -// } else { -// return { granted: false, canRequestAgain: true }; -// } -// } catch (error) { -// console.warn('Permission request error:', error); -// return { granted: false, canRequestAgain: true }; -// } -// } -// return { granted: true, canRequestAgain: false }; -// } - -// /** -// * Check if storage permissions are currently granted -// */ -// static async checkStoragePermission(): Promise { -// if (Platform.OS === 'android') { -// const permission = PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE; -// try { -// const result = await check(permission); -// return result === RESULTS.GRANTED; -// } catch (error) { -// console.warn('Permission check error:', error); -// return false; -// } -// } else if (Platform.OS === 'ios') { -// const permission = PERMISSIONS.IOS.PHOTO_LIBRARY; -// try { -// const result = await check(permission); -// return result === RESULTS.GRANTED; -// } catch (error) { -// console.warn('Permission check error:', error); -// return false; -// } -// } -// return true; -// } - -// /** -// * Show permission explanation dialog -// */ -// static showPermissionExplanation(onRetry: () => void, onCancel: () => void) { -// Alert.alert( -// 'Storage Permission Required', -// 'This app needs storage permission to save CSV files to your device. You can still use the share feature without this permission.', -// [ -// { -// text: 'Cancel', -// style: 'cancel', -// onPress: onCancel, -// }, -// { -// text: 'Grant Permission', -// onPress: onRetry, -// }, -// ] -// ); -// } - -// /** -// * Show permission denied dialog -// */ -// static showPermissionDenied(onUseAppStorage: () => void) { -// Alert.alert( -// 'Permission Denied', -// 'Storage permission was denied. You can either:\n\n1. Enable it in Settings\n2. Use app storage (files will be saved in app folder)', -// [ -// { -// text: 'Use App Storage', -// onPress: onUseAppStorage, -// }, -// { -// text: 'Open Settings', -// onPress: () => openSettings(), -// }, -// ] -// ); -// } -// } - import { Platform, Alert } from "react-native"; import { check, From 1b033a343877980b5de2341e8f557ca2a6a6dacf Mon Sep 17 00:00:00 2001 From: FireFistisDead Date: Sun, 17 Aug 2025 01:03:09 +0530 Subject: [PATCH 7/7] made changes for permissions --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index 18b149e..da654c3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -4,7 +4,7 @@ buildscript { minSdkVersion = 24 compileSdkVersion = 35 targetSdkVersion = 35 - ndkVersion = "26.3.11579264" + ndkVersion = "27.1.12297006" kotlinVersion = "2.0.21" } repositories {