Skip to content

Commit

Permalink
Merge pull request #1 from 100Daisy/staging
Browse files Browse the repository at this point in the history
Merge staging into main
  • Loading branch information
100Daisy authored Oct 16, 2023
2 parents 774d2f2 + cdb1c95 commit 6ad1a78
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 3,053 deletions.
57 changes: 28 additions & 29 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { StyleSheet, FlatList, Clipboard, useColorScheme, Linking } from 'react-
import { PaperProvider, Button, Card, Chip, Text, Searchbar, Appbar, Snackbar, SegmentedButtons, ActivityIndicator } from 'react-native-paper';
import ReactNativeBlobUtil from 'react-native-blob-util';
import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
import { pickDirectory } from 'react-native-document-picker'
import { MD3DarkTheme, MD3LightTheme } from 'react-native-paper';

import { useMaterial3Theme } from '@pchmn/expo-material3-theme';
Expand All @@ -12,7 +11,11 @@ import { useMaterial3Theme } from '@pchmn/expo-material3-theme';
import Papa from "papaparse"
import { useState, useEffect } from 'react';

import { trigger } from "react-native-haptic-feedback";

export default function App() {
const dirs = ReactNativeBlobUtil.fs.dirs

const colorScheme = useColorScheme();
const { theme } = useMaterial3Theme();
const paperTheme =
Expand All @@ -24,15 +27,16 @@ export default function App() {
// paddingHorizontal: 20,
backgroundColor: paperTheme.colors.background,
},
item: {
},
chip: {
flex: 1,
flexDirection: 'row',
},
card: {
borderRadius: 25,
marginVertical: 10,
},
snackbar: {
backgroundColor: paperTheme.colors.primary,
}
});
const [value, setValue] = useState('PSV');
Expand All @@ -52,37 +56,31 @@ export default function App() {
setSearchQuery(query)
};

function contentURItoPath(contentURI) {
// revert url decode
contentURI = decodeURIComponent(contentURI)
const path = contentURI.replace('content://com.android.externalstorage.documents/tree/primary:', '/storage/emulated/0/');
return path
}
async function downloadFile(item) {
await pickDirectory().then((result) => {
ReactNativeBlobUtil.config({
addAndroidDownloads : {
useDownloadManager : true, // <-- this is the only thing required
notification : true,
// Optional, override notification setting (default to true)
// Optional, but recommended since android DownloadManager will fail when
// the url does not contains a file extension, by default the mime type will be text/plain
mime : 'text/plain',
description : 'File downloaded by download manager.',
path : contentURItoPath(result.uri) + `/${item["Name"]}.pkg`,
}
})
.fetch('GET', item["PKG direct link"])
.then((resp) => {
resp.path()
})
}).catch((err) => {
setSnackbarText(err.message)
trigger('effectClick')
setSnackbar(true)
setSnackbarText(`Downloading ${item["Name"]}...`)
// show all dirs properties
ReactNativeBlobUtil.config({
addAndroidDownloads : {
useDownloadManager : true,
notification : true,
path : `${dirs.LegacyDownloadDir}/NPSReact/${item["Name"]}.pkg`,
}
})
.fetch('GET', item["PKG direct link"])
.then((resp) => {
resp.path()
})
.catch((err) => {
trigger('notificationError')
setSnackbar(true)
setSnackbarText(`Error downloading ${item["Name"]}`)
})
}

function getLatestTSV(console) {
trigger('effectClick')
setSearchQuery('')
setFilteredData([])
setFetching(true)
Expand Down Expand Up @@ -114,6 +112,7 @@ export default function App() {
<Appbar.Content title="NoPayStation" onPress={async () => {
const supported = await Linking.canOpenURL('https://nopaystation.com');
if (supported) {
trigger('effectClick')
Linking.openURL('https://nopaystation.com')}
}
} />
Expand Down Expand Up @@ -162,7 +161,7 @@ export default function App() {
<Card.Actions>
<Button mode="contained" onPress={() => downloadFile(item)}>Download</Button>
{
item["zRIF"] ? <Button mode="contained-tonal" onPress={() => Clipboard.setString(item["zRIF"])}>zRIF</Button> : null
item["zRIF"] ? <Button mode="contained-tonal" onPress={() => {Clipboard.setString(item["zRIF"]); trigger('effectClick')}}>zRIF</Button> : null
}
</Card.Actions>
</Card>
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<data android:scheme="https"/>
</intent>
</queries>
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme">
<application android:name=".MainApplication" android:label="@string/app_name" android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:allowBackup="true" android:theme="@style/AppTheme" android:usesCleartextTraffic="true">
<meta-data android:name="expo.modules.updates.ENABLED" android:value="false"/>
<meta-data android:name="expo.modules.updates.EXPO_SDK_VERSION" android:value="49.0.0"/>
<meta-data android:name="expo.modules.updates.EXPO_UPDATES_CHECK_ON_LAUNCH" android:value="ALWAYS"/>
Expand Down
Loading

0 comments on commit 6ad1a78

Please sign in to comment.