Support Google Services based sign-in config
This commit is contained in:
parent
3de2fa714f
commit
ac9c9de753
@ -4,6 +4,10 @@ plugins {
|
|||||||
id("dev.flutter.flutter-gradle-plugin")
|
id("dev.flutter.flutter-gradle-plugin")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (file("google-services.json").exists()) {
|
||||||
|
apply(plugin = "com.google.gms.google-services")
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "hu.otthonnaptar.otthon_naptar"
|
namespace = "hu.otthonnaptar.otthon_naptar"
|
||||||
compileSdk = flutter.compileSdkVersion
|
compileSdk = flutter.compileSdkVersion
|
||||||
|
|||||||
@ -21,6 +21,7 @@ plugins {
|
|||||||
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
|
||||||
id("com.android.application") version "9.0.1" apply false
|
id("com.android.application") version "9.0.1" apply false
|
||||||
id("org.jetbrains.kotlin.android") version "2.3.20" apply false
|
id("org.jetbrains.kotlin.android") version "2.3.20" apply false
|
||||||
|
id("com.google.gms.google-services") version "4.4.4" apply false
|
||||||
}
|
}
|
||||||
|
|
||||||
include(":app")
|
include(":app")
|
||||||
|
|||||||
@ -30,7 +30,7 @@ class _AccountsPageState extends State<AccountsPage> {
|
|||||||
final googleSignIn = GoogleSignIn.instance;
|
final googleSignIn = GoogleSignIn.instance;
|
||||||
List<GoogleCalendarInfo> googleCalendars = [];
|
List<GoogleCalendarInfo> googleCalendars = [];
|
||||||
GoogleSignInAccount? signedInAccount;
|
GoogleSignInAccount? signedInAccount;
|
||||||
String runtimeServerClientId = googleCalendarServerClientId;
|
String? runtimeServerClientId;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
bool loadingCalendars = false;
|
bool loadingCalendars = false;
|
||||||
bool syncing = false;
|
bool syncing = false;
|
||||||
@ -53,16 +53,7 @@ class _AccountsPageState extends State<AccountsPage> {
|
|||||||
|
|
||||||
final configuredClientId = await _loadGoogleServerClientId();
|
final configuredClientId = await _loadGoogleServerClientId();
|
||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
if (configuredClientId == null || configuredClientId.trim().isEmpty) {
|
runtimeServerClientId = configuredClientId?.trim();
|
||||||
setState(() {
|
|
||||||
loadingCalendars = false;
|
|
||||||
statusMessage =
|
|
||||||
'A Google napt\u00e1rkapcsolat m\u00e9g nincs bek\u00f6tve. A csal\u00e1dtagoknak nem kell client ID-t megadniuk; a JARVIS admin fel\u00fcleten kell egyszer be\u00e1ll\u00edtani a Google Calendar OAuth azonos\u00edt\u00f3t.';
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
runtimeServerClientId = configuredClientId.trim();
|
|
||||||
await _initializeGoogle();
|
await _initializeGoogle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +112,10 @@ class _AccountsPageState extends State<AccountsPage> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
loadingCalendars = false;
|
loadingCalendars = false;
|
||||||
statusMessage = 'Google inicializ\u00e1l\u00e1s nem siker\u00fclt: $error';
|
statusMessage = _friendlyGoogleError(
|
||||||
|
'Google inicializ\u00e1l\u00e1s nem siker\u00fclt',
|
||||||
|
error,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -163,17 +157,30 @@ class _AccountsPageState extends State<AccountsPage> {
|
|||||||
if (!mounted) return;
|
if (!mounted) return;
|
||||||
setState(() {
|
setState(() {
|
||||||
loadingCalendars = false;
|
loadingCalendars = false;
|
||||||
statusMessage = 'Google bejelentkez\u00e9s nem siker\u00fclt: $error';
|
statusMessage = _friendlyGoogleError(
|
||||||
|
'Google bejelentkez\u00e9s nem siker\u00fclt',
|
||||||
|
error,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String _friendlyGoogleError(String prefix, Object error) {
|
||||||
|
final raw = error.toString();
|
||||||
|
if (raw.contains('serverClientId must be provided') ||
|
||||||
|
raw.contains('CredentialManager requires a serverClientId')) {
|
||||||
|
return '$prefix: hi\u00e1nyzik az app Google konfigur\u00e1ci\u00f3ja. '
|
||||||
|
'A bel\u00e9p\u00e9si ablakos m\u0171k\u00f6d\u00e9shez tedd be az android/app/google-services.json f\u00e1jlt, '
|
||||||
|
'amely tartalmaz Web application OAuth client ID-t, majd buildeld \u00fajra az APK-t.';
|
||||||
|
}
|
||||||
|
return '$prefix: $raw';
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> _ensureGoogleInitialized() async {
|
Future<void> _ensureGoogleInitialized() async {
|
||||||
final clientId = runtimeServerClientId.trim();
|
final clientId = runtimeServerClientId;
|
||||||
if (clientId.isEmpty) {
|
if (clientId == null || clientId.isEmpty) {
|
||||||
throw Exception(
|
await googleSignIn.initialize();
|
||||||
'A Google napt\u00e1rkapcsolat m\u00e9g nincs bek\u00f6tve.',
|
return;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await googleSignIn.initialize(
|
await googleSignIn.initialize(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user