Skip to content

Commit

Permalink
Merge pull request #965 from ImranR98/dev
Browse files Browse the repository at this point in the history
Parallelize Update Checking (#963), Bugfixes (#954, #962)
  • Loading branch information
ImranR98 authored Oct 7, 2023
2 parents 4b1c5e1 + 4e5a9b2 commit c8f2f42
Show file tree
Hide file tree
Showing 10 changed files with 193 additions and 129 deletions.
23 changes: 16 additions & 7 deletions .github/workflows/android.yml → .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: android
name: Release (Manual/Draft)

on:
workflow_dispatch:
Expand All @@ -25,12 +25,16 @@ jobs:
env:
KEYSTORE_BASE64: ${{ secrets.KEYSTORE_BASE64 }}
KEYSTORE_PASS: ${{ secrets.KEYSTORE_PASS }}
GPG_KEY: ${{ secrets.GPG_KEY }}
run: |
echo "${KEYSTORE_BASE64}" | base64 -d > apksign.keystore
echo "$GPG_KEY" | gpg --import
for apk in ./build/app/outputs/flutter-apk/*-release*.apk; do
out=${apk/-release/-release-signed}
${ANDROID_HOME}/build-tools/30.0.2/apksigner sign --ks apksign.keystore --ks-pass env:KEYSTORE_PASS --out "${out}" "${apk}"
echo "$(sha256sum ${out})"
unsignedFn=${apk/-release/-unsigned}
mv "$apk" "$unsignedFn"
${ANDROID_HOME}/build-tools/30.0.2/apksigner sign --ks apksign.keystore --ks-pass env:KEYSTORE_PASS --out "${apk}" "${unsignedFn}"
sha256sum ${apk} | cut -d " " -f 1 > "$apk".sha256
gpg --sign --detach-sig "$apk".sha256
done
rm apksign.keystore
Expand All @@ -39,14 +43,19 @@ jobs:
run: |
VERSION=$(grep -oP "currentVersion = '\K[^']+" lib/main.dart)
echo "::set-output name=version::$VERSION"
TAG=$(grep -oP "'.*\\\$currentVersion.*'" lib/main.dart | head -c -2 | tail -c +2 | sed "s/\$currentVersion/$VERSION/g")
echo "::set-output name=tag::$TAG"
if [ -n "$(echo $TAG | grep -oP '\-beta$')" ]; then BETA=true; else BETA=false; fi
echo "::set-output name=beta::$BETA"
- name: Create Release And Upload APKs
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.GAT }}
tag: "v${{ steps.extract_version.outputs.version }}-beta"
prerelease: true
artifacts: ./build/app/outputs/flutter-apk/*-signed*.apk
tag: "${{ steps.extract_version.outputs.tag }}"
prerelease: "${{ steps.extract_version.outputs.beta }}"
artifacts: ./build/app/outputs/flutter-apk/*-release*.apk*
draft: true

- name: Archive Reports For Job
uses: actions/upload-artifact@v3
Expand Down
12 changes: 8 additions & 4 deletions lib/app_sources/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,14 @@ class HTML extends AppSource {
GeneratedFormTextField('matchGroupToUse',
label: tr('matchGroupToUse'),
required: false,
hint: '1',
hint: '0',
textInputType: const TextInputType.numberWithOptions(),
additionalValidators: [
(value) {
if (value?.isEmpty == true) {
value = null;
}
value ??= '1';
value ??= '0';
return intValidator(value);
}
])
Expand Down Expand Up @@ -216,8 +216,12 @@ class HTML extends AppSource {
if (match.isEmpty) {
throw NoVersionError();
}
version = match.last
.group(int.parse(additionalSettings['matchGroupToUse'] as String));
String matchGroupString =
(additionalSettings['matchGroupToUse'] as String).trim();
if (matchGroupString.isEmpty) {
matchGroupString = "0";
}
version = match.last.group(int.parse(matchGroupString));
if (version?.isEmpty == true) {
throw NoVersionError();
}
Expand Down
16 changes: 16 additions & 0 deletions lib/app_sources/uptodown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,20 @@ class Uptodown extends AppSource {
version, getApkUrlsFromUrls([apkUrl]), AppNames(author, appName),
releaseDate: relDate);
}

@override
Future<String> apkUrlPrefetchModifier(
String apkUrl, String standardUrl) async {
var res = await sourceRequest(apkUrl);
if (res.statusCode != 200) {
throw getObtainiumHttpError(res);
}
var html = parse(res.body);
var finalUrl =
(html.querySelector('.post-download')?.attributes['data-url']);
if (finalUrl == null) {
throw NoAPKError();
}
return finalUrl;
}
}
27 changes: 16 additions & 11 deletions lib/custom_errors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,30 @@ class NotImplementedError extends ObtainiumError {
}

class MultiAppMultiError extends ObtainiumError {
Map<String, List<String>> content = {};
Map<String, dynamic> rawErrors = {};
Map<String, List<String>> idsByErrorString = {};
Map<String, String> appIdNames = {};

MultiAppMultiError() : super(tr('placeholder'), unexpected: true);

add(String appId, String string) {
var tempIds = content.remove(string);
add(String appId, dynamic error, {String? appName}) {
rawErrors[appId] = error;
var string = error.toString();
var tempIds = idsByErrorString.remove(string);
tempIds ??= [];
tempIds.add(appId);
content.putIfAbsent(string, () => tempIds!);
idsByErrorString.putIfAbsent(string, () => tempIds!);
if (appName != null) {
appIdNames[appId] = appName;
}
}

String errorString(String appId) =>
'${appIdNames.containsKey(appId) ? '${appIdNames[appId]} ($appId)' : appId}: ${rawErrors[appId].toString()}';

@override
String toString() {
String finalString = '';
for (var e in content.keys) {
finalString += '$e: ${content[e].toString()}\n\n';
}
return finalString;
}
String toString() =>
idsByErrorString.keys.map((e) => errorString(e)).join('\n\n');
}

showError(dynamic e, BuildContext context) {
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
// ignore: implementation_imports
import 'package:easy_localization/src/localization.dart';

const String currentVersion = '0.14.22';
const String currentVersion = '0.14.23';
const String currentReleaseTag =
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES

Expand Down
4 changes: 2 additions & 2 deletions lib/pages/apps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class AppsPageState extends State<AppsPage> {
refreshingSince = DateTime.now();
});
return appsProvider.checkUpdates().catchError((e) {
showError(e, context);
showError(e is Map ? e['errors'] : e, context);
return <App>[];
}).whenComplete(() {
setState(() {
Expand Down Expand Up @@ -833,7 +833,7 @@ class AppsPageState extends State<AppsPage> {
items: const [],
initValid: true,
message: tr('installStatusOfXWillBeResetExplanation',
args: [plural('app', selectedAppIds.length)]),
args: [plural('apps', selectedAppIds.length)]),
);
});
if (values != null) {
Expand Down
5 changes: 3 additions & 2 deletions lib/pages/import_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ class _ImportExportPageState extends State<ImportExportPage> {
if (errors.isEmpty) {
// ignore: use_build_context_synchronously
showError(
tr('importedX', args: [plural('app', selectedUrls.length)]),
tr('importedX',
args: [plural('apps', selectedUrls.length)]),
context);
} else {
// ignore: use_build_context_synchronously
Expand Down Expand Up @@ -274,7 +275,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
if (errors.isEmpty) {
// ignore: use_build_context_synchronously
showError(
tr('importedX', args: [plural('app', selectedUrls.length)]),
tr('importedX', args: [plural('apps', selectedUrls.length)]),
context);
} else {
// ignore: use_build_context_synchronously
Expand Down
Loading

0 comments on commit c8f2f42

Please sign in to comment.