Skip to content

Use QR Code for Setup #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { EvaIconsPack } from "@ui-kitten/eva-icons";
import * as SplashScreen from "expo-splash-screen";
import { decode, encode } from "base-64";
import translations from "./i18n";
import QRCodeCamera from "./screens/QRCodeCamera";

if (!global.btoa) {
global.btoa = encode;
Expand Down Expand Up @@ -82,6 +83,14 @@ function AppNavigator() {
presentation: "modal",
}}
/>
<Stack.Screen
name="QRCodeCamera"
component={QRCodeCamera}
options={{
animation: "slide_from_bottom",
presentation: "modal",
}}
/>
</>
)}
</Stack.Navigator>
Expand Down
10 changes: 9 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"CFBundleDevelopmentRegion": "de",
"CFBundleAllowMixedLocalizations": true,
"NSLocalNetworkUsageDescription": "Die App benötigt Zugriff auf das lokale Netzwerk, um deine evcc Instanz zu finden.",
"NSCameraUsageDescription": "Die App benötigt Kamerazugriff zum Scannen von QR-Codes.",
"NSAppTransportSecurity": {
"NSAllowsArbitraryLoads": true
},
Expand All @@ -37,7 +38,8 @@
"permissions": [
"android.permission.ACCESS_NETWORK_STATE",
"android.permission.ACCESS_WIFI_STATE",
"android.permission.CHANGE_WIFI_MULTICAST_STATE"
"android.permission.CHANGE_WIFI_MULTICAST_STATE",
"android.permission.CAMERA"
],
"package": "io.evcc.android",
"adaptiveIcon": {
Expand All @@ -60,6 +62,12 @@
"plugins": [
["./scripts/fdroid/removeDKBuildId.js"],
["./scripts/fdroid/disableDependencyMetadata.js"],
[
"expo-camera",
{
"cameraPermission": "Allow evcc to access your camera to scan QR codes"
}
],
[
"expo-build-properties",
{
Expand Down
45 changes: 45 additions & 0 deletions components/ScanQRCodeButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { Button, ButtonProps } from "@ui-kitten/components";
import { useTranslation } from "react-i18next";
import { useCameraPermissions } from "expo-camera";
import { Linking } from "react-native";

export default function ScanQRCodeButton({ navigation }) {
const { t } = useTranslation();
const [permission, requestPermission] = useCameraPermissions();

function qrCodeButton(s: string, props: ButtonProps = {}) {
return (
<Button
style={{ marginVertical: 8 }}
appearance="outline"
status="primary"
{...props}
>
{t(`servers.manually.qrcode.${s}`)}
</Button>
);
}

if (!permission) {
return;
} else if (!permission.canAskAgain) {
return qrCodeButton("permissionDenied", {
onPress: async () => {
await Linking.openSettings();
},
});
} else {
return qrCodeButton("scan", {
onPress: async () => {
if (!permission.granted) {
const result = await requestPermission();
if (result.granted) {
navigation.navigate("QRCodeCamera");
}
} else {
navigation.navigate("QRCodeCamera");
}
},
});
}
}
11 changes: 9 additions & 2 deletions i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
"serverIncompatible": "Die evcc Instanz ist noch nicht App-kompatibel. Aktualisiere deine Installation.",
"serverNotAvailable": "Server nicht erreichbar. Bitte prüfe die Adresse.",
"specify": "Adresse manuell eingeben",
"user": "Benutzer"
"user": "Benutzer",
"qrcode": {
"scan": "QR-Code scannen",
"permissionDenied": "Aktiviere den Kamerazugriff in den Einstellungen, um einen QR-Code zu scannen.",
"recognized": "QR-Code erkannt!",
"invalid": "Kein gültiger evcc QR-Code.",
"scanning": "erkennen..."
}
},
"removeServer": "Server entfernen",
"search": {
Expand All @@ -27,4 +34,4 @@
"select": "Auswählen",
"useDemo": "Demoinstanz verwenden"
}
}
}
9 changes: 8 additions & 1 deletion i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
"serverIncompatible": "The evcc instance is not yet app-compatible. Update your installation.",
"serverNotAvailable": "Server not available. Please check the address.",
"specify": "Enter address manually",
"user": "User"
"user": "User",
"qrcode": {
"scan": "Scan QR code",
"permissionDenied": "Enable camera access in the settings to scan a QR code.",
"recognized": "QR code detected!",
"invalid": "Not a valid evcc QR code.",
"scanning": "detecting..."
}
},
"removeServer": "Remove server",
"search": {
Expand Down
Loading