Skip to content

Commit

Permalink
You can now select the APK version + better layout
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoReX committed Sep 15, 2024
1 parent 9e3dfc4 commit ec0b95d
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 38 deletions.
85 changes: 65 additions & 20 deletions App.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@ 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() {
const [localVersion, setlocalVersion] = useState("N/A");
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";

Expand All @@ -26,6 +40,11 @@ export default function App() {
if (ver !== null) {
setlocalVersion(ver);
}

apk = await AsyncStorage.getItem("apk-value");
if (apk !== null) {
setApkValue(apk);
}
})();
}, []);

Expand All @@ -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();
Expand All @@ -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;
}
Expand All @@ -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);
}
};

Expand All @@ -95,24 +116,48 @@ export default function App() {
<Text />
<Text style={Styles.text}>{latestLabel}</Text>
<Text style={Styles.text}>{latestVersion}</Text>
<View style={Styles.dropDown}>
<Text style={Styles.textApk}>APK to download:</Text>
<DropDownPicker
open={open}
value={apkValue}
items={apkItems}
setOpen={setOpen}
setValue={setApkValue}
setItems={setApkItems}
disableBorderRadius={true}
onChangeValue={(value) => {
(async () => {
await AsyncStorage.setItem("apk-value", value);
})();
}}
/>
</View>
</View>
<View style={Styles.footerContainer}>
<Text>{status}</Text>
<Text />
<Button title={buttonText} onPress={updateCheck} />
<Text>{statusLabel}</Text>
<Button title={buttonLabel} onPress={updateCheck} />
<View style={Styles.checkboxContainer}>
<CheckBox
style={Styles.checkbox}
disabled={forceCheckboxDisabled}
value={forceDownload}
onValueChange={(newValue) => {
doForceDownload(true);
isForceCheckboxDisabled(true);

if (updateChecked) {
setButtonLabel(DOWNLOAD_UPDATE);
wasUpdateFound(true);
}
}}
/>
<Text style={Styles.checkBoxLabel}>FORCE DOWNLOAD</Text>
</View>
{loading && <Text />}
{loading && <ActivityIndicator size="large" />}
<Text />
</View>
<View style={Styles.checkboxContainer}>
<CheckBox
style={Styles.checkbox}
disabled={false}
value={forceDownload}
onValueChange={(newValue) => doForceDownload(newValue)}
/>
<Text style={Styles.checkText}>FORCE DOWNLOAD</Text>
</View>
</View>
);
}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ App made to update PipePipe (https://github.com/InfinityLoop1308/PipePipe) more


## Screenshots
![Screenshot 1](/screenshots/Screenshot_1726407159.png)
![Screenshot 1](/screenshots/screenshot1.png) ![Screenshot 2](/screenshots/screenshot2.png)
![Screenshot 3](/screenshots/screenshot3.png) ![Screenshot 4](/screenshots/screenshot4.png)

![Screenshot 2](/screenshots/Screenshot_1726407185.png)

![Screenshot 3](/screenshots/Screenshot_1726407220.png)

![Screenshot 4](/screenshots/Screenshot_1726407227.png)
17 changes: 14 additions & 3 deletions Styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const Styles = StyleSheet.create({
footerContainer: {
flex: 1 / 3,
alignItems: "center",
marginBottom: 50,
marginBottom: 110,
marginHorizontal: 5,
textAlign: "center",
},
Expand All @@ -26,7 +26,7 @@ export const Styles = StyleSheet.create({
},
text: {
color: "#000",
fontSize: 36,
fontSize: 28,
textTransform: "uppercase",
},
textTitle: {
Expand All @@ -39,7 +39,18 @@ export const Styles = StyleSheet.create({
checkbox: {
alignSelf: "center",
},
checkText: {
checkBoxLabel: {
marginLeft: -3,
margin: 5,
},
dropDown: {
marginTop: 60,
marginHorizontal: 60,
alignItems: "center",
},
textApk: {
color: "#000",
fontSize: 22,
textTransform: "uppercase",
},
});
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"expo": {
"name": "PipepipeUpdater",
"slug": "PipepipeUpdater",
"version": "1.0.0",
"name": "PipePipeUpdater",
"slug": "PipePipeUpdater",
"version": "1.1",
"orientation": "portrait",
"icon": "./assets/icon.png",
"userInterfaceStyle": "light",
Expand Down
19 changes: 15 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pipepipeupdater",
"version": "1.0.0",
"name": "PipePipeUpdater",
"version": "1.1",
"main": "expo/AppEntry.js",
"scripts": {
"start": "expo start",
Expand All @@ -15,6 +15,7 @@
"expo-status-bar": "~1.12.1",
"react": "18.2.0",
"react-native": "0.74.5",
"react-native-dropdown-picker": "^5.4.6",
"react-native-exit-app": "^2.0.0"
},
"devDependencies": {
Expand Down
Binary file removed screenshots/Screenshot_1726407159.png
Binary file not shown.
Binary file removed screenshots/Screenshot_1726407185.png
Binary file not shown.
Binary file removed screenshots/Screenshot_1726407220.png
Binary file not shown.
Binary file removed screenshots/Screenshot_1726407227.png
Binary file not shown.
Binary file added screenshots/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/screenshot4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ec0b95d

Please sign in to comment.