Add warning popup toggles + fix breaking bug in add app

This commit is contained in:
Imran Remtulla
2023-04-30 00:58:32 -04:00
parent 04b3c8ad7d
commit dd19fcf6da
14 changed files with 132 additions and 28 deletions

View File

@@ -332,13 +332,16 @@ class AppsProvider with ChangeNotifier {
getHost(apkUrl.value) != getHost(app.url) &&
context != null) {
// ignore: use_build_context_synchronously
if (await showDialog(
context: context,
builder: (BuildContext ctx) {
return APKOriginWarningDialog(
sourceUrl: app.url, apkUrl: apkUrl!.value);
}) !=
true) {
var settingsProvider = context.read<SettingsProvider>();
if (!(settingsProvider.hideAPKOriginWarning) &&
// ignore: use_build_context_synchronously
await showDialog(
context: context,
builder: (BuildContext ctx) {
return APKOriginWarningDialog(
sourceUrl: app.url, apkUrl: apkUrl!.value);
}) !=
true) {
apkUrl = null;
}
}

View File

@@ -163,6 +163,24 @@ class SettingsProvider with ChangeNotifier {
notifyListeners();
}
bool get hideTrackOnlyWarning {
return prefs?.getBool('hideTrackOnlyWarning') ?? false;
}
set hideTrackOnlyWarning(bool show) {
prefs?.setBool('hideTrackOnlyWarning', show);
notifyListeners();
}
bool get hideAPKOriginWarning {
return prefs?.getBool('hideAPKOriginWarning') ?? false;
}
set hideAPKOriginWarning(bool show) {
prefs?.setBool('hideAPKOriginWarning', show);
notifyListeners();
}
String? getSettingString(String settingId) {
return prefs?.getString(settingId);
}

View File

@@ -470,7 +470,7 @@ class SourceProvider {
}
AppSource? source;
for (var s in sources.where((element) => element.host != null)) {
if (RegExp('://${s.host}').hasMatch(url)) {
if (RegExp('://${s.host}(/|\\z)?').hasMatch(url)) {
source = s;
break;
}