mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 16:05:39 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fbfb887e0a | ||
|
|
10db4c503a |
Generated
+13
-2
@@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "bulwark-mobile",
|
"name": "bulwark-mobile",
|
||||||
"version": "1.0.0",
|
"version": "0.1.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "bulwark-mobile",
|
"name": "bulwark-mobile",
|
||||||
"version": "1.0.0",
|
"version": "0.1.2",
|
||||||
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
"@react-native-community/datetimepicker": "8.4.4",
|
"@react-native-community/datetimepicker": "8.4.4",
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
"expo": "~54.0.33",
|
"expo": "~54.0.33",
|
||||||
"expo-file-system": "~19.0.21",
|
"expo-file-system": "~19.0.21",
|
||||||
"expo-image-picker": "~17.0.10",
|
"expo-image-picker": "~17.0.10",
|
||||||
|
"expo-intent-launcher": "~13.0.8",
|
||||||
"expo-secure-store": "~15.0.8",
|
"expo-secure-store": "~15.0.8",
|
||||||
"expo-sharing": "~14.0.8",
|
"expo-sharing": "~14.0.8",
|
||||||
"expo-status-bar": "~3.0.9",
|
"expo-status-bar": "~3.0.9",
|
||||||
@@ -5234,6 +5236,15 @@
|
|||||||
"expo": "*"
|
"expo": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/expo-intent-launcher": {
|
||||||
|
"version": "13.0.8",
|
||||||
|
"resolved": "https://registry.npmjs.org/expo-intent-launcher/-/expo-intent-launcher-13.0.8.tgz",
|
||||||
|
"integrity": "sha512-sgGFotttKKN6dIatjOEJT8M6Arfakus7vIxgshg5VkxarVhZBGJzOJam7rbUlB1O/gQ8em9G8vhEU9AfjEIe7A==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"expo": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/expo-modules-autolinking": {
|
"node_modules/expo-modules-autolinking": {
|
||||||
"version": "3.0.24",
|
"version": "3.0.24",
|
||||||
"resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-3.0.24.tgz",
|
"resolved": "https://registry.npmjs.org/expo-modules-autolinking/-/expo-modules-autolinking-3.0.24.tgz",
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "bulwark-mobile",
|
"name": "bulwark-mobile",
|
||||||
"version": "0.1.2",
|
"version": "0.1.3",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"expo": "~54.0.33",
|
"expo": "~54.0.33",
|
||||||
"expo-file-system": "~19.0.21",
|
"expo-file-system": "~19.0.21",
|
||||||
"expo-image-picker": "~17.0.10",
|
"expo-image-picker": "~17.0.10",
|
||||||
|
"expo-intent-launcher": "~13.0.8",
|
||||||
"expo-secure-store": "~15.0.8",
|
"expo-secure-store": "~15.0.8",
|
||||||
"expo-sharing": "~14.0.8",
|
"expo-sharing": "~14.0.8",
|
||||||
"expo-status-bar": "~3.0.9",
|
"expo-status-bar": "~3.0.9",
|
||||||
|
|||||||
@@ -1,21 +1,26 @@
|
|||||||
import { Platform } from 'react-native';
|
import { Platform } from 'react-native';
|
||||||
import { File, Paths } from 'expo-file-system';
|
import { File, Paths } from 'expo-file-system';
|
||||||
import * as Sharing from 'expo-sharing';
|
import * as FileSystemLegacy from 'expo-file-system/legacy';
|
||||||
|
import * as IntentLauncher from 'expo-intent-launcher';
|
||||||
import type { ReleaseAsset } from '../api/updates';
|
import type { ReleaseAsset } from '../api/updates';
|
||||||
|
|
||||||
|
const FLAG_GRANT_READ_URI_PERMISSION = 0x00000001;
|
||||||
|
const FLAG_ACTIVITY_NEW_TASK = 0x10000000;
|
||||||
|
|
||||||
export async function downloadAndInstallApk(asset: ReleaseAsset): Promise<void> {
|
export async function downloadAndInstallApk(asset: ReleaseAsset): Promise<void> {
|
||||||
if (Platform.OS !== 'android') {
|
if (Platform.OS !== 'android') {
|
||||||
throw new Error('APK install is only supported on Android');
|
throw new Error('APK install is only supported on Android');
|
||||||
}
|
}
|
||||||
|
|
||||||
const dest = new File(Paths.cache, asset.name);
|
const dest = new File(Paths.cache, asset.name);
|
||||||
if (dest.exists) dest.delete();
|
if (dest.exists) dest.delete();
|
||||||
const downloaded = await File.downloadFileAsync(asset.browser_download_url, dest);
|
const downloaded = await File.downloadFileAsync(asset.browser_download_url, dest);
|
||||||
if (!(await Sharing.isAvailableAsync())) {
|
|
||||||
throw new Error('Sharing is not available on this device');
|
const contentUri = await FileSystemLegacy.getContentUriAsync(downloaded.uri);
|
||||||
}
|
|
||||||
await Sharing.shareAsync(downloaded.uri, {
|
await IntentLauncher.startActivityAsync('android.intent.action.VIEW', {
|
||||||
mimeType: 'application/vnd.android.package-archive',
|
data: contentUri,
|
||||||
dialogTitle: 'Install update',
|
type: 'application/vnd.android.package-archive',
|
||||||
UTI: 'com.android.package-archive',
|
flags: FLAG_GRANT_READ_URI_PERMISSION | FLAG_ACTIVITY_NEW_TASK,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user