mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-12 21:06:43 +02:00
Merge pull request #2350 from ImranR98/dev
- Minor wording changes (#2226, #2313, #2317, #2338) - HTML bugfix: Incorrect URL resolution on redirected pages (#2315)
This commit is contained in:
2
.flutter
2
.flutter
Submodule .flutter updated: b25305a883...6fba2447e9
@ -63,7 +63,7 @@ Or, contribute some configurations to the website by creating a PR at [this repo
|
||||
|
||||
Verification info:
|
||||
- Package ID: `dev.imranr.obtainium`
|
||||
- SHA-256 Hash of Signing Certificate: `B3:53:60:1F:6A:1D:5F:D6:60:3A:E2:F5:0B:E8:0C:F3:01:36:7B:86:B6:AB:8B:1F:66:24:3D:A9:6C:D5:73:62`
|
||||
- SHA-256 hash of signing certificate: `B3:53:60:1F:6A:1D:5F:D6:60:3A:E2:F5:0B:E8:0C:F3:01:36:7B:86:B6:AB:8B:1F:66:24:3D:A9:6C:D5:73:62`
|
||||
- Note: The above signature is also valid for the F-Droid flavour of Obtainium, thanks to [reproducible builds](https://f-droid.org/docs/Reproducible_Builds/).
|
||||
- [PGP Public Key](https://keyserver.ubuntu.com/pks/lookup?search=contact%40imranr.dev&fingerprint=on&op=index) (to verify APK hashes)
|
||||
|
||||
|
@ -12,8 +12,9 @@ class APKCombo extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
var match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -22,25 +23,30 @@ class APKCombo extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
return {
|
||||
"User-Agent": "curl/8.0.1",
|
||||
"Accept": "*/*",
|
||||
"Connection": "keep-alive",
|
||||
"Host": hosts[0]
|
||||
"Host": hosts[0],
|
||||
};
|
||||
}
|
||||
|
||||
Future<List<MapEntry<String, String>>> getApkUrls(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest('$standardUrl/download/apk', {});
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
@ -65,7 +71,9 @@ class APKCombo extends AppSource {
|
||||
String verCode =
|
||||
e.querySelector('.info .header .vercode')?.text.trim() ?? '';
|
||||
return MapEntry<String, String>(
|
||||
arch != null ? '$arch-$verCode.apk' : '', url ?? '');
|
||||
arch != null ? '$arch-$verCode.apk' : '',
|
||||
url ?? '',
|
||||
);
|
||||
}).toList();
|
||||
})
|
||||
.reduce((value, element) => [...value, ...element])
|
||||
@ -74,8 +82,11 @@ class APKCombo extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> apkUrlPrefetchModifier(String apkUrl, String standardUrl,
|
||||
Map<String, dynamic> additionalSettings) async {
|
||||
Future<String> apkUrlPrefetchModifier(
|
||||
String apkUrl,
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var freshURLs = await getApkUrls(standardUrl, additionalSettings);
|
||||
var path2Match = Uri.parse(apkUrl).path;
|
||||
for (var url in freshURLs) {
|
||||
@ -116,9 +127,10 @@ class APKCombo extends AppSource {
|
||||
}
|
||||
}
|
||||
return APKDetails(
|
||||
version,
|
||||
await getApkUrls(standardUrl, additionalSettings),
|
||||
AppNames(author, appName),
|
||||
releaseDate: releaseDate);
|
||||
version,
|
||||
await getApkUrls(standardUrl, additionalSettings),
|
||||
AppNames(author, appName),
|
||||
releaseDate: releaseDate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,37 +17,44 @@ class APKMirror extends AppSource {
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
GeneratedFormSwitch(
|
||||
'fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormTextField('filterReleaseTitlesByRegEx',
|
||||
label: tr('filterReleaseTitlesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
}
|
||||
])
|
||||
]
|
||||
GeneratedFormTextField(
|
||||
'filterReleaseTitlesByRegEx',
|
||||
label: tr('filterReleaseTitlesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
return {
|
||||
"User-Agent":
|
||||
"Obtainium/${(await getInstalledInfo(obtainiumId))?.versionName ?? '1.0.0'}"
|
||||
"Obtainium/${(await getInstalledInfo(obtainiumId))?.versionName ?? '1.0.0'}",
|
||||
};
|
||||
}
|
||||
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/apk/[^/]+/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -68,12 +75,14 @@ class APKMirror extends AppSource {
|
||||
additionalSettings['fallbackToOlderReleases'] == true;
|
||||
String? regexFilter =
|
||||
(additionalSettings['filterReleaseTitlesByRegEx'] as String?)
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseTitlesByRegEx']
|
||||
: null;
|
||||
Response res =
|
||||
await sourceRequest('$standardUrl/feed/', additionalSettings);
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseTitlesByRegEx']
|
||||
: null;
|
||||
Response res = await sourceRequest(
|
||||
'$standardUrl/feed/',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var items = parse(res.body).querySelectorAll('item');
|
||||
dynamic targetRelease;
|
||||
@ -95,11 +104,14 @@ class APKMirror extends AppSource {
|
||||
.split(' ')
|
||||
.sublist(0, 5)
|
||||
.join(' ');
|
||||
DateTime? releaseDate =
|
||||
dateString != null ? HttpDate.parse('$dateString GMT') : null;
|
||||
DateTime? releaseDate = dateString != null
|
||||
? HttpDate.parse('$dateString GMT')
|
||||
: null;
|
||||
String? version = titleString
|
||||
?.substring(RegExp('[0-9]').firstMatch(titleString)?.start ?? 0,
|
||||
RegExp(' by ').allMatches(titleString).last.start)
|
||||
?.substring(
|
||||
RegExp('[0-9]').firstMatch(titleString)?.start ?? 0,
|
||||
RegExp(' by ').allMatches(titleString).last.start,
|
||||
)
|
||||
.trim();
|
||||
if (version == null || version.isEmpty) {
|
||||
version = titleString;
|
||||
@ -107,8 +119,12 @@ class APKMirror extends AppSource {
|
||||
if (version == null || version.isEmpty) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
return APKDetails(version, [], getAppNames(standardUrl),
|
||||
releaseDate: releaseDate);
|
||||
return APKDetails(
|
||||
version,
|
||||
[],
|
||||
getAppNames(standardUrl),
|
||||
releaseDate: releaseDate,
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
extension Unique<E, Id> on List<E> {
|
||||
List<E> unique([Id Function(E element)? id, bool inplace = true]) {
|
||||
final ids = Set();
|
||||
final ids = <dynamic>{};
|
||||
var list = inplace ? this : List<E>.from(this);
|
||||
list.retainWhere((x) => ids.add(id != null ? id(x) : x as Id));
|
||||
return list;
|
||||
@ -23,33 +23,44 @@ class APKPure extends AppSource {
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
GeneratedFormSwitch(
|
||||
'fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('stayOneVersionBehind',
|
||||
label: tr('stayOneVersionBehind'), defaultValue: false)
|
||||
GeneratedFormSwitch(
|
||||
'stayOneVersionBehind',
|
||||
label: tr('stayOneVersionBehind'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('useFirstApkOfVersion',
|
||||
label: tr('useFirstApkOfVersion'), defaultValue: true)
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'useFirstApkOfVersion',
|
||||
label: tr('useFirstApkOfVersion'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegExB = RegExp(
|
||||
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://m.${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegExB.firstMatch(url);
|
||||
if (match != null) {
|
||||
var uri = Uri.parse(url);
|
||||
url = 'https://${uri.host.substring(2)}${uri.path}';
|
||||
}
|
||||
RegExp standardUrlRegExA = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}(/+[^/]{2})?/+[^/]+/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
match = standardUrlRegExA.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -58,15 +69,18 @@ class APKPure extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
getDetailsForVersion(
|
||||
List<Map<String, dynamic>> versionVariants,
|
||||
List<String> supportedArchs,
|
||||
Map<String, dynamic> additionalSettings) async {
|
||||
Future<APKDetails> getDetailsForVersion(
|
||||
List<Map<String, dynamic>> versionVariants,
|
||||
List<String> supportedArchs,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var apkUrls = versionVariants
|
||||
.map((e) {
|
||||
String appId = e['package_name'];
|
||||
@ -88,8 +102,9 @@ class APKPure extends AppSource {
|
||||
String downloadUri = e['asset']['url'];
|
||||
|
||||
return MapEntry(
|
||||
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
|
||||
downloadUri);
|
||||
'$appId-$versionCode-$architectureString.${type.toLowerCase()}',
|
||||
downloadUri,
|
||||
);
|
||||
})
|
||||
.nonNulls
|
||||
.toList()
|
||||
@ -114,14 +129,20 @@ class APKPure extends AppSource {
|
||||
apkUrls = [apkUrls.first];
|
||||
}
|
||||
|
||||
return APKDetails(version, apkUrls, AppNames(author, appName),
|
||||
releaseDate: releaseDate, changeLog: changeLog);
|
||||
return APKDetails(
|
||||
version,
|
||||
apkUrls,
|
||||
AppNames(author, appName),
|
||||
releaseDate: releaseDate,
|
||||
changeLog: changeLog,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
if (forAPKDownload) {
|
||||
return null;
|
||||
} else {
|
||||
@ -145,19 +166,22 @@ class APKPure extends AppSource {
|
||||
|
||||
// request versions from API
|
||||
var res = await sourceRequest(
|
||||
"https://tapi.pureapk.com/v3/get_app_his_version?package_name=$appId&hl=en",
|
||||
additionalSettings);
|
||||
"https://tapi.pureapk.com/v3/get_app_his_version?package_name=$appId&hl=en",
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
List<Map<String, dynamic>> apks =
|
||||
jsonDecode(res.body)['version_list'].cast<Map<String, dynamic>>();
|
||||
List<Map<String, dynamic>> apks = jsonDecode(
|
||||
res.body,
|
||||
)['version_list'].cast<Map<String, dynamic>>();
|
||||
|
||||
// group by version
|
||||
List<List<Map<String, dynamic>>> versions = apks
|
||||
.fold<Map<String, List<Map<String, dynamic>>>>({},
|
||||
(Map<String, List<Map<String, dynamic>>> val,
|
||||
Map<String, dynamic> element) {
|
||||
.fold<Map<String, List<Map<String, dynamic>>>>({}, (
|
||||
Map<String, List<Map<String, dynamic>>> val,
|
||||
Map<String, dynamic> element,
|
||||
) {
|
||||
String v = element['version_name'];
|
||||
if (!val.containsKey(v)) {
|
||||
val[v] = [];
|
||||
@ -179,7 +203,10 @@ class APKPure extends AppSource {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
return await getDetailsForVersion(
|
||||
v, supportedArchs, additionalSettings);
|
||||
v,
|
||||
supportedArchs,
|
||||
additionalSettings,
|
||||
);
|
||||
} catch (e) {
|
||||
if (additionalSettings['fallbackToOlderReleases'] != true ||
|
||||
i == versions.length - 1) {
|
||||
|
@ -16,8 +16,9 @@ class Aptoide extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||
caseSensitive: false);
|
||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -26,14 +27,20 @@ class Aptoide extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return (await getAppDetailsJSON(
|
||||
standardUrl, additionalSettings))['package'];
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
))['package'];
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getAppDetailsJSON(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest(standardUrl, additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
@ -46,7 +53,9 @@ class Aptoide extends AppSource {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
var res2 = await sourceRequest(
|
||||
'https://ws2.aptoide.com/api/7/getApp/app_id/$id', additionalSettings);
|
||||
'https://ws2.aptoide.com/api/7/getApp/app_id/$id',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res2.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
@ -76,7 +85,10 @@ class Aptoide extends AppSource {
|
||||
}
|
||||
|
||||
return APKDetails(
|
||||
version, getApkUrlsFromUrls([apkUrl]), AppNames(author, appName),
|
||||
releaseDate: relDate);
|
||||
version,
|
||||
getApkUrlsFromUrls([apkUrl]),
|
||||
AppNames(author, appName),
|
||||
releaseDate: relDate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ class Codeberg extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -36,8 +37,9 @@ class Codeberg extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
return await gh.getLatestAPKDetailsCommon2(standardUrl, additionalSettings,
|
||||
(bool useTagUrl) async {
|
||||
return await gh.getLatestAPKDetailsCommon2(standardUrl, additionalSettings, (
|
||||
bool useTagUrl,
|
||||
) async {
|
||||
return 'https://${hosts[0]}/api/v1/repos${standardUrl.substring('https://${hosts[0]}'.length)}/${useTagUrl ? 'tags' : 'releases'}?per_page=100';
|
||||
}, null);
|
||||
}
|
||||
@ -49,12 +51,15 @@ class Codeberg extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
return gh.searchCommon(
|
||||
query,
|
||||
'https://${hosts[0]}/api/v1/repos/search?q=${Uri.encodeQueryComponent(query)}&limit=100',
|
||||
'data',
|
||||
querySettings: querySettings);
|
||||
query,
|
||||
'https://${hosts[0]}/api/v1/repos/search?q=${Uri.encodeQueryComponent(query)}&limit=100',
|
||||
'data',
|
||||
querySettings: querySettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,9 @@ class CoolApk extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
r'^https?://(www\.)?coolapk\.com/apk/[^/]+',
|
||||
caseSensitive: false);
|
||||
r'^https?://(www\.)?coolapk\.com/apk/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
var match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -30,17 +31,19 @@ class CoolApk extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
String appId = Uri.parse(standardUrl).pathSegments.last;
|
||||
return appId;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
String appId = (await tryInferringAppId(standardUrl))!;
|
||||
String apiUrl = 'https://api2.coolapk.com';
|
||||
|
||||
@ -65,13 +68,19 @@ class CoolApk extends AppSource {
|
||||
String changelog = detail['changelog']?.toString() ?? '';
|
||||
int? releaseDate = detail['lastupdate'] != null
|
||||
? (detail['lastupdate'] is int
|
||||
? detail['lastupdate'] * 1000
|
||||
: int.parse(detail['lastupdate'].toString()) * 1000)
|
||||
? detail['lastupdate'] * 1000
|
||||
: int.parse(detail['lastupdate'].toString()) * 1000)
|
||||
: null;
|
||||
String aid = detail['id'].toString();
|
||||
|
||||
// get apk url
|
||||
String apkUrl = await _getLatestApkUrl(apiUrl, appId, aid, version, headers);
|
||||
String apkUrl = await _getLatestApkUrl(
|
||||
apiUrl,
|
||||
appId,
|
||||
aid,
|
||||
version,
|
||||
headers,
|
||||
);
|
||||
if (apkUrl.isEmpty) {
|
||||
throw NoAPKError();
|
||||
}
|
||||
@ -89,8 +98,13 @@ class CoolApk extends AppSource {
|
||||
);
|
||||
}
|
||||
|
||||
Future<String> _getLatestApkUrl(String apiUrl, String appId, String aid,
|
||||
String version, Map<String, String>? headers) async {
|
||||
Future<String> _getLatestApkUrl(
|
||||
String apiUrl,
|
||||
String appId,
|
||||
String aid,
|
||||
String version,
|
||||
Map<String, String>? headers,
|
||||
) async {
|
||||
String url = '$apiUrl/v6/apk/download?pn=$appId&aid=$aid';
|
||||
var res = await sourceRequest(url, {}, followRedirects: false);
|
||||
if (res.statusCode >= 300 && res.statusCode < 400) {
|
||||
@ -102,13 +116,14 @@ class CoolApk extends AppSource {
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
var tokenPair = _getToken();
|
||||
// CoolAPK header
|
||||
return {
|
||||
'User-Agent':
|
||||
'Dalvik/2.1.0 (Linux; U; Android 9; MI 8 SE MIUI/9.5.9) (#Build; Xiaomi; MI 8 SE; PKQ1.181121.001; 9) +CoolMarket/12.4.2-2208241-universal',
|
||||
'Dalvik/2.1.0 (Linux; U; Android 9; MI 8 SE MIUI/9.5.9) (#Build; Xiaomi; MI 8 SE; PKQ1.181121.001; 9) +CoolMarket/12.4.2-2208241-universal',
|
||||
'X-App-Id': 'com.coolapk.market',
|
||||
'X-Requested-With': 'XMLHttpRequest',
|
||||
'X-Sdk-Int': '30',
|
||||
@ -128,14 +143,15 @@ class CoolApk extends AppSource {
|
||||
Map<String, String> _getToken() {
|
||||
final rand = Random();
|
||||
|
||||
String randHexString(int n) =>
|
||||
List.generate(n, (_) => rand.nextInt(256).toRadixString(16).padLeft(2, '0'))
|
||||
.join()
|
||||
.toUpperCase();
|
||||
String randHexString(int n) => List.generate(
|
||||
n,
|
||||
(_) => rand.nextInt(256).toRadixString(16).padLeft(2, '0'),
|
||||
).join().toUpperCase();
|
||||
|
||||
String randMacAddress() =>
|
||||
List.generate(6, (_) => rand.nextInt(256).toRadixString(16).padLeft(2, '0'))
|
||||
.join(':');
|
||||
String randMacAddress() => List.generate(
|
||||
6,
|
||||
(_) => rand.nextInt(256).toRadixString(16).padLeft(2, '0'),
|
||||
).join(':');
|
||||
|
||||
// 加密算法来自 https://github.com/XiaoMengXinX/FuckCoolapkTokenV2、https://github.com/Coolapk-UWP/Coolapk-UWP
|
||||
// device
|
||||
@ -147,11 +163,13 @@ class CoolApk extends AppSource {
|
||||
const buildNumber = 'SQ1D.220105.007';
|
||||
|
||||
// generate deviceCode
|
||||
String deviceCode =
|
||||
base64.encode('$aid; ; ; $mac; $manufactor; $brand; $model; $buildNumber'.codeUnits);
|
||||
String deviceCode = base64.encode(
|
||||
'$aid; ; ; $mac; $manufactor; $brand; $model; $buildNumber'.codeUnits,
|
||||
);
|
||||
|
||||
// generate timestamp
|
||||
String timeStamp = (DateTime.now().millisecondsSinceEpoch ~/ 1000).toString();
|
||||
String timeStamp = (DateTime.now().millisecondsSinceEpoch ~/ 1000)
|
||||
.toString();
|
||||
String base64TimeStamp = base64.encode(timeStamp.codeUnits);
|
||||
String md5TimeStamp = md5.convert(timeStamp.codeUnits).toString();
|
||||
String md5DeviceCode = md5.convert(deviceCode.codeUnits).toString();
|
||||
@ -164,7 +182,8 @@ class CoolApk extends AppSource {
|
||||
String md5Token = md5.convert(token.codeUnits).toString();
|
||||
|
||||
// generate salt and hash
|
||||
String bcryptSalt = '\$2a\$10\$${base64TimeStamp.substring(0, 14)}/${md5Token.substring(0, 6)}u';
|
||||
String bcryptSalt =
|
||||
'\$2a\$10\$${base64TimeStamp.substring(0, 14)}/${md5Token.substring(0, 6)}u';
|
||||
String bcryptResult = BCrypt.hashpw(md5Base64Token, bcryptSalt);
|
||||
String reBcryptResult = bcryptResult.replaceRange(0, 3, '\$2y');
|
||||
String finalToken = 'v2${base64.encode(reBcryptResult.codeUnits)}';
|
||||
|
@ -11,20 +11,23 @@ class DirectAPKLink extends AppSource {
|
||||
name = tr('directAPKLink');
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
...html.additionalSourceAppSpecificSettingFormItems
|
||||
.where((element) => element
|
||||
.where((element) => element.key == 'requestHeader')
|
||||
.isNotEmpty)
|
||||
.toList(),
|
||||
.where(
|
||||
(element) => element
|
||||
.where((element) => element.key == 'requestHeader')
|
||||
.isNotEmpty,
|
||||
)
|
||||
,
|
||||
[
|
||||
GeneratedFormDropdown(
|
||||
'defaultPseudoVersioningMethod',
|
||||
[
|
||||
MapEntry('partialAPKHash', tr('partialAPKHash')),
|
||||
MapEntry('ETag', 'ETag')
|
||||
],
|
||||
label: tr('defaultPseudoVersioningMethod'),
|
||||
defaultValue: 'partialAPKHash')
|
||||
]
|
||||
'defaultPseudoVersioningMethod',
|
||||
[
|
||||
MapEntry('partialAPKHash', tr('partialAPKHash')),
|
||||
MapEntry('ETag', 'ETag'),
|
||||
],
|
||||
label: tr('defaultPseudoVersioningMethod'),
|
||||
defaultValue: 'partialAPKHash',
|
||||
),
|
||||
],
|
||||
];
|
||||
excludeCommonSettingKeys = [
|
||||
'versionExtractionRegEx',
|
||||
@ -32,7 +35,7 @@ class DirectAPKLink extends AppSource {
|
||||
'versionDetection',
|
||||
'useVersionCodeAsOSVersion',
|
||||
'apkFilterRegEx',
|
||||
'autoApkFilterByArch'
|
||||
'autoApkFilterByArch',
|
||||
];
|
||||
}
|
||||
|
||||
@ -51,10 +54,13 @@ class DirectAPKLink extends AppSource {
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) {
|
||||
return html.getRequestHeaders(additionalSettings,
|
||||
forAPKDownload: forAPKDownload);
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) {
|
||||
return html.getRequestHeaders(
|
||||
additionalSettings,
|
||||
forAPKDownload: forAPKDownload,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -62,8 +68,9 @@ class DirectAPKLink extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var additionalSettingsNew =
|
||||
getDefaultValuesFromFormItems(html.combinedAppSpecificSettingFormItems);
|
||||
var additionalSettingsNew = getDefaultValuesFromFormItems(
|
||||
html.combinedAppSpecificSettingFormItems,
|
||||
);
|
||||
for (var s in additionalSettings.keys) {
|
||||
if (additionalSettingsNew.containsKey(s)) {
|
||||
additionalSettingsNew[s] = additionalSettings[s];
|
||||
|
@ -17,22 +17,28 @@ class FDroid extends AppSource {
|
||||
canSearch = true;
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormTextField('filterVersionsByRegEx',
|
||||
label: tr('filterVersionsByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
}
|
||||
])
|
||||
GeneratedFormTextField(
|
||||
'filterVersionsByRegEx',
|
||||
label: tr('filterVersionsByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('trySelectingSuggestedVersionCode',
|
||||
label: tr('trySelectingSuggestedVersionCode'))
|
||||
GeneratedFormSwitch(
|
||||
'trySelectingSuggestedVersionCode',
|
||||
label: tr('trySelectingSuggestedVersionCode'),
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('autoSelectHighestVersionCode',
|
||||
label: tr('autoSelectHighestVersionCode'))
|
||||
GeneratedFormSwitch(
|
||||
'autoSelectHighestVersionCode',
|
||||
label: tr('autoSelectHighestVersionCode'),
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
@ -40,16 +46,18 @@ class FDroid extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegExB = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+[^/]+/+packages/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegExB.firstMatch(url);
|
||||
if (match != null) {
|
||||
url =
|
||||
'https://${Uri.parse(match.group(0)!).host}/packages/${Uri.parse(url).pathSegments.where((s) => s.trim().isNotEmpty).last}';
|
||||
}
|
||||
RegExp standardUrlRegExA = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+packages/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/+packages/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
match = standardUrlRegExA.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -58,8 +66,10 @@ class FDroid extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
@ -71,22 +81,28 @@ class FDroid extends AppSource {
|
||||
String? appId = await tryInferringAppId(standardUrl);
|
||||
String host = Uri.parse(standardUrl).host;
|
||||
var details = getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||
await sourceRequest(
|
||||
'https://$host/api/v1/packages/$appId', additionalSettings),
|
||||
'https://$host/repo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
additionalSettings: additionalSettings);
|
||||
await sourceRequest(
|
||||
'https://$host/api/v1/packages/$appId',
|
||||
additionalSettings,
|
||||
),
|
||||
'https://$host/repo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
additionalSettings: additionalSettings,
|
||||
);
|
||||
if (!hostChanged) {
|
||||
try {
|
||||
var res = await sourceRequest(
|
||||
'https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/$appId.yml',
|
||||
additionalSettings);
|
||||
'https://gitlab.com/fdroid/fdroiddata/-/raw/master/metadata/$appId.yml',
|
||||
additionalSettings,
|
||||
);
|
||||
var lines = res.body.split('\n');
|
||||
var authorLines = lines.where((l) => l.startsWith('AuthorName: '));
|
||||
if (authorLines.isNotEmpty) {
|
||||
details.names.author =
|
||||
authorLines.first.split(': ').sublist(1).join(': ');
|
||||
details.names.author = authorLines.first
|
||||
.split(': ')
|
||||
.sublist(1)
|
||||
.join(': ');
|
||||
}
|
||||
var changelogUrls = lines
|
||||
.where((l) => l.startsWith('Changelog: '))
|
||||
@ -110,9 +126,9 @@ class FDroid extends AppSource {
|
||||
if ((isGitHub || isGitLab) &&
|
||||
(details.changeLog?.indexOf('/blob/') ?? -1) >= 0) {
|
||||
details.changeLog = (await sourceRequest(
|
||||
details.changeLog!.replaceFirst('/blob/', '/raw/'),
|
||||
additionalSettings))
|
||||
.body;
|
||||
details.changeLog!.replaceFirst('/blob/', '/raw/'),
|
||||
additionalSettings,
|
||||
)).body;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
@ -126,10 +142,14 @@ class FDroid extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
Response res = await sourceRequest(
|
||||
'https://search.${hosts[0]}/?q=${Uri.encodeQueryComponent(query)}', {});
|
||||
'https://search.${hosts[0]}/?q=${Uri.encodeQueryComponent(query)}',
|
||||
{},
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
Map<String, List<String>> urlsWithDescriptions = {};
|
||||
parse(res.body).querySelectorAll('.package-header').forEach((e) {
|
||||
@ -145,7 +165,7 @@ class FDroid extends AppSource {
|
||||
urlsWithDescriptions[url] = [
|
||||
e.querySelector('.package-name')?.text.trim() ?? '',
|
||||
e.querySelector('.package-summary')?.text.trim() ??
|
||||
tr('noDescription')
|
||||
tr('noDescription'),
|
||||
];
|
||||
}
|
||||
});
|
||||
@ -156,29 +176,36 @@ class FDroid extends AppSource {
|
||||
}
|
||||
|
||||
APKDetails getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||
Response res, String apkUrlPrefix, String standardUrl, String sourceName,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) {
|
||||
Response res,
|
||||
String apkUrlPrefix,
|
||||
String standardUrl,
|
||||
String sourceName, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) {
|
||||
var autoSelectHighestVersionCode =
|
||||
additionalSettings['autoSelectHighestVersionCode'] == true;
|
||||
var trySelectingSuggestedVersionCode =
|
||||
additionalSettings['trySelectingSuggestedVersionCode'] == true;
|
||||
var filterVersionsByRegEx =
|
||||
(additionalSettings['filterVersionsByRegEx'] as String?)?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterVersionsByRegEx']
|
||||
: null;
|
||||
true
|
||||
? additionalSettings['filterVersionsByRegEx']
|
||||
: null;
|
||||
var apkFilterRegEx =
|
||||
(additionalSettings['apkFilterRegEx'] as String?)?.isNotEmpty == true
|
||||
? additionalSettings['apkFilterRegEx']
|
||||
: null;
|
||||
? additionalSettings['apkFilterRegEx']
|
||||
: null;
|
||||
if (res.statusCode == 200) {
|
||||
var response = jsonDecode(res.body);
|
||||
List<dynamic> releases = response['packages'] ?? [];
|
||||
if (apkFilterRegEx != null) {
|
||||
releases = releases.where((rel) {
|
||||
String apk = '${apkUrlPrefix}_${rel['versionCode']}.apk';
|
||||
return filterApks([MapEntry(apk, apk)], apkFilterRegEx, false)
|
||||
.isNotEmpty;
|
||||
return filterApks(
|
||||
[MapEntry(apk, apk)],
|
||||
apkFilterRegEx,
|
||||
false,
|
||||
).isNotEmpty;
|
||||
}).toList();
|
||||
}
|
||||
if (releases.isEmpty) {
|
||||
@ -191,8 +218,10 @@ class FDroid extends AppSource {
|
||||
if (trySelectingSuggestedVersionCode &&
|
||||
response['suggestedVersionCode'] != null &&
|
||||
filterVersionsByRegEx == null) {
|
||||
var suggestedReleases = releases.where((element) =>
|
||||
element['versionCode'] == response['suggestedVersionCode']);
|
||||
var suggestedReleases = releases.where(
|
||||
(element) =>
|
||||
element['versionCode'] == response['suggestedVersionCode'],
|
||||
);
|
||||
if (suggestedReleases.isNotEmpty) {
|
||||
releaseChoices = suggestedReleases;
|
||||
version = suggestedReleases.first['versionName'];
|
||||
@ -203,8 +232,9 @@ class FDroid extends AppSource {
|
||||
version = null;
|
||||
releaseChoices = [];
|
||||
for (var i = 0; i < releases.length; i++) {
|
||||
if (RegExp(filterVersionsByRegEx!)
|
||||
.hasMatch(releases[i]['versionName'])) {
|
||||
if (RegExp(
|
||||
filterVersionsByRegEx!,
|
||||
).hasMatch(releases[i]['versionName'])) {
|
||||
version = releases[i]['versionName'];
|
||||
}
|
||||
}
|
||||
@ -219,8 +249,9 @@ class FDroid extends AppSource {
|
||||
}
|
||||
// If a suggested release was not already picked, pick all those with the selected version
|
||||
if (releaseChoices.isEmpty) {
|
||||
releaseChoices =
|
||||
releases.where((element) => element['versionName'] == version);
|
||||
releaseChoices = releases.where(
|
||||
(element) => element['versionName'] == version,
|
||||
);
|
||||
}
|
||||
// For the remaining releases, use the toggles to auto-select one if possible
|
||||
if (releaseChoices.length > 1) {
|
||||
@ -228,8 +259,10 @@ class FDroid extends AppSource {
|
||||
releaseChoices = [releaseChoices.first];
|
||||
} else if (trySelectingSuggestedVersionCode &&
|
||||
response['suggestedVersionCode'] != null) {
|
||||
var suggestedReleases = releaseChoices.where((element) =>
|
||||
element['versionCode'] == response['suggestedVersionCode']);
|
||||
var suggestedReleases = releaseChoices.where(
|
||||
(element) =>
|
||||
element['versionCode'] == response['suggestedVersionCode'],
|
||||
);
|
||||
if (suggestedReleases.isNotEmpty) {
|
||||
releaseChoices = suggestedReleases;
|
||||
}
|
||||
@ -241,8 +274,11 @@ class FDroid extends AppSource {
|
||||
List<String> apkUrls = releaseChoices
|
||||
.map((e) => '${apkUrlPrefix}_${e['versionCode']}.apk')
|
||||
.toList();
|
||||
return APKDetails(version, getApkUrlsFromUrls(apkUrls.toSet().toList()),
|
||||
AppNames(sourceName, Uri.parse(standardUrl).pathSegments.last));
|
||||
return APKDetails(
|
||||
version,
|
||||
getApkUrlsFromUrls(apkUrls.toSet().toList()),
|
||||
AppNames(sourceName, Uri.parse(standardUrl).pathSegments.last),
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -15,15 +15,20 @@ class FDroidRepo extends AppSource {
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormTextField('appIdOrName',
|
||||
label: tr('appIdOrName'),
|
||||
hint: tr('reposHaveMultipleApps'),
|
||||
required: true)
|
||||
GeneratedFormTextField(
|
||||
'appIdOrName',
|
||||
label: tr('appIdOrName'),
|
||||
hint: tr('reposHaveMultipleApps'),
|
||||
required: true,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('pickHighestVersionCode',
|
||||
label: tr('pickHighestVersionCode'), defaultValue: false)
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'pickHighestVersionCode',
|
||||
label: tr('pickHighestVersionCode'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -54,8 +59,10 @@ class FDroidRepo extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
String? url = querySettings['url'];
|
||||
if (url == null) {
|
||||
throw NoReleasesError();
|
||||
@ -73,11 +80,8 @@ class FDroidRepo extends AppSource {
|
||||
appId.contains(query) ||
|
||||
appName.contains(query) ||
|
||||
appDesc.contains(query)) {
|
||||
results[
|
||||
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}?appId=$appId'] = [
|
||||
appName,
|
||||
appDesc
|
||||
];
|
||||
results['${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}?appId=$appId'] =
|
||||
[appName, appDesc];
|
||||
}
|
||||
});
|
||||
return results;
|
||||
@ -90,21 +94,21 @@ class FDroidRepo extends AppSource {
|
||||
void runOnAddAppInputChange(String userInput) {
|
||||
additionalSourceAppSpecificSettingFormItems =
|
||||
additionalSourceAppSpecificSettingFormItems.map((row) {
|
||||
row = row.map((item) {
|
||||
if (item.key == 'appIdOrName') {
|
||||
try {
|
||||
var appId = Uri.parse(userInput).queryParameters['appId'];
|
||||
if (appId != null && item is GeneratedFormTextField) {
|
||||
item.required = false;
|
||||
row = row.map((item) {
|
||||
if (item.key == 'appIdOrName') {
|
||||
try {
|
||||
var appId = Uri.parse(userInput).queryParameters['appId'];
|
||||
if (appId != null && item is GeneratedFormTextField) {
|
||||
item.required = false;
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
}
|
||||
return item;
|
||||
}).toList();
|
||||
return row;
|
||||
}).toList();
|
||||
return item;
|
||||
}).toList();
|
||||
return row;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -119,8 +123,11 @@ class FDroidRepo extends AppSource {
|
||||
if (appId != null) {
|
||||
app.url = uri
|
||||
.replace(
|
||||
queryParameters: Map.fromEntries(
|
||||
[...uri.queryParameters.entries, MapEntry('appId', appId)]))
|
||||
queryParameters: Map.fromEntries([
|
||||
...uri.queryParameters.entries,
|
||||
MapEntry('appId', appId),
|
||||
]),
|
||||
)
|
||||
.toString();
|
||||
app.additionalSettings['appIdOrName'] = appId;
|
||||
app.id = appId;
|
||||
@ -133,8 +140,9 @@ class FDroidRepo extends AppSource {
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest(
|
||||
'$url${url.endsWith('/index.xml') ? '' : '/index.xml'}',
|
||||
additionalSettings);
|
||||
'$url${url.endsWith('/index.xml') ? '' : '/index.xml'}',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
var base = url.endsWith('/index.xml')
|
||||
? url.split('/').reversed.toList().sublist(1).reversed.join('/')
|
||||
@ -142,7 +150,9 @@ class FDroidRepo extends AppSource {
|
||||
res = await sourceRequest('$base/repo/index.xml', additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
res = await sourceRequest(
|
||||
'$base/fdroid/repo/index.xml', additionalSettings);
|
||||
'$base/fdroid/repo/index.xml',
|
||||
additionalSettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
@ -164,8 +174,10 @@ class FDroidRepo extends AppSource {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
additionalSettings['appIdOrName'] = appIdOrName;
|
||||
var res =
|
||||
await sourceRequestWithURLVariants(standardUrl, additionalSettings);
|
||||
var res = await sourceRequestWithURLVariants(
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var body = parse(res.body);
|
||||
var foundApps = body.querySelectorAll('application').where((element) {
|
||||
@ -202,24 +214,32 @@ class FDroidRepo extends AppSource {
|
||||
throw NoVersionError();
|
||||
}
|
||||
var latestVersionReleases = releases
|
||||
.where((element) =>
|
||||
element.querySelector('version')?.innerHtml == latestVersion &&
|
||||
element.querySelector('apkname') != null)
|
||||
.where(
|
||||
(element) =>
|
||||
element.querySelector('version')?.innerHtml == latestVersion &&
|
||||
element.querySelector('apkname') != null,
|
||||
)
|
||||
.toList();
|
||||
if (latestVersionReleases.length > 1 && pickHighestVersionCode) {
|
||||
latestVersionReleases.sort((e1, e2) {
|
||||
return int.parse(e2.querySelector('versioncode')!.innerHtml)
|
||||
.compareTo(int.parse(e1.querySelector('versioncode')!.innerHtml));
|
||||
return int.parse(
|
||||
e2.querySelector('versioncode')!.innerHtml,
|
||||
).compareTo(int.parse(e1.querySelector('versioncode')!.innerHtml));
|
||||
});
|
||||
latestVersionReleases = [latestVersionReleases[0]];
|
||||
}
|
||||
List<String> apkUrls = latestVersionReleases
|
||||
.map((e) =>
|
||||
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}/${e.querySelector('apkname')!.innerHtml}')
|
||||
.map(
|
||||
(e) =>
|
||||
'${res.request!.url.toString().split('/').reversed.toList().sublist(1).reversed.join('/')}/${e.querySelector('apkname')!.innerHtml}',
|
||||
)
|
||||
.toList();
|
||||
return APKDetails(latestVersion, getApkUrlsFromUrls(apkUrls),
|
||||
AppNames(authorName, appName),
|
||||
releaseDate: releaseDate);
|
||||
return APKDetails(
|
||||
latestVersion,
|
||||
getApkUrlsFromUrls(apkUrls),
|
||||
AppNames(authorName, appName),
|
||||
releaseDate: releaseDate,
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -19,145 +19,185 @@ class GitHub extends AppSource {
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
sourceConfigSettingFormItems = [
|
||||
GeneratedFormTextField('github-creds',
|
||||
label: tr('githubPATLabel'),
|
||||
password: true,
|
||||
required: false,
|
||||
belowWidgets: [
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
GeneratedFormTextField(
|
||||
'github-creds',
|
||||
label: tr('githubPATLabel'),
|
||||
password: true,
|
||||
required: false,
|
||||
belowWidgets: [
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token',
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
tr('about'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token',
|
||||
mode: LaunchMode.externalApplication);
|
||||
},
|
||||
child: Text(
|
||||
tr('about'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline, fontSize: 12),
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
),
|
||||
])
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('includePrereleases',
|
||||
label: tr('includePrereleases'), defaultValue: false)
|
||||
GeneratedFormSwitch(
|
||||
'includePrereleases',
|
||||
label: tr('includePrereleases'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
GeneratedFormSwitch(
|
||||
'fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormTextField('filterReleaseTitlesByRegEx',
|
||||
label: tr('filterReleaseTitlesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
}
|
||||
])
|
||||
GeneratedFormTextField(
|
||||
'filterReleaseTitlesByRegEx',
|
||||
label: tr('filterReleaseTitlesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormTextField('filterReleaseNotesByRegEx',
|
||||
label: tr('filterReleaseNotesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
}
|
||||
])
|
||||
GeneratedFormTextField(
|
||||
'filterReleaseNotesByRegEx',
|
||||
label: tr('filterReleaseNotesByRegEx'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[GeneratedFormSwitch('verifyLatestTag', label: tr('verifyLatestTag'))],
|
||||
[
|
||||
GeneratedFormDropdown(
|
||||
'sortMethodChoice',
|
||||
[
|
||||
MapEntry('date', tr('releaseDate')),
|
||||
MapEntry('smartname', tr('smartname')),
|
||||
MapEntry('none', tr('none')),
|
||||
MapEntry('smartname-datefallback',
|
||||
'${tr('smartname')} x ${tr('releaseDate')}'),
|
||||
MapEntry('name', tr('name')),
|
||||
],
|
||||
label: tr('sortMethod'),
|
||||
defaultValue: 'date')
|
||||
'sortMethodChoice',
|
||||
[
|
||||
MapEntry('date', tr('releaseDate')),
|
||||
MapEntry('smartname', tr('smartname')),
|
||||
MapEntry('none', tr('none')),
|
||||
MapEntry(
|
||||
'smartname-datefallback',
|
||||
'${tr('smartname')} x ${tr('releaseDate')}',
|
||||
),
|
||||
MapEntry('name', tr('name')),
|
||||
],
|
||||
label: tr('sortMethod'),
|
||||
defaultValue: 'date',
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('useLatestAssetDateAsReleaseDate',
|
||||
label: tr('useLatestAssetDateAsReleaseDate'), defaultValue: false)
|
||||
GeneratedFormSwitch(
|
||||
'useLatestAssetDateAsReleaseDate',
|
||||
label: tr('useLatestAssetDateAsReleaseDate'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('releaseTitleAsVersion',
|
||||
label: tr('releaseTitleAsVersion'), defaultValue: false)
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'releaseTitleAsVersion',
|
||||
label: tr('releaseTitleAsVersion'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
];
|
||||
|
||||
canSearch = true;
|
||||
searchQuerySettingFormItems = [
|
||||
GeneratedFormTextField('minStarCount',
|
||||
label: tr('minStarCount'),
|
||||
defaultValue: '0',
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
try {
|
||||
int.parse(value ?? '0');
|
||||
} catch (e) {
|
||||
return tr('invalidInput');
|
||||
}
|
||||
return null;
|
||||
GeneratedFormTextField(
|
||||
'minStarCount',
|
||||
label: tr('minStarCount'),
|
||||
defaultValue: '0',
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
try {
|
||||
int.parse(value ?? '0');
|
||||
} catch (e) {
|
||||
return tr('invalidInput');
|
||||
}
|
||||
])
|
||||
return null;
|
||||
},
|
||||
],
|
||||
),
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
const possibleBuildGradleLocations = [
|
||||
'/app/build.gradle',
|
||||
'android/app/build.gradle',
|
||||
'src/app/build.gradle'
|
||||
'src/app/build.gradle',
|
||||
];
|
||||
for (var path in possibleBuildGradleLocations) {
|
||||
try {
|
||||
var res = await sourceRequest(
|
||||
'${await convertStandardUrlToAPIUrl(standardUrl, additionalSettings)}/contents/$path',
|
||||
additionalSettings);
|
||||
'${await convertStandardUrlToAPIUrl(standardUrl, additionalSettings)}/contents/$path',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
try {
|
||||
var body = jsonDecode(res.body);
|
||||
var trimmedLines = utf8
|
||||
.decode(base64
|
||||
.decode(body['content'].toString().split('\n').join('')))
|
||||
.decode(
|
||||
base64.decode(
|
||||
body['content'].toString().split('\n').join(''),
|
||||
),
|
||||
)
|
||||
.split('\n')
|
||||
.map((e) => e.trim());
|
||||
var appIds = trimmedLines.where((l) =>
|
||||
l.startsWith('applicationId "') ||
|
||||
l.startsWith('applicationId \''));
|
||||
appIds = appIds.map((appId) => appId
|
||||
.split(appId.startsWith('applicationId "') ? '"' : '\'')[1]);
|
||||
appIds = appIds.map((appId) {
|
||||
if (appId.startsWith('\${') && appId.endsWith('}')) {
|
||||
appId = trimmedLines
|
||||
.where((l) => l.startsWith(
|
||||
'def ${appId.substring(2, appId.length - 1)}'))
|
||||
.first;
|
||||
appId = appId.split(appId.contains('"') ? '"' : '\'')[1];
|
||||
}
|
||||
return appId;
|
||||
}).where((appId) => appId.isNotEmpty);
|
||||
var appIds = trimmedLines.where(
|
||||
(l) =>
|
||||
l.startsWith('applicationId "') ||
|
||||
l.startsWith('applicationId \''),
|
||||
);
|
||||
appIds = appIds.map(
|
||||
(appId) => appId.split(
|
||||
appId.startsWith('applicationId "') ? '"' : '\'',
|
||||
)[1],
|
||||
);
|
||||
appIds = appIds
|
||||
.map((appId) {
|
||||
if (appId.startsWith('\${') && appId.endsWith('}')) {
|
||||
appId = trimmedLines
|
||||
.where(
|
||||
(l) => l.startsWith(
|
||||
'def ${appId.substring(2, appId.length - 1)}',
|
||||
),
|
||||
)
|
||||
.first;
|
||||
appId = appId.split(appId.contains('"') ? '"' : '\'')[1];
|
||||
}
|
||||
return appId;
|
||||
})
|
||||
.where((appId) => appId.isNotEmpty);
|
||||
if (appIds.length == 1) {
|
||||
return appIds.first;
|
||||
}
|
||||
} catch (err) {
|
||||
LogsProvider().add(
|
||||
'Error parsing build.gradle from ${res.request!.url.toString()}: ${err.toString()}');
|
||||
'Error parsing build.gradle from ${res.request!.url.toString()}: ${err.toString()}',
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
@ -170,8 +210,9 @@ class GitHub extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -181,8 +222,9 @@ class GitHub extends AppSource {
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
var token = await getTokenIfAny(additionalSettings);
|
||||
var headers = <String, String>{};
|
||||
if (token != null && token.isNotEmpty) {
|
||||
@ -201,14 +243,17 @@ class GitHub extends AppSource {
|
||||
Future<String?> getTokenIfAny(Map<String, dynamic> additionalSettings) async {
|
||||
SettingsProvider settingsProvider = SettingsProvider();
|
||||
await settingsProvider.initializeSettings();
|
||||
var sourceConfig =
|
||||
await getSourceConfigValues(additionalSettings, settingsProvider);
|
||||
var sourceConfig = await getSourceConfigValues(
|
||||
additionalSettings,
|
||||
settingsProvider,
|
||||
);
|
||||
String? creds = sourceConfig['github-creds'];
|
||||
if (creds != null) {
|
||||
var userNameEndIndex = creds.indexOf(':');
|
||||
if (userNameEndIndex > 0) {
|
||||
creds = creds.substring(
|
||||
userNameEndIndex + 1); // For old username-included token inputs
|
||||
userNameEndIndex + 1,
|
||||
); // For old username-included token inputs
|
||||
}
|
||||
return creds;
|
||||
} else {
|
||||
@ -228,31 +273,36 @@ class GitHub extends AppSource {
|
||||
'https://api.${hosts[0]}';
|
||||
|
||||
Future<String> convertStandardUrlToAPIUrl(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async =>
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async =>
|
||||
'${await getAPIHost(additionalSettings)}/repos${standardUrl.substring('https://${hosts[0]}'.length)}';
|
||||
|
||||
@override
|
||||
String? changeLogPageFromStandardUrl(String standardUrl) =>
|
||||
'$standardUrl/releases';
|
||||
|
||||
Future<APKDetails> getLatestAPKDetailsCommon(String requestUrl,
|
||||
String standardUrl, Map<String, dynamic> additionalSettings,
|
||||
{Function(Response)? onHttpErrorCode}) async {
|
||||
Future<APKDetails> getLatestAPKDetailsCommon(
|
||||
String requestUrl,
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
Function(Response)? onHttpErrorCode,
|
||||
}) async {
|
||||
bool includePrereleases = additionalSettings['includePrereleases'] == true;
|
||||
bool fallbackToOlderReleases =
|
||||
additionalSettings['fallbackToOlderReleases'] == true;
|
||||
String? regexFilter =
|
||||
(additionalSettings['filterReleaseTitlesByRegEx'] as String?)
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseTitlesByRegEx']
|
||||
: null;
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseTitlesByRegEx']
|
||||
: null;
|
||||
String? regexNotesFilter =
|
||||
(additionalSettings['filterReleaseNotesByRegEx'] as String?)
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseNotesByRegEx']
|
||||
: null;
|
||||
?.isNotEmpty ==
|
||||
true
|
||||
? additionalSettings['filterReleaseNotesByRegEx']
|
||||
: null;
|
||||
bool verifyLatestTag = additionalSettings['verifyLatestTag'] == true;
|
||||
bool useLatestAssetDateAsReleaseDate =
|
||||
additionalSettings['useLatestAssetDateAsReleaseDate'] == true;
|
||||
@ -262,8 +312,9 @@ class GitHub extends AppSource {
|
||||
if (verifyLatestTag) {
|
||||
var temp = requestUrl.split('?');
|
||||
Response res = await sourceRequest(
|
||||
'${temp[0]}/latest${temp.length > 1 ? '?${temp.sublist(1).join('?')}' : ''}',
|
||||
additionalSettings);
|
||||
'${temp[0]}/latest${temp.length > 1 ? '?${temp.sublist(1).join('?')}' : ''}',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
if (onHttpErrorCode != null) {
|
||||
onHttpErrorCode(res);
|
||||
@ -278,8 +329,10 @@ class GitHub extends AppSource {
|
||||
if (latestRelease != null) {
|
||||
var latestTag = latestRelease['tag_name'] ?? latestRelease['name'];
|
||||
if (releases
|
||||
.where((element) =>
|
||||
(element['tag_name'] ?? element['name']) == latestTag)
|
||||
.where(
|
||||
(element) =>
|
||||
(element['tag_name'] ?? element['name']) == latestTag,
|
||||
)
|
||||
.isEmpty) {
|
||||
releases = [latestRelease, ...releases];
|
||||
}
|
||||
@ -299,10 +352,10 @@ class GitHub extends AppSource {
|
||||
|
||||
DateTime? getPublishDateFromRelease(dynamic rel) =>
|
||||
rel?['published_at'] != null
|
||||
? DateTime.parse(rel['published_at'])
|
||||
: rel?['commit']?['created'] != null
|
||||
? DateTime.parse(rel['commit']['created'])
|
||||
: null;
|
||||
? DateTime.parse(rel['published_at'])
|
||||
: rel?['commit']?['created'] != null
|
||||
? DateTime.parse(rel['commit']['created'])
|
||||
: null;
|
||||
DateTime? getNewestAssetDateFromRelease(dynamic rel) {
|
||||
var allAssets = rel['assets'] as List<dynamic>?;
|
||||
var filteredAssets = rel['filteredAssets'] as List<dynamic>?;
|
||||
@ -323,8 +376,8 @@ class GitHub extends AppSource {
|
||||
|
||||
DateTime? getReleaseDateFromRelease(dynamic rel, bool useAssetDate) =>
|
||||
!useAssetDate
|
||||
? getPublishDateFromRelease(rel)
|
||||
: getNewestAssetDateFromRelease(rel);
|
||||
? getPublishDateFromRelease(rel)
|
||||
: getNewestAssetDateFromRelease(rel);
|
||||
|
||||
if (sortMethod == 'none') {
|
||||
releases = releases.reversed.toList();
|
||||
@ -340,29 +393,40 @@ class GitHub extends AppSource {
|
||||
} else {
|
||||
var nameA = a['tag_name'] ?? a['name'];
|
||||
var nameB = b['tag_name'] ?? b['name'];
|
||||
var stdFormats = findStandardFormatsForVersion(nameA, false)
|
||||
.intersection(findStandardFormatsForVersion(nameB, false));
|
||||
var stdFormats = findStandardFormatsForVersion(
|
||||
nameA,
|
||||
false,
|
||||
).intersection(findStandardFormatsForVersion(nameB, false));
|
||||
if (sortMethod == 'date' ||
|
||||
(sortMethod == 'smartname-datefallback' &&
|
||||
stdFormats.isEmpty)) {
|
||||
return (getReleaseDateFromRelease(
|
||||
a, useLatestAssetDateAsReleaseDate) ??
|
||||
a,
|
||||
useLatestAssetDateAsReleaseDate,
|
||||
) ??
|
||||
DateTime(1))
|
||||
.compareTo(getReleaseDateFromRelease(
|
||||
b, useLatestAssetDateAsReleaseDate) ??
|
||||
DateTime(0));
|
||||
.compareTo(
|
||||
getReleaseDateFromRelease(
|
||||
b,
|
||||
useLatestAssetDateAsReleaseDate,
|
||||
) ??
|
||||
DateTime(0),
|
||||
);
|
||||
} else {
|
||||
if (sortMethod != 'name' && stdFormats.isNotEmpty) {
|
||||
var reg = RegExp(stdFormats.last);
|
||||
var matchA = reg.firstMatch(nameA);
|
||||
var matchB = reg.firstMatch(nameB);
|
||||
return compareAlphaNumeric(
|
||||
(nameA as String).substring(matchA!.start, matchA.end),
|
||||
(nameB as String).substring(matchB!.start, matchB.end));
|
||||
(nameA as String).substring(matchA!.start, matchA.end),
|
||||
(nameB as String).substring(matchB!.start, matchB.end),
|
||||
);
|
||||
} else {
|
||||
// 'name'
|
||||
return compareAlphaNumeric(
|
||||
(nameA as String), (nameB as String));
|
||||
(nameA as String),
|
||||
(nameB as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,9 +438,11 @@ class GitHub extends AppSource {
|
||||
latestRelease !=
|
||||
(releases[releases.length - 1]['tag_name'] ??
|
||||
releases[0]['name'])) {
|
||||
var ind = releases.indexWhere((element) =>
|
||||
(latestRelease['tag_name'] ?? latestRelease['name']) ==
|
||||
(element['tag_name'] ?? element['name']));
|
||||
var ind = releases.indexWhere(
|
||||
(element) =>
|
||||
(latestRelease['tag_name'] ?? latestRelease['name']) ==
|
||||
(element['tag_name'] ?? element['name']),
|
||||
);
|
||||
if (ind >= 0) {
|
||||
releases.add(releases.removeAt(ind));
|
||||
}
|
||||
@ -404,8 +470,9 @@ class GitHub extends AppSource {
|
||||
continue;
|
||||
}
|
||||
if (regexNotesFilter != null &&
|
||||
!RegExp(regexNotesFilter)
|
||||
.hasMatch(((releases[i]['body'] as String?) ?? '').trim())) {
|
||||
!RegExp(
|
||||
regexNotesFilter,
|
||||
).hasMatch(((releases[i]['body'] as String?) ?? '').trim())) {
|
||||
continue;
|
||||
}
|
||||
var allAssetsWithUrls = findReleaseAssetUrls(releases[i]);
|
||||
@ -413,24 +480,31 @@ class GitHub extends AppSource {
|
||||
.map((e) => e['final_url'] as MapEntry<String, String>)
|
||||
.toList();
|
||||
var apkAssetsWithUrls = allAssetsWithUrls
|
||||
.where((element) =>
|
||||
(element['final_url'] as MapEntry<String, String>)
|
||||
.key
|
||||
.toLowerCase()
|
||||
.endsWith('.apk'))
|
||||
.where(
|
||||
(element) => (element['final_url'] as MapEntry<String, String>)
|
||||
.key
|
||||
.toLowerCase()
|
||||
.endsWith('.apk'),
|
||||
)
|
||||
.toList();
|
||||
|
||||
var filteredApkUrls = filterApks(
|
||||
apkAssetsWithUrls
|
||||
.map((e) => e['final_url'] as MapEntry<String, String>)
|
||||
.toList(),
|
||||
additionalSettings['apkFilterRegEx'],
|
||||
additionalSettings['invertAPKFilter']);
|
||||
apkAssetsWithUrls
|
||||
.map((e) => e['final_url'] as MapEntry<String, String>)
|
||||
.toList(),
|
||||
additionalSettings['apkFilterRegEx'],
|
||||
additionalSettings['invertAPKFilter'],
|
||||
);
|
||||
var filteredApks = apkAssetsWithUrls
|
||||
.where((e) => filteredApkUrls
|
||||
.where((e2) =>
|
||||
e2.key == (e['final_url'] as MapEntry<String, String>).key)
|
||||
.isNotEmpty)
|
||||
.where(
|
||||
(e) => filteredApkUrls
|
||||
.where(
|
||||
(e2) =>
|
||||
e2.key ==
|
||||
(e['final_url'] as MapEntry<String, String>).key,
|
||||
)
|
||||
.isNotEmpty,
|
||||
)
|
||||
.toList();
|
||||
|
||||
if (filteredApks.isEmpty && additionalSettings['trackOnly'] != true) {
|
||||
@ -441,17 +515,23 @@ class GitHub extends AppSource {
|
||||
targetRelease['filteredAssets'] = filteredApks;
|
||||
targetRelease['version'] =
|
||||
additionalSettings['releaseTitleAsVersion'] == true
|
||||
? nameToFilter
|
||||
: targetRelease['tag_name'] ?? targetRelease['name'];
|
||||
? nameToFilter
|
||||
: targetRelease['tag_name'] ?? targetRelease['name'];
|
||||
if (targetRelease['tarball_url'] != null) {
|
||||
allAssetUrls.add(MapEntry(
|
||||
allAssetUrls.add(
|
||||
MapEntry(
|
||||
(targetRelease['version'] ?? 'source') + '.tar.gz',
|
||||
targetRelease['tarball_url']));
|
||||
targetRelease['tarball_url'],
|
||||
),
|
||||
);
|
||||
}
|
||||
if (targetRelease['zipball_url'] != null) {
|
||||
allAssetUrls.add(MapEntry(
|
||||
allAssetUrls.add(
|
||||
MapEntry(
|
||||
(targetRelease['version'] ?? 'source') + '.zip',
|
||||
targetRelease['zipball_url']));
|
||||
targetRelease['zipball_url'],
|
||||
),
|
||||
);
|
||||
}
|
||||
targetRelease['allAssetUrls'] = allAssetUrls;
|
||||
break;
|
||||
@ -462,19 +542,22 @@ class GitHub extends AppSource {
|
||||
String? version = targetRelease['version'];
|
||||
|
||||
DateTime? releaseDate = getReleaseDateFromRelease(
|
||||
targetRelease, useLatestAssetDateAsReleaseDate);
|
||||
targetRelease,
|
||||
useLatestAssetDateAsReleaseDate,
|
||||
);
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
var changeLog = (targetRelease['body'] ?? '').toString();
|
||||
return APKDetails(
|
||||
version,
|
||||
targetRelease['apkUrls'] as List<MapEntry<String, String>>,
|
||||
getAppNames(standardUrl),
|
||||
releaseDate: releaseDate,
|
||||
changeLog: changeLog.isEmpty ? null : changeLog,
|
||||
allAssetUrls:
|
||||
targetRelease['allAssetUrls'] as List<MapEntry<String, String>>);
|
||||
version,
|
||||
targetRelease['apkUrls'] as List<MapEntry<String, String>>,
|
||||
getAppNames(standardUrl),
|
||||
releaseDate: releaseDate,
|
||||
changeLog: changeLog.isEmpty ? null : changeLog,
|
||||
allAssetUrls:
|
||||
targetRelease['allAssetUrls'] as List<MapEntry<String, String>>,
|
||||
);
|
||||
} else {
|
||||
if (onHttpErrorCode != null) {
|
||||
onHttpErrorCode(res);
|
||||
@ -483,20 +566,27 @@ class GitHub extends AppSource {
|
||||
}
|
||||
}
|
||||
|
||||
getLatestAPKDetailsCommon2(
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
Future<String> Function(bool) reqUrlGenerator,
|
||||
dynamic Function(Response)? onHttpErrorCode) async {
|
||||
Future<APKDetails> getLatestAPKDetailsCommon2(
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
Future<String> Function(bool) reqUrlGenerator,
|
||||
dynamic Function(Response)? onHttpErrorCode,
|
||||
) async {
|
||||
try {
|
||||
return await getLatestAPKDetailsCommon(
|
||||
await reqUrlGenerator(false), standardUrl, additionalSettings,
|
||||
onHttpErrorCode: onHttpErrorCode);
|
||||
await reqUrlGenerator(false),
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
onHttpErrorCode: onHttpErrorCode,
|
||||
);
|
||||
} catch (err) {
|
||||
if (err is NoReleasesError && additionalSettings['trackOnly'] == true) {
|
||||
return await getLatestAPKDetailsCommon(
|
||||
await reqUrlGenerator(true), standardUrl, additionalSettings,
|
||||
onHttpErrorCode: onHttpErrorCode);
|
||||
await reqUrlGenerator(true),
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
onHttpErrorCode: onHttpErrorCode,
|
||||
);
|
||||
} else {
|
||||
rethrow;
|
||||
}
|
||||
@ -508,12 +598,16 @@ class GitHub extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
return await getLatestAPKDetailsCommon2(standardUrl, additionalSettings,
|
||||
(bool useTagUrl) async {
|
||||
return '${await convertStandardUrlToAPIUrl(standardUrl, additionalSettings)}/${useTagUrl ? 'tags' : 'releases'}?per_page=100';
|
||||
}, (Response res) {
|
||||
rateLimitErrorCheck(res);
|
||||
});
|
||||
return await getLatestAPKDetailsCommon2(
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
(bool useTagUrl) async {
|
||||
return '${await convertStandardUrlToAPIUrl(standardUrl, additionalSettings)}/${useTagUrl ? 'tags' : 'releases'}?per_page=100';
|
||||
},
|
||||
(Response res) {
|
||||
rateLimitErrorCheck(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
AppNames getAppNames(String standardUrl) {
|
||||
@ -523,9 +617,12 @@ class GitHub extends AppSource {
|
||||
}
|
||||
|
||||
Future<Map<String, List<String>>> searchCommon(
|
||||
String query, String requestUrl, String rootProp,
|
||||
{Function(Response)? onHttpErrorCode,
|
||||
Map<String, dynamic> querySettings = const {}}) async {
|
||||
String query,
|
||||
String requestUrl,
|
||||
String rootProp, {
|
||||
Function(Response)? onHttpErrorCode,
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
Response res = await sourceRequest(requestUrl, {});
|
||||
if (res.statusCode == 200) {
|
||||
int minStarCount = querySettings['minStarCount'] != null
|
||||
@ -540,8 +637,8 @@ class GitHub extends AppSource {
|
||||
((e['archived'] == true ? '[ARCHIVED] ' : '') +
|
||||
(e['description'] != null
|
||||
? e['description'] as String
|
||||
: tr('noDescription')))
|
||||
]
|
||||
: tr('noDescription'))),
|
||||
],
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -555,22 +652,27 @@ class GitHub extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
return searchCommon(
|
||||
query,
|
||||
'${await getAPIHost({})}/search/repositories?q=${Uri.encodeQueryComponent(query)}&per_page=100',
|
||||
'items', onHttpErrorCode: (Response res) {
|
||||
rateLimitErrorCheck(res);
|
||||
}, querySettings: querySettings);
|
||||
query,
|
||||
'${await getAPIHost({})}/search/repositories?q=${Uri.encodeQueryComponent(query)}&per_page=100',
|
||||
'items',
|
||||
onHttpErrorCode: (Response res) {
|
||||
rateLimitErrorCheck(res);
|
||||
},
|
||||
querySettings: querySettings,
|
||||
);
|
||||
}
|
||||
|
||||
rateLimitErrorCheck(Response res) {
|
||||
void rateLimitErrorCheck(Response res) {
|
||||
if (res.headers['x-ratelimit-remaining'] == '0') {
|
||||
throw RateLimitError(
|
||||
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') /
|
||||
60000000)
|
||||
.round());
|
||||
(int.parse(res.headers['x-ratelimit-reset'] ?? '1800000000') / 60000000)
|
||||
.round(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,36 +18,41 @@ class GitLab extends AppSource {
|
||||
showReleaseDateAsVersionToggle = true;
|
||||
|
||||
sourceConfigSettingFormItems = [
|
||||
GeneratedFormTextField('gitlab-creds',
|
||||
label: tr('gitlabPATLabel'),
|
||||
password: true,
|
||||
required: false,
|
||||
belowWidgets: [
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
GeneratedFormTextField(
|
||||
'gitlab-creds',
|
||||
label: tr('gitlabPATLabel'),
|
||||
password: true,
|
||||
required: false,
|
||||
belowWidgets: [
|
||||
const SizedBox(height: 4),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token',
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
tr('about'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontSize: 12,
|
||||
),
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html#create-a-personal-access-token',
|
||||
mode: LaunchMode.externalApplication);
|
||||
},
|
||||
child: Text(
|
||||
tr('about'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline, fontSize: 12),
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 4,
|
||||
)
|
||||
])
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
],
|
||||
),
|
||||
];
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -55,11 +60,13 @@ class GitLab extends AppSource {
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
var urlSegments = url.split('/');
|
||||
var cutOffIndex = urlSegments.indexWhere((s) => s == '-');
|
||||
url =
|
||||
urlSegments.sublist(0, cutOffIndex <= 0 ? null : cutOffIndex).join('/');
|
||||
url = urlSegments
|
||||
.sublist(0, cutOffIndex <= 0 ? null : cutOffIndex)
|
||||
.join('/');
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+(/[^((\b/\b)|(\b/-/\b))]+){1,20}',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+(/[^((\b/\b)|(\b/-/\b))]+){1,20}',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -70,15 +77,19 @@ class GitLab extends AppSource {
|
||||
Future<String?> getPATIfAny(Map<String, dynamic> additionalSettings) async {
|
||||
SettingsProvider settingsProvider = SettingsProvider();
|
||||
await settingsProvider.initializeSettings();
|
||||
var sourceConfig =
|
||||
await getSourceConfigValues(additionalSettings, settingsProvider);
|
||||
var sourceConfig = await getSourceConfigValues(
|
||||
additionalSettings,
|
||||
settingsProvider,
|
||||
);
|
||||
String? creds = sourceConfig['gitlab-creds'];
|
||||
return creds != null && creds.isNotEmpty ? creds : null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
var url =
|
||||
'https://${hosts[0]}/api/v4/projects?search=${Uri.encodeQueryComponent(query)}';
|
||||
var res = await sourceRequest(url, {});
|
||||
@ -90,7 +101,7 @@ class GitLab extends AppSource {
|
||||
for (var element in json) {
|
||||
results['https://${hosts[0]}/${element['path_with_namespace']}'] = [
|
||||
element['name_with_namespace'],
|
||||
element['description'] ?? tr('noDescription')
|
||||
element['description'] ?? tr('noDescription'),
|
||||
];
|
||||
}
|
||||
return results;
|
||||
@ -102,8 +113,9 @@ class GitLab extends AppSource {
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
// Change headers to pacify, e.g. cloudflare protection
|
||||
// Related to: (#1397, #1389, #1384, #1382, #1381, #1380, #1359, #854, #785, #697)
|
||||
var headers = <String, String>{};
|
||||
@ -116,8 +128,11 @@ class GitLab extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> apkUrlPrefetchModifier(String apkUrl, String standardUrl,
|
||||
Map<String, dynamic> additionalSettings) async {
|
||||
Future<String> apkUrlPrefetchModifier(
|
||||
String apkUrl,
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
String? PAT = await getPATIfAny(hostChanged ? additionalSettings : {});
|
||||
String optionalAuth = (PAT != null) ? 'private_token=$PAT' : '';
|
||||
return '$apkUrl${(Uri.parse(apkUrl).query.isEmpty ? '?' : '&')}$optionalAuth';
|
||||
@ -139,8 +154,9 @@ class GitLab extends AppSource {
|
||||
|
||||
// Get project ID
|
||||
Response res0 = await sourceRequest(
|
||||
'https://${hosts[0]}/api/v4/projects/$projectUriComponent?$optionalAuth',
|
||||
additionalSettings);
|
||||
'https://${hosts[0]}/api/v4/projects/$projectUriComponent?$optionalAuth',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res0.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res0);
|
||||
}
|
||||
@ -151,8 +167,9 @@ class GitLab extends AppSource {
|
||||
|
||||
// Request data from REST API
|
||||
Response res = await sourceRequest(
|
||||
'https://${hosts[0]}/api/v4/projects/$projectUriComponent/${trackOnly ? 'repository/tags' : 'releases'}?$optionalAuth',
|
||||
additionalSettings);
|
||||
'https://${hosts[0]}/api/v4/projects/$projectUriComponent/${trackOnly ? 'repository/tags' : 'releases'}?$optionalAuth',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
@ -166,11 +183,13 @@ class GitLab extends AppSource {
|
||||
var url = (e['direct_asset_url'] ?? e['url'] ?? '') as String;
|
||||
var parsedUrl = url.isNotEmpty ? Uri.parse(url) : null;
|
||||
return MapEntry(
|
||||
(e['name'] ??
|
||||
(parsedUrl != null && parsedUrl.pathSegments.isNotEmpty
|
||||
? parsedUrl.pathSegments.last
|
||||
: 'unknown')) as String,
|
||||
(e['direct_asset_url'] ?? e['url'] ?? '') as String);
|
||||
(e['name'] ??
|
||||
(parsedUrl != null && parsedUrl.pathSegments.isNotEmpty
|
||||
? parsedUrl.pathSegments.last
|
||||
: 'unknown'))
|
||||
as String,
|
||||
(e['direct_asset_url'] ?? e['url'] ?? '') as String,
|
||||
);
|
||||
})
|
||||
.where((s) => s.key.isNotEmpty)
|
||||
.toList();
|
||||
@ -193,11 +212,15 @@ class GitLab extends AppSource {
|
||||
}
|
||||
var releaseDateString =
|
||||
e['released_at'] ?? e['created_at'] ?? e['commit']?['created_at'];
|
||||
DateTime? releaseDate =
|
||||
releaseDateString != null ? DateTime.parse(releaseDateString) : null;
|
||||
return APKDetails(e['tag_name'] ?? e['name'], apkUrls.entries.toList(),
|
||||
AppNames(names.author, names.name.split('/').last),
|
||||
releaseDate: releaseDate);
|
||||
DateTime? releaseDate = releaseDateString != null
|
||||
? DateTime.parse(releaseDateString)
|
||||
: null;
|
||||
return APKDetails(
|
||||
e['tag_name'] ?? e['name'],
|
||||
apkUrls.entries.toList(),
|
||||
AppNames(names.author, names.name.split('/').last),
|
||||
releaseDate: releaseDate,
|
||||
);
|
||||
});
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
@ -208,8 +231,9 @@ class GitLab extends AppSource {
|
||||
bool fallbackToOlderReleases =
|
||||
additionalSettings['fallbackToOlderReleases'] == true;
|
||||
if (finalResult.apkUrls.isEmpty && fallbackToOlderReleases && !trackOnly) {
|
||||
apkDetailsList =
|
||||
apkDetailsList.where((e) => e.apkUrls.isNotEmpty).toList();
|
||||
apkDetailsList = apkDetailsList
|
||||
.where((e) => e.apkUrls.isNotEmpty)
|
||||
.toList();
|
||||
finalResult = apkDetailsList.first;
|
||||
}
|
||||
|
||||
@ -218,10 +242,13 @@ class GitLab extends AppSource {
|
||||
}
|
||||
|
||||
finalResult.apkUrls = finalResult.apkUrls.map((apkUrl) {
|
||||
if (RegExp('^$standardUrl/-/jobs/[0-9]+/artifacts/file/[^/]+')
|
||||
.hasMatch(apkUrl.value)) {
|
||||
if (RegExp(
|
||||
'^$standardUrl/-/jobs/[0-9]+/artifacts/file/[^/]+',
|
||||
).hasMatch(apkUrl.value)) {
|
||||
return MapEntry(
|
||||
apkUrl.key, apkUrl.value.replaceFirst('/file/', '/raw/'));
|
||||
apkUrl.key,
|
||||
apkUrl.value.replaceFirst('/file/', '/raw/'),
|
||||
);
|
||||
} else {
|
||||
return apkUrl;
|
||||
}
|
||||
|
@ -9,6 +9,13 @@ import 'package:obtainium/providers/apps_provider.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
String ensureAbsoluteUrl(String ambiguousUrl, Uri referenceAbsoluteUrl) {
|
||||
try {
|
||||
if (Uri.parse(ambiguousUrl).isAbsolute) {
|
||||
return ambiguousUrl; // #2315
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
}
|
||||
return referenceAbsoluteUrl.resolve(ambiguousUrl).toString();
|
||||
}
|
||||
|
||||
@ -93,28 +100,37 @@ bool _isNumeric(String s) {
|
||||
return s.codeUnitAt(0) >= 48 && s.codeUnitAt(0) <= 57;
|
||||
}
|
||||
|
||||
List<MapEntry<String, String>> getLinksInLines(String lines) => RegExp(
|
||||
r'(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?')
|
||||
.allMatches(lines)
|
||||
.map((match) =>
|
||||
MapEntry(match.group(0)!, match.group(0)?.split('/').last ?? ''))
|
||||
.toList();
|
||||
List<MapEntry<String, String>> getLinksInLines(String lines) =>
|
||||
RegExp(
|
||||
r'(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?',
|
||||
)
|
||||
.allMatches(lines)
|
||||
.map(
|
||||
(match) =>
|
||||
MapEntry(match.group(0)!, match.group(0)?.split('/').last ?? ''),
|
||||
)
|
||||
.toList();
|
||||
|
||||
// Given an HTTP response, grab some links according to the common additional settings
|
||||
// (those that apply to intermediate and final steps)
|
||||
Future<List<MapEntry<String, String>>> grabLinksCommon(
|
||||
Response res, Map<String, dynamic> additionalSettings) async {
|
||||
Response res,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
var html = parse(res.body);
|
||||
List<MapEntry<String, String>> allLinks = html
|
||||
.querySelectorAll('a')
|
||||
.map((element) => MapEntry(
|
||||
.map(
|
||||
(element) => MapEntry(
|
||||
element.attributes['href'] ?? '',
|
||||
element.text.isNotEmpty
|
||||
? element.text
|
||||
: (element.attributes['href'] ?? '').split('/').last))
|
||||
: (element.attributes['href'] ?? '').split('/').last,
|
||||
),
|
||||
)
|
||||
.where((element) => element.key.isNotEmpty)
|
||||
.map((e) => MapEntry(ensureAbsoluteUrl(e.key, res.request!.url), e.value))
|
||||
.toList();
|
||||
@ -127,9 +143,13 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
|
||||
var jsonStrings = collectAllStringsFromJSONObject(jsonDecode(res.body));
|
||||
allLinks = getLinksInLines(jsonStrings.join('\n'));
|
||||
if (allLinks.isEmpty) {
|
||||
allLinks = getLinksInLines(jsonStrings.map((l) {
|
||||
return ensureAbsoluteUrl(l, res.request!.url);
|
||||
}).join('\n'));
|
||||
allLinks = getLinksInLines(
|
||||
jsonStrings
|
||||
.map((l) {
|
||||
return ensureAbsoluteUrl(l, res.request!.url);
|
||||
})
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
//
|
||||
@ -158,17 +178,20 @@ Future<List<MapEntry<String, String>>> grabLinksCommon(
|
||||
} catch (e) {
|
||||
// Some links may not have valid encoding
|
||||
}
|
||||
return Uri.parse(filterLinkByText ? element.value : link)
|
||||
.path
|
||||
.toLowerCase()
|
||||
.endsWith('.apk');
|
||||
return Uri.parse(
|
||||
filterLinkByText ? element.value : link,
|
||||
).path.toLowerCase().endsWith('.apk');
|
||||
}).toList();
|
||||
}
|
||||
if (!skipSort) {
|
||||
links.sort((a, b) => additionalSettings['sortByLastLinkSegment'] == true
|
||||
? compareAlphaNumeric(a.key.split('/').where((e) => e.isNotEmpty).last,
|
||||
b.key.split('/').where((e) => e.isNotEmpty).last)
|
||||
: compareAlphaNumeric(a.key, b.key));
|
||||
links.sort(
|
||||
(a, b) => additionalSettings['sortByLastLinkSegment'] == true
|
||||
? compareAlphaNumeric(
|
||||
a.key.split('/').where((e) => e.isNotEmpty).last,
|
||||
b.key.split('/').where((e) => e.isNotEmpty).last,
|
||||
)
|
||||
: compareAlphaNumeric(a.key, b.key),
|
||||
);
|
||||
}
|
||||
if (additionalSettings['reverseSort'] == true) {
|
||||
links = links.reversed.toList();
|
||||
@ -194,102 +217,119 @@ class HTML extends AppSource {
|
||||
|
||||
var finalStepFormitems = [
|
||||
[
|
||||
GeneratedFormTextField('customLinkFilterRegex',
|
||||
label: tr('customLinkFilterRegex'),
|
||||
hint: 'download/(.*/)?(android|apk|mobile)',
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
}
|
||||
])
|
||||
GeneratedFormTextField(
|
||||
'customLinkFilterRegex',
|
||||
label: tr('customLinkFilterRegex'),
|
||||
hint: 'download/(.*/)?(android|apk|mobile)',
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
return regExValidator(value);
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('versionExtractWholePage',
|
||||
label: tr('versionExtractWholePage'))
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'versionExtractWholePage',
|
||||
label: tr('versionExtractWholePage'),
|
||||
),
|
||||
],
|
||||
];
|
||||
var commonFormItems = [
|
||||
[GeneratedFormSwitch('filterByLinkText', label: tr('filterByLinkText'))],
|
||||
[GeneratedFormSwitch('skipSort', label: tr('skipSort'))],
|
||||
[GeneratedFormSwitch('reverseSort', label: tr('takeFirstLink'))],
|
||||
[
|
||||
GeneratedFormSwitch('sortByLastLinkSegment',
|
||||
label: tr('sortByLastLinkSegment'))
|
||||
GeneratedFormSwitch(
|
||||
'sortByLastLinkSegment',
|
||||
label: tr('sortByLastLinkSegment'),
|
||||
),
|
||||
],
|
||||
];
|
||||
var intermediateFormItems = [
|
||||
[
|
||||
GeneratedFormTextField('customLinkFilterRegex',
|
||||
label: tr('intermediateLinkRegex'),
|
||||
hint: '([0-9]+.)*[0-9]+/\$',
|
||||
required: true,
|
||||
additionalValidators: [(value) => regExValidator(value)])
|
||||
GeneratedFormTextField(
|
||||
'customLinkFilterRegex',
|
||||
label: tr('intermediateLinkRegex'),
|
||||
hint: '([0-9]+.)*[0-9]+/\$',
|
||||
required: true,
|
||||
additionalValidators: [(value) => regExValidator(value)],
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormSwitch('autoLinkFilterByArch',
|
||||
label: tr('autoLinkFilterByArch'), defaultValue: false)
|
||||
GeneratedFormSwitch(
|
||||
'autoLinkFilterByArch',
|
||||
label: tr('autoLinkFilterByArch'),
|
||||
defaultValue: false,
|
||||
),
|
||||
],
|
||||
];
|
||||
HTML() {
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSubForm(
|
||||
'intermediateLink', [...intermediateFormItems, ...commonFormItems],
|
||||
label: tr('intermediateLink'))
|
||||
GeneratedFormSubForm('intermediateLink', [
|
||||
...intermediateFormItems,
|
||||
...commonFormItems,
|
||||
], label: tr('intermediateLink')),
|
||||
],
|
||||
finalStepFormitems[0],
|
||||
...commonFormItems,
|
||||
...finalStepFormitems.sublist(1),
|
||||
[
|
||||
GeneratedFormSubForm(
|
||||
'requestHeader',
|
||||
'requestHeader',
|
||||
[
|
||||
[
|
||||
[
|
||||
GeneratedFormTextField('requestHeader',
|
||||
label: tr('requestHeader'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
if ((value ?? 'empty:valid')
|
||||
.split(':')
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.length <
|
||||
2) {
|
||||
return tr('invalidInput');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
])
|
||||
]
|
||||
GeneratedFormTextField(
|
||||
'requestHeader',
|
||||
label: tr('requestHeader'),
|
||||
required: false,
|
||||
additionalValidators: [
|
||||
(value) {
|
||||
if ((value ?? 'empty:valid')
|
||||
.split(':')
|
||||
.map((e) => e.trim())
|
||||
.where((e) => e.isNotEmpty)
|
||||
.length <
|
||||
2) {
|
||||
return tr('invalidInput');
|
||||
}
|
||||
return null;
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
label: tr('requestHeader'),
|
||||
defaultValue: [
|
||||
{
|
||||
'requestHeader':
|
||||
'User-Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36'
|
||||
}
|
||||
])
|
||||
],
|
||||
label: tr('requestHeader'),
|
||||
defaultValue: [
|
||||
{
|
||||
'requestHeader':
|
||||
'User-Agent: Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Mobile Safari/537.36',
|
||||
},
|
||||
],
|
||||
),
|
||||
],
|
||||
[
|
||||
GeneratedFormDropdown(
|
||||
'defaultPseudoVersioningMethod',
|
||||
[
|
||||
MapEntry('partialAPKHash', tr('partialAPKHash')),
|
||||
MapEntry('APKLinkHash', tr('APKLinkHash')),
|
||||
MapEntry('ETag', 'ETag')
|
||||
],
|
||||
label: tr('defaultPseudoVersioningMethod'),
|
||||
defaultValue: 'partialAPKHash')
|
||||
]
|
||||
'defaultPseudoVersioningMethod',
|
||||
[
|
||||
MapEntry('partialAPKHash', tr('partialAPKHash')),
|
||||
MapEntry('APKLinkHash', tr('APKLinkHash')),
|
||||
MapEntry('ETag', 'ETag'),
|
||||
],
|
||||
label: tr('defaultPseudoVersioningMethod'),
|
||||
defaultValue: 'partialAPKHash',
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, String>?> getRequestHeaders(
|
||||
Map<String, dynamic> additionalSettings,
|
||||
{bool forAPKDownload = false}) async {
|
||||
Map<String, dynamic> additionalSettings, {
|
||||
bool forAPKDownload = false,
|
||||
}) async {
|
||||
if (additionalSettings.isNotEmpty) {
|
||||
if (additionalSettings['requestHeader']?.isNotEmpty != true) {
|
||||
additionalSettings['requestHeader'] = [];
|
||||
@ -329,8 +369,9 @@ class HTML extends AppSource {
|
||||
.toList();
|
||||
for (int i = 0; i < (additionalSettings['intermediateLink'].length); i++) {
|
||||
var intLinks = await grabLinksCommon(
|
||||
await sourceRequest(currentUrl, additionalSettings),
|
||||
additionalSettings['intermediateLink'][i]);
|
||||
await sourceRequest(currentUrl, additionalSettings),
|
||||
additionalSettings['intermediateLink'][i],
|
||||
);
|
||||
if (intLinks.isEmpty) {
|
||||
throw NoReleasesError(note: currentUrl);
|
||||
} else {
|
||||
@ -346,11 +387,17 @@ class HTML extends AppSource {
|
||||
String versionExtractionWholePageString = currentUrl;
|
||||
if (additionalSettings['directAPKLink'] != true) {
|
||||
Response res = await sourceRequest(currentUrl, additionalSettings);
|
||||
versionExtractionWholePageString =
|
||||
res.body.split('\r\n').join('\n').split('\n').join('\\n');
|
||||
versionExtractionWholePageString = res.body
|
||||
.split('\r\n')
|
||||
.join('\n')
|
||||
.split('\n')
|
||||
.join('\\n');
|
||||
links = await grabLinksCommon(res, additionalSettings);
|
||||
links = filterApks(links, additionalSettings['apkFilterRegEx'],
|
||||
additionalSettings['invertAPKFilter']);
|
||||
links = filterApks(
|
||||
links,
|
||||
additionalSettings['apkFilterRegEx'],
|
||||
additionalSettings['invertAPKFilter'],
|
||||
);
|
||||
if (links.isEmpty) {
|
||||
throw NoReleasesError(note: currentUrl);
|
||||
}
|
||||
@ -366,37 +413,45 @@ class HTML extends AppSource {
|
||||
}
|
||||
String? version;
|
||||
version = extractVersion(
|
||||
additionalSettings['versionExtractionRegEx'] as String?,
|
||||
additionalSettings['matchGroupToUse'] as String?,
|
||||
additionalSettings['versionExtractWholePage'] == true
|
||||
? versionExtractionWholePageString
|
||||
: relDecoded);
|
||||
var apkReqHeaders =
|
||||
await getRequestHeaders(additionalSettings, forAPKDownload: true);
|
||||
additionalSettings['versionExtractionRegEx'] as String?,
|
||||
additionalSettings['matchGroupToUse'] as String?,
|
||||
additionalSettings['versionExtractWholePage'] == true
|
||||
? versionExtractionWholePageString
|
||||
: relDecoded,
|
||||
);
|
||||
var apkReqHeaders = await getRequestHeaders(
|
||||
additionalSettings,
|
||||
forAPKDownload: true,
|
||||
);
|
||||
if (version == null &&
|
||||
additionalSettings['defaultPseudoVersioningMethod'] == 'ETag') {
|
||||
version = await checkETagHeader(rel,
|
||||
headers: apkReqHeaders,
|
||||
allowInsecure: additionalSettings['allowInsecure'] == true);
|
||||
version = await checkETagHeader(
|
||||
rel,
|
||||
headers: apkReqHeaders,
|
||||
allowInsecure: additionalSettings['allowInsecure'] == true,
|
||||
);
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
}
|
||||
version ??=
|
||||
additionalSettings['defaultPseudoVersioningMethod'] == 'APKLinkHash'
|
||||
? rel.hashCode.toString()
|
||||
: (await checkPartialDownloadHashDynamic(rel,
|
||||
headers: apkReqHeaders,
|
||||
allowInsecure: additionalSettings['allowInsecure'] == true))
|
||||
.toString();
|
||||
? rel.hashCode.toString()
|
||||
: (await checkPartialDownloadHashDynamic(
|
||||
rel,
|
||||
headers: apkReqHeaders,
|
||||
allowInsecure: additionalSettings['allowInsecure'] == true,
|
||||
)).toString();
|
||||
return APKDetails(
|
||||
version,
|
||||
[rel].map((e) {
|
||||
var uri = Uri.parse(e);
|
||||
var fileName =
|
||||
uri.pathSegments.isNotEmpty ? uri.pathSegments.last : uri.origin;
|
||||
return MapEntry('${e.hashCode}-$fileName', e);
|
||||
}).toList(),
|
||||
AppNames(uri.host, tr('app')));
|
||||
version,
|
||||
[rel].map((e) {
|
||||
var uri = Uri.parse(e);
|
||||
var fileName = uri.pathSegments.isNotEmpty
|
||||
? uri.pathSegments.last
|
||||
: uri.origin;
|
||||
return MapEntry('${e.hashCode}-$fileName', e);
|
||||
}).toList(),
|
||||
AppNames(uri.host, tr('app')),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -14,8 +14,9 @@ class HuaweiAppGallery extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}(/#)?/(app|appdl)/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -23,13 +24,18 @@ class HuaweiAppGallery extends AppSource {
|
||||
return match.group(0)!;
|
||||
}
|
||||
|
||||
getDlUrl(String standardUrl) =>
|
||||
String getDlUrl(String standardUrl) =>
|
||||
'https://${hosts[0].replaceAll('appgallery.huawei', 'appgallery.cloud.huawei')}/appdl/${standardUrl.split('/').last}';
|
||||
|
||||
requestAppdlRedirect(
|
||||
String dlUrl, Map<String, dynamic> additionalSettings) async {
|
||||
Response res =
|
||||
await sourceRequest(dlUrl, additionalSettings, followRedirects: false);
|
||||
Future<Response> requestAppdlRedirect(
|
||||
String dlUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
Response res = await sourceRequest(
|
||||
dlUrl,
|
||||
additionalSettings,
|
||||
followRedirects: false,
|
||||
);
|
||||
if (res.statusCode == 200 ||
|
||||
res.statusCode == 302 ||
|
||||
res.statusCode == 304) {
|
||||
@ -39,7 +45,7 @@ class HuaweiAppGallery extends AppSource {
|
||||
}
|
||||
}
|
||||
|
||||
appIdFromRedirectDlUrl(String redirectDlUrl) {
|
||||
String appIdFromRedirectDlUrl(String redirectDlUrl) {
|
||||
var parts = redirectDlUrl
|
||||
.split('?')[0]
|
||||
.split('/')
|
||||
@ -53,8 +59,10 @@ class HuaweiAppGallery extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
String dlUrl = getDlUrl(standardUrl);
|
||||
Response res = await requestAppdlRedirect(dlUrl, additionalSettings);
|
||||
return res.headers['location'] != null
|
||||
@ -76,8 +84,11 @@ class HuaweiAppGallery extends AppSource {
|
||||
if (appId.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
var relDateStr =
|
||||
res.headers['location']?.split('?')[0].split('.').reversed.toList()[1];
|
||||
var relDateStr = res.headers['location']
|
||||
?.split('?')[0]
|
||||
.split('.')
|
||||
.reversed
|
||||
.toList()[1];
|
||||
if (relDateStr == null || relDateStr.length != 10) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
@ -88,10 +99,15 @@ class HuaweiAppGallery extends AppSource {
|
||||
relDateStrAdj.insert((i + i ~/ 2 - 1), '-');
|
||||
i += 2;
|
||||
}
|
||||
var relDate =
|
||||
DateFormat('yy-MM-dd-HH-mm', 'en_US').parse(relDateStrAdj.join(''));
|
||||
var relDate = DateFormat(
|
||||
'yy-MM-dd-HH-mm',
|
||||
'en_US',
|
||||
).parse(relDateStrAdj.join(''));
|
||||
return APKDetails(
|
||||
relDateStr, [MapEntry('$appId.apk', dlUrl)], AppNames(name, appId),
|
||||
releaseDate: relDate);
|
||||
relDateStr,
|
||||
[MapEntry('$appId.apk', dlUrl)],
|
||||
AppNames(name, appId),
|
||||
releaseDate: relDate,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -16,13 +16,15 @@ class IzzyOnDroid extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegExA = RegExp(
|
||||
'^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://android.${getSourceRegex(hosts)}/repo/apk/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegExA.firstMatch(url);
|
||||
if (match == null) {
|
||||
RegExp standardUrlRegExB = RegExp(
|
||||
'^https?://apt.${getSourceRegex(hosts)}/fdroid/index/apk/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://apt.${getSourceRegex(hosts)}/fdroid/index/apk/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
match = standardUrlRegExB.firstMatch(url);
|
||||
}
|
||||
if (match == null) {
|
||||
@ -32,8 +34,10 @@ class IzzyOnDroid extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return fd.tryInferringAppId(standardUrl);
|
||||
}
|
||||
|
||||
@ -44,12 +48,14 @@ class IzzyOnDroid extends AppSource {
|
||||
) async {
|
||||
String? appId = await tryInferringAppId(standardUrl);
|
||||
return fd.getAPKUrlsFromFDroidPackagesAPIResponse(
|
||||
await sourceRequest(
|
||||
'https://apt.izzysoft.de/fdroid/api/v1/packages/$appId',
|
||||
additionalSettings),
|
||||
'https://android.izzysoft.de/frepo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
additionalSettings: additionalSettings);
|
||||
await sourceRequest(
|
||||
'https://apt.izzysoft.de/fdroid/api/v1/packages/$appId',
|
||||
additionalSettings,
|
||||
),
|
||||
'https://android.izzysoft.de/frepo/$appId',
|
||||
standardUrl,
|
||||
name,
|
||||
additionalSettings: additionalSettings,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -31,14 +31,17 @@ class Jenkins extends AppSource {
|
||||
) async {
|
||||
standardUrl = trimJobUrl(standardUrl);
|
||||
Response res = await sourceRequest(
|
||||
'$standardUrl/lastSuccessfulBuild/api/json', additionalSettings);
|
||||
'$standardUrl/lastSuccessfulBuild/api/json',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var json = jsonDecode(res.body);
|
||||
var releaseDate = json['timestamp'] == null
|
||||
? null
|
||||
: DateTime.fromMillisecondsSinceEpoch(json['timestamp'] as int);
|
||||
var version =
|
||||
json['number'] == null ? null : (json['number'] as int).toString();
|
||||
var version = json['number'] == null
|
||||
? null
|
||||
: (json['number'] as int).toString();
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
@ -51,16 +54,21 @@ class Jenkins extends AppSource {
|
||||
return path == null
|
||||
? const MapEntry<String, String>('', '')
|
||||
: MapEntry<String, String>(
|
||||
(e['fileName'] ?? e['relativePath']) as String, path);
|
||||
(e['fileName'] ?? e['relativePath']) as String,
|
||||
path,
|
||||
);
|
||||
})
|
||||
.where((url) =>
|
||||
url.value.isNotEmpty && url.key.toLowerCase().endsWith('.apk'))
|
||||
.where(
|
||||
(url) =>
|
||||
url.value.isNotEmpty && url.key.toLowerCase().endsWith('.apk'),
|
||||
)
|
||||
.toList();
|
||||
return APKDetails(
|
||||
version,
|
||||
apkUrls,
|
||||
releaseDate: releaseDate,
|
||||
AppNames(Uri.parse(standardUrl).host, standardUrl.split('/').last));
|
||||
version,
|
||||
apkUrls,
|
||||
releaseDate: releaseDate,
|
||||
AppNames(Uri.parse(standardUrl).host, standardUrl.split('/').last),
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -12,8 +12,9 @@ class Mullvad extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -31,7 +32,9 @@ class Mullvad extends AppSource {
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
Response res = await sourceRequest(
|
||||
'$standardUrl/en/download/android', additionalSettings);
|
||||
'$standardUrl/en/download/android',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var versions = parse(res.body)
|
||||
.querySelectorAll('p')
|
||||
@ -53,17 +56,18 @@ class Mullvad extends AppSource {
|
||||
String? changeLog;
|
||||
try {
|
||||
changeLog = (await GitHub().getLatestAPKDetails(
|
||||
'https://github.com/mullvad/mullvadvpn-app',
|
||||
{'fallbackToOlderReleases': true}))
|
||||
.changeLog;
|
||||
'https://github.com/mullvad/mullvadvpn-app',
|
||||
{'fallbackToOlderReleases': true},
|
||||
)).changeLog;
|
||||
} catch (e) {
|
||||
// Ignore
|
||||
}
|
||||
return APKDetails(
|
||||
versions[0],
|
||||
getApkUrlsFromUrls(['https://mullvad.net/download/app/apk/latest']),
|
||||
AppNames(name, 'Mullvad-VPN'),
|
||||
changeLog: changeLog);
|
||||
versions[0],
|
||||
getApkUrlsFromUrls(['https://mullvad.net/download/app/apk/latest']),
|
||||
AppNames(name, 'Mullvad-VPN'),
|
||||
changeLog: changeLog,
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -12,8 +12,9 @@ class NeutronCode extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/downloads/file/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -55,7 +56,7 @@ class NeutronCode extends AppSource {
|
||||
}
|
||||
}
|
||||
|
||||
customDateParse(String dateString) {
|
||||
String? customDateParse(String dateString) {
|
||||
List<String> parts = dateString.split(' ');
|
||||
if (parts.length != 3) {
|
||||
return null;
|
||||
@ -89,24 +90,31 @@ class NeutronCode extends AppSource {
|
||||
if (filename == null) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
var version =
|
||||
http.querySelector('.pd-version-txt')?.nextElementSibling?.innerHtml;
|
||||
var version = http
|
||||
.querySelector('.pd-version-txt')
|
||||
?.nextElementSibling
|
||||
?.innerHtml;
|
||||
if (version == null) {
|
||||
throw NoVersionError();
|
||||
}
|
||||
String? apkUrl = 'https://${hosts[0]}/download/$filename';
|
||||
var dateStringOriginal =
|
||||
http.querySelector('.pd-date-txt')?.nextElementSibling?.innerHtml;
|
||||
var dateStringOriginal = http
|
||||
.querySelector('.pd-date-txt')
|
||||
?.nextElementSibling
|
||||
?.innerHtml;
|
||||
var dateString = dateStringOriginal != null
|
||||
? (customDateParse(dateStringOriginal))
|
||||
: null;
|
||||
var changeLogElements = http.querySelectorAll('.pd-fdesc p');
|
||||
return APKDetails(version, getApkUrlsFromUrls([apkUrl]),
|
||||
AppNames(runtimeType.toString(), name ?? standardUrl.split('/').last),
|
||||
releaseDate: dateString != null ? DateTime.parse(dateString) : null,
|
||||
changeLog: changeLogElements.isNotEmpty
|
||||
? changeLogElements.last.innerHtml
|
||||
: null);
|
||||
return APKDetails(
|
||||
version,
|
||||
getApkUrlsFromUrls([apkUrl]),
|
||||
AppNames(runtimeType.toString(), name ?? standardUrl.split('/').last),
|
||||
releaseDate: dateString != null ? DateTime.parse(dateString) : null,
|
||||
changeLog: changeLogElements.isNotEmpty
|
||||
? changeLogElements.last.innerHtml
|
||||
: null,
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -18,8 +18,9 @@ class RuStore extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/catalog/app/+[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/catalog/app/+[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -28,16 +29,18 @@ class RuStore extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
Future<String> decodeString(String str) async {
|
||||
try {
|
||||
return (await CharsetDetector.autoDecode(
|
||||
Uint8List.fromList(str.codeUnits)))
|
||||
.string;
|
||||
Uint8List.fromList(str.codeUnits),
|
||||
)).string;
|
||||
} catch (e) {
|
||||
return str;
|
||||
}
|
||||
@ -50,8 +53,9 @@ class RuStore extends AppSource {
|
||||
) async {
|
||||
String? appId = await tryInferringAppId(standardUrl);
|
||||
Response res0 = await sourceRequest(
|
||||
'https://backapi.rustore.ru/applicationData/overallInfo/$appId',
|
||||
additionalSettings);
|
||||
'https://backapi.rustore.ru/applicationData/overallInfo/$appId',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res0.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res0);
|
||||
}
|
||||
@ -74,10 +78,11 @@ class RuStore extends AppSource {
|
||||
}
|
||||
|
||||
Response res1 = await sourceRequest(
|
||||
'https://backapi.rustore.ru/applicationData/download-link',
|
||||
additionalSettings,
|
||||
followRedirects: false,
|
||||
postBody: {"appId": appDetails['appId'], "firstInstall": true});
|
||||
'https://backapi.rustore.ru/applicationData/download-link',
|
||||
additionalSettings,
|
||||
followRedirects: false,
|
||||
postBody: {"appId": appDetails['appId'], "firstInstall": true},
|
||||
);
|
||||
var downloadDetails = jsonDecode(res1.body)['body'];
|
||||
if (res1.statusCode != 200 || downloadDetails['apkUrl'] == null) {
|
||||
throw NoAPKError();
|
||||
@ -88,13 +93,16 @@ class RuStore extends AppSource {
|
||||
changeLog = changeLog != null ? await decodeString(changeLog) : null;
|
||||
|
||||
return APKDetails(
|
||||
version,
|
||||
getApkUrlsFromUrls([
|
||||
(downloadDetails['apkUrl'] as String)
|
||||
.replaceAll(RegExp('\\.zip\$'), '.apk')
|
||||
]),
|
||||
AppNames(author, appName),
|
||||
releaseDate: relDate,
|
||||
changeLog: changeLog);
|
||||
version,
|
||||
getApkUrlsFromUrls([
|
||||
(downloadDetails['apkUrl'] as String).replaceAll(
|
||||
RegExp('\\.zip\$'),
|
||||
'.apk',
|
||||
),
|
||||
]),
|
||||
AppNames(author, appName),
|
||||
releaseDate: relDate,
|
||||
changeLog: changeLog,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -11,23 +11,27 @@ class SourceForge extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
var sourceRegex = getSourceRegex(hosts);
|
||||
RegExp standardUrlRegExC =
|
||||
RegExp('^https?://(www\\.)?$sourceRegex/p/.+', caseSensitive: false);
|
||||
RegExp standardUrlRegExC = RegExp(
|
||||
'^https?://(www\\.)?$sourceRegex/p/.+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegExC.firstMatch(url);
|
||||
if (match != null) {
|
||||
url =
|
||||
'https://${Uri.parse(match.group(0)!).host}/projects/${url.substring(Uri.parse(match.group(0)!).host.length + '/projects/'.length + 1)}';
|
||||
}
|
||||
RegExp standardUrlRegExB = RegExp(
|
||||
'^https?://(www\\.)?$sourceRegex/projects/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?$sourceRegex/projects/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
match = standardUrlRegExB.firstMatch(url);
|
||||
if (match != null && match.group(0) == url) {
|
||||
url = '$url/files';
|
||||
}
|
||||
RegExp standardUrlRegExA = RegExp(
|
||||
'^https?://(www\\.)?$sourceRegex/projects/[^/]+/files(/.+)?',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?$sourceRegex/projects/[^/]+/files(/.+)?',
|
||||
caseSensitive: false,
|
||||
);
|
||||
match = standardUrlRegExA.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -46,8 +50,9 @@ class SourceForge extends AppSource {
|
||||
standardUri = Uri.parse(standardUrl);
|
||||
}
|
||||
Response res = await sourceRequest(
|
||||
'${standardUri.origin}/${standardUri.pathSegments.sublist(0, 2).join('/')}/rss?path=/',
|
||||
additionalSettings);
|
||||
'${standardUri.origin}/${standardUri.pathSegments.sublist(0, 2).join('/')}/rss?path=/',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var parsedHtml = parse(res.body);
|
||||
var allDownloadLinks = parsedHtml
|
||||
@ -74,9 +79,10 @@ class SourceForge extends AppSource {
|
||||
if (version != null) {
|
||||
try {
|
||||
var extractedVersion = extractVersion(
|
||||
additionalSettings['versionExtractionRegEx'] as String?,
|
||||
additionalSettings['matchGroupToUse'] as String?,
|
||||
version);
|
||||
additionalSettings['versionExtractionRegEx'] as String?,
|
||||
additionalSettings['matchGroupToUse'] as String?,
|
||||
version,
|
||||
);
|
||||
if (extractedVersion != null) {
|
||||
version = extractedVersion;
|
||||
}
|
||||
@ -111,8 +117,11 @@ class SourceForge extends AppSource {
|
||||
.where((element) => getVersion(element) == version)
|
||||
.toList();
|
||||
var segments = standardUrl.split('/');
|
||||
return APKDetails(version, getApkUrlsFromUrls(apkUrlList),
|
||||
AppNames(name, segments[segments.indexOf('files') - 1]));
|
||||
return APKDetails(
|
||||
version,
|
||||
getApkUrlsFromUrls(apkUrlList),
|
||||
AppNames(name, segments[segments.indexOf('files') - 1]),
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -13,17 +13,21 @@ class SourceHut extends AppSource {
|
||||
|
||||
additionalSourceAppSpecificSettingFormItems = [
|
||||
[
|
||||
GeneratedFormSwitch('fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'), defaultValue: true)
|
||||
]
|
||||
GeneratedFormSwitch(
|
||||
'fallbackToOlderReleases',
|
||||
label: tr('fallbackToOlderReleases'),
|
||||
defaultValue: true,
|
||||
),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://(www\\.)?${getSourceRegex(hosts)}/[^/]+/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -52,8 +56,10 @@ class SourceHut extends AppSource {
|
||||
String appName = standardUri.pathSegments.last;
|
||||
bool fallbackToOlderReleases =
|
||||
additionalSettings['fallbackToOlderReleases'] == true;
|
||||
Response res =
|
||||
await sourceRequest('$standardUrl/refs/rss.xml', additionalSettings);
|
||||
Response res = await sourceRequest(
|
||||
'$standardUrl/refs/rss.xml',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var parsedHtml = parse(res.body);
|
||||
List<APKDetails> apkDetailsList = [];
|
||||
@ -63,10 +69,10 @@ class SourceHut extends AppSource {
|
||||
ind++;
|
||||
String releasePage = // querySelector('link') fails for some reason
|
||||
entry
|
||||
.querySelector('guid') // Luckily guid is identical
|
||||
?.innerHtml
|
||||
.trim() ??
|
||||
'';
|
||||
.querySelector('guid') // Luckily guid is identical
|
||||
?.innerHtml
|
||||
.trim() ??
|
||||
'';
|
||||
if (!releasePage.startsWith('$standardUrl/refs')) {
|
||||
continue;
|
||||
}
|
||||
@ -84,8 +90,9 @@ class SourceHut extends AppSource {
|
||||
? DateFormat('E, dd MMM yyyy HH:mm:ss Z').parse(releaseDateString)
|
||||
: null;
|
||||
releaseDate = releaseDateString != null
|
||||
? DateFormat('EEE, dd MMM yyyy HH:mm:ss Z')
|
||||
.parse(releaseDateString)
|
||||
? DateFormat(
|
||||
'EEE, dd MMM yyyy HH:mm:ss Z',
|
||||
).parse(releaseDateString)
|
||||
: null;
|
||||
} catch (e) {
|
||||
// ignore
|
||||
@ -93,27 +100,35 @@ class SourceHut extends AppSource {
|
||||
var res2 = await sourceRequest(releasePage, additionalSettings);
|
||||
List<MapEntry<String, String>> apkUrls = [];
|
||||
if (res2.statusCode == 200) {
|
||||
apkUrls = getApkUrlsFromUrls(parse(res2.body)
|
||||
.querySelectorAll('a')
|
||||
.map((e) => e.attributes['href'] ?? '')
|
||||
.where((e) => e.toLowerCase().endsWith('.apk'))
|
||||
.map((e) => ensureAbsoluteUrl(e, standardUri))
|
||||
.toList());
|
||||
apkUrls = getApkUrlsFromUrls(
|
||||
parse(res2.body)
|
||||
.querySelectorAll('a')
|
||||
.map((e) => e.attributes['href'] ?? '')
|
||||
.where((e) => e.toLowerCase().endsWith('.apk'))
|
||||
.map((e) => ensureAbsoluteUrl(e, standardUri))
|
||||
.toList(),
|
||||
);
|
||||
}
|
||||
apkDetailsList.add(APKDetails(
|
||||
apkDetailsList.add(
|
||||
APKDetails(
|
||||
version,
|
||||
apkUrls,
|
||||
AppNames(entry.querySelector('author')?.innerHtml.trim() ?? appName,
|
||||
appName),
|
||||
releaseDate: releaseDate));
|
||||
AppNames(
|
||||
entry.querySelector('author')?.innerHtml.trim() ?? appName,
|
||||
appName,
|
||||
),
|
||||
releaseDate: releaseDate,
|
||||
),
|
||||
);
|
||||
}
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
}
|
||||
if (fallbackToOlderReleases) {
|
||||
if (additionalSettings['trackOnly'] != true) {
|
||||
apkDetailsList =
|
||||
apkDetailsList.where((e) => e.apkUrls.isNotEmpty).toList();
|
||||
apkDetailsList = apkDetailsList
|
||||
.where((e) => e.apkUrls.isNotEmpty)
|
||||
.toList();
|
||||
}
|
||||
if (apkDetailsList.isEmpty) {
|
||||
throw NoReleasesError();
|
||||
|
@ -20,12 +20,15 @@ class TelegramApp extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
Response res =
|
||||
await sourceRequest('https://t.me/s/TAndroidAPK', additionalSettings);
|
||||
Response res = await sourceRequest(
|
||||
'https://t.me/s/TAndroidAPK',
|
||||
additionalSettings,
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
var http = parse(res.body);
|
||||
var messages =
|
||||
http.querySelectorAll('.tgme_widget_message_text.js-message_text');
|
||||
var messages = http.querySelectorAll(
|
||||
'.tgme_widget_message_text.js-message_text',
|
||||
);
|
||||
var version = messages.isNotEmpty
|
||||
? messages.last.innerHtml.split('\n').first.trim().split(' ').first
|
||||
: null;
|
||||
@ -33,10 +36,9 @@ class TelegramApp extends AppSource {
|
||||
throw NoVersionError();
|
||||
}
|
||||
String? apkUrl = 'https://telegram.org/dl/android/apk';
|
||||
return APKDetails(
|
||||
version,
|
||||
[MapEntry<String, String>('telegram-$version.apk', apkUrl)],
|
||||
AppNames('Telegram', 'Telegram'));
|
||||
return APKDetails(version, [
|
||||
MapEntry<String, String>('telegram-$version.apk', apkUrl),
|
||||
], AppNames('Telegram', 'Telegram'));
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -15,8 +15,9 @@ class Tencent extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://${getSourceRegex(hosts)}/appdetail/[^/]+',
|
||||
caseSensitive: false);
|
||||
'^https?://${getSourceRegex(hosts)}/appdetail/[^/]+',
|
||||
caseSensitive: false,
|
||||
);
|
||||
var match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -25,8 +26,10 @@ class Tencent extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return Uri.parse(standardUrl).pathSegments.last;
|
||||
}
|
||||
|
||||
@ -36,18 +39,16 @@ class Tencent extends AppSource {
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
String appId = (await tryInferringAppId(standardUrl))!;
|
||||
String baseHost = Uri.parse(standardUrl)
|
||||
.host
|
||||
.split('.')
|
||||
.reversed
|
||||
.toList()
|
||||
.sublist(0, 2)
|
||||
.reversed
|
||||
.join('.');
|
||||
String baseHost = Uri.parse(
|
||||
standardUrl,
|
||||
).host.split('.').reversed.toList().sublist(0, 2).reversed.join('.');
|
||||
|
||||
var res = await sourceRequest(
|
||||
'https://upage.html5.$baseHost/wechat-apkinfo', additionalSettings,
|
||||
followRedirects: false, postBody: {"packagename": appId});
|
||||
'https://upage.html5.$baseHost/wechat-apkinfo',
|
||||
additionalSettings,
|
||||
followRedirects: false,
|
||||
postBody: {"packagename": appId},
|
||||
);
|
||||
|
||||
if (res.statusCode == 200) {
|
||||
var json = jsonDecode(res.body);
|
||||
@ -64,14 +65,18 @@ class Tencent extends AppSource {
|
||||
var author = json['app_detail_records'][appId]['app_info']['author'];
|
||||
var releaseDate =
|
||||
json['app_detail_records'][appId]['app_info']['update_time'];
|
||||
var apkName = Uri.parse(apkUrl).queryParameters['fsname'] ??
|
||||
var apkName =
|
||||
Uri.parse(apkUrl).queryParameters['fsname'] ??
|
||||
'${appId}_$version.apk';
|
||||
|
||||
return APKDetails(
|
||||
version, [MapEntry(apkName, apkUrl)], AppNames(author, appName),
|
||||
releaseDate: releaseDate != null
|
||||
? DateTime.fromMillisecondsSinceEpoch(releaseDate * 1000)
|
||||
: null);
|
||||
version,
|
||||
[MapEntry(apkName, apkUrl)],
|
||||
AppNames(author, appName),
|
||||
releaseDate: releaseDate != null
|
||||
? DateTime.fromMillisecondsSinceEpoch(releaseDate * 1000)
|
||||
: null,
|
||||
);
|
||||
} else {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ import 'package:html/parser.dart';
|
||||
import 'package:obtainium/custom_errors.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
|
||||
parseDateTimeMMMddCommayyyy(String? dateString) {
|
||||
DateTime? parseDateTimeMMMddCommayyyy(String? dateString) {
|
||||
DateTime? releaseDate;
|
||||
try {
|
||||
releaseDate = dateString != null
|
||||
@ -30,8 +30,9 @@ class Uptodown extends AppSource {
|
||||
@override
|
||||
String sourceSpecificStandardizeURL(String url, {bool forSelection = false}) {
|
||||
RegExp standardUrlRegEx = RegExp(
|
||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||
caseSensitive: false);
|
||||
'^https?://([^\\.]+\\.){2,}${getSourceRegex(hosts)}',
|
||||
caseSensitive: false,
|
||||
);
|
||||
RegExpMatch? match = standardUrlRegEx.firstMatch(url);
|
||||
if (match == null) {
|
||||
throw InvalidURLError(name);
|
||||
@ -40,14 +41,20 @@ class Uptodown extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
return (await getAppDetailsFromPage(
|
||||
standardUrl, additionalSettings))['appId'];
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
))['appId'];
|
||||
}
|
||||
|
||||
Future<Map<String, String?>> getAppDetailsFromPage(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest(standardUrl, additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
@ -63,8 +70,9 @@ class Uptodown extends AppSource {
|
||||
.toList();
|
||||
String? appId = detailElements.elementAtOrNull(0);
|
||||
String? dateStr = detailElements.elementAtOrNull(6);
|
||||
String? fileId =
|
||||
html.querySelector('#detail-app-name')?.attributes['data-file-id'];
|
||||
String? fileId = html
|
||||
.querySelector('#detail-app-name')
|
||||
?.attributes['data-file-id'];
|
||||
String? extension = detailElements.elementAtOrNull(7)?.toLowerCase();
|
||||
return Map.fromEntries([
|
||||
MapEntry('version', version),
|
||||
@ -73,7 +81,7 @@ class Uptodown extends AppSource {
|
||||
MapEntry('author', author),
|
||||
MapEntry('dateStr', dateStr),
|
||||
MapEntry('fileId', fileId),
|
||||
MapEntry('extension', extension)
|
||||
MapEntry('extension', extension),
|
||||
]);
|
||||
}
|
||||
|
||||
@ -82,8 +90,10 @@ class Uptodown extends AppSource {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var appDetails =
|
||||
await getAppDetailsFromPage(standardUrl, additionalSettings);
|
||||
var appDetails = await getAppDetailsFromPage(
|
||||
standardUrl,
|
||||
additionalSettings,
|
||||
);
|
||||
var version = appDetails['version'];
|
||||
var appId = appDetails['appId'];
|
||||
var fileId = appDetails['fileId'];
|
||||
@ -105,21 +115,28 @@ class Uptodown extends AppSource {
|
||||
if (dateStr != null) {
|
||||
relDate = parseDateTimeMMMddCommayyyy(dateStr);
|
||||
}
|
||||
return APKDetails(version, [MapEntry('$appId.$extension', apkUrl)],
|
||||
AppNames(author, appName),
|
||||
releaseDate: relDate);
|
||||
return APKDetails(
|
||||
version,
|
||||
[MapEntry('$appId.$extension', apkUrl)],
|
||||
AppNames(author, appName),
|
||||
releaseDate: relDate,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String> apkUrlPrefetchModifier(String apkUrl, String standardUrl,
|
||||
Map<String, dynamic> additionalSettings) async {
|
||||
Future<String> apkUrlPrefetchModifier(
|
||||
String apkUrl,
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var res = await sourceRequest(apkUrl, additionalSettings);
|
||||
if (res.statusCode != 200) {
|
||||
throw getObtainiumHttpError(res);
|
||||
}
|
||||
var html = parse(res.body);
|
||||
var finalUrlKey =
|
||||
html.querySelector('#detail-download-button')?.attributes['data-url'];
|
||||
var finalUrlKey = html
|
||||
.querySelector('#detail-download-button')
|
||||
?.attributes['data-url'];
|
||||
if (finalUrlKey == null) {
|
||||
throw NoAPKError();
|
||||
}
|
||||
|
@ -23,15 +23,19 @@ class VivoAppStore extends AppSource {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<String?> tryInferringAppId(String standardUrl,
|
||||
{Map<String, dynamic> additionalSettings = const {}}) async {
|
||||
Future<String?> tryInferringAppId(
|
||||
String standardUrl, {
|
||||
Map<String, dynamic> additionalSettings = const {},
|
||||
}) async {
|
||||
var json = await getDetailJson(standardUrl, additionalSettings);
|
||||
return json['package_name'];
|
||||
}
|
||||
|
||||
@override
|
||||
Future<APKDetails> getLatestAPKDetails(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var json = await getDetailJson(standardUrl, additionalSettings);
|
||||
var appName = json['title_zh'].toString();
|
||||
var packageName = json['package_name'].toString();
|
||||
@ -42,13 +46,18 @@ class VivoAppStore extends AppSource {
|
||||
var apkUrl = json['download_url'].toString();
|
||||
var apkName = '${packageName}_$versionCode.apk';
|
||||
return APKDetails(
|
||||
versionName, [MapEntry(apkName, apkUrl)], AppNames(developer, appName),
|
||||
releaseDate: DateTime.parse(uploadTime));
|
||||
versionName,
|
||||
[MapEntry(apkName, apkUrl)],
|
||||
AppNames(developer, appName),
|
||||
releaseDate: DateTime.parse(uploadTime),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> search(String query,
|
||||
{Map<String, dynamic> querySettings = const {}}) async {
|
||||
Future<Map<String, List<String>>> search(
|
||||
String query, {
|
||||
Map<String, dynamic> querySettings = const {},
|
||||
}) async {
|
||||
var apiBaseUrl =
|
||||
'https://h5-api.appstore.vivo.com.cn/h5appstore/search/result-list?app_version=2100&page_index=1&apps_per_page=20&target=local&cfrom=2&key=';
|
||||
var searchUrl = '$apiBaseUrl${Uri.encodeQueryComponent(query)}';
|
||||
@ -65,14 +74,16 @@ class VivoAppStore extends AppSource {
|
||||
for (var item in (resultsJson as List<dynamic>)) {
|
||||
results['$appDetailUrl${item['id']}'] = [
|
||||
item['title_zh'].toString(),
|
||||
item['developer'].toString()
|
||||
item['developer'].toString(),
|
||||
];
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getDetailJson(
|
||||
String standardUrl, Map<String, dynamic> additionalSettings) async {
|
||||
String standardUrl,
|
||||
Map<String, dynamic> additionalSettings,
|
||||
) async {
|
||||
var vivoAppId = parseVivoAppId(standardUrl);
|
||||
var apiBaseUrl = 'https://h5-api.appstore.vivo.com.cn/detail/';
|
||||
var params = '?frompage=messageh5&app_version=2100';
|
||||
|
@ -20,8 +20,9 @@ class _CustomAppBarState extends State<CustomAppBar> {
|
||||
titlePadding: const EdgeInsets.symmetric(horizontal: 20, vertical: 16),
|
||||
title: Text(
|
||||
widget.title,
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).textTheme.bodyMedium!.color),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).textTheme.bodyMedium!.color,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -16,11 +16,13 @@ abstract class GeneratedFormItem {
|
||||
dynamic ensureType(dynamic val);
|
||||
GeneratedFormItem clone();
|
||||
|
||||
GeneratedFormItem(this.key,
|
||||
{this.label = 'Input',
|
||||
this.belowWidgets = const [],
|
||||
this.defaultValue,
|
||||
this.additionalValidators = const []});
|
||||
GeneratedFormItem(
|
||||
this.key, {
|
||||
this.label = 'Input',
|
||||
this.belowWidgets = const [],
|
||||
this.defaultValue,
|
||||
this.additionalValidators = const [],
|
||||
});
|
||||
}
|
||||
|
||||
class GeneratedFormTextField extends GeneratedFormItem {
|
||||
@ -31,18 +33,19 @@ class GeneratedFormTextField extends GeneratedFormItem {
|
||||
late TextInputType? textInputType;
|
||||
late List<String>? autoCompleteOptions;
|
||||
|
||||
GeneratedFormTextField(super.key,
|
||||
{super.label,
|
||||
super.belowWidgets,
|
||||
String super.defaultValue = '',
|
||||
List<String? Function(String? value)> super.additionalValidators =
|
||||
const [],
|
||||
this.required = true,
|
||||
this.max = 1,
|
||||
this.hint,
|
||||
this.password = false,
|
||||
this.textInputType,
|
||||
this.autoCompleteOptions});
|
||||
GeneratedFormTextField(
|
||||
super.key, {
|
||||
super.label,
|
||||
super.belowWidgets,
|
||||
String super.defaultValue = '',
|
||||
List<String? Function(String? value)> super.additionalValidators = const [],
|
||||
this.required = true,
|
||||
this.max = 1,
|
||||
this.hint,
|
||||
this.password = false,
|
||||
this.textInputType,
|
||||
this.autoCompleteOptions,
|
||||
});
|
||||
|
||||
@override
|
||||
String ensureType(val) {
|
||||
@ -51,16 +54,18 @@ class GeneratedFormTextField extends GeneratedFormItem {
|
||||
|
||||
@override
|
||||
GeneratedFormTextField clone() {
|
||||
return GeneratedFormTextField(key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
required: required,
|
||||
max: max,
|
||||
hint: hint,
|
||||
password: password,
|
||||
textInputType: textInputType);
|
||||
return GeneratedFormTextField(
|
||||
key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
required: required,
|
||||
max: max,
|
||||
hint: hint,
|
||||
password: password,
|
||||
textInputType: textInputType,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,8 +96,9 @@ class GeneratedFormDropdown extends GeneratedFormItem {
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
disabledOptKeys:
|
||||
disabledOptKeys != null ? List.from(disabledOptKeys!) : null,
|
||||
disabledOptKeys: disabledOptKeys != null
|
||||
? List.from(disabledOptKeys!)
|
||||
: null,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
);
|
||||
}
|
||||
@ -117,12 +123,14 @@ class GeneratedFormSwitch extends GeneratedFormItem {
|
||||
|
||||
@override
|
||||
GeneratedFormSwitch clone() {
|
||||
return GeneratedFormSwitch(key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
disabled: false,
|
||||
additionalValidators: List.from(additionalValidators));
|
||||
return GeneratedFormSwitch(
|
||||
key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
disabled: false,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,17 +140,20 @@ class GeneratedFormTagInput extends GeneratedFormItem {
|
||||
late WrapAlignment alignment;
|
||||
late String emptyMessage;
|
||||
late bool showLabelWhenNotEmpty;
|
||||
GeneratedFormTagInput(super.key,
|
||||
{super.label,
|
||||
super.belowWidgets,
|
||||
Map<String, MapEntry<int, bool>> super.defaultValue = const {},
|
||||
List<String? Function(Map<String, MapEntry<int, bool>> value)>
|
||||
super.additionalValidators = const [],
|
||||
this.deleteConfirmationMessage,
|
||||
this.singleSelect = false,
|
||||
this.alignment = WrapAlignment.start,
|
||||
this.emptyMessage = 'Input',
|
||||
this.showLabelWhenNotEmpty = true});
|
||||
GeneratedFormTagInput(
|
||||
super.key, {
|
||||
super.label,
|
||||
super.belowWidgets,
|
||||
Map<String, MapEntry<int, bool>> super.defaultValue = const {},
|
||||
List<String? Function(Map<String, MapEntry<int, bool>> value)>
|
||||
super.additionalValidators =
|
||||
const [],
|
||||
this.deleteConfirmationMessage,
|
||||
this.singleSelect = false,
|
||||
this.alignment = WrapAlignment.start,
|
||||
this.emptyMessage = 'Input',
|
||||
this.showLabelWhenNotEmpty = true,
|
||||
});
|
||||
|
||||
@override
|
||||
Map<String, MapEntry<int, bool>> ensureType(val) {
|
||||
@ -151,25 +162,30 @@ class GeneratedFormTagInput extends GeneratedFormItem {
|
||||
|
||||
@override
|
||||
GeneratedFormTagInput clone() {
|
||||
return GeneratedFormTagInput(key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
deleteConfirmationMessage: deleteConfirmationMessage,
|
||||
singleSelect: singleSelect,
|
||||
alignment: alignment,
|
||||
emptyMessage: emptyMessage,
|
||||
showLabelWhenNotEmpty: showLabelWhenNotEmpty);
|
||||
return GeneratedFormTagInput(
|
||||
key,
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
additionalValidators: List.from(additionalValidators),
|
||||
deleteConfirmationMessage: deleteConfirmationMessage,
|
||||
singleSelect: singleSelect,
|
||||
alignment: alignment,
|
||||
emptyMessage: emptyMessage,
|
||||
showLabelWhenNotEmpty: showLabelWhenNotEmpty,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
typedef OnValueChanges = void Function(
|
||||
Map<String, dynamic> values, bool valid, bool isBuilding);
|
||||
typedef OnValueChanges =
|
||||
void Function(Map<String, dynamic> values, bool valid, bool isBuilding);
|
||||
|
||||
class GeneratedForm extends StatefulWidget {
|
||||
const GeneratedForm(
|
||||
{super.key, required this.items, required this.onValueChanges});
|
||||
const GeneratedForm({
|
||||
super.key,
|
||||
required this.items,
|
||||
required this.onValueChanges,
|
||||
});
|
||||
|
||||
final List<List<GeneratedFormItem>> items;
|
||||
final OnValueChanges onValueChanges;
|
||||
@ -179,7 +195,8 @@ class GeneratedForm extends StatefulWidget {
|
||||
}
|
||||
|
||||
List<List<GeneratedFormItem>> cloneFormItems(
|
||||
List<List<GeneratedFormItem>> items) {
|
||||
List<List<GeneratedFormItem>> items,
|
||||
) {
|
||||
List<List<GeneratedFormItem>> clonedItems = [];
|
||||
for (var row in items) {
|
||||
List<GeneratedFormItem> clonedRow = [];
|
||||
@ -194,8 +211,13 @@ List<List<GeneratedFormItem>> cloneFormItems(
|
||||
class GeneratedFormSubForm extends GeneratedFormItem {
|
||||
final List<List<GeneratedFormItem>> items;
|
||||
|
||||
GeneratedFormSubForm(super.key, this.items,
|
||||
{super.label, super.belowWidgets, super.defaultValue = const []});
|
||||
GeneratedFormSubForm(
|
||||
super.key,
|
||||
this.items, {
|
||||
super.label,
|
||||
super.belowWidgets,
|
||||
super.defaultValue = const [],
|
||||
});
|
||||
|
||||
@override
|
||||
ensureType(val) {
|
||||
@ -204,8 +226,13 @@ class GeneratedFormSubForm extends GeneratedFormItem {
|
||||
|
||||
@override
|
||||
GeneratedFormSubForm clone() {
|
||||
return GeneratedFormSubForm(key, cloneFormItems(items),
|
||||
label: label, belowWidgets: belowWidgets, defaultValue: defaultValue);
|
||||
return GeneratedFormSubForm(
|
||||
key,
|
||||
cloneFormItems(items),
|
||||
label: label,
|
||||
belowWidgets: belowWidgets,
|
||||
defaultValue: defaultValue,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,13 +247,18 @@ Color generateRandomLightColor() {
|
||||
// Map from HPLuv color space to RGB, use constant saturation=100, lightness=70
|
||||
final List<double> rgbValuesDbl = Hsluv.hpluvToRgb([hue, 100, 70]);
|
||||
// Map RBG values from 0-1 to 0-255:
|
||||
final List<int> rgbValues =
|
||||
rgbValuesDbl.map((rgb) => (rgb * 255).toInt()).toList();
|
||||
final List<int> rgbValues = rgbValuesDbl
|
||||
.map((rgb) => (rgb * 255).toInt())
|
||||
.toList();
|
||||
return Color.fromARGB(255, rgbValues[0], rgbValues[1], rgbValues[2]);
|
||||
}
|
||||
|
||||
int generateRandomNumber(int seed1,
|
||||
{int seed2 = 0, int seed3 = 0, max = 10000}) {
|
||||
int generateRandomNumber(
|
||||
int seed1, {
|
||||
int seed2 = 0,
|
||||
int seed3 = 0,
|
||||
max = 10000,
|
||||
}) {
|
||||
int combinedSeed = seed1.hashCode ^ seed2.hashCode ^ seed3.hashCode;
|
||||
Random random = Random(combinedSeed);
|
||||
int randomNumber = random.nextInt(max);
|
||||
@ -261,7 +293,7 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
widget.onValueChanges(returnValues, valid, isBuilding);
|
||||
}
|
||||
|
||||
initForm() {
|
||||
void initForm() {
|
||||
initKey = widget.key.toString();
|
||||
// Initialize form values as all empty
|
||||
values.clear();
|
||||
@ -297,9 +329,9 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
});
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
helperText:
|
||||
formItem.label + (formItem.required ? ' *' : ''),
|
||||
hintText: formItem.hint),
|
||||
helperText: formItem.label + (formItem.required ? ' *' : ''),
|
||||
hintText: formItem.hint,
|
||||
),
|
||||
minLines: formItem.max <= 1 ? null : formItem.max,
|
||||
maxLines: formItem.max <= 1 ? 1 : formItem.max,
|
||||
validator: (value) {
|
||||
@ -339,23 +371,26 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
return Text(tr('dropdownNoOptsError'));
|
||||
}
|
||||
return DropdownButtonFormField(
|
||||
decoration: InputDecoration(labelText: formItem.label),
|
||||
value: values[formItem.key],
|
||||
items: formItem.opts!.map((e2) {
|
||||
var enabled =
|
||||
formItem.disabledOptKeys?.contains(e2.key) != true;
|
||||
return DropdownMenuItem(
|
||||
value: e2.key,
|
||||
enabled: enabled,
|
||||
child: Opacity(
|
||||
opacity: enabled ? 1 : 0.5, child: Text(e2.value)));
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
values[formItem.key] = value ?? formItem.opts!.first.key;
|
||||
someValueChanged();
|
||||
});
|
||||
decoration: InputDecoration(labelText: formItem.label),
|
||||
value: values[formItem.key],
|
||||
items: formItem.opts!.map((e2) {
|
||||
var enabled = formItem.disabledOptKeys?.contains(e2.key) != true;
|
||||
return DropdownMenuItem(
|
||||
value: e2.key,
|
||||
enabled: enabled,
|
||||
child: Opacity(
|
||||
opacity: enabled ? 1 : 0.5,
|
||||
child: Text(e2.value),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
values[formItem.key] = value ?? formItem.opts!.first.key;
|
||||
someValueChanged();
|
||||
});
|
||||
},
|
||||
);
|
||||
} else if (formItem is GeneratedFormSubForm) {
|
||||
values[formItem.key] = [];
|
||||
for (Map<String, dynamic> v
|
||||
@ -394,33 +429,33 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Flexible(child: Text(widget.items[r][e].label)),
|
||||
const SizedBox(
|
||||
width: 8,
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Switch(
|
||||
value: values[fieldKey],
|
||||
onChanged:
|
||||
(widget.items[r][e] as GeneratedFormSwitch).disabled
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
values[fieldKey] = value;
|
||||
someValueChanged();
|
||||
});
|
||||
})
|
||||
value: values[fieldKey],
|
||||
onChanged: (widget.items[r][e] as GeneratedFormSwitch).disabled
|
||||
? null
|
||||
: (value) {
|
||||
setState(() {
|
||||
values[fieldKey] = value;
|
||||
someValueChanged();
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (widget.items[r][e] is GeneratedFormTagInput) {
|
||||
onAddPressed() {
|
||||
showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: widget.items[r][e].label,
|
||||
items: [
|
||||
[GeneratedFormTextField('label', label: tr('label'))]
|
||||
]);
|
||||
}).then((value) {
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: widget.items[r][e].label,
|
||||
items: [
|
||||
[GeneratedFormTextField('label', label: tr('label'))],
|
||||
],
|
||||
);
|
||||
},
|
||||
).then((value) {
|
||||
String? label = value?['label'];
|
||||
if (label != null) {
|
||||
setState(() {
|
||||
@ -434,8 +469,10 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
var someSelected = temp.entries
|
||||
.where((element) => element.value.value)
|
||||
.isNotEmpty;
|
||||
temp[label] = MapEntry(generateRandomLightColor().value,
|
||||
!(someSelected && singleSelect));
|
||||
temp[label] = MapEntry(
|
||||
generateRandomLightColor().value,
|
||||
!(someSelected && singleSelect),
|
||||
);
|
||||
values[fieldKey] = temp;
|
||||
someValueChanged();
|
||||
}
|
||||
@ -444,236 +481,274 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
});
|
||||
}
|
||||
|
||||
formInputs[r][e] =
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
if ((values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.isNotEmpty ==
|
||||
true &&
|
||||
(widget.items[r][e] as GeneratedFormTagInput)
|
||||
.showLabelWhenNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
(widget.items[r][e] as GeneratedFormTagInput).alignment ==
|
||||
WrapAlignment.center
|
||||
? CrossAxisAlignment.center
|
||||
: CrossAxisAlignment.stretch,
|
||||
formInputs[r][e] = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if ((values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.isNotEmpty ==
|
||||
true &&
|
||||
(widget.items[r][e] as GeneratedFormTagInput)
|
||||
.showLabelWhenNotEmpty)
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
(widget.items[r][e] as GeneratedFormTagInput).alignment ==
|
||||
WrapAlignment.center
|
||||
? CrossAxisAlignment.center
|
||||
: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
Text(widget.items[r][e].label),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
alignment:
|
||||
(widget.items[r][e] as GeneratedFormTagInput).alignment,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
Text(widget.items[r][e].label),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
],
|
||||
),
|
||||
Wrap(
|
||||
alignment:
|
||||
(widget.items[r][e] as GeneratedFormTagInput).alignment,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: [
|
||||
// (values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
// ?.isEmpty ==
|
||||
// true
|
||||
// ? Text(
|
||||
// (widget.items[r][e] as GeneratedFormTagInput)
|
||||
// .emptyMessage,
|
||||
// )
|
||||
// : const SizedBox.shrink(),
|
||||
...(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.entries
|
||||
.map((e2) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: ChoiceChip(
|
||||
label: Text(e2.key),
|
||||
backgroundColor: Color(e2.value.key).withAlpha(50),
|
||||
selectedColor: Color(e2.value.key),
|
||||
visualDensity: VisualDensity.compact,
|
||||
selected: e2.value.value,
|
||||
onSelected: (value) {
|
||||
setState(() {
|
||||
(values[fieldKey] as Map<String,
|
||||
MapEntry<int, bool>>)[e2.key] =
|
||||
MapEntry(
|
||||
(values[fieldKey] as Map<String,
|
||||
MapEntry<int, bool>>)[e2.key]!
|
||||
.key,
|
||||
value);
|
||||
if ((widget.items[r][e]
|
||||
as GeneratedFormTagInput)
|
||||
.singleSelect &&
|
||||
value == true) {
|
||||
for (var key in (values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>)
|
||||
.keys) {
|
||||
if (key != e2.key) {
|
||||
(values[fieldKey] as Map<
|
||||
String,
|
||||
MapEntry<int,
|
||||
bool>>)[key] = MapEntry(
|
||||
(values[fieldKey] as Map<String,
|
||||
MapEntry<int, bool>>)[key]!
|
||||
.key,
|
||||
false);
|
||||
// (values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
// ?.isEmpty ==
|
||||
// true
|
||||
// ? Text(
|
||||
// (widget.items[r][e] as GeneratedFormTagInput)
|
||||
// .emptyMessage,
|
||||
// )
|
||||
// : const SizedBox.shrink(),
|
||||
...(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.entries
|
||||
.map((e2) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: 4,
|
||||
),
|
||||
child: ChoiceChip(
|
||||
label: Text(e2.key),
|
||||
backgroundColor: Color(
|
||||
e2.value.key,
|
||||
).withAlpha(50),
|
||||
selectedColor: Color(e2.value.key),
|
||||
visualDensity: VisualDensity.compact,
|
||||
selected: e2.value.value,
|
||||
onSelected: (value) {
|
||||
setState(() {
|
||||
(values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>)[e2
|
||||
.key] = MapEntry(
|
||||
(values[fieldKey]
|
||||
as Map<
|
||||
String,
|
||||
MapEntry<int, bool>
|
||||
>)[e2.key]!
|
||||
.key,
|
||||
value,
|
||||
);
|
||||
if ((widget.items[r][e]
|
||||
as GeneratedFormTagInput)
|
||||
.singleSelect &&
|
||||
value == true) {
|
||||
for (var key
|
||||
in (values[fieldKey]
|
||||
as Map<
|
||||
String,
|
||||
MapEntry<int, bool>
|
||||
>)
|
||||
.keys) {
|
||||
if (key != e2.key) {
|
||||
(values[fieldKey]
|
||||
as Map<
|
||||
String,
|
||||
MapEntry<int, bool>
|
||||
>)[key] = MapEntry(
|
||||
(values[fieldKey]
|
||||
as Map<
|
||||
String,
|
||||
MapEntry<int, bool>
|
||||
>)[key]!
|
||||
.key,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
someValueChanged();
|
||||
});
|
||||
},
|
||||
));
|
||||
}) ??
|
||||
[const SizedBox.shrink()],
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.values
|
||||
.where((e) => e.value)
|
||||
.length ==
|
||||
1
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
var temp = values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>;
|
||||
// get selected category str where bool is true
|
||||
final oldEntry = temp.entries
|
||||
.firstWhere((entry) => entry.value.value);
|
||||
// generate new color, ensure it is not the same
|
||||
int newColor = oldEntry.value.key;
|
||||
while (oldEntry.value.key == newColor) {
|
||||
newColor = generateRandomLightColor().value;
|
||||
}
|
||||
// Update entry with new color, remain selected
|
||||
temp.update(oldEntry.key,
|
||||
(old) => MapEntry(newColor, old.value));
|
||||
values[fieldKey] = temp;
|
||||
someValueChanged();
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.format_color_fill_rounded),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('colour'),
|
||||
))
|
||||
: const SizedBox.shrink(),
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.values
|
||||
.where((e) => e.value)
|
||||
.isNotEmpty ==
|
||||
true
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
fn() {
|
||||
someValueChanged();
|
||||
});
|
||||
},
|
||||
),
|
||||
);
|
||||
}) ??
|
||||
[const SizedBox.shrink()],
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.values
|
||||
.where((e) => e.value)
|
||||
.length ==
|
||||
1
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
var temp = values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>;
|
||||
temp.removeWhere((key, value) => value.value);
|
||||
var temp =
|
||||
values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>;
|
||||
// get selected category str where bool is true
|
||||
final oldEntry = temp.entries.firstWhere(
|
||||
(entry) => entry.value.value,
|
||||
);
|
||||
// generate new color, ensure it is not the same
|
||||
int newColor = oldEntry.value.key;
|
||||
while (oldEntry.value.key == newColor) {
|
||||
newColor = generateRandomLightColor().value;
|
||||
}
|
||||
// Update entry with new color, remain selected
|
||||
temp.update(
|
||||
oldEntry.key,
|
||||
(old) => MapEntry(newColor, old.value),
|
||||
);
|
||||
values[fieldKey] = temp;
|
||||
someValueChanged();
|
||||
});
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.format_color_fill_rounded),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('colour'),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.values
|
||||
.where((e) => e.value)
|
||||
.isNotEmpty ==
|
||||
true
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: () {
|
||||
fn() {
|
||||
setState(() {
|
||||
var temp =
|
||||
values[fieldKey]
|
||||
as Map<String, MapEntry<int, bool>>;
|
||||
temp.removeWhere((key, value) => value.value);
|
||||
values[fieldKey] = temp;
|
||||
someValueChanged();
|
||||
});
|
||||
}
|
||||
|
||||
if ((widget.items[r][e] as GeneratedFormTagInput)
|
||||
.deleteConfirmationMessage !=
|
||||
null) {
|
||||
var message =
|
||||
(widget.items[r][e] as GeneratedFormTagInput)
|
||||
.deleteConfirmationMessage!;
|
||||
showDialog<Map<String, dynamic>?>(
|
||||
if ((widget.items[r][e] as GeneratedFormTagInput)
|
||||
.deleteConfirmationMessage !=
|
||||
null) {
|
||||
var message =
|
||||
(widget.items[r][e]
|
||||
as GeneratedFormTagInput)
|
||||
.deleteConfirmationMessage!;
|
||||
showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: message.key,
|
||||
message: message.value,
|
||||
items: const []);
|
||||
}).then((value) {
|
||||
if (value != null) {
|
||||
fn();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.remove),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('remove'),
|
||||
))
|
||||
: const SizedBox.shrink(),
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.isEmpty ==
|
||||
true
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: TextButton.icon(
|
||||
onPressed: onAddPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(
|
||||
title: message.key,
|
||||
message: message.value,
|
||||
items: const [],
|
||||
);
|
||||
},
|
||||
).then((value) {
|
||||
if (value != null) {
|
||||
fn();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
fn();
|
||||
}
|
||||
},
|
||||
icon: const Icon(Icons.remove),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('remove'),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
(values[fieldKey] as Map<String, MapEntry<int, bool>>?)
|
||||
?.isEmpty ==
|
||||
true
|
||||
? Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: TextButton.icon(
|
||||
onPressed: onAddPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(
|
||||
(widget.items[r][e] as GeneratedFormTagInput)
|
||||
.label),
|
||||
))
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: onAddPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('add'),
|
||||
)),
|
||||
],
|
||||
)
|
||||
]);
|
||||
.label,
|
||||
),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 4),
|
||||
child: IconButton(
|
||||
onPressed: onAddPressed,
|
||||
icon: const Icon(Icons.add),
|
||||
visualDensity: VisualDensity.compact,
|
||||
tooltip: tr('add'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
} else if (widget.items[r][e] is GeneratedFormSubForm) {
|
||||
List<Widget> subformColumn = [];
|
||||
var compact = (widget.items[r][e] as GeneratedFormSubForm)
|
||||
.items
|
||||
.length ==
|
||||
1 &&
|
||||
var compact =
|
||||
(widget.items[r][e] as GeneratedFormSubForm).items.length == 1 &&
|
||||
(widget.items[r][e] as GeneratedFormSubForm).items[0].length == 1;
|
||||
for (int i = 0; i < values[fieldKey].length; i++) {
|
||||
var internalFormKey = ValueKey(generateRandomNumber(
|
||||
var internalFormKey = ValueKey(
|
||||
generateRandomNumber(
|
||||
values[fieldKey].length,
|
||||
seed2: i,
|
||||
seed3: forceUpdateKeyCount));
|
||||
subformColumn.add(Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!compact)
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
seed3: forceUpdateKeyCount,
|
||||
),
|
||||
);
|
||||
subformColumn.add(
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
if (!compact) const SizedBox(height: 16),
|
||||
if (!compact)
|
||||
Text(
|
||||
'${(widget.items[r][e] as GeneratedFormSubForm).label} (${i + 1})',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
GeneratedForm(
|
||||
key: internalFormKey,
|
||||
items:
|
||||
cloneFormItems(
|
||||
(widget.items[r][e] as GeneratedFormSubForm)
|
||||
.items,
|
||||
)
|
||||
.map(
|
||||
(x) => x.map((y) {
|
||||
y.defaultValue = values[fieldKey]?[i]?[y.key];
|
||||
y.key = '${y.key.toString()},$internalFormKey';
|
||||
return y;
|
||||
}).toList(),
|
||||
)
|
||||
.toList(),
|
||||
onValueChanges: (values, valid, isBuilding) {
|
||||
values = values.map(
|
||||
(key, value) => MapEntry(key.split(',')[0], value),
|
||||
);
|
||||
if (valid) {
|
||||
this.values[fieldKey]?[i] = values;
|
||||
}
|
||||
someValueChanged(
|
||||
isBuilding: isBuilding,
|
||||
forceInvalid: !valid,
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!compact)
|
||||
Text(
|
||||
'${(widget.items[r][e] as GeneratedFormSubForm).label} (${i + 1})',
|
||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||
),
|
||||
GeneratedForm(
|
||||
key: internalFormKey,
|
||||
items: cloneFormItems(
|
||||
(widget.items[r][e] as GeneratedFormSubForm).items)
|
||||
.map((x) => x.map((y) {
|
||||
y.defaultValue = values[fieldKey]?[i]?[y.key];
|
||||
y.key = '${y.key.toString()},$internalFormKey';
|
||||
return y;
|
||||
}).toList())
|
||||
.toList(),
|
||||
onValueChanges: (values, valid, isBuilding) {
|
||||
values = values.map(
|
||||
(key, value) => MapEntry(key.split(',')[0], value));
|
||||
if (valid) {
|
||||
this.values[fieldKey]?[i] = values;
|
||||
}
|
||||
someValueChanged(
|
||||
isBuilding: isBuilding, forceInvalid: !valid);
|
||||
},
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton.icon(
|
||||
style: TextButton.styleFrom(
|
||||
foregroundColor:
|
||||
Theme.of(context).colorScheme.error),
|
||||
foregroundColor: Theme.of(context).colorScheme.error,
|
||||
),
|
||||
onPressed: (values[fieldKey].length > 0)
|
||||
? () {
|
||||
var temp = List.from(values[fieldKey]);
|
||||
@ -686,33 +761,40 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
label: Text(
|
||||
'${(widget.items[r][e] as GeneratedFormSubForm).label} (${i + 1})',
|
||||
),
|
||||
icon: const Icon(
|
||||
Icons.delete_outline_rounded,
|
||||
))
|
||||
],
|
||||
)
|
||||
],
|
||||
));
|
||||
icon: const Icon(Icons.delete_outline_rounded),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
subformColumn.add(Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0, top: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
subformColumn.add(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(bottom: 0, top: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ElevatedButton.icon(
|
||||
onPressed: () {
|
||||
values[fieldKey].add(getDefaultValuesFromFormItems(
|
||||
(widget.items[r][e] as GeneratedFormSubForm)
|
||||
.items));
|
||||
forceUpdateKeyCount++;
|
||||
someValueChanged();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text((widget.items[r][e] as GeneratedFormSubForm)
|
||||
.label))),
|
||||
],
|
||||
onPressed: () {
|
||||
values[fieldKey].add(
|
||||
getDefaultValuesFromFormItems(
|
||||
(widget.items[r][e] as GeneratedFormSubForm).items,
|
||||
),
|
||||
);
|
||||
forceUpdateKeyCount++;
|
||||
someValueChanged();
|
||||
},
|
||||
icon: const Icon(Icons.add),
|
||||
label: Text(
|
||||
(widget.items[r][e] as GeneratedFormSubForm).label,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
));
|
||||
);
|
||||
formInputs[r][e] = Column(children: subformColumn);
|
||||
}
|
||||
}
|
||||
@ -726,38 +808,43 @@ class _GeneratedFormState extends State<GeneratedForm> {
|
||||
height: widget.items[rowInputs.key - 1][0] is GeneratedFormSwitch
|
||||
? 8
|
||||
: 25,
|
||||
)
|
||||
),
|
||||
]);
|
||||
}
|
||||
List<Widget> rowItems = [];
|
||||
rowInputs.value.asMap().entries.forEach((rowInput) {
|
||||
if (rowInput.key > 0) {
|
||||
rowItems.add(const SizedBox(
|
||||
width: 20,
|
||||
));
|
||||
rowItems.add(const SizedBox(width: 20));
|
||||
}
|
||||
rowItems.add(Expanded(
|
||||
rowItems.add(
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
rowInput.value,
|
||||
...widget.items[rowInputs.key][rowInput.key].belowWidgets
|
||||
])));
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
rowInput.value,
|
||||
...widget.items[rowInputs.key][rowInput.key].belowWidgets,
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
rows.add(rowItems);
|
||||
});
|
||||
|
||||
return Form(
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
...rows.map((row) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [...row.map((e) => e)],
|
||||
))
|
||||
],
|
||||
));
|
||||
key: _formKey,
|
||||
child: Column(
|
||||
children: [
|
||||
...rows.map(
|
||||
(row) => Row(
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [...row.map((e) => e)],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -4,15 +4,16 @@ import 'package:flutter/services.dart';
|
||||
import 'package:obtainium/components/generated_form.dart';
|
||||
|
||||
class GeneratedFormModal extends StatefulWidget {
|
||||
const GeneratedFormModal(
|
||||
{super.key,
|
||||
required this.title,
|
||||
required this.items,
|
||||
this.initValid = false,
|
||||
this.message = '',
|
||||
this.additionalWidgets = const [],
|
||||
this.singleNullReturnButton,
|
||||
this.primaryActionColour});
|
||||
const GeneratedFormModal({
|
||||
super.key,
|
||||
required this.title,
|
||||
required this.items,
|
||||
this.initValid = false,
|
||||
this.message = '',
|
||||
this.additionalWidgets = const [],
|
||||
this.singleNullReturnButton,
|
||||
this.primaryActionColour,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String message;
|
||||
@ -41,14 +42,12 @@ class _GeneratedFormModalState extends State<GeneratedFormModal> {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(widget.title),
|
||||
content:
|
||||
Column(crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
if (widget.message.isNotEmpty) Text(widget.message),
|
||||
if (widget.message.isNotEmpty)
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
GeneratedForm(
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
if (widget.message.isNotEmpty) Text(widget.message),
|
||||
if (widget.message.isNotEmpty) const SizedBox(height: 16),
|
||||
GeneratedForm(
|
||||
items: widget.items,
|
||||
onValueChanges: (values, valid, isBuilding) {
|
||||
if (isBuilding) {
|
||||
@ -60,23 +59,29 @@ class _GeneratedFormModalState extends State<GeneratedFormModal> {
|
||||
this.valid = valid;
|
||||
});
|
||||
}
|
||||
}),
|
||||
if (widget.additionalWidgets.isNotEmpty) ...widget.additionalWidgets
|
||||
]),
|
||||
},
|
||||
),
|
||||
if (widget.additionalWidgets.isNotEmpty) ...widget.additionalWidgets,
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(widget.singleNullReturnButton == null
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(
|
||||
widget.singleNullReturnButton == null
|
||||
? tr('cancel')
|
||||
: widget.singleNullReturnButton!)),
|
||||
: widget.singleNullReturnButton!,
|
||||
),
|
||||
),
|
||||
widget.singleNullReturnButton == null
|
||||
? TextButton(
|
||||
style: widget.primaryActionColour == null
|
||||
? null
|
||||
: TextButton.styleFrom(
|
||||
foregroundColor: widget.primaryActionColour),
|
||||
foregroundColor: widget.primaryActionColour,
|
||||
),
|
||||
onPressed: !valid
|
||||
? null
|
||||
: () {
|
||||
@ -85,8 +90,9 @@ class _GeneratedFormModalState extends State<GeneratedFormModal> {
|
||||
Navigator.of(context).pop(values);
|
||||
}
|
||||
},
|
||||
child: Text(tr('continue')))
|
||||
: const SizedBox.shrink()
|
||||
child: Text(tr('continue')),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
@ -20,23 +20,24 @@ class ObtainiumError {
|
||||
class RateLimitError extends ObtainiumError {
|
||||
late int remainingMinutes;
|
||||
RateLimitError(this.remainingMinutes)
|
||||
: super(plural('tooManyRequestsTryAgainInMinutes', remainingMinutes));
|
||||
: super(plural('tooManyRequestsTryAgainInMinutes', remainingMinutes));
|
||||
}
|
||||
|
||||
class InvalidURLError extends ObtainiumError {
|
||||
InvalidURLError(String sourceName)
|
||||
: super(tr('invalidURLForSource', args: [sourceName]));
|
||||
: super(tr('invalidURLForSource', args: [sourceName]));
|
||||
}
|
||||
|
||||
class CredsNeededError extends ObtainiumError {
|
||||
CredsNeededError(String sourceName)
|
||||
: super(tr('requiresCredentialsInSettings', args: [sourceName]));
|
||||
: super(tr('requiresCredentialsInSettings', args: [sourceName]));
|
||||
}
|
||||
|
||||
class NoReleasesError extends ObtainiumError {
|
||||
NoReleasesError({String? note})
|
||||
: super(
|
||||
'${tr('noReleaseFound')}${note?.isNotEmpty == true ? '\n\n$note' : ''}');
|
||||
: super(
|
||||
'${tr('noReleaseFound')}${note?.isNotEmpty == true ? '\n\n$note' : ''}',
|
||||
);
|
||||
}
|
||||
|
||||
class NoAPKError extends ObtainiumError {
|
||||
@ -57,7 +58,7 @@ class DowngradeError extends ObtainiumError {
|
||||
|
||||
class InstallError extends ObtainiumError {
|
||||
InstallError(int code)
|
||||
: super(PackageInstallerStatus.byCode(code).name.substring(7));
|
||||
: super(PackageInstallerStatus.byCode(code).name.substring(7));
|
||||
}
|
||||
|
||||
class IDChangedError extends ObtainiumError {
|
||||
@ -75,7 +76,7 @@ class MultiAppMultiError extends ObtainiumError {
|
||||
|
||||
MultiAppMultiError() : super(tr('placeholder'), unexpected: true);
|
||||
|
||||
add(String appId, dynamic error, {String? appName}) {
|
||||
void add(String appId, dynamic error, {String? appName}) {
|
||||
if (error is SocketException) {
|
||||
error = error.message;
|
||||
}
|
||||
@ -93,8 +94,11 @@ class MultiAppMultiError extends ObtainiumError {
|
||||
String errorString(String appId, {bool includeIdsWithNames = false}) =>
|
||||
'${appIdNames.containsKey(appId) ? '${appIdNames[appId]}${includeIdsWithNames ? ' ($appId)' : ''}' : appId}: ${rawErrors[appId].toString()}';
|
||||
|
||||
String errorsAppsString(String errString, List<String> appIds,
|
||||
{bool includeIdsWithNames = false}) =>
|
||||
String errorsAppsString(
|
||||
String errString,
|
||||
List<String> appIds, {
|
||||
bool includeIdsWithNames = false,
|
||||
}) =>
|
||||
'$errString [${list2FriendlyString(appIds.map((id) => appIdNames.containsKey(id) == true ? '${appIdNames[id]}${includeIdsWithNames ? ' ($id)' : ''}' : id).toList())}]';
|
||||
|
||||
@override
|
||||
@ -103,43 +107,50 @@ class MultiAppMultiError extends ObtainiumError {
|
||||
.join('\n\n');
|
||||
}
|
||||
|
||||
showMessage(dynamic e, BuildContext context, {bool isError = false}) {
|
||||
Provider.of<LogsProvider>(context, listen: false)
|
||||
.add(e.toString(), level: isError ? LogLevels.error : LogLevels.info);
|
||||
void showMessage(dynamic e, BuildContext context, {bool isError = false}) {
|
||||
Provider.of<LogsProvider>(
|
||||
context,
|
||||
listen: false,
|
||||
).add(e.toString(), level: isError ? LogLevels.error : LogLevels.info);
|
||||
if (e is String || (e is ObtainiumError && !e.unexpected)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString())),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(e.toString())));
|
||||
} else {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(e is MultiAppMultiError
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
title: Text(
|
||||
e is MultiAppMultiError
|
||||
? tr(isError ? 'someErrors' : 'updates')
|
||||
: tr(isError ? 'unexpectedError' : 'unknown')),
|
||||
content: GestureDetector(
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: e.toString()));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(tr('copiedToClipboard')),
|
||||
));
|
||||
},
|
||||
child: Text(e.toString())),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(tr('ok'))),
|
||||
],
|
||||
);
|
||||
});
|
||||
: tr(isError ? 'unexpectedError' : 'unknown'),
|
||||
),
|
||||
content: GestureDetector(
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: e.toString()));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(tr('copiedToClipboard'))));
|
||||
},
|
||||
child: Text(e.toString()),
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(tr('ok')),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
showError(dynamic e, BuildContext context) {
|
||||
void showError(dynamic e, BuildContext context) {
|
||||
showMessage(e, context, isError: true);
|
||||
}
|
||||
|
||||
@ -147,14 +158,16 @@ String list2FriendlyString(List<String> list) {
|
||||
return list.length == 2
|
||||
? '${list[0]} ${tr('and')} ${list[1]}'
|
||||
: list
|
||||
.asMap()
|
||||
.entries
|
||||
.map((e) =>
|
||||
e.value +
|
||||
(e.key == list.length - 1
|
||||
? ''
|
||||
: e.key == list.length - 2
|
||||
.asMap()
|
||||
.entries
|
||||
.map(
|
||||
(e) =>
|
||||
e.value +
|
||||
(e.key == list.length - 1
|
||||
? ''
|
||||
: e.key == list.length - 2
|
||||
? ' and '
|
||||
: ', '))
|
||||
.join('');
|
||||
: ', '),
|
||||
)
|
||||
.join('');
|
||||
}
|
||||
|
222
lib/main.dart
222
lib/main.dart
@ -43,8 +43,10 @@ List<MapEntry<Locale, String>> supportedLocales = const [
|
||||
MapEntry(Locale('tr'), 'Türkçe'),
|
||||
MapEntry(Locale('uk'), 'Українська'),
|
||||
MapEntry(Locale('da'), 'Dansk'),
|
||||
MapEntry(Locale('en', 'EO'),
|
||||
'Esperanto'), // https://github.com/aissat/easy_localization/issues/220#issuecomment-846035493
|
||||
MapEntry(
|
||||
Locale('en', 'EO'),
|
||||
'Esperanto',
|
||||
), // https://github.com/aissat/easy_localization/issues/220#issuecomment-846035493
|
||||
MapEntry(Locale('in'), 'Bahasa Indonesia'),
|
||||
MapEntry(Locale('ko'), '한국어'),
|
||||
MapEntry(Locale('ca'), 'Català'),
|
||||
@ -76,9 +78,11 @@ Future<void> loadTranslations() async {
|
||||
},
|
||||
);
|
||||
await controller.loadTranslations();
|
||||
Localization.load(controller.locale,
|
||||
translations: controller.translations,
|
||||
fallbackTranslations: controller.fallbackTranslations);
|
||||
Localization.load(
|
||||
controller.locale,
|
||||
translations: controller.translations,
|
||||
fallbackTranslations: controller.fallbackTranslations,
|
||||
);
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@ -97,10 +101,12 @@ void backgroundFetchHeadlessTask(HeadlessTask task) async {
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
try {
|
||||
ByteData data =
|
||||
await PlatformAssetBundle().load('assets/ca/lets-encrypt-r3.pem');
|
||||
SecurityContext.defaultContext
|
||||
.setTrustedCertificatesBytes(data.buffer.asUint8List());
|
||||
ByteData data = await PlatformAssetBundle().load(
|
||||
'assets/ca/lets-encrypt-r3.pem',
|
||||
);
|
||||
SecurityContext.defaultContext.setTrustedCertificatesBytes(
|
||||
data.buffer.asUint8List(),
|
||||
);
|
||||
} catch (e) {
|
||||
// Already added, do nothing (see #375)
|
||||
}
|
||||
@ -113,20 +119,23 @@ void main() async {
|
||||
}
|
||||
final np = NotificationsProvider();
|
||||
await np.initialize();
|
||||
runApp(MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (context) => AppsProvider()),
|
||||
ChangeNotifierProvider(create: (context) => SettingsProvider()),
|
||||
Provider(create: (context) => np),
|
||||
Provider(create: (context) => LogsProvider())
|
||||
],
|
||||
child: EasyLocalization(
|
||||
runApp(
|
||||
MultiProvider(
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (context) => AppsProvider()),
|
||||
ChangeNotifierProvider(create: (context) => SettingsProvider()),
|
||||
Provider(create: (context) => np),
|
||||
Provider(create: (context) => LogsProvider()),
|
||||
],
|
||||
child: EasyLocalization(
|
||||
supportedLocales: supportedLocales.map((e) => e.key).toList(),
|
||||
path: localeDir,
|
||||
fallbackLocale: fallbackLocale,
|
||||
useOnlyLangCode: false,
|
||||
child: const Obtainium()),
|
||||
));
|
||||
child: const Obtainium(),
|
||||
),
|
||||
),
|
||||
);
|
||||
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
|
||||
}
|
||||
|
||||
@ -148,22 +157,26 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
|
||||
Future<void> initPlatformState() async {
|
||||
await BackgroundFetch.configure(
|
||||
BackgroundFetchConfig(
|
||||
minimumFetchInterval: 15,
|
||||
stopOnTerminate: false,
|
||||
startOnBoot: true,
|
||||
enableHeadless: true,
|
||||
requiresBatteryNotLow: false,
|
||||
requiresCharging: false,
|
||||
requiresStorageNotLow: false,
|
||||
requiresDeviceIdle: false,
|
||||
requiredNetworkType: NetworkType.ANY), (String taskId) async {
|
||||
await bgUpdateCheck(taskId, null);
|
||||
BackgroundFetch.finish(taskId);
|
||||
}, (String taskId) async {
|
||||
context.read<LogsProvider>().add('BG update task timed out.');
|
||||
BackgroundFetch.finish(taskId);
|
||||
});
|
||||
BackgroundFetchConfig(
|
||||
minimumFetchInterval: 15,
|
||||
stopOnTerminate: false,
|
||||
startOnBoot: true,
|
||||
enableHeadless: true,
|
||||
requiresBatteryNotLow: false,
|
||||
requiresCharging: false,
|
||||
requiresStorageNotLow: false,
|
||||
requiresDeviceIdle: false,
|
||||
requiredNetworkType: NetworkType.ANY,
|
||||
),
|
||||
(String taskId) async {
|
||||
await bgUpdateCheck(taskId, null);
|
||||
BackgroundFetch.finish(taskId);
|
||||
},
|
||||
(String taskId) async {
|
||||
context.read<LogsProvider>().add('BG update task timed out.');
|
||||
BackgroundFetch.finish(taskId);
|
||||
},
|
||||
);
|
||||
if (!mounted) return;
|
||||
}
|
||||
|
||||
@ -183,30 +196,33 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
// If this is the first run, ask for notification permissions and add Obtainium to the Apps list
|
||||
Permission.notification.request();
|
||||
if (!fdroid) {
|
||||
getInstalledInfo(obtainiumId).then((value) {
|
||||
if (value?.versionName != null) {
|
||||
appsProvider.saveApps([
|
||||
App(
|
||||
obtainiumId,
|
||||
obtainiumUrl,
|
||||
'ImranR98',
|
||||
'Obtainium',
|
||||
value!.versionName,
|
||||
value.versionName!,
|
||||
[],
|
||||
0,
|
||||
{
|
||||
'versionDetection': true,
|
||||
'apkFilterRegEx': 'fdroid',
|
||||
'invertAPKFilter': true
|
||||
},
|
||||
null,
|
||||
false)
|
||||
], onlyIfExists: false);
|
||||
}
|
||||
}).catchError((err) {
|
||||
print(err);
|
||||
});
|
||||
getInstalledInfo(obtainiumId)
|
||||
.then((value) {
|
||||
if (value?.versionName != null) {
|
||||
appsProvider.saveApps([
|
||||
App(
|
||||
obtainiumId,
|
||||
obtainiumUrl,
|
||||
'ImranR98',
|
||||
'Obtainium',
|
||||
value!.versionName,
|
||||
value.versionName!,
|
||||
[],
|
||||
0,
|
||||
{
|
||||
'versionDetection': true,
|
||||
'apkFilterRegEx': 'fdroid',
|
||||
'invertAPKFilter': true,
|
||||
},
|
||||
null,
|
||||
false,
|
||||
),
|
||||
], onlyIfExists: false);
|
||||
}
|
||||
})
|
||||
.catchError((err) {
|
||||
print(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (!supportedLocales.map((e) => e.key).contains(context.locale) ||
|
||||
@ -221,32 +237,35 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
});
|
||||
|
||||
return DynamicColorBuilder(
|
||||
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
|
||||
// Decide on a colour/brightness scheme based on OS and user settings
|
||||
ColorScheme lightColorScheme;
|
||||
ColorScheme darkColorScheme;
|
||||
if (lightDynamic != null &&
|
||||
darkDynamic != null &&
|
||||
settingsProvider.useMaterialYou) {
|
||||
lightColorScheme = lightDynamic.harmonized();
|
||||
darkColorScheme = darkDynamic.harmonized();
|
||||
} else {
|
||||
lightColorScheme =
|
||||
ColorScheme.fromSeed(seedColor: settingsProvider.themeColor);
|
||||
darkColorScheme = ColorScheme.fromSeed(
|
||||
builder: (ColorScheme? lightDynamic, ColorScheme? darkDynamic) {
|
||||
// Decide on a colour/brightness scheme based on OS and user settings
|
||||
ColorScheme lightColorScheme;
|
||||
ColorScheme darkColorScheme;
|
||||
if (lightDynamic != null &&
|
||||
darkDynamic != null &&
|
||||
settingsProvider.useMaterialYou) {
|
||||
lightColorScheme = lightDynamic.harmonized();
|
||||
darkColorScheme = darkDynamic.harmonized();
|
||||
} else {
|
||||
lightColorScheme = ColorScheme.fromSeed(
|
||||
seedColor: settingsProvider.themeColor,
|
||||
brightness: Brightness.dark);
|
||||
}
|
||||
);
|
||||
darkColorScheme = ColorScheme.fromSeed(
|
||||
seedColor: settingsProvider.themeColor,
|
||||
brightness: Brightness.dark,
|
||||
);
|
||||
}
|
||||
|
||||
// set the background and surface colors to pure black in the amoled theme
|
||||
if (settingsProvider.useBlackTheme) {
|
||||
darkColorScheme =
|
||||
darkColorScheme.copyWith(surface: Colors.black).harmonized();
|
||||
}
|
||||
// set the background and surface colors to pure black in the amoled theme
|
||||
if (settingsProvider.useBlackTheme) {
|
||||
darkColorScheme = darkColorScheme
|
||||
.copyWith(surface: Colors.black)
|
||||
.harmonized();
|
||||
}
|
||||
|
||||
if (settingsProvider.useSystemFont) NativeFeatures.loadSystemFont();
|
||||
if (settingsProvider.useSystemFont) NativeFeatures.loadSystemFont();
|
||||
|
||||
return MaterialApp(
|
||||
return MaterialApp(
|
||||
title: 'Obtainium',
|
||||
localizationsDelegates: context.localizationDelegates,
|
||||
supportedLocales: context.supportedLocales,
|
||||
@ -254,22 +273,31 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
navigatorKey: globalNavigatorKey,
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: settingsProvider.theme == ThemeSettings.dark
|
||||
? darkColorScheme
|
||||
: lightColorScheme,
|
||||
fontFamily:
|
||||
settingsProvider.useSystemFont ? 'SystemFont' : 'Montserrat'),
|
||||
useMaterial3: true,
|
||||
colorScheme: settingsProvider.theme == ThemeSettings.dark
|
||||
? darkColorScheme
|
||||
: lightColorScheme,
|
||||
fontFamily: settingsProvider.useSystemFont
|
||||
? 'SystemFont'
|
||||
: 'Montserrat',
|
||||
),
|
||||
darkTheme: ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: settingsProvider.theme == ThemeSettings.light
|
||||
? lightColorScheme
|
||||
: darkColorScheme,
|
||||
fontFamily:
|
||||
settingsProvider.useSystemFont ? 'SystemFont' : 'Montserrat'),
|
||||
home: Shortcuts(shortcuts: <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
|
||||
}, child: const HomePage()));
|
||||
});
|
||||
useMaterial3: true,
|
||||
colorScheme: settingsProvider.theme == ThemeSettings.light
|
||||
? lightColorScheme
|
||||
: darkColorScheme,
|
||||
fontFamily: settingsProvider.useSystemFont
|
||||
? 'SystemFont'
|
||||
: 'Montserrat',
|
||||
),
|
||||
home: Shortcuts(
|
||||
shortcuts: <LogicalKeySet, Intent>{
|
||||
LogicalKeySet(LogicalKeyboardKey.select): const ActivateIntent(),
|
||||
},
|
||||
child: const HomePage(),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,4 +3,4 @@ import 'main.dart' as m;
|
||||
void main() async {
|
||||
m.fdroid = true;
|
||||
m.main();
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,15 @@ class GitHubStars implements MassAppUrlSource {
|
||||
late List<String> requiredArgs = [tr('uname')];
|
||||
|
||||
Future<Map<String, List<String>>> getOnePageOfUserStarredUrlsWithDescriptions(
|
||||
String username, int page) async {
|
||||
String username,
|
||||
int page,
|
||||
) async {
|
||||
Response res = await get(
|
||||
Uri.parse(
|
||||
'https://api.github.com/users/$username/starred?per_page=100&page=$page'),
|
||||
headers: await GitHub().getRequestHeaders({}));
|
||||
Uri.parse(
|
||||
'https://api.github.com/users/$username/starred?per_page=100&page=$page',
|
||||
),
|
||||
headers: await GitHub().getRequestHeaders({}),
|
||||
);
|
||||
if (res.statusCode == 200) {
|
||||
Map<String, List<String>> urlsWithDescriptions = {};
|
||||
for (var e in (jsonDecode(res.body) as List<dynamic>)) {
|
||||
@ -27,8 +31,8 @@ class GitHubStars implements MassAppUrlSource {
|
||||
e['full_name'] as String,
|
||||
e['description'] != null
|
||||
? e['description'] as String
|
||||
: tr('noDescription')
|
||||
]
|
||||
: tr('noDescription'),
|
||||
],
|
||||
});
|
||||
}
|
||||
return urlsWithDescriptions;
|
||||
@ -41,15 +45,18 @@ class GitHubStars implements MassAppUrlSource {
|
||||
|
||||
@override
|
||||
Future<Map<String, List<String>>> getUrlsWithDescriptions(
|
||||
List<String> args) async {
|
||||
List<String> args,
|
||||
) async {
|
||||
if (args.length != requiredArgs.length) {
|
||||
throw ObtainiumError(tr('wrongArgNum'));
|
||||
}
|
||||
Map<String, List<String>> urlsWithDescriptions = {};
|
||||
var page = 1;
|
||||
while (true) {
|
||||
var pageUrls =
|
||||
await getOnePageOfUserStarredUrlsWithDescriptions(args[0], page++);
|
||||
var pageUrls = await getOnePageOfUserStarredUrlsWithDescriptions(
|
||||
args[0],
|
||||
page++,
|
||||
);
|
||||
urlsWithDescriptions.addAll(pageUrls);
|
||||
if (pageUrls.length < 100) {
|
||||
break;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -40,13 +40,15 @@ class _AppPageState extends State<AppPage> {
|
||||
onWebResourceError: (WebResourceError error) {
|
||||
if (error.isForMainFrame == true) {
|
||||
showError(
|
||||
ObtainiumError(error.description, unexpected: true), context);
|
||||
ObtainiumError(error.description, unexpected: true),
|
||||
context,
|
||||
);
|
||||
}
|
||||
},
|
||||
onNavigationRequest: (NavigationRequest request) =>
|
||||
request.url.startsWith("rustore://")
|
||||
? NavigationDecision.prevent
|
||||
: NavigationDecision.navigate,
|
||||
? NavigationDecision.prevent
|
||||
: NavigationDecision.navigate,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -85,8 +87,10 @@ class _AppPageState extends State<AppPage> {
|
||||
var sourceProvider = SourceProvider();
|
||||
AppInMemory? app = appsProvider.apps[widget.appId]?.deepCopy();
|
||||
var source = app != null
|
||||
? sourceProvider.getSource(app.app.url,
|
||||
overrideSource: app.app.overrideSource)
|
||||
? sourceProvider.getSource(
|
||||
app.app.url,
|
||||
overrideSource: app.app.overrideSource,
|
||||
)
|
||||
: null;
|
||||
if (!areDownloadsRunning &&
|
||||
prevApp == null &&
|
||||
@ -100,7 +104,9 @@ class _AppPageState extends State<AppPage> {
|
||||
bool isVersionDetectionStandard =
|
||||
app?.app.additionalSettings['versionDetection'] == true;
|
||||
|
||||
bool installedVersionIsEstimate = app?.app != null ? isVersionPseudo(app!.app) : false;
|
||||
bool installedVersionIsEstimate = app?.app != null
|
||||
? isVersionPseudo(app!.app)
|
||||
: false;
|
||||
|
||||
if (app != null && !_wasWebViewOpened) {
|
||||
_wasWebViewOpened = true;
|
||||
@ -122,11 +128,14 @@ class _AppPageState extends State<AppPage> {
|
||||
if (!upToDate) {
|
||||
versionLines += '\n${app?.app.latestVersion} ${tr('latest')}';
|
||||
}
|
||||
String infoLines = tr('lastUpdateCheckX', args: [
|
||||
app?.app.lastUpdateCheck == null
|
||||
? tr('never')
|
||||
: '${app?.app.lastUpdateCheck?.toLocal()}'
|
||||
]);
|
||||
String infoLines = tr(
|
||||
'lastUpdateCheckX',
|
||||
args: [
|
||||
app?.app.lastUpdateCheck == null
|
||||
? tr('never')
|
||||
: '${app?.app.lastUpdateCheck?.toLocal()}',
|
||||
],
|
||||
);
|
||||
if (trackOnly) {
|
||||
infoLines = '${tr('xIsTrackOnly', args: [tr('app')])}\n$infoLines';
|
||||
}
|
||||
@ -146,15 +155,14 @@ class _AppPageState extends State<AppPage> {
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 24),
|
||||
child: Column(
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
versionLines,
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodyLarge!.copyWith(fontWeight: FontWeight.bold),
|
||||
),
|
||||
Text(versionLines,
|
||||
textAlign: TextAlign.start,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.bodyLarge!
|
||||
.copyWith(fontWeight: FontWeight.bold)),
|
||||
changeLogFn != null || app?.app.releaseDate != null
|
||||
? GestureDetector(
|
||||
onTap: changeLogFn,
|
||||
@ -163,21 +171,19 @@ class _AppPageState extends State<AppPage> {
|
||||
? tr('changes')
|
||||
: app!.app.releaseDate!.toLocal().toString(),
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: changeLogFn != null
|
||||
? TextDecoration.underline
|
||||
: null,
|
||||
fontStyle: changeLogFn != null
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
style: Theme.of(context).textTheme.labelSmall!
|
||||
.copyWith(
|
||||
decoration: changeLogFn != null
|
||||
? TextDecoration.underline
|
||||
: null,
|
||||
fontStyle: changeLogFn != null
|
||||
? FontStyle.italic
|
||||
: null,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox.shrink(),
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -189,101 +195,108 @@ class _AppPageState extends State<AppPage> {
|
||||
if (app?.app.apkUrls.isNotEmpty == true ||
|
||||
app?.app.otherAssetUrls.isNotEmpty == true)
|
||||
GestureDetector(
|
||||
onTap: app?.app == null || updating
|
||||
? null
|
||||
: () async {
|
||||
try {
|
||||
await appsProvider
|
||||
.downloadAppAssets([app!.app.id], context);
|
||||
} catch (e) {
|
||||
showError(e, context);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: settingsProvider.highlightTouchTargets
|
||||
? (Theme.of(context).brightness ==
|
||||
Brightness.light
|
||||
? Theme.of(context).primaryColor
|
||||
: Theme.of(context).primaryColorLight)
|
||||
.withAlpha(Theme.of(context).brightness ==
|
||||
Brightness.light
|
||||
? 20
|
||||
: 40)
|
||||
: null),
|
||||
padding: settingsProvider.highlightTouchTargets
|
||||
? const EdgeInsetsDirectional.fromSTEB(12, 6, 12, 6)
|
||||
: const EdgeInsetsDirectional.fromSTEB(0, 6, 0, 6),
|
||||
margin:
|
||||
const EdgeInsetsDirectional.fromSTEB(0, 6, 0, 0),
|
||||
child: Text(
|
||||
tr('downloadX',
|
||||
args: [tr('releaseAsset').toLowerCase()]),
|
||||
textAlign: TextAlign.center,
|
||||
style:
|
||||
Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
))
|
||||
],
|
||||
)),
|
||||
const SizedBox(
|
||||
height: 48,
|
||||
),
|
||||
onTap: app?.app == null || updating
|
||||
? null
|
||||
: () async {
|
||||
try {
|
||||
await appsProvider.downloadAppAssets([
|
||||
app!.app.id,
|
||||
], context);
|
||||
} catch (e) {
|
||||
showError(e, context);
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: settingsProvider.highlightTouchTargets
|
||||
? (Theme.of(context).brightness == Brightness.light
|
||||
? Theme.of(context).primaryColor
|
||||
: Theme.of(context).primaryColorLight)
|
||||
.withAlpha(
|
||||
Theme.of(context).brightness ==
|
||||
Brightness.light
|
||||
? 20
|
||||
: 40,
|
||||
)
|
||||
: null,
|
||||
),
|
||||
padding: settingsProvider.highlightTouchTargets
|
||||
? const EdgeInsetsDirectional.fromSTEB(12, 6, 12, 6)
|
||||
: const EdgeInsetsDirectional.fromSTEB(0, 6, 0, 6),
|
||||
margin: const EdgeInsetsDirectional.fromSTEB(0, 6, 0, 0),
|
||||
child: Text(
|
||||
tr('downloadX', args: [tr('releaseAsset').toLowerCase()]),
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
CategoryEditorSelector(
|
||||
alignment: WrapAlignment.center,
|
||||
preselected: app?.app.categories != null
|
||||
? app!.app.categories.toSet()
|
||||
: {},
|
||||
onSelected: (categories) {
|
||||
if (app != null) {
|
||||
app.app.categories = categories;
|
||||
appsProvider.saveApps([app.app]);
|
||||
}
|
||||
}),
|
||||
alignment: WrapAlignment.center,
|
||||
preselected: app?.app.categories != null
|
||||
? app!.app.categories.toSet()
|
||||
: {},
|
||||
onSelected: (categories) {
|
||||
if (app != null) {
|
||||
app.app.categories = categories;
|
||||
appsProvider.saveApps([app.app]);
|
||||
}
|
||||
},
|
||||
),
|
||||
if (app?.app.additionalSettings['about'] is String &&
|
||||
app?.app.additionalSettings['about'].isNotEmpty)
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 48,
|
||||
),
|
||||
const SizedBox(height: 48),
|
||||
GestureDetector(
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(
|
||||
text: app?.app.additionalSettings['about'] ?? ''));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(tr('copiedToClipboard')),
|
||||
));
|
||||
},
|
||||
child: Markdown(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
styleSheet: MarkdownStyleSheet(
|
||||
blockquoteDecoration:
|
||||
BoxDecoration(color: Theme.of(context).cardColor),
|
||||
textAlign: WrapAlignment.center),
|
||||
data: app?.app.additionalSettings['about'],
|
||||
onTapLink: (text, href, title) {
|
||||
if (href != null) {
|
||||
launchUrlString(href,
|
||||
mode: LaunchMode.externalApplication);
|
||||
}
|
||||
},
|
||||
extensionSet: md.ExtensionSet(
|
||||
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
[
|
||||
md.EmojiSyntax(),
|
||||
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes
|
||||
],
|
||||
onLongPress: () {
|
||||
Clipboard.setData(
|
||||
ClipboardData(
|
||||
text: app?.app.additionalSettings['about'] ?? '',
|
||||
),
|
||||
))
|
||||
);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(tr('copiedToClipboard'))),
|
||||
);
|
||||
},
|
||||
child: Markdown(
|
||||
physics: NeverScrollableScrollPhysics(),
|
||||
shrinkWrap: true,
|
||||
styleSheet: MarkdownStyleSheet(
|
||||
blockquoteDecoration: BoxDecoration(
|
||||
color: Theme.of(context).cardColor,
|
||||
),
|
||||
textAlign: WrapAlignment.center,
|
||||
),
|
||||
data: app?.app.additionalSettings['about'],
|
||||
onTapLink: (text, href, title) {
|
||||
if (href != null) {
|
||||
launchUrlString(
|
||||
href,
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
}
|
||||
},
|
||||
extensionSet: md.ExtensionSet(
|
||||
md.ExtensionSet.gitHubFlavored.blockSyntaxes,
|
||||
[
|
||||
md.EmojiSyntax(),
|
||||
...md.ExtensionSet.gitHubFlavored.inlineSyntaxes,
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
@ -291,132 +304,143 @@ class _AppPageState extends State<AppPage> {
|
||||
}
|
||||
|
||||
getFullInfoColumn({bool small = false}) => Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: small ? 5 : 20),
|
||||
FutureBuilder(
|
||||
future:
|
||||
appsProvider.updateAppIcon(app?.app.id, ignoreCache: true),
|
||||
builder: (ctx, val) {
|
||||
return app?.icon != null
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: app == null
|
||||
? null
|
||||
: () => pm.openApp(app.app.id),
|
||||
child: Image.memory(
|
||||
app!.icon!,
|
||||
height: small ? 70 : 150,
|
||||
gaplessPlayback: true,
|
||||
),
|
||||
)
|
||||
])
|
||||
: Container();
|
||||
}),
|
||||
SizedBox(
|
||||
height: small ? 10 : 25,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SizedBox(height: small ? 5 : 20),
|
||||
FutureBuilder(
|
||||
future: appsProvider.updateAppIcon(app?.app.id, ignoreCache: true),
|
||||
builder: (ctx, val) {
|
||||
return app?.icon != null
|
||||
? Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GestureDetector(
|
||||
onTap: app == null
|
||||
? null
|
||||
: () => pm.openApp(app.app.id),
|
||||
child: Image.memory(
|
||||
app!.icon!,
|
||||
height: small ? 70 : 150,
|
||||
gaplessPlayback: true,
|
||||
),
|
||||
),
|
||||
],
|
||||
)
|
||||
: Container();
|
||||
},
|
||||
),
|
||||
SizedBox(height: small ? 10 : 25),
|
||||
Text(
|
||||
app?.name ?? tr('app'),
|
||||
textAlign: TextAlign.center,
|
||||
style: small
|
||||
? Theme.of(context).textTheme.displaySmall
|
||||
: Theme.of(context).textTheme.displayLarge,
|
||||
),
|
||||
Text(
|
||||
tr('byX', args: [app?.author ?? tr('unknown')]),
|
||||
textAlign: TextAlign.center,
|
||||
style: small
|
||||
? Theme.of(context).textTheme.headlineSmall
|
||||
: Theme.of(context).textTheme.headlineMedium,
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (app?.app.url != null) {
|
||||
launchUrlString(
|
||||
app?.app.url ?? '',
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: app?.app.url ?? ''));
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text(tr('copiedToClipboard'))));
|
||||
},
|
||||
child: Text(
|
||||
app?.app.url ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic,
|
||||
),
|
||||
Text(
|
||||
app?.name ?? tr('app'),
|
||||
textAlign: TextAlign.center,
|
||||
style: small
|
||||
? Theme.of(context).textTheme.displaySmall
|
||||
: Theme.of(context).textTheme.displayLarge,
|
||||
),
|
||||
Text(tr('byX', args: [app?.author ?? tr('unknown')]),
|
||||
textAlign: TextAlign.center,
|
||||
style: small
|
||||
? Theme.of(context).textTheme.headlineSmall
|
||||
: Theme.of(context).textTheme.headlineMedium),
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
if (app?.app.url != null) {
|
||||
launchUrlString(app?.app.url ?? '',
|
||||
mode: LaunchMode.externalApplication);
|
||||
}
|
||||
},
|
||||
onLongPress: () {
|
||||
Clipboard.setData(ClipboardData(text: app?.app.url ?? ''));
|
||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||
content: Text(tr('copiedToClipboard')),
|
||||
));
|
||||
},
|
||||
child: Text(
|
||||
app?.app.url ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall!.copyWith(
|
||||
decoration: TextDecoration.underline,
|
||||
fontStyle: FontStyle.italic),
|
||||
)),
|
||||
Text(
|
||||
app?.app.id ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
getInfoColumn(),
|
||||
const SizedBox(height: 150)
|
||||
],
|
||||
);
|
||||
),
|
||||
),
|
||||
Text(
|
||||
app?.app.id ?? '',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.labelSmall,
|
||||
),
|
||||
getInfoColumn(),
|
||||
const SizedBox(height: 150),
|
||||
],
|
||||
);
|
||||
|
||||
getAppWebView() => app != null
|
||||
? WebViewWidget(
|
||||
key: ObjectKey(_webViewController),
|
||||
controller: _webViewController
|
||||
..setBackgroundColor(Theme.of(context).colorScheme.surface))
|
||||
..setBackgroundColor(Theme.of(context).colorScheme.surface),
|
||||
)
|
||||
: Container();
|
||||
|
||||
showMarkUpdatedDialog() {
|
||||
return showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(tr('alreadyUpToDateQuestion')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('no'))),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
HapticFeedback.selectionClick();
|
||||
var updatedApp = app?.app;
|
||||
if (updatedApp != null) {
|
||||
updatedApp.installedVersion = updatedApp.latestVersion;
|
||||
appsProvider.saveApps([updatedApp]);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('yesMarkUpdated')))
|
||||
],
|
||||
);
|
||||
});
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(tr('alreadyUpToDateQuestion')),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('no')),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
HapticFeedback.selectionClick();
|
||||
var updatedApp = app?.app;
|
||||
if (updatedApp != null) {
|
||||
updatedApp.installedVersion = updatedApp.latestVersion;
|
||||
appsProvider.saveApps([updatedApp]);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('yesMarkUpdated')),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
showAdditionalOptionsDialog() async {
|
||||
return await showDialog<Map<String, dynamic>?>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
var items =
|
||||
(source?.combinedAppSpecificSettingFormItems ?? []).map((row) {
|
||||
row = row.map((e) {
|
||||
if (app?.app.additionalSettings[e.key] != null) {
|
||||
e.defaultValue = app?.app.additionalSettings[e.key];
|
||||
}
|
||||
return e;
|
||||
}).toList();
|
||||
return row;
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
var items = (source?.combinedAppSpecificSettingFormItems ?? []).map((
|
||||
row,
|
||||
) {
|
||||
row = row.map((e) {
|
||||
if (app?.app.additionalSettings[e.key] != null) {
|
||||
e.defaultValue = app?.app.additionalSettings[e.key];
|
||||
}
|
||||
return e;
|
||||
}).toList();
|
||||
return row;
|
||||
}).toList();
|
||||
|
||||
return GeneratedFormModal(
|
||||
title: tr('additionalOptions'), items: items);
|
||||
});
|
||||
return GeneratedFormModal(
|
||||
title: tr('additionalOptions'),
|
||||
items: items,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
handleAdditionalOptionChanges(Map<String, dynamic>? values) {
|
||||
@ -430,18 +454,18 @@ class _AppPageState extends State<AppPage> {
|
||||
}
|
||||
var versionDetectionEnabled =
|
||||
app.app.additionalSettings['versionDetection'] == true &&
|
||||
originalSettings['versionDetection'] != true;
|
||||
originalSettings['versionDetection'] != true;
|
||||
var releaseDateVersionEnabled =
|
||||
app.app.additionalSettings['releaseDateAsVersion'] == true &&
|
||||
originalSettings['releaseDateAsVersion'] != true;
|
||||
originalSettings['releaseDateAsVersion'] != true;
|
||||
var releaseDateVersionDisabled =
|
||||
app.app.additionalSettings['releaseDateAsVersion'] != true &&
|
||||
originalSettings['releaseDateAsVersion'] == true;
|
||||
originalSettings['releaseDateAsVersion'] == true;
|
||||
if (releaseDateVersionEnabled) {
|
||||
if (app.app.releaseDate != null) {
|
||||
bool isUpdated = app.app.installedVersion == app.app.latestVersion;
|
||||
app.app.latestVersion =
|
||||
app.app.releaseDate!.microsecondsSinceEpoch.toString();
|
||||
app.app.latestVersion = app.app.releaseDate!.microsecondsSinceEpoch
|
||||
.toString();
|
||||
if (isUpdated) {
|
||||
app.app.installedVersion = app.app.latestVersion;
|
||||
}
|
||||
@ -461,172 +485,195 @@ class _AppPageState extends State<AppPage> {
|
||||
}
|
||||
|
||||
getInstallOrUpdateButton() => TextButton(
|
||||
onPressed: !updating &&
|
||||
(app?.app.installedVersion == null ||
|
||||
app?.app.installedVersion != app?.app.latestVersion) &&
|
||||
!areDownloadsRunning
|
||||
? () async {
|
||||
try {
|
||||
var successMessage = app?.app.installedVersion == null
|
||||
? tr('installed')
|
||||
: tr('appsUpdated');
|
||||
HapticFeedback.heavyImpact();
|
||||
var res = await appsProvider.downloadAndInstallLatestApps(
|
||||
app?.app.id != null ? [app!.app.id] : [],
|
||||
globalNavigatorKey.currentContext,
|
||||
);
|
||||
if (res.isNotEmpty && !trackOnly) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showMessage(successMessage, context);
|
||||
}
|
||||
if (res.isNotEmpty && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} catch (e) {
|
||||
onPressed:
|
||||
!updating &&
|
||||
(app?.app.installedVersion == null ||
|
||||
app?.app.installedVersion != app?.app.latestVersion) &&
|
||||
!areDownloadsRunning
|
||||
? () async {
|
||||
try {
|
||||
var successMessage = app?.app.installedVersion == null
|
||||
? tr('installed')
|
||||
: tr('appsUpdated');
|
||||
HapticFeedback.heavyImpact();
|
||||
var res = await appsProvider.downloadAndInstallLatestApps(
|
||||
app?.app.id != null ? [app!.app.id] : [],
|
||||
globalNavigatorKey.currentContext,
|
||||
);
|
||||
if (res.isNotEmpty && !trackOnly) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showError(e, context);
|
||||
showMessage(successMessage, context);
|
||||
}
|
||||
if (res.isNotEmpty && mounted) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore: use_build_context_synchronously
|
||||
showError(e, context);
|
||||
}
|
||||
: null,
|
||||
child: Text(app?.app.installedVersion == null
|
||||
}
|
||||
: null,
|
||||
child: Text(
|
||||
app?.app.installedVersion == null
|
||||
? !trackOnly
|
||||
? tr('install')
|
||||
: tr('markInstalled')
|
||||
? tr('install')
|
||||
: tr('markInstalled')
|
||||
: !trackOnly
|
||||
? tr('update')
|
||||
: tr('markUpdated')));
|
||||
? tr('update')
|
||||
: tr('markUpdated'),
|
||||
),
|
||||
);
|
||||
|
||||
getBottomSheetMenu() => Padding(
|
||||
padding:
|
||||
EdgeInsets.fromLTRB(0, 0, 0, MediaQuery.of(context).padding.bottom),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
if (source != null &&
|
||||
source.combinedAppSpecificSettingFormItems.isNotEmpty)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: () async {
|
||||
var values =
|
||||
await showAdditionalOptionsDialog();
|
||||
handleAdditionalOptionChanges(values);
|
||||
},
|
||||
tooltip: tr('additionalOptions'),
|
||||
icon: const Icon(Icons.edit)),
|
||||
if (app != null && app.installedInfo != null)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
appsProvider.openAppSettings(app.app.id);
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
MediaQuery.of(context).padding.bottom,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
if (source != null &&
|
||||
source.combinedAppSpecificSettingFormItems.isNotEmpty)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: () async {
|
||||
var values = await showAdditionalOptionsDialog();
|
||||
handleAdditionalOptionChanges(values);
|
||||
},
|
||||
icon: const Icon(Icons.settings),
|
||||
tooltip: tr('settings'),
|
||||
),
|
||||
if (app != null && settingsProvider.showAppWebpage)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
content: getFullInfoColumn(small: true),
|
||||
title: Text(app.name),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('continue')))
|
||||
],
|
||||
);
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
tooltip: tr('more')),
|
||||
if (app?.app.installedVersion != null &&
|
||||
app?.app.installedVersion != app?.app.latestVersion &&
|
||||
!isVersionDetectionStandard &&
|
||||
!trackOnly)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: showMarkUpdatedDialog,
|
||||
tooltip: tr('markUpdated'),
|
||||
icon: const Icon(Icons.done)),
|
||||
if ((!isVersionDetectionStandard || trackOnly) &&
|
||||
app?.app.installedVersion != null &&
|
||||
app?.app.installedVersion == app?.app.latestVersion)
|
||||
IconButton(
|
||||
onPressed: app?.app == null || updating
|
||||
? null
|
||||
: () {
|
||||
app!.app.installedVersion = null;
|
||||
appsProvider.saveApps([app.app]);
|
||||
},
|
||||
icon: const Icon(Icons.restore_rounded),
|
||||
tooltip: tr('resetInstallStatus')),
|
||||
const SizedBox(width: 16.0),
|
||||
Expanded(child: getInstallOrUpdateButton()),
|
||||
const SizedBox(width: 16.0),
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: () {
|
||||
appsProvider
|
||||
.removeAppsWithModal(
|
||||
context, app != null ? [app.app] : [])
|
||||
.then((value) {
|
||||
if (value == true) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
},
|
||||
tooltip: tr('remove'),
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
),
|
||||
])),
|
||||
if (app?.downloadProgress != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
||||
child: LinearProgressIndicator(
|
||||
value: app!.downloadProgress! >= 0
|
||||
? app.downloadProgress! / 100
|
||||
: null))
|
||||
],
|
||||
));
|
||||
tooltip: tr('additionalOptions'),
|
||||
icon: const Icon(Icons.edit),
|
||||
),
|
||||
if (app != null && app.installedInfo != null)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
appsProvider.openAppSettings(app.app.id);
|
||||
},
|
||||
icon: const Icon(Icons.settings),
|
||||
tooltip: tr('settings'),
|
||||
),
|
||||
if (app != null && settingsProvider.showAppWebpage)
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
scrollable: true,
|
||||
content: getFullInfoColumn(small: true),
|
||||
title: Text(app.name),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(tr('continue')),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
tooltip: tr('more'),
|
||||
),
|
||||
if (app?.app.installedVersion != null &&
|
||||
app?.app.installedVersion != app?.app.latestVersion &&
|
||||
!isVersionDetectionStandard &&
|
||||
!trackOnly)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: showMarkUpdatedDialog,
|
||||
tooltip: tr('markUpdated'),
|
||||
icon: const Icon(Icons.done),
|
||||
),
|
||||
if ((!isVersionDetectionStandard || trackOnly) &&
|
||||
app?.app.installedVersion != null &&
|
||||
app?.app.installedVersion == app?.app.latestVersion)
|
||||
IconButton(
|
||||
onPressed: app?.app == null || updating
|
||||
? null
|
||||
: () {
|
||||
app!.app.installedVersion = null;
|
||||
appsProvider.saveApps([app.app]);
|
||||
},
|
||||
icon: const Icon(Icons.restore_rounded),
|
||||
tooltip: tr('resetInstallStatus'),
|
||||
),
|
||||
const SizedBox(width: 16.0),
|
||||
Expanded(child: getInstallOrUpdateButton()),
|
||||
const SizedBox(width: 16.0),
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null || updating
|
||||
? null
|
||||
: () {
|
||||
appsProvider
|
||||
.removeAppsWithModal(
|
||||
context,
|
||||
app != null ? [app.app] : [],
|
||||
)
|
||||
.then((value) {
|
||||
if (value == true) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
});
|
||||
},
|
||||
tooltip: tr('remove'),
|
||||
icon: const Icon(Icons.delete_outline),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (app?.downloadProgress != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(0, 8, 0, 0),
|
||||
child: LinearProgressIndicator(
|
||||
value: app!.downloadProgress! >= 0
|
||||
? app.downloadProgress! / 100
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
appScreenAppBar() => AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
leading: IconButton(
|
||||
icon: const Icon(Icons.arrow_back),
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
return Scaffold(
|
||||
appBar: settingsProvider.showAppWebpage ? AppBar() : appScreenAppBar(),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: RefreshIndicator(
|
||||
child: settingsProvider.showAppWebpage
|
||||
? getAppWebView()
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Column(children: [getFullInfoColumn()])),
|
||||
],
|
||||
appBar: settingsProvider.showAppWebpage ? AppBar() : appScreenAppBar(),
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: RefreshIndicator(
|
||||
child: settingsProvider.showAppWebpage
|
||||
? getAppWebView()
|
||||
: CustomScrollView(
|
||||
slivers: [
|
||||
SliverToBoxAdapter(
|
||||
child: Column(children: [getFullInfoColumn()]),
|
||||
),
|
||||
onRefresh: () async {
|
||||
if (app != null) {
|
||||
getUpdate(app.app.id);
|
||||
}
|
||||
}),
|
||||
bottomSheet: getBottomSheetMenu());
|
||||
],
|
||||
),
|
||||
onRefresh: () async {
|
||||
if (app != null) {
|
||||
getUpdate(app.app.id);
|
||||
}
|
||||
},
|
||||
),
|
||||
bottomSheet: getBottomSheetMenu(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
1398
lib/pages/apps.dart
1398
lib/pages/apps.dart
File diff suppressed because it is too large
Load Diff
@ -43,13 +43,22 @@ class _HomePageState extends State<HomePage> {
|
||||
bool isLinkActivity = false;
|
||||
|
||||
List<NavigationPageItem> pages = [
|
||||
NavigationPageItem(tr('appsString'), Icons.apps,
|
||||
AppsPage(key: GlobalKey<AppsPageState>())),
|
||||
NavigationPageItem(
|
||||
tr('addApp'), Icons.add, AddAppPage(key: GlobalKey<AddAppPageState>())),
|
||||
tr('appsString'),
|
||||
Icons.apps,
|
||||
AppsPage(key: GlobalKey<AppsPageState>()),
|
||||
),
|
||||
NavigationPageItem(
|
||||
tr('importExport'), Icons.import_export, const ImportExportPage()),
|
||||
NavigationPageItem(tr('settings'), Icons.settings, const SettingsPage())
|
||||
tr('addApp'),
|
||||
Icons.add,
|
||||
AddAppPage(key: GlobalKey<AddAppPageState>()),
|
||||
),
|
||||
NavigationPageItem(
|
||||
tr('importExport'),
|
||||
Icons.import_export,
|
||||
const ImportExportPage(),
|
||||
),
|
||||
NavigationPageItem(tr('settings'), Icons.settings, const SettingsPage()),
|
||||
];
|
||||
|
||||
@override
|
||||
@ -60,63 +69,69 @@ class _HomePageState extends State<HomePage> {
|
||||
var sp = context.read<SettingsProvider>();
|
||||
if (!sp.welcomeShown) {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(tr('welcome')),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 20,
|
||||
children: [
|
||||
Text(tr('documentationLinksNote')),
|
||||
GestureDetector(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return AlertDialog(
|
||||
title: Text(tr('welcome')),
|
||||
content: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
spacing: 20,
|
||||
children: [
|
||||
Text(tr('documentationLinksNote')),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://github.com/ImranR98/Obtainium/blob/main/README.md',
|
||||
mode: LaunchMode.externalApplication,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
'https://github.com/ImranR98/Obtainium/blob/main/README.md',
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(tr('batteryOptimizationNote')),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
launchUrlString(
|
||||
'https://github.com/ImranR98/Obtainium/blob/main/README.md',
|
||||
mode: LaunchMode.externalApplication);
|
||||
final intent = AndroidIntent(
|
||||
action:
|
||||
'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS',
|
||||
package:
|
||||
obtainiumId, // Replace with your app's package name
|
||||
);
|
||||
|
||||
intent.launch();
|
||||
},
|
||||
child: Text(
|
||||
'https://github.com/ImranR98/Obtainium/blob/main/README.md',
|
||||
tr('settings'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.bold),
|
||||
)),
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(tr('batteryOptimizationNote')),
|
||||
GestureDetector(
|
||||
onTap: () {
|
||||
final intent = AndroidIntent(
|
||||
action:
|
||||
'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS',
|
||||
package:
|
||||
obtainiumId, // Replace with your app's package name
|
||||
);
|
||||
|
||||
intent.launch();
|
||||
},
|
||||
child: Text(
|
||||
tr('settings'),
|
||||
style: const TextStyle(
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.bold),
|
||||
decoration: TextDecoration.underline,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
sp.welcomeShown = true;
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(tr('ok'))),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
});
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
sp.welcomeShown = true;
|
||||
Navigator.of(context).pop(null);
|
||||
},
|
||||
child: Text(tr('ok')),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -126,13 +141,12 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
goToAddApp(String data) async {
|
||||
switchToPage(1);
|
||||
while (
|
||||
(pages[1].widget.key as GlobalKey<AddAppPageState>?)?.currentState ==
|
||||
null) {
|
||||
while ((pages[1].widget.key as GlobalKey<AddAppPageState>?)
|
||||
?.currentState ==
|
||||
null) {
|
||||
await Future.delayed(const Duration(microseconds: 1));
|
||||
}
|
||||
(pages[1].widget.key as GlobalKey<AddAppPageState>?)
|
||||
?.currentState
|
||||
(pages[1].widget.key as GlobalKey<AddAppPageState>?)?.currentState
|
||||
?.linkFn(data);
|
||||
}
|
||||
|
||||
@ -146,44 +160,55 @@ class _HomePageState extends State<HomePage> {
|
||||
} else if (action == 'app' || action == 'apps') {
|
||||
var dataStr = Uri.decodeComponent(data);
|
||||
if (await showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: tr('importX', args: [
|
||||
action == 'app' ? tr('app') : tr('appsString')
|
||||
]),
|
||||
items: const [],
|
||||
additionalWidgets: [
|
||||
ExpansionTile(
|
||||
title: const Text('Raw JSON'),
|
||||
children: [
|
||||
Text(
|
||||
dataStr,
|
||||
style: const TextStyle(fontFamily: 'monospace'),
|
||||
)
|
||||
],
|
||||
)
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: tr(
|
||||
'importX',
|
||||
args: [
|
||||
(action == 'app' ? tr('app') : tr('appsString'))
|
||||
.toLowerCase(),
|
||||
],
|
||||
);
|
||||
}) !=
|
||||
),
|
||||
items: const [],
|
||||
additionalWidgets: [
|
||||
ExpansionTile(
|
||||
title: const Text('Raw JSON'),
|
||||
children: [
|
||||
Text(
|
||||
dataStr,
|
||||
style: const TextStyle(fontFamily: 'monospace'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
) !=
|
||||
null) {
|
||||
// ignore: use_build_context_synchronously
|
||||
var appsProvider = context.read<AppsProvider>();
|
||||
var result = await appsProvider.import(action == 'app'
|
||||
? '{ "apps": [$dataStr] }'
|
||||
: '{ "apps": $dataStr }');
|
||||
var result = await appsProvider.import(
|
||||
action == 'app'
|
||||
? '{ "apps": [$dataStr] }'
|
||||
: '{ "apps": $dataStr }',
|
||||
);
|
||||
// ignore: use_build_context_synchronously
|
||||
showMessage(
|
||||
tr('importedX', args: [plural('apps', result.key.length)]),
|
||||
context);
|
||||
tr(
|
||||
'importedX',
|
||||
args: [plural('apps', result.key.length).toLowerCase()],
|
||||
),
|
||||
context,
|
||||
);
|
||||
await appsProvider
|
||||
.checkUpdates(specificIds: result.key.map((e) => e.id).toList())
|
||||
.catchError((e) {
|
||||
if (e is Map && e['errors'] is MultiAppMultiError) {
|
||||
showError(e['errors'].toString(), context);
|
||||
}
|
||||
return <App>[];
|
||||
});
|
||||
if (e is Map && e['errors'] is MultiAppMultiError) {
|
||||
showError(e['errors'].toString(), context);
|
||||
}
|
||||
return <App>[];
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw ObtainiumError(tr('unknown'));
|
||||
@ -210,15 +235,16 @@ class _HomePageState extends State<HomePage> {
|
||||
});
|
||||
}
|
||||
|
||||
setIsReversing(int targetIndex) {
|
||||
bool reversing = selectedIndexHistory.isNotEmpty &&
|
||||
void setIsReversing(int targetIndex) {
|
||||
bool reversing =
|
||||
selectedIndexHistory.isNotEmpty &&
|
||||
selectedIndexHistory.last > targetIndex;
|
||||
setState(() {
|
||||
isReversing = reversing;
|
||||
});
|
||||
}
|
||||
|
||||
switchToPage(int index) async {
|
||||
Future<void> switchToPage(int index) async {
|
||||
setIsReversing(index);
|
||||
if (index == 0) {
|
||||
while ((pages[0].widget.key as GlobalKey<AppsPageState>).currentState !=
|
||||
@ -259,65 +285,71 @@ class _HomePageState extends State<HomePage> {
|
||||
prevIsLoading = appsProvider.loadingApps;
|
||||
|
||||
return WillPopScope(
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: PageTransitionSwitcher(
|
||||
duration: Duration(
|
||||
milliseconds:
|
||||
settingsProvider.disablePageTransitions ? 0 : 300),
|
||||
reverse: settingsProvider.reversePageTransitions
|
||||
? !isReversing
|
||||
: isReversing,
|
||||
transitionBuilder: (
|
||||
Widget child,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return SharedAxisTransition(
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
transitionType: SharedAxisTransitionType.horizontal,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: pages
|
||||
.elementAt(selectedIndexHistory.isEmpty
|
||||
? 0
|
||||
: selectedIndexHistory.last)
|
||||
.widget,
|
||||
child: Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: PageTransitionSwitcher(
|
||||
duration: Duration(
|
||||
milliseconds: settingsProvider.disablePageTransitions ? 0 : 300,
|
||||
),
|
||||
bottomNavigationBar: NavigationBar(
|
||||
destinations: pages
|
||||
.map((e) =>
|
||||
NavigationDestination(icon: Icon(e.icon), label: e.title))
|
||||
.toList(),
|
||||
onDestinationSelected: (int index) async {
|
||||
HapticFeedback.selectionClick();
|
||||
switchToPage(index);
|
||||
},
|
||||
selectedIndex:
|
||||
reverse: settingsProvider.reversePageTransitions
|
||||
? !isReversing
|
||||
: isReversing,
|
||||
transitionBuilder:
|
||||
(
|
||||
Widget child,
|
||||
Animation<double> animation,
|
||||
Animation<double> secondaryAnimation,
|
||||
) {
|
||||
return SharedAxisTransition(
|
||||
animation: animation,
|
||||
secondaryAnimation: secondaryAnimation,
|
||||
transitionType: SharedAxisTransitionType.horizontal,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
child: pages
|
||||
.elementAt(
|
||||
selectedIndexHistory.isEmpty ? 0 : selectedIndexHistory.last,
|
||||
),
|
||||
)
|
||||
.widget,
|
||||
),
|
||||
onWillPop: () async {
|
||||
if (isLinkActivity &&
|
||||
selectedIndexHistory.length == 1 &&
|
||||
selectedIndexHistory.last == 1) {
|
||||
return true;
|
||||
}
|
||||
setIsReversing(selectedIndexHistory.length >= 2
|
||||
bottomNavigationBar: NavigationBar(
|
||||
destinations: pages
|
||||
.map(
|
||||
(e) =>
|
||||
NavigationDestination(icon: Icon(e.icon), label: e.title),
|
||||
)
|
||||
.toList(),
|
||||
onDestinationSelected: (int index) async {
|
||||
HapticFeedback.selectionClick();
|
||||
switchToPage(index);
|
||||
},
|
||||
selectedIndex: selectedIndexHistory.isEmpty
|
||||
? 0
|
||||
: selectedIndexHistory.last,
|
||||
),
|
||||
),
|
||||
onWillPop: () async {
|
||||
if (isLinkActivity &&
|
||||
selectedIndexHistory.length == 1 &&
|
||||
selectedIndexHistory.last == 1) {
|
||||
return true;
|
||||
}
|
||||
setIsReversing(
|
||||
selectedIndexHistory.length >= 2
|
||||
? selectedIndexHistory.reversed.toList()[1]
|
||||
: 0);
|
||||
if (selectedIndexHistory.isNotEmpty) {
|
||||
setState(() {
|
||||
selectedIndexHistory.removeLast();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return !(pages[0].widget.key as GlobalKey<AppsPageState>)
|
||||
.currentState
|
||||
?.clearSelected();
|
||||
});
|
||||
: 0,
|
||||
);
|
||||
if (selectedIndexHistory.isNotEmpty) {
|
||||
setState(() {
|
||||
selectedIndexHistory.removeLast();
|
||||
});
|
||||
return false;
|
||||
}
|
||||
return !(pages[0].widget.key as GlobalKey<AppsPageState>).currentState!
|
||||
.clearSelected();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@ class Log {
|
||||
idColumn: id,
|
||||
levelColumn: level.index,
|
||||
messageColumn: message,
|
||||
timestampColumn: timestamp.millisecondsSinceEpoch
|
||||
timestampColumn: timestamp.millisecondsSinceEpoch,
|
||||
};
|
||||
return map;
|
||||
}
|
||||
@ -33,8 +33,9 @@ class Log {
|
||||
id = map[idColumn] as int;
|
||||
level = LogLevels.values.elementAt(map[levelColumn] as int);
|
||||
message = map[messageColumn] as String;
|
||||
timestamp =
|
||||
DateTime.fromMillisecondsSinceEpoch(map[timestampColumn] as int);
|
||||
timestamp = DateTime.fromMillisecondsSinceEpoch(
|
||||
map[timestampColumn] as int,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -51,16 +52,19 @@ class LogsProvider {
|
||||
Database? db;
|
||||
|
||||
Future<Database> getDB() async {
|
||||
db ??= await openDatabase(dbPath, version: 1,
|
||||
onCreate: (Database db, int version) async {
|
||||
await db.execute('''
|
||||
db ??= await openDatabase(
|
||||
dbPath,
|
||||
version: 1,
|
||||
onCreate: (Database db, int version) async {
|
||||
await db.execute('''
|
||||
create table if not exists $logTable (
|
||||
$idColumn integer primary key autoincrement,
|
||||
$levelColumn integer not null,
|
||||
$messageColumn text not null,
|
||||
$timestampColumn integer not null)
|
||||
''');
|
||||
});
|
||||
},
|
||||
);
|
||||
return db!;
|
||||
}
|
||||
|
||||
@ -75,27 +79,38 @@ create table if not exists $logTable (
|
||||
|
||||
Future<List<Log>> get({DateTime? before, DateTime? after}) async {
|
||||
var where = getWhereDates(before: before, after: after);
|
||||
return (await (await getDB())
|
||||
.query(logTable, where: where.key, whereArgs: where.value))
|
||||
.map((e) => Log.fromMap(e))
|
||||
.toList();
|
||||
return (await (await getDB()).query(
|
||||
logTable,
|
||||
where: where.key,
|
||||
whereArgs: where.value,
|
||||
)).map((e) => Log.fromMap(e)).toList();
|
||||
}
|
||||
|
||||
Future<int> clear({DateTime? before, DateTime? after}) async {
|
||||
var where = getWhereDates(before: before, after: after);
|
||||
var res = await (await getDB())
|
||||
.delete(logTable, where: where.key, whereArgs: where.value);
|
||||
var res = await (await getDB()).delete(
|
||||
logTable,
|
||||
where: where.key,
|
||||
whereArgs: where.value,
|
||||
);
|
||||
if (res > 0) {
|
||||
add(plural('clearedNLogsBeforeXAfterY', res,
|
||||
add(
|
||||
plural(
|
||||
'clearedNLogsBeforeXAfterY',
|
||||
res,
|
||||
namedArgs: {'before': before.toString(), 'after': after.toString()},
|
||||
name: 'n'));
|
||||
name: 'n',
|
||||
),
|
||||
);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
MapEntry<String?, List<int>?> getWhereDates(
|
||||
{DateTime? before, DateTime? after}) {
|
||||
MapEntry<String?, List<int>?> getWhereDates({
|
||||
DateTime? before,
|
||||
DateTime? after,
|
||||
}) {
|
||||
List<String> where = [];
|
||||
List<int> whereArgs = [];
|
||||
if (before != null) {
|
||||
|
@ -20,91 +20,116 @@ class ObtainiumNotification {
|
||||
bool onlyAlertOnce;
|
||||
String? payload;
|
||||
|
||||
ObtainiumNotification(this.id, this.title, this.message, this.channelCode,
|
||||
this.channelName, this.channelDescription, this.importance,
|
||||
{this.onlyAlertOnce = false, this.progPercent, this.payload});
|
||||
ObtainiumNotification(
|
||||
this.id,
|
||||
this.title,
|
||||
this.message,
|
||||
this.channelCode,
|
||||
this.channelName,
|
||||
this.channelDescription,
|
||||
this.importance, {
|
||||
this.onlyAlertOnce = false,
|
||||
this.progPercent,
|
||||
this.payload,
|
||||
});
|
||||
}
|
||||
|
||||
class UpdateNotification extends ObtainiumNotification {
|
||||
UpdateNotification(List<App> updates, {int? id})
|
||||
: super(
|
||||
id ?? 2,
|
||||
tr('updatesAvailable'),
|
||||
'',
|
||||
'UPDATES_AVAILABLE',
|
||||
tr('updatesAvailableNotifChannel'),
|
||||
tr('updatesAvailableNotifDescription'),
|
||||
Importance.max) {
|
||||
: super(
|
||||
id ?? 2,
|
||||
tr('updatesAvailable'),
|
||||
'',
|
||||
'UPDATES_AVAILABLE',
|
||||
tr('updatesAvailableNotifChannel'),
|
||||
tr('updatesAvailableNotifDescription'),
|
||||
Importance.max,
|
||||
) {
|
||||
message = updates.isEmpty
|
||||
? tr('noNewUpdates')
|
||||
: updates.length == 1
|
||||
? tr('xHasAnUpdate', args: [updates[0].finalName])
|
||||
: plural('xAndNMoreUpdatesAvailable', updates.length - 1,
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()]);
|
||||
? tr('xHasAnUpdate', args: [updates[0].finalName])
|
||||
: plural(
|
||||
'xAndNMoreUpdatesAvailable',
|
||||
updates.length - 1,
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SilentUpdateNotification extends ObtainiumNotification {
|
||||
SilentUpdateNotification(List<App> updates, bool succeeded, {int? id})
|
||||
: super(
|
||||
id ?? 3,
|
||||
succeeded ? tr('appsUpdated') : tr('appsNotUpdated'),
|
||||
'',
|
||||
'APPS_UPDATED',
|
||||
tr('appsUpdatedNotifChannel'),
|
||||
tr('appsUpdatedNotifDescription'),
|
||||
Importance.defaultImportance) {
|
||||
: super(
|
||||
id ?? 3,
|
||||
succeeded ? tr('appsUpdated') : tr('appsNotUpdated'),
|
||||
'',
|
||||
'APPS_UPDATED',
|
||||
tr('appsUpdatedNotifChannel'),
|
||||
tr('appsUpdatedNotifDescription'),
|
||||
Importance.defaultImportance,
|
||||
) {
|
||||
message = updates.length == 1
|
||||
? tr(succeeded ? 'xWasUpdatedToY' : 'xWasNotUpdatedToY',
|
||||
args: [updates[0].finalName, updates[0].latestVersion])
|
||||
? tr(
|
||||
succeeded ? 'xWasUpdatedToY' : 'xWasNotUpdatedToY',
|
||||
args: [updates[0].finalName, updates[0].latestVersion],
|
||||
)
|
||||
: plural(
|
||||
succeeded ? 'xAndNMoreUpdatesInstalled' : "xAndNMoreUpdatesFailed",
|
||||
updates.length - 1,
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()]);
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SilentUpdateAttemptNotification extends ObtainiumNotification {
|
||||
SilentUpdateAttemptNotification(List<App> updates, {int? id})
|
||||
: super(
|
||||
id ?? 3,
|
||||
tr('appsPossiblyUpdated'),
|
||||
'',
|
||||
'APPS_POSSIBLY_UPDATED',
|
||||
tr('appsPossiblyUpdatedNotifChannel'),
|
||||
tr('appsPossiblyUpdatedNotifDescription'),
|
||||
Importance.defaultImportance) {
|
||||
: super(
|
||||
id ?? 3,
|
||||
tr('appsPossiblyUpdated'),
|
||||
'',
|
||||
'APPS_POSSIBLY_UPDATED',
|
||||
tr('appsPossiblyUpdatedNotifChannel'),
|
||||
tr('appsPossiblyUpdatedNotifDescription'),
|
||||
Importance.defaultImportance,
|
||||
) {
|
||||
message = updates.length == 1
|
||||
? tr('xWasPossiblyUpdatedToY',
|
||||
args: [updates[0].finalName, updates[0].latestVersion])
|
||||
: plural('xAndNMoreUpdatesPossiblyInstalled', updates.length - 1,
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()]);
|
||||
? tr(
|
||||
'xWasPossiblyUpdatedToY',
|
||||
args: [updates[0].finalName, updates[0].latestVersion],
|
||||
)
|
||||
: plural(
|
||||
'xAndNMoreUpdatesPossiblyInstalled',
|
||||
updates.length - 1,
|
||||
args: [updates[0].finalName, (updates.length - 1).toString()],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ErrorCheckingUpdatesNotification extends ObtainiumNotification {
|
||||
ErrorCheckingUpdatesNotification(String error, {int? id})
|
||||
: super(
|
||||
id ?? 5,
|
||||
tr('errorCheckingUpdates'),
|
||||
error,
|
||||
'BG_UPDATE_CHECK_ERROR',
|
||||
tr('errorCheckingUpdatesNotifChannel'),
|
||||
tr('errorCheckingUpdatesNotifDescription'),
|
||||
Importance.high,
|
||||
payload: "${tr('errorCheckingUpdates')}\n$error");
|
||||
: super(
|
||||
id ?? 5,
|
||||
tr('errorCheckingUpdates'),
|
||||
error,
|
||||
'BG_UPDATE_CHECK_ERROR',
|
||||
tr('errorCheckingUpdatesNotifChannel'),
|
||||
tr('errorCheckingUpdatesNotifDescription'),
|
||||
Importance.high,
|
||||
payload: "${tr('errorCheckingUpdates')}\n$error",
|
||||
);
|
||||
}
|
||||
|
||||
class AppsRemovedNotification extends ObtainiumNotification {
|
||||
AppsRemovedNotification(List<List<String>> namedReasons)
|
||||
: super(
|
||||
6,
|
||||
tr('appsRemoved'),
|
||||
'',
|
||||
'APPS_REMOVED',
|
||||
tr('appsRemovedNotifChannel'),
|
||||
tr('appsRemovedNotifDescription'),
|
||||
Importance.max) {
|
||||
: super(
|
||||
6,
|
||||
tr('appsRemoved'),
|
||||
'',
|
||||
'APPS_REMOVED',
|
||||
tr('appsRemovedNotifChannel'),
|
||||
tr('appsRemovedNotifDescription'),
|
||||
Importance.max,
|
||||
) {
|
||||
message = '';
|
||||
for (var r in namedReasons) {
|
||||
message += '${tr('xWasRemovedDueToErrorY', args: [r[0], r[1]])} \n';
|
||||
@ -115,49 +140,53 @@ class AppsRemovedNotification extends ObtainiumNotification {
|
||||
|
||||
class DownloadNotification extends ObtainiumNotification {
|
||||
DownloadNotification(String appName, int progPercent)
|
||||
: super(
|
||||
appName.hashCode,
|
||||
tr('downloadingX', args: [appName]),
|
||||
'',
|
||||
'APP_DOWNLOADING',
|
||||
tr('downloadingXNotifChannel', args: [tr('app')]),
|
||||
tr('downloadNotifDescription'),
|
||||
Importance.low,
|
||||
onlyAlertOnce: true,
|
||||
progPercent: progPercent);
|
||||
: super(
|
||||
appName.hashCode,
|
||||
tr('downloadingX', args: [appName]),
|
||||
'',
|
||||
'APP_DOWNLOADING',
|
||||
tr('downloadingXNotifChannel', args: [tr('app')]),
|
||||
tr('downloadNotifDescription'),
|
||||
Importance.low,
|
||||
onlyAlertOnce: true,
|
||||
progPercent: progPercent,
|
||||
);
|
||||
}
|
||||
|
||||
class DownloadedNotification extends ObtainiumNotification {
|
||||
DownloadedNotification(String fileName, String downloadUrl)
|
||||
: super(
|
||||
downloadUrl.hashCode,
|
||||
tr('downloadedX', args: [fileName]),
|
||||
'',
|
||||
'FILE_DOWNLOADED',
|
||||
tr('downloadedXNotifChannel', args: [tr('app')]),
|
||||
tr('downloadedX', args: [tr('app')]),
|
||||
Importance.defaultImportance);
|
||||
: super(
|
||||
downloadUrl.hashCode,
|
||||
tr('downloadedX', args: [fileName]),
|
||||
'',
|
||||
'FILE_DOWNLOADED',
|
||||
tr('downloadedXNotifChannel', args: [tr('app')]),
|
||||
tr('downloadedX', args: [tr('app')]),
|
||||
Importance.defaultImportance,
|
||||
);
|
||||
}
|
||||
|
||||
final completeInstallationNotification = ObtainiumNotification(
|
||||
1,
|
||||
tr('completeAppInstallation'),
|
||||
tr('obtainiumMustBeOpenToInstallApps'),
|
||||
'COMPLETE_INSTALL',
|
||||
tr('completeAppInstallationNotifChannel'),
|
||||
tr('completeAppInstallationNotifDescription'),
|
||||
Importance.max);
|
||||
1,
|
||||
tr('completeAppInstallation'),
|
||||
tr('obtainiumMustBeOpenToInstallApps'),
|
||||
'COMPLETE_INSTALL',
|
||||
tr('completeAppInstallationNotifChannel'),
|
||||
tr('completeAppInstallationNotifDescription'),
|
||||
Importance.max,
|
||||
);
|
||||
|
||||
class CheckingUpdatesNotification extends ObtainiumNotification {
|
||||
CheckingUpdatesNotification(String appName)
|
||||
: super(
|
||||
4,
|
||||
tr('checkingForUpdates'),
|
||||
appName,
|
||||
'BG_UPDATE_CHECK',
|
||||
tr('checkingForUpdatesNotifChannel'),
|
||||
tr('checkingForUpdatesNotifDescription'),
|
||||
Importance.min);
|
||||
: super(
|
||||
4,
|
||||
tr('checkingForUpdates'),
|
||||
appName,
|
||||
'BG_UPDATE_CHECK',
|
||||
tr('checkingForUpdatesNotifChannel'),
|
||||
tr('checkingForUpdatesNotifDescription'),
|
||||
Importance.min,
|
||||
);
|
||||
}
|
||||
|
||||
class NotificationsProvider {
|
||||
@ -173,13 +202,15 @@ class NotificationsProvider {
|
||||
Importance.max: Priority.max,
|
||||
Importance.min: Priority.min,
|
||||
Importance.none: Priority.min,
|
||||
Importance.unspecified: Priority.defaultPriority
|
||||
Importance.unspecified: Priority.defaultPriority,
|
||||
};
|
||||
|
||||
Future<void> initialize() async {
|
||||
isInitialized = await notifications.initialize(
|
||||
isInitialized =
|
||||
await notifications.initialize(
|
||||
const InitializationSettings(
|
||||
android: AndroidInitializationSettings('ic_notification')),
|
||||
android: AndroidInitializationSettings('ic_notification'),
|
||||
),
|
||||
onDidReceiveNotificationResponse: (NotificationResponse response) {
|
||||
_showNotificationPayload(response.payload);
|
||||
},
|
||||
@ -187,16 +218,18 @@ class NotificationsProvider {
|
||||
false;
|
||||
}
|
||||
|
||||
checkLaunchByNotif() async {
|
||||
final NotificationAppLaunchDetails? launchDetails =
|
||||
await notifications.getNotificationAppLaunchDetails();
|
||||
Future<void> checkLaunchByNotif() async {
|
||||
final NotificationAppLaunchDetails? launchDetails = await notifications
|
||||
.getNotificationAppLaunchDetails();
|
||||
if (launchDetails?.didNotificationLaunchApp ?? false) {
|
||||
_showNotificationPayload(launchDetails!.notificationResponse?.payload,
|
||||
doublePop: true);
|
||||
_showNotificationPayload(
|
||||
launchDetails!.notificationResponse?.payload,
|
||||
doublePop: true,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
_showNotificationPayload(String? payload, {bool doublePop = false}) {
|
||||
void _showNotificationPayload(String? payload, {bool doublePop = false}) {
|
||||
if (payload?.isNotEmpty == true) {
|
||||
var title = (payload ?? '\n\n').split('\n').first;
|
||||
var content = (payload ?? '\n\n').split('\n').sublist(1).join('\n');
|
||||
@ -207,13 +240,14 @@ class NotificationsProvider {
|
||||
content: Text(content),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop(null);
|
||||
if (doublePop) {
|
||||
Navigator.of(context).pop(null);
|
||||
if (doublePop) {
|
||||
Navigator.of(context).pop(null);
|
||||
}
|
||||
},
|
||||
child: Text(tr('ok'))),
|
||||
}
|
||||
},
|
||||
child: Text(tr('ok')),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
@ -229,17 +263,18 @@ class NotificationsProvider {
|
||||
}
|
||||
|
||||
Future<void> notifyRaw(
|
||||
int id,
|
||||
String title,
|
||||
String message,
|
||||
String channelCode,
|
||||
String channelName,
|
||||
String channelDescription,
|
||||
Importance importance,
|
||||
{bool cancelExisting = false,
|
||||
int? progPercent,
|
||||
bool onlyAlertOnce = false,
|
||||
String? payload}) async {
|
||||
int id,
|
||||
String title,
|
||||
String message,
|
||||
String channelCode,
|
||||
String channelName,
|
||||
String channelDescription,
|
||||
Importance importance, {
|
||||
bool cancelExisting = false,
|
||||
int? progPercent,
|
||||
bool onlyAlertOnce = false,
|
||||
String? payload,
|
||||
}) async {
|
||||
if (cancelExisting) {
|
||||
await cancel(id);
|
||||
}
|
||||
@ -247,29 +282,42 @@ class NotificationsProvider {
|
||||
await initialize();
|
||||
}
|
||||
await notifications.show(
|
||||
id,
|
||||
title,
|
||||
message,
|
||||
NotificationDetails(
|
||||
android: AndroidNotificationDetails(channelCode, channelName,
|
||||
channelDescription: channelDescription,
|
||||
importance: importance,
|
||||
priority: importanceToPriority[importance]!,
|
||||
groupKey: '$obtainiumId.$channelCode',
|
||||
progress: progPercent ?? 0,
|
||||
maxProgress: 100,
|
||||
showProgress: progPercent != null,
|
||||
onlyAlertOnce: onlyAlertOnce,
|
||||
indeterminate: progPercent != null && progPercent < 0)),
|
||||
payload: payload);
|
||||
id,
|
||||
title,
|
||||
message,
|
||||
NotificationDetails(
|
||||
android: AndroidNotificationDetails(
|
||||
channelCode,
|
||||
channelName,
|
||||
channelDescription: channelDescription,
|
||||
importance: importance,
|
||||
priority: importanceToPriority[importance]!,
|
||||
groupKey: '$obtainiumId.$channelCode',
|
||||
progress: progPercent ?? 0,
|
||||
maxProgress: 100,
|
||||
showProgress: progPercent != null,
|
||||
onlyAlertOnce: onlyAlertOnce,
|
||||
indeterminate: progPercent != null && progPercent < 0,
|
||||
),
|
||||
),
|
||||
payload: payload,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> notify(ObtainiumNotification notif,
|
||||
{bool cancelExisting = false}) =>
|
||||
notifyRaw(notif.id, notif.title, notif.message, notif.channelCode,
|
||||
notif.channelName, notif.channelDescription, notif.importance,
|
||||
cancelExisting: cancelExisting,
|
||||
onlyAlertOnce: notif.onlyAlertOnce,
|
||||
progPercent: notif.progPercent,
|
||||
payload: notif.payload);
|
||||
Future<void> notify(
|
||||
ObtainiumNotification notif, {
|
||||
bool cancelExisting = false,
|
||||
}) => notifyRaw(
|
||||
notif.id,
|
||||
notif.title,
|
||||
notif.message,
|
||||
notif.channelCode,
|
||||
notif.channelName,
|
||||
notif.channelDescription,
|
||||
notif.importance,
|
||||
cancelExisting: cancelExisting,
|
||||
onlyAlertOnce: notif.onlyAlertOnce,
|
||||
progPercent: notif.progPercent,
|
||||
payload: notif.payload,
|
||||
);
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
ThemeSettings get theme {
|
||||
return ThemeSettings
|
||||
.values[prefs?.getInt('theme') ?? ThemeSettings.system.index];
|
||||
return ThemeSettings.values[prefs?.getInt('theme') ??
|
||||
ThemeSettings.system.index];
|
||||
}
|
||||
|
||||
set theme(ThemeSettings t) {
|
||||
@ -123,8 +123,8 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
SortColumnSettings get sortColumn {
|
||||
return SortColumnSettings.values[
|
||||
prefs?.getInt('sortColumn') ?? SortColumnSettings.nameAuthor.index];
|
||||
return SortColumnSettings.values[prefs?.getInt('sortColumn') ??
|
||||
SortColumnSettings.nameAuthor.index];
|
||||
}
|
||||
|
||||
set sortColumn(SortColumnSettings s) {
|
||||
@ -133,8 +133,8 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
SortOrderSettings get sortOrder {
|
||||
return SortOrderSettings.values[
|
||||
prefs?.getInt('sortOrder') ?? SortOrderSettings.ascending.index];
|
||||
return SortOrderSettings.values[prefs?.getInt('sortOrder') ??
|
||||
SortOrderSettings.ascending.index];
|
||||
}
|
||||
|
||||
set sortOrder(SortOrderSettings s) {
|
||||
@ -171,7 +171,9 @@ class SettingsProvider with ChangeNotifier {
|
||||
while (!(await Permission.requestInstallPackages.isGranted)) {
|
||||
// Explicit request as InstallPlugin request sometimes bugged
|
||||
Fluttertoast.showToast(
|
||||
msg: tr('pleaseAllowInstallPerm'), toastLength: Toast.LENGTH_LONG);
|
||||
msg: tr('pleaseAllowInstallPerm'),
|
||||
toastLength: Toast.LENGTH_LONG,
|
||||
);
|
||||
if ((await Permission.requestInstallPackages.request()) ==
|
||||
PermissionStatus.granted) {
|
||||
return true;
|
||||
@ -470,7 +472,8 @@ class SettingsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
List<String> get searchDeselected {
|
||||
return prefs?.getStringList('searchDeselected') ?? SourceProvider().sources.map((s) => s.name).toList();
|
||||
return prefs?.getStringList('searchDeselected') ??
|
||||
SourceProvider().sources.map((s) => s.name).toList();
|
||||
}
|
||||
|
||||
set searchDeselected(List<String> list) {
|
||||
|
File diff suppressed because it is too large
Load Diff
18
pubspec.lock
18
pubspec.lock
@ -288,10 +288,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
sha256: "77f8e81d22d2a07d0dee2c62e1dda71dc1da73bf43bb2d45af09727406167964"
|
||||
sha256: ef9908739bdd9c476353d6adff72e88fd00c625f5b959ae23f7567bd5137db0a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "10.1.9"
|
||||
version: "10.2.0"
|
||||
fixnum:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -804,10 +804,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pointer_interceptor_web
|
||||
sha256: "7a7087782110f8c1827170660b09f8aa893e0e9a61431dbbe2ac3fc482e8c044"
|
||||
sha256: "460b600e71de6fcea2b3d5f662c92293c049c4319e27f0829310e5a953b3ee2a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.10.2+1"
|
||||
version: "0.10.3"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -893,7 +893,7 @@ packages:
|
||||
description:
|
||||
path: "."
|
||||
ref: master
|
||||
resolved-ref: "89cdb5434a7ac7510f6bcdb60e1d51a27ee2f40b"
|
||||
resolved-ref: "012e22791138958e089f6c1a8d6c4c6943a9f253"
|
||||
url: "https://github.com/AlexBacich/shared-storage"
|
||||
source: git
|
||||
version: "0.7.0"
|
||||
@ -1155,10 +1155,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webview_flutter_platform_interface
|
||||
sha256: "7cb32b21825bd65569665c32bb00a34ded5779786d6201f5350979d2d529940d"
|
||||
sha256: f0dc2dc3a2b1e3a6abdd6801b9355ebfeb3b8f6cde6b9dc7c9235909c4a1f147
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.13.0"
|
||||
version: "2.13.1"
|
||||
webview_flutter_wkwebview:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -1171,10 +1171,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
sha256: "329edf97fdd893e0f1e3b9e88d6a0e627128cc17cc316a8d67fda8f1451178ba"
|
||||
sha256: "66814138c3562338d05613a6e368ed8cfb237ad6d64a9e9334be3f309acfca03"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "5.13.0"
|
||||
version: "5.14.0"
|
||||
win32_registry:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 1.1.56+2313
|
||||
version: 1.1.57+2314
|
||||
|
||||
environment:
|
||||
sdk: ^3.8.1
|
||||
@ -149,4 +149,4 @@ flutter:
|
||||
fonts:
|
||||
- family: Montserrat
|
||||
fonts:
|
||||
- asset: assets/fonts/Montserrat-Regular.ttf
|
||||
- asset: assets/fonts/Montserrat-Regular.ttf
|
||||
|
Reference in New Issue
Block a user