Skip to content

Commit

Permalink
fix(inji-522): enable the location service before initiating the vc s…
Browse files Browse the repository at this point in the history
…haring. (#1004)

* fix(inji-522): enable the location service before initiating the vc sharing.

Signed-off-by: Vijay <[email protected]>

* fix(inji-522): update literals in the location service enabling popup

Signed-off-by: Vijay <[email protected]>

* fix(inji-522): update checkLocation state name

Signed-off-by: Vijay <[email protected]>

* fix(inji-522): removed duplicate namespace

Signed-off-by: Vijay <[email protected]>

---------

Signed-off-by: Vijay <[email protected]>
  • Loading branch information
vijay151096 authored Nov 16, 2023
1 parent a557b67 commit b0ebef0
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 270 deletions.
13 changes: 4 additions & 9 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
plugins {
plugins {
id 'com.gladed.androidgitversion' version '0.4.14'
}

apply plugin: "com.android.application"
apply plugin: "com.facebook.react"

import com.android.build.OutputFile

react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
Expand Down Expand Up @@ -102,9 +100,6 @@ android {
}


namespace 'io.mosip.residentapp'


namespace 'io.mosip.residentapp'

defaultConfig {
Expand All @@ -130,7 +125,7 @@ android {
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}

signingConfigs {
release {
def keystore = file('release.keystore')
Expand Down Expand Up @@ -232,7 +227,7 @@ dependencies {
implementation 'com.facebook.fresco:animated-webp:2.0.0'
}
}

compileOnly project(':react-native-android-location-services-dialog-box')
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
Expand All @@ -252,4 +247,4 @@ dependencies {
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: "./eas-build.gradle"
apply from: "./eas-build.gradle"
5 changes: 3 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ rootProject.name = 'Inji'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/react-native-gradle-plugin')

include ':react-native-android-location-services-dialog-box'
project(':react-native-android-location-services-dialog-box').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-android-location-services-dialog-box/android')
apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
useExpoModules()
3 changes: 2 additions & 1 deletion locales/ara.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
"sharingVc": "مشاركة بطاقة ",
"errors": {
"locationDisabled": {
"message": "يجب تمكين خدمات الموقع لمشاركة البطاقة",
"message": "للمتابعة، اسمح لجهازك بتشغيل الموقع",
"button": "تمكين خدمات الموقع"
},
"locationDenied": {
Expand Down Expand Up @@ -593,6 +593,7 @@
"cancel": "إلغاء",
"accept": "يقبل",
"save": "حفظ",
"ok": "نعم",
"dismiss": "رفض",
"editLabel": "يحرر {{label}}",
"tryAgain": "حاول مجددا",
Expand Down
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
"scanningGuide": "Hold the phone steady and scan the QR code",
"errors": {
"locationDisabled": {
"message": "Location services must be enabled to share card",
"message": "To continue, let your device turn on location",
"button": "Enable location services"
},
"locationDenied": {
Expand Down
3 changes: 2 additions & 1 deletion locales/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@
"scanningGuide": "Panatilihin ang telepono at i-scan ang QR code",
"errors": {
"locationDisabled": {
"message": "Dapat na nakabukas ang Location services ng iyong mobile para maaaring makapag-scan",
"message": "Para magpatuloy, hayaang i-on ng iyong device ang lokasyon",
"button": "Buksan ang location services"
},
"locationDenied": {
Expand Down Expand Up @@ -596,6 +596,7 @@
"cancel": "Kanselahin",
"accept": "Tanggapin",
"save": "I-save",
"ok": "Ok",
"dismiss": "Dismissed",
"editLabel": "Palitan ang {{label}}",
"tryAgain": "Subukan muli",
Expand Down
3 changes: 2 additions & 1 deletion locales/hin.json
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@
"scanningGuide": "फ़ोन को स्थिर रखें और QR कोड को स्कैन करें",
"errors": {
"locationDisabled": {
"message": "स्थान सेवाओं को स्कैनिंग कार्यक्षमता के लिए सक्षम किया जाना चाहिए",
"message": "जारी रखने के लिए, अपने डिवाइस को स्थान चालू करने दें",
"button": "स्थान सेवाएं सक्षम करें"
},
"locationDenied": {
Expand Down Expand Up @@ -592,6 +592,7 @@
"common": {
"cancel": "रद्द करें",
"save": "सहेजें",
"ok": "ठीक है",
"dismiss": "नकार देना",
"editLabel": "संपादित करें {{label}}",
"tryAgain": "पुनः प्रयास करें",
Expand Down
3 changes: 2 additions & 1 deletion locales/kan.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
"scanningGuide": "ಫೋನ್ ಅನ್ನು ಸ್ಥಿರವಾಗಿ ಹಿಡಿದುಕೊಳ್ಳಿ ಮತ್ತು QR ಕೋಡ್ ಅನ್ನು ಸ್ಕ್ಯಾನ್ ಮಾಡಿ",
"errors": {
"locationDisabled": {
"message": "ಸ್ಕ್ಯಾನಿಂಗ್ ಕಾರ್ಯಕ್ಕಾಗಿ ಸ್ಥಳ ಸೇವೆಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಬೇಕು",
"message": "ಮುಂದುವರಿಸಲು, ನಿಮ್ಮ ಸಾಧನವು ಸ್ಥಳವನ್ನು ಆನ್ ಮಾಡಲು ಅನುಮತಿಸಿ",
"button": "ಸ್ಥಳ ಸೇವೆಗಳನ್ನು ಸಕ್ರಿಯಗೊಳಿಸಿ"
},
"locationDenied": {
Expand Down Expand Up @@ -591,6 +591,7 @@
"cancel": "ರದ್ದು",
"accept": "ಒಪ್ಪಿಕೊಳ್ಳಿ",
"save": "ಉಳಿಸು",
"ok": "ಸರಿ",
"dismiss": "ವಜಾಗೊಳಿಸಿ",
"editLabel": "ಸಂಪಾದಿಸು {{label}}",
"tryAgain": "ಮತ್ತೆ ಪ್ರಯತ್ನಿಸು",
Expand Down
3 changes: 2 additions & 1 deletion locales/spa.json
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@
"enableBluetoothButtonText": "Permitir permisos de Bluetooth",
"errors": {
"locationDisabled": {
"message": "Los servicios de ubicación deben estar habilitados para compartir la tarjeta",
"message": "Para continuar, deja que tu dispositivo active la ubicación.",
"button": "Habilitar servicios de ubicación"
},
"locationDenied": {
Expand Down Expand Up @@ -501,6 +501,7 @@
"common": {
"cancel": "Cancelar",
"save": "Guardar",
"ok": "Ok",
"dismiss": "Cerrar",
"editLabel": "Editar {{label}}",
"tryAgain": "Intentar de nuevo",
Expand Down
3 changes: 2 additions & 1 deletion locales/tam.json
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
"scanningGuide": "ஃபோனை நிலையாகப் பிடித்து, QR குறியீட்டை ஸ்கேன் செய்யவும்s",
"errors": {
"locationDisabled": {
"message": "ஸ்கேனிங் செயல்பாட்டிற்கு இருப்பிடச் சேவைகள் இயக்கப்பட வேண்டும்",
"message": "தொடர, இருப்பிடத்தை இயக்க உங்கள் சாதனத்தை அனுமதிக்கவும்",
"button": "இருப்பிட சேவைகளை இயக்கு"
},
"locationDenied": {
Expand Down Expand Up @@ -591,6 +591,7 @@
"cancel": "ரத்துசெய்",
"accept": "ஏற்றுக்கொள்",
"save": "சேமி",
"ok": "சரி",
"dismiss": "நிராகரி",
"editLabel": "திருத்து {{label}}",
"tryAgain": "மீண்டும் முயற்சி செய்",
Expand Down
47 changes: 37 additions & 10 deletions machines/bleShare/scan/scanMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import {subscribe} from '../../../shared/openIdBLE/walletEventHandler';
import {
check,
checkMultiple,
PermissionStatus,
PERMISSIONS,
PermissionStatus,
requestMultiple,
RESULTS,
} from 'react-native-permissions';
import {
checkLocationPermissionStatus,
checkLocationService,
requestLocationPermission,
} from '../../../shared/location';
import {CameraCapturedPicture} from 'expo-camera';
Expand All @@ -40,14 +41,14 @@ import {BLEError} from '../types';
import Storage from '../../../shared/storage';
import {VCMetadata} from '../../../shared/VCMetadata';
import {
getStartEventData,
getEndEventData,
sendStartEvent,
sendEndEvent,
sendImpressionEvent,
getErrorEventData,
getImpressionEventData,
getStartEventData,
sendEndEvent,
sendErrorEvent,
getErrorEventData,
sendImpressionEvent,
sendStartEvent,
} from '../../../shared/telemetry/TelemetryUtils';
import {TelemetryConstants} from '../../../shared/telemetry/TelemetryConstants';

Expand Down Expand Up @@ -307,7 +308,7 @@ export const scanMachine =
always: [
{
cond: 'uptoAndroid11',
target: '#scan.checkingLocationService',
target: '#scan.checkingLocationState',
},
{
target: '#scan.clearingConnection',
Expand Down Expand Up @@ -337,7 +338,7 @@ export const scanMachine =
always: [
{
cond: 'uptoAndroid11',
target: '#scan.checkingLocationService',
target: '#scan.checkingLocationState',
},
{
target: '#scan.clearingConnection',
Expand Down Expand Up @@ -678,9 +679,22 @@ export const scanMachine =
},
},
},
checkingLocationService: {
initial: 'checkingPermissionStatus',
checkingLocationState: {
initial: 'checkLocationService',
states: {
checkLocationService: {
invoke: {
src: 'checkLocationStatus',
},
on: {
LOCATION_ENABLED: {
target: 'checkingPermissionStatus',
},
LOCATION_DISABLED: {
target: 'disabled',
},
},
},
checkingPermissionStatus: {
invoke: {
src: 'checkLocationPermission',
Expand Down Expand Up @@ -717,6 +731,13 @@ export const scanMachine =
},
},
},
disabled: {
on: {
LOCATION_REQUEST: {
target: 'checkLocationService',
},
},
},
},
},
},
Expand Down Expand Up @@ -1096,6 +1117,12 @@ export const scanMachine =
() => callback(model.events.LOCATION_DISABLED()),
);
},
checkLocationStatus: () => callback => {
return checkLocationService(
() => callback(model.events.LOCATION_ENABLED()),
() => callback(model.events.LOCATION_DISABLED()),
);
},

startConnection: context => callback => {
wallet.startConnection(context.openId4VpUri);
Expand Down
Loading

0 comments on commit b0ebef0

Please sign in to comment.