added expo-linking to allow SMSTO & EMAILTO

This commit is contained in:
2024-08-12 18:44:24 +08:00
parent db115f1a58
commit 9b81225fb1
21 changed files with 64 additions and 18782 deletions

View File

@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.safeqr.safeqr"> <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.CAMERA"/> <uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
@@ -14,11 +14,9 @@
</intent> </intent>
</queries> </queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="true" android:theme="@style/AppTheme"> <application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:allowBackup="true" android:theme="@style/AppTheme">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="true"/> <meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="51.0.0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/> <meta-data android:name="expo.modules.updates.EXPO_UPDATES_LAUNCH_WAIT_MS" android:value="0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATE_URL" android:value="https://exp.host/@piggyinu/safeqr"/>
<activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait"> <activity android:name=".MainActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize|screenLayout|uiMode" android:launchMode="singleTask" android:windowSoftInputMode="adjustResize" android:theme="@style/Theme.App.SplashScreen" android:exported="true" android:screenOrientation="portrait">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 KiB

After

Width:  |  Height:  |  Size: 189 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

View File

@@ -5,7 +5,6 @@
<item name="android:editTextBackground">@drawable/rn_edit_text_material</item> <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="android:statusBarColor">#ffffff</item> <item name="android:statusBarColor">#ffffff</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
</style> </style>
<style name="ResetEditText" parent="@android:style/Widget.EditText"> <style name="ResetEditText" parent="@android:style/Widget.EditText">
<item name="android:padding">0dp</item> <item name="android:padding">0dp</item>

View File

@@ -58,5 +58,4 @@ EX_DEV_CLIENT_NETWORK_INSPECTOR=true
# Use legacy packaging to compress native libraries in the resulting APK. # Use legacy packaging to compress native libraries in the resulting APK.
expo.useLegacyPackaging=false expo.useLegacyPackaging=false
expo.jsEngine=jsc
VisionCamera_enableCodeScanner=true VisionCamera_enableCodeScanner=true

View File

@@ -1,9 +1,14 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { View, Text, StyleSheet, Image, TouchableOpacity, Modal, ActivityIndicator, ScrollView, Dimensions, Linking, Clipboard } from 'react-native'; import { View, Text, StyleSheet, Image, TouchableOpacity, Modal, ActivityIndicator, ScrollView, Dimensions, Clipboard, Platform } from 'react-native';
import QRCode from 'react-native-qrcode-svg'; import QRCode from 'react-native-qrcode-svg';
import { Ionicons, MaterialCommunityIcons, SimpleLineIcons } from '@expo/vector-icons'; import { Ionicons, MaterialCommunityIcons, SimpleLineIcons } from '@expo/vector-icons';
import { getQRCodeDetails } from '../api/qrCodeAPI'; import { getQRCodeDetails } from '../api/qrCodeAPI';
import SecureWebView from '../components/SecureWebView'; import SecureWebView from '../components/SecureWebView';
import { startActivityAsync, ActivityAction } from 'expo-intent-launcher';
import * as Linking from 'expo-linking';
@@ -159,12 +164,6 @@ const getEncryptionStatus = (encryption) => {
const { text: encryptionText, icon: encryptionIcon } = getEncryptionStatus(encryption); const { text: encryptionText, icon: encryptionIcon } = getEncryptionStatus(encryption);
// Function to handle the connect to WiFi action
const handleConnectToWifi = (wifiContent) => {
Linking.openURL(wifiContent).catch(err => console.error('Error connecting to WiFi:', err));
};
// Function to open the Wi-Fi configuration in the OS // Function to open the Wi-Fi configuration in the OS
const handleOpenUrl = (url: string) => { const handleOpenUrl = (url: string) => {
Linking.openURL(url).catch(err => console.error('Error opening URL:', err)); Linking.openURL(url).catch(err => console.error('Error opening URL:', err));
@@ -175,16 +174,23 @@ const handleConnectToWifi = (wifiContent) => {
Clipboard.setString(contents); Clipboard.setString(contents);
}; };
// Function to send SMS const constructSMSUrl = (contents) => {
const handleSendSMS = () => { // Split the contents and extract the phone number and message
const smsUrl = `sms:${contents}`; const [phone, ...messageParts] = contents.split(':').slice(1);
Linking.openURL(smsUrl).catch(err => console.error('Error sending SMS:', err)); const message = messageParts.join(':');
};
// Log the extracted phone number and message
// Function to make a phone call console.log('Phone:', phone);
const handleMakeCall = () => { console.log('Message:', message);
const telUrl = `tel:${contents}`;
Linking.openURL(telUrl).catch(err => console.error('Error making call:', err)); // Construct the SMS URL based on the platform
if (Platform.OS === 'android') {
return `sms:${phone}?body=${message}`;
} else if (Platform.OS === 'ios') {
return `sms:${phone};body=${message}`;
} else {
return `sms:${phone}`; // Fallback if platform is unknown
}
}; };
return ( return (
@@ -309,11 +315,16 @@ const handleConnectToWifi = (wifiContent) => {
{/* Divider */} {/* Divider */}
<View style={styles.dividerHorizontal} /> <View style={styles.dividerHorizontal} />
{/* Connect to WiFi Button */} {/* Connect to Wi-Fi Button */}
<TouchableOpacity style={styles.connectButton} onPress={() => handleConnectToWifi(contents)}> <TouchableOpacity
<Ionicons name="wifi-outline" size={screenWidth * 0.045} color="#fff" /> style={[styles.connectButton, { backgroundColor: resultColor }]}
<Text style={styles.connectButtonText}>Connect to WiFi</Text> onPress={() => {
</TouchableOpacity> startActivityAsync(ActivityAction.WIFI_SETTINGS)
.catch(err => console.error('Error opening Wi-Fi settings:', err));
}}
>
<Text style={styles.connectButtonText}>Connect to Wi-Fi</Text>
</TouchableOpacity>
</> </>
)} )}
@@ -321,35 +332,34 @@ const handleConnectToWifi = (wifiContent) => {
{/* TEXT Type */} {type === 'TEL' && (
{type === 'TEXT' && ( <TouchableOpacity style={styles.iconButton} onPress={() => Linking.openURL(contents)}>
<View style={styles.iconContainer}> <Ionicons name="call-outline" size={screenWidth * 0.045} color="#2196F3" />
<TouchableOpacity style={styles.iconButton} onPress={handleCopyToClipboard}> <Text style={styles.iconText}>Call Number</Text>
<Ionicons name="clipboard-outline" size={screenWidth * 0.045} color="#2196F3" /> </TouchableOpacity>
<Text style={styles.iconText}>Copy</Text> )}
</TouchableOpacity>
</View> {type === 'SMS' && (
)} <TouchableOpacity
style={styles.iconButton}
onPress={() => {
const smsUrl = constructSMSUrl(contents);
Linking.openURL(smsUrl).catch(err => console.error('Error sending SMS:', err));
}}
>
<Ionicons name="chatbubble-outline" size={screenWidth * 0.045} color="#2196F3" />
<Text style={styles.iconText}>Send SMS</Text>
</TouchableOpacity>
)}
{type === 'EMAIL' && (
<TouchableOpacity style={styles.iconButton} onPress={() => Linking.openURL(contents)}>
<Ionicons name="mail-outline" size={screenWidth * 0.045} color="#2196F3" />
<Text style={styles.iconText}>Send Email</Text>
</TouchableOpacity>
)}
{/* SMS Type */}
{type === 'SMS' && (
<View style={styles.iconContainer}>
<TouchableOpacity style={styles.iconButton} onPress={handleSendSMS}>
<Ionicons name="chatbubble-outline" size={screenWidth * 0.045} color="#2196F3" />
<Text style={styles.iconText}>Send SMS</Text>
</TouchableOpacity>
</View>
)}
{/* TEL Type */}
{type === 'TEL' && (
<View style={styles.iconContainer}>
<TouchableOpacity style={styles.iconButton} onPress={handleMakeCall}>
<Ionicons name="call-outline" size={screenWidth * 0.045} color="#2196F3" />
<Text style={styles.iconText}>Call</Text>
</TouchableOpacity>
</View>
)}
{/* Full Content Modal */} {/* Full Content Modal */}
<Modal <Modal

18725
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -33,6 +33,8 @@
"expo-dev-client": "~4.0.19", "expo-dev-client": "~4.0.19",
"expo-image-manipulator": "^12.0.5", "expo-image-manipulator": "^12.0.5",
"expo-image-picker": "~15.0.7", "expo-image-picker": "~15.0.7",
"expo-intent-launcher": "~11.0.1",
"expo-linking": "~6.3.1",
"expo-sharing": "~12.0.1", "expo-sharing": "~12.0.1",
"expo-status-bar": "~1.12.1", "expo-status-bar": "~1.12.1",
"react": "18.2.0", "react": "18.2.0",
@@ -48,8 +50,7 @@
"react-native-vision-camera": "^4.5.1", "react-native-vision-camera": "^4.5.1",
"react-native-webview": "^13.8.6", "react-native-webview": "^13.8.6",
"react-redux": "^9.1.2", "react-redux": "^9.1.2",
"redux": "^5.0.1", "redux": "^5.0.1"
"safeqr": "file:"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.20.0", "@babel/core": "^7.20.0",