Add toggle for App ID inferring where optional

This commit is contained in:
Imran Remtulla
2023-05-27 21:01:16 -04:00
parent 6f9ef6d51e
commit a0d466a074
12 changed files with 39 additions and 4 deletions

View File

@@ -233,6 +233,7 @@
"about": "Über",
"requiresCredentialsInSettings": "Benötigt zusätzliche Anmeldedaten (in den Einstellungen)",
"checkOnStart": "Überprüfe einmalig beim Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "App entfernen?",
"other": "Apps entfernen?"

View File

@@ -233,6 +233,7 @@
"about": "About",
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "Remove App?",
"other": "Remove Apps?"

View File

@@ -233,6 +233,7 @@
"about": "About",
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "¿Eliminar Aplicación?",
"other": "¿Eliminar Aplicaciones?"

View File

@@ -233,6 +233,7 @@
"about": "About",
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "برنامه حذف شود؟",
"other": "برنامه ها حذف شوند؟"

View File

@@ -233,6 +233,7 @@
"about": "About",
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "Supprimer l'application ?",
"other": "Supprimer les applications ?"

View File

@@ -232,6 +232,7 @@
"about": "Rólunk",
"requiresCredentialsInSettings": "Ehhez további hitelesítő adatokra van szükség (a Beállításokban)",
"checkOnStart": "Egyszer az indításkor",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "Eltávolítja az alkalmazást?",
"other": "Eltávolítja az alkalmazást?"

View File

@@ -233,6 +233,7 @@
"about": "About",
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "Rimuovere l'App?",
"other": "Rimuovere le App?"

View File

@@ -233,6 +233,7 @@
"about": "概要",
"requiresCredentialsInSettings": "これには追加の認証が必要です (設定にて)",
"checkOnStart": "Check Once on Start",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "アプリを削除しますか?",
"other": "アプリを削除しますか?"

View File

@@ -233,6 +233,7 @@
"about": "相关文档",
"requiresCredentialsInSettings": "此功能需要额外的凭据(在“设置”中添加)",
"checkOnStart": "启动时进行一次检查",
"tryInferAppIdFromCode": "Try inferring App ID from source code",
"removeAppQuestion": {
"one": "是否删除应用?",
"other": "是否删除应用?"

View File

@@ -14,6 +14,7 @@ import 'package:url_launcher/url_launcher_string.dart';
class GitHub extends AppSource {
GitHub() {
host = 'github.com';
appIdInferIsOptional = true;
additionalSourceSpecificSettingFormItems = [
GeneratedFormTextField('github-creds',

View File

@@ -33,6 +33,7 @@ class _AddAppPageState extends State<AddAppPage> {
AppSource? pickedSource;
Map<String, dynamic> additionalSettings = {};
bool additionalSettingsValid = true;
bool inferAppIdIfOptional = true;
List<String> pickedCategories = [];
int searchnum = 0;
SourceProvider sourceProvider = SourceProvider();
@@ -78,6 +79,7 @@ class _AddAppPageState extends State<AddAppPage> {
additionalSettingsValid = source != null
? !sourceProvider.ifRequiredAppSpecificSettingsExist(source)
: true;
inferAppIdIfOptional = true;
}
});
}
@@ -147,7 +149,8 @@ class _AddAppPageState extends State<AddAppPage> {
app = await sourceProvider.getApp(
pickedSource!, userInput, additionalSettings,
trackOnlyOverride: trackOnly,
overrideSource: pickedSourceOverride);
overrideSource: pickedSourceOverride,
inferAppIdIfOptional: inferAppIdIfOptional);
// Only download the APK here if you need to for the package ID
if (sourceProvider.isTempId(app) &&
app.additionalSettings['trackOnly'] != true) {
@@ -428,6 +431,23 @@ class _AddAppPageState extends State<AddAppPage> {
}),
],
),
if (pickedSource != null && pickedSource!.appIdInferIsOptional)
GeneratedForm(
key: const Key('inferAppIdIfOptional'),
items: [
[
GeneratedFormSwitch('inferAppIdIfOptional',
label: tr('tryInferAppIdFromCode'),
defaultValue: inferAppIdIfOptional)
]
],
onValueChanges: (values, valid, isBuilding) {
if (!isBuilding) {
setState(() {
inferAppIdIfOptional = values['inferAppIdIfOptional'];
});
}
}),
],
);

View File

@@ -317,6 +317,7 @@ abstract class AppSource {
late String name;
bool enforceTrackOnly = false;
bool changeLogIfAnyIsMarkDown = true;
bool appIdInferIsOptional = false;
AppSource() {
name = runtimeType.toString();
@@ -552,7 +553,8 @@ class SourceProvider {
AppSource source, String url, Map<String, dynamic> additionalSettings,
{App? currentApp,
bool trackOnlyOverride = false,
String? overrideSource}) async {
String? overrideSource,
bool inferAppIdIfOptional = false}) async {
if (trackOnlyOverride || source.enforceTrackOnly) {
additionalSettings['trackOnly'] = true;
}
@@ -592,8 +594,11 @@ class SourceProvider {
: apk.names.name[0].toUpperCase() + apk.names.name.substring(1);
return App(
currentApp?.id ??
await source.tryInferringAppId(standardUrl,
additionalSettings: additionalSettings) ??
((!source.appIdInferIsOptional ||
(source.appIdInferIsOptional && inferAppIdIfOptional))
? await source.tryInferringAppId(standardUrl,
additionalSettings: additionalSettings)
: null) ??
generateTempID(standardUrl, additionalSettings),
standardUrl,
apk.names.author[0].toUpperCase() + apk.names.author.substring(1),