diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d4bd632..690fc81 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,12 @@ name: Build and Release on: workflow_dispatch: + inputs: + beta: + type: boolean + description: Is beta? + environment: + type: environment jobs: build: @@ -47,12 +53,13 @@ jobs: - name: Extract Version id: extract_version run: | - VERSION=$(grep -oP "currentVersion = '\K[^']+" lib/main.dart) + VERSION=$(grep -oP "^version: [^\+]+" pubspec.yaml | tail -c +10) echo "version=$VERSION" >> $GITHUB_OUTPUT - TAG=$(grep -oP "'.*\\\$currentVersion.*'" lib/main.dart | head -c -2 | tail -c +2 | sed "s/\$currentVersion/$VERSION/g") - echo "tag=$TAG" >> $GITHUB_OUTPUT - if [ -n "$(echo $TAG | grep -oP '\-beta$')" ]; then BETA=true; else BETA=false; fi + if [ ${{ inputs.beta }} == true ]; then BETA=true; else BETA=false; fi echo "beta=$BETA" >> $GITHUB_OUTPUT + TAG="v$VERSION" + if [ $BETA == true ]; then TAG="$TAG"-beta; fi + echo "tag=$TAG" >> $GITHUB_OUTPUT - name: Create Tag uses: mathieudutour/github-tag-action@v6.1 diff --git a/lib/main.dart b/lib/main.dart index ea3fb1d..c965ce2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,6 +7,7 @@ import 'package:obtainium/providers/apps_provider.dart'; import 'package:obtainium/providers/logs_provider.dart'; import 'package:obtainium/providers/notifications_provider.dart'; import 'package:obtainium/providers/settings_provider.dart'; +import 'package:obtainium/providers/source_provider.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:provider/provider.dart'; import 'package:dynamic_color/dynamic_color.dart'; @@ -18,10 +19,6 @@ import 'package:easy_localization/src/easy_localization_controller.dart'; // ignore: implementation_imports import 'package:easy_localization/src/localization.dart'; -const String currentVersion = '0.15.11'; -const String currentReleaseTag = - 'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES - List> supportedLocales = const [ MapEntry(Locale('en'), 'English'), MapEntry(Locale('zh'), '简体中文'), @@ -174,7 +171,29 @@ class _ObtainiumState extends State { // If this is the first run, ask for notification permissions and add Obtainium to the Apps list Permission.notification.request(); if (!fdroid) { - appsProvider.saveApps([obtainiumApp], onlyIfExists: false); + getInstalledInfo(obtainiumId).then((value) { + if (value?.versionName != null) { + appsProvider.saveApps([ + App( + obtainiumId, + obtainiumUrl, + 'ImranR98', + 'Obtainium', + value!.versionName, + value.versionName!, + [], + 0, + { + 'includePrereleases': true, + 'versionDetection': 'standardVersionDetection' + }, + null, + false) + ], onlyIfExists: false); + } + }).catchError((err) { + print(err); + }); } } if (!supportedLocales diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 83b15d7..c5570c0 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -904,7 +904,7 @@ class AppsPageState extends State { }))}">${a.name}\n'; } urls += - '\n\n

${tr('about')}

'; + '\n\n

${tr('about')}

'; Share.share(urls, subject: '${tr('obtainium')} - ${tr('appsString')}'); diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index ad3dd73..38f6417 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -234,6 +234,20 @@ Future downloadFile( return downloadedFile; } +Future getInstalledInfo(String? packageName, + {bool printErr = true}) async { + if (packageName != null) { + try { + return await pm.getPackageInfo(packageName: packageName); + } catch (e) { + if (printErr) { + print(e); // OK + } + } + } + return null; +} + class AppsProvider with ChangeNotifier { // In memory App state (should always be kept in sync with local storage versions) Map apps = {}; @@ -404,7 +418,7 @@ class AppsProvider with ChangeNotifier { .isNotEmpty; Future canInstallSilently(App app) async { - if (app.id == obtainiumApp.id) { + if (app.id == obtainiumId) { return false; } if (!settingsProvider.enableBackgroundUpdates) { @@ -428,7 +442,7 @@ class AppsProvider with ChangeNotifier { } catch (e) { // Probably not installed - ignore } - if (installerPackageName != obtainiumApp.id) { + if (installerPackageName != obtainiumId) { // If we did not install the app (or it isn't installed), silent install is not possible return false; } @@ -639,6 +653,7 @@ class AppsProvider with ChangeNotifier { MapEntry? apkUrl; var trackOnly = apps[id]!.app.additionalSettings['trackOnly'] == true; if (!trackOnly) { + // ignore: use_build_context_synchronously apkUrl = await confirmApkUrl(apps[id]!.app, context); } if (apkUrl != null) { @@ -673,7 +688,7 @@ class AppsProvider with ChangeNotifier { // Move Obtainium to the end of the line (let all other apps update first) appsToInstall = - moveStrToEnd(appsToInstall, obtainiumApp.id, strB: obtainiumTempId); + moveStrToEnd(appsToInstall, obtainiumId, strB: obtainiumTempId); Future updateFn(String id, {bool skipInstalls = false}) async { try { @@ -775,20 +790,6 @@ class AppsProvider with ChangeNotifier { return appsDir; } - Future getInstalledInfo(String? packageName, - {bool printErr = true}) async { - if (packageName != null) { - try { - return await pm.getPackageInfo(packageName: packageName); - } catch (e) { - if (printErr) { - print(e); // OK - } - } - } - return null; - } - bool isVersionDetectionPossible(AppInMemory? app) { if (app?.app == null) { return false; @@ -1678,8 +1679,7 @@ Future bgUpdateCheck(String taskId, Map? params) async { } if (toInstall.isNotEmpty) { logs.add('BG install task: Started (${toInstall.length}).'); - var tempObtArr = - toInstall.where((element) => element.key == obtainiumApp.id); + var tempObtArr = toInstall.where((element) => element.key == obtainiumId); if (tempObtArr.isNotEmpty) { // Move obtainium to the end of the list as it must always install last var obt = tempObtArr.first; diff --git a/lib/providers/settings_provider.dart b/lib/providers/settings_provider.dart index fdfb585..147dfc9 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -15,22 +15,8 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_storage/shared_storage.dart' as saf; String obtainiumTempId = 'imranr98_obtainium_${GitHub().hosts[0]}'; - -App obtainiumApp = App( - 'dev.imranr.obtainium', - 'https://github.com/ImranR98/Obtainium', - 'ImranR98', - 'Obtainium', - currentReleaseTag, - currentReleaseTag, - [], - 0, - { - 'includePrereleases': true, - 'versionDetection': 'standardVersionDetection' - }, - null, - false); +String obtainiumId = 'dev.imranr.obtainium'; +String obtainiumUrl = 'https://github.com/ImranR98/Obtainium'; enum InstallMethodSettings { normal, shizuku, root }