Skip to content

Commit

Permalink
refactor: remove permission request
Browse files Browse the repository at this point in the history
  • Loading branch information
LazyAfternoons committed Jan 7, 2025
1 parent 87d2a16 commit 19507a3
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 221 deletions.
3 changes: 3 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ dependencies {
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
// Specifing this avoid :app:checkDebugDuplicateClasses failure
implementation "com.google.guava:guava:27.0.1-android"
// Required by react-native-image-picker because we target a minSdkVersion < 30. In can be removed when we target minSdkVersion >= 30.
// https://github.com/react-native-image-picker/react-native-image-picker?tab=readme-ov-file#android-1
implementation("androidx.activity:activity:1.9.+")
}

// Add the following line to the bottom of the file:
Expand Down
13 changes: 13 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@
<data android:host="continua.io.pagopa.it" />
</intent-filter>
</activity>

<!-- Trigger Google Play services to install the backported photo picker module. -->
<!-- This is needed by react-native-image-picker because we target a minSdkVersion < 30. In can be removed when we target minSdkVersion >= 30.
https://developer.android.com/training/data-storage/shared/photopicker#device-availability -->
<service android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
android:exported="false"
tools:ignore="MissingClass">
<intent-filter>
<action android:name="com.google.android.gms.metadata.MODULE_DEPENDENCIES" />
</intent-filter>
<meta-data android:name="photopicker_activity:0:required" android:value="" />
</service>
</application>

</manifest>
4 changes: 2 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ PODS:
- React
- react-native-get-random-values (1.11.0):
- React-Core
- react-native-image-picker (7.2.2):
- react-native-image-picker (7.2.3):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -2501,7 +2501,7 @@ SPEC CHECKSUMS:
react-native-document-picker: a2e1577d26b9758ef3092e66f5d67f6e8c7454d9
react-native-fingerprint-scanner: 91bf6825709dd7bd3abc4588a4772eb097a2b2d8
react-native-get-random-values: d16467cf726c618e9c7a8c3c39c31faa2244bbba
react-native-image-picker: 19a8d8471a239890675726f88f9c18dd213656d5
react-native-image-picker: 130fad649d07e4eec8faaed361d3bba570e1e5ff
react-native-netinfo: cec9c4e86083cb5b6aba0e0711f563e2fbbff187
react-native-notifications-utils: 2684eeb23e47ea5d892b151c28ae07840d1448d1
react-native-pager-view: 8bd7d72d1c260ef565952ac617ab6e492c457894
Expand Down
18 changes: 0 additions & 18 deletions locales/de/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3219,24 +3219,6 @@ transaction:
subject: "Zahlungsgrund"
noticeCode: "Kodex der Zahlungsmitteilung"
taxCode: "Steuernummer Körperschaft"
permissionRequest:
gallery:
title: "Erlaube IO den Zugriff auf deine Fotos"
subtitle: "Dazu musst du die Rechte in den Einstellungen deines Geräts ändern."
caption: "So geht's:"
step: "Schritt {{step}}"
steps:
android:
1: "Geh zu 'Einstellungen'"
2: "Wähle 'Apps'"
3: "Wähle 'IO'"
4: "Wähle den Punkt App-Berechtigungen"
5: "Lass den Zugriff auf Dateien und Medien zu"
ios:
1: "Geh zu 'Einstellungen'"
2: "Wähle 'IO'"
3: "Wähle 'Fotos' und erlaube den Zugriff"
cta: "Öffne Einstellungen"
FIMS:
updateApp:
header: "Aktualisiere die App, um fortzufahren"
Expand Down
18 changes: 0 additions & 18 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4189,24 +4189,6 @@ transaction:
subject: Oggetto del pagamento
noticeCode: Codice avviso
taxCode: Codice Fiscale Ente
permissionRequest:
gallery:
title: Consenti a IO di accedere alle tue foto
subtitle: Per farlo, devi modificare le preferenze nelle impostazioni di sistema del tuo dispositivo.
caption: "Ecco come:"
step: Step {{step}}
steps:
android:
1: Vai su “Impostazioni”
2: Seleziona “Applicazioni”
3: Seleziona “IO”
4: Seleziona la voce relativa alle autorizzazioni
5: Consenti l’accesso a file e media
ios:
1: Vai su “Impostazioni”
2: Seleziona “IO”
3: Seleziona “Foto” e consenti l’accesso
cta: Apri Impostazioni
FIMS:
updateApp:
header: "Aggiorna l’app per proseguire"
Expand Down
18 changes: 0 additions & 18 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4189,24 +4189,6 @@ transaction:
subject: Oggetto del pagamento
noticeCode: Codice avviso
taxCode: Codice Fiscale Ente
permissionRequest:
gallery:
title: Consenti a IO di accedere alle tue foto
subtitle: Per farlo, devi modificare le preferenze nelle impostazioni di sistema del tuo dispositivo.
caption: "Ecco come:"
step: Step {{step}}
steps:
android:
1: Vai su “Impostazioni”
2: Seleziona “Applicazioni”
3: Seleziona “IO”
4: Seleziona la voce relativa alle autorizzazioni
5: Consenti l’accesso a file e media
ios:
1: Vai su “Impostazioni”
2: Seleziona “IO”
3: Seleziona “Foto” e consenti l’accesso
cta: Apri Impostazioni
FIMS:
updateApp:
header: "Aggiorna l’app per proseguire"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"react-native-haptic-feedback": "^2.3.3",
"react-native-i18n": "^2.0.15",
"react-native-image-pan-zoom": "^2.1.11",
"react-native-image-picker": "7.2.2",
"react-native-image-picker": "7.2.3",
"react-native-keychain": "^4.0.5",
"react-native-linear-gradient": "^2.5.6",
"react-native-markdown-display": "^7.0.2",
Expand Down
14 changes: 0 additions & 14 deletions ts/features/barcode/hooks/useIOBarcodeFileReader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Divider, ListItemNav, VSpacer } from "@pagopa/io-app-design-system";
import { useNavigation } from "@react-navigation/native";
import * as A from "fp-ts/lib/Array";
import * as E from "fp-ts/lib/Either";
import * as O from "fp-ts/lib/Option";
Expand All @@ -19,13 +18,7 @@ import {
ImageLibraryOptions
} from "react-native-image-picker";
import I18n from "../../../i18n";
import {
AppParamsList,
IOStackNavigationProp
} from "../../../navigation/params/AppParamsList";
import ROUTES from "../../../navigation/routes";
import { useIOBottomSheetAutoresizableModal } from "../../../utils/hooks/bottomSheet";
import { requestMediaPermission } from "../../../utils/permission";
import {
BarcodeAnalyticsFlow,
trackBarcodeFileUpload,
Expand Down Expand Up @@ -118,7 +111,6 @@ const useIOBarcodeFileReader = ({
}: IOBarcodeFileReaderConfiguration): IOBarcodeFileReader => {
const [isFilePickerVisible, setFilePickerVisible] = React.useState(false);
const [isLoading, setIsLoading] = React.useState(false);
const navigation = useNavigation<IOStackNavigationProp<AppParamsList>>();

const handleBarcodeSuccess = (barcodes: Array<IOBarcode>) => {
setIsLoading(false);
Expand Down Expand Up @@ -176,12 +168,6 @@ const useIOBarcodeFileReader = ({
};

const showImagePicker = async () => {
const permissionGranted = await requestMediaPermission();
if (!permissionGranted) {
navigation.navigate(ROUTES.GALLERY_PERMISSION_INSTRUCTIONS);
return;
}

setIsLoading(true);

void launchImageLibrary(imageLibraryOptions, onImageSelected);
Expand Down
9 changes: 0 additions & 9 deletions ts/navigation/AuthenticatedStackNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import ServicesNavigator from "../features/services/common/navigation/navigator"
import { SERVICES_ROUTES } from "../features/services/common/navigation/routes";
import { ZendeskStackNavigator } from "../features/zendesk/navigation/navigator";
import ZENDESK_ROUTES from "../features/zendesk/navigation/routes";
import { GalleryPermissionInstructionsScreen } from "../screens/misc/GalleryPermissionInstructionsScreen";
import { PaymentsReceiptRoutes } from "../features/payments/receipts/navigation/routes";
import { PaymentsReceiptNavigator } from "../features/payments/receipts/navigation/navigator";
import { useIOSelector } from "../store/hooks";
Expand Down Expand Up @@ -188,14 +187,6 @@ const AuthenticatedStackNavigator = () => {
}}
/>

<Stack.Screen
name={ROUTES.GALLERY_PERMISSION_INSTRUCTIONS}
component={GalleryPermissionInstructionsScreen}
options={{
gestureEnabled: isGestureEnabled
}}
/>

{cgnEnabled && (
<Stack.Screen
name={CGN_ROUTES.ACTIVATION.MAIN}
Expand Down
2 changes: 0 additions & 2 deletions ts/navigation/params/AppParamsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ export type AppParamsList = {

[ROUTES.BARCODE_SCAN]: undefined;

[ROUTES.GALLERY_PERMISSION_INSTRUCTIONS]: undefined;

[CGN_ROUTES.ACTIVATION.MAIN]: NavigatorScreenParams<CgnActivationParamsList>;
[CGN_ROUTES.DETAILS.MAIN]: NavigatorScreenParams<CgnDetailsParamsList>;
[CGN_ROUTES.EYCA.ACTIVATION
Expand Down
3 changes: 0 additions & 3 deletions ts/navigation/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ const ROUTES = {
// Barcode scan
BARCODE_SCAN: "BARCODE_SCAN",

// Misc
GALLERY_PERMISSION_INSTRUCTIONS: "GALLERY_PERMISSION_INSTRUCTIONS",

// Developer Mode
DESIGN_SYSTEM: "DESIGN_SYSTEM",
CGN_LANDING_PLAYGROUND: "CGN_LANDING_PLAYGROUND",
Expand Down
109 changes: 0 additions & 109 deletions ts/screens/misc/GalleryPermissionInstructionsScreen.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions ts/utils/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,25 +56,3 @@ export const requestWriteCalendarPermission = async (
ios: Promise.resolve(true),
default: Promise.resolve(true)
});

/**
* Wrapper function to request permission to read images from the gallery
* @returns boolean that indicates wether the user has granted the permission or not
*/
export const requestMediaPermission = async () => {
switch (Platform.OS) {
case "android":
return requestIOPermission(
Platform.Version >= 33
? RNPermissions.PERMISSIONS.ANDROID.READ_MEDIA_IMAGES
: RNPermissions.PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE
);
case "ios":
// On iOS, photo selection from the gallery is implicitly handled by the image picker.
// The picker itself prompts the user for permission to access photos, allowing them to
// select a photo that is then seamlessly passed back to the app.
return true;
default:
return false;
}
};
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13693,7 +13693,7 @@ __metadata:
react-native-haptic-feedback: ^2.3.3
react-native-i18n: ^2.0.15
react-native-image-pan-zoom: ^2.1.11
react-native-image-picker: 7.2.2
react-native-image-picker: 7.2.3
react-native-keychain: ^4.0.5
react-native-linear-gradient: ^2.5.6
react-native-markdown-display: ^7.0.2
Expand Down Expand Up @@ -19007,13 +19007,13 @@ __metadata:
languageName: node
linkType: hard

"react-native-image-picker@npm:7.2.2":
version: 7.2.2
resolution: "react-native-image-picker@npm:7.2.2"
"react-native-image-picker@npm:7.2.3":
version: 7.2.3
resolution: "react-native-image-picker@npm:7.2.3"
peerDependencies:
react: "*"
react-native: "*"
checksum: 34289e29a28c3f8d869db46fdf5bfdeec8b37221ee4dcd9a63698b106f0097d11f4c40f3a2789c23a728dc94e37e02a0cf61add80aa04ffe60a6cf82115cddea
checksum: 96d67516e8e1c1768c593ca1b0a507d5212d8ac5df2610ad9d6f38c188b8d0720966559867849f74b6c19d2500664ce17c907e5fa37ab72487abd363cf493e7d
languageName: node
linkType: hard

Expand Down

0 comments on commit 19507a3

Please sign in to comment.