diff --git a/App.js b/App.js index 7ab8c17..1ba272b 100644 --- a/App.js +++ b/App.js @@ -3,6 +3,7 @@ import { ActivityIndicator, Button, Linking, Text, View } from "react-native"; import { Styles } from "./Styles"; import AsyncStorage from "@react-native-async-storage/async-storage"; import CheckBox from "@react-native-community/checkbox"; +import DropDownPicker from "react-native-dropdown-picker"; import RNExitApp from "react-native-exit-app"; export default function App() { @@ -10,12 +11,25 @@ export default function App() { const [latestLabel, setLatestLabel] = useState(""); const [latestVersion, setLatestVersion] = useState(""); const [loading, isLoading] = useState(false); - const [status, setStatus] = useState(""); - const [buttonText, setButtonText] = useState("CHECK FOR UPDATES"); + const [statusLabel, setStatusLabel] = useState(""); + const [buttonLabel, setButtonLabel] = useState("CHECK FOR UPDATES"); const [updateFound, wasUpdateFound] = useState(false); + const [updateChecked, wasUpdateChecked] = useState(false); const [downloadUrl, setDownloadUrl] = useState(""); const [forceDownload, doForceDownload] = useState(false); + const [forceCheckboxDisabled, isForceCheckboxDisabled] = useState(false); + const [open, setOpen] = useState(false); + const [apkValue, setApkValue] = useState("universal"); + const [apkItems, setApkItems] = useState([ + { label: "Universal", value: "universal" }, + { label: "arm64-v8a", value: "arm64-v8a" }, + { label: "armeabi-v7a", value: "armeabi-v7a" }, + { label: "x86_64", value: "x86_64" }, + { label: "x86", value: "x86" }, + ]); + + const DOWNLOAD_UPDATE = "DOWNLOAD UPDATE"; const API_URL = "https://api.github.com/repos/InfinityLoop1308/PipePipe/releases/latest"; @@ -26,6 +40,11 @@ export default function App() { if (ver !== null) { setlocalVersion(ver); } + + apk = await AsyncStorage.getItem("apk-value"); + if (apk !== null) { + setApkValue(apk); + } })(); }, []); @@ -52,7 +71,7 @@ export default function App() { }); if (!response.ok) { - setStatus("Unable to fetch!"); + setStatusLabel("Unable to fetch!"); isLoading(false); } else { data = await response.json(); @@ -61,7 +80,7 @@ export default function App() { for (var i = 0; i < dls.length; i++) { url = dls[i].browser_download_url; - if (url.endsWith("-universal-release.apk")) { + if (url.endsWith(`-${apkValue}-release.apk`)) { setDownloadUrl(url); break; } @@ -72,16 +91,18 @@ export default function App() { isLoading(false); if (localVersion.localeCompare(latest) == 0) { - setStatus("Your version is up to date."); + setStatusLabel("Your version is up to date."); if (forceDownload) { - setButtonText("DOWNLOAD UPDATE"); + setButtonLabel(DOWNLOAD_UPDATE); wasUpdateFound(true); } } else { - setStatus("New version found!"); - setButtonText("DOWNLOAD UPDATE"); + setStatusLabel("New version found!"); + setButtonLabel(DOWNLOAD_UPDATE); wasUpdateFound(true); } + + wasUpdateChecked(true); } }; @@ -95,24 +116,48 @@ export default function App() { {latestLabel} {latestVersion} + + APK to download: + { + (async () => { + await AsyncStorage.setItem("apk-value", value); + })(); + }} + /> + - {status} - -