From 60869a049021254993dbbd6e086c31952d7587cc Mon Sep 17 00:00:00 2001 From: Imran Remtulla Date: Fri, 12 Jan 2024 23:46:50 -0500 Subject: [PATCH] Allow entire app config to be shared as link (see https://github.com/ImranR98/apps.obtainium.imranr.dev/issues/5) --- assets/translations/bs.json | 2 ++ assets/translations/cs.json | 2 ++ assets/translations/de.json | 2 ++ assets/translations/en.json | 2 ++ assets/translations/es.json | 2 ++ assets/translations/fa.json | 2 ++ assets/translations/fr.json | 2 ++ assets/translations/hu.json | 2 ++ assets/translations/it.json | 2 ++ assets/translations/ja.json | 2 ++ assets/translations/nl.json | 2 ++ assets/translations/pl.json | 2 ++ assets/translations/pt.json | 2 ++ assets/translations/ru.json | 2 ++ assets/translations/sv.json | 2 ++ assets/translations/tr.json | 2 ++ assets/translations/vi.json | 2 ++ assets/translations/zh.json | 2 ++ lib/main.dart | 16 +----------- lib/pages/apps.dart | 38 +++++++++++++++++++++++----- lib/providers/apps_provider.dart | 9 ++++--- lib/providers/settings_provider.dart | 17 ++++++++++++- lib/providers/source_provider.dart | 7 ++--- 23 files changed, 94 insertions(+), 29 deletions(-) diff --git a/assets/translations/bs.json b/assets/translations/bs.json index fa1fcba..77ed5a8 100644 --- a/assets/translations/bs.json +++ b/assets/translations/bs.json @@ -73,6 +73,8 @@ "unpinFromTop": "Otkvači sa vrha", "resetInstallStatusForSelectedAppsQuestion": "Resetujte status instalacije za odabrane aplikacije?", "installStatusOfXWillBeResetExplanation": "Status instalacije bilo koje odabrane aplikacije će se resetovati.\n\nTo može pomoći kada je verzija aplikacije prikazana u Obtainiumu netačna zbog neuspjelih ažuriranja ili drugih problema.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Podijeli odabrane URL-ove aplikacija", "resetInstallStatus": "Resetujte status instalacije", "more": "Više", diff --git a/assets/translations/cs.json b/assets/translations/cs.json index 18b0a67..17840ac 100644 --- a/assets/translations/cs.json +++ b/assets/translations/cs.json @@ -73,6 +73,8 @@ "unpinFromTop": "Odepnout shora", "resetInstallStatusForSelectedAppsQuestion": "Obnovit stav instalace vybraných aplikací?", "installStatusOfXWillBeResetExplanation": "Stav instalace vybraných aplikací bude resetován. To může být užitečné, pokud je verze aplikace zobrazená v Obtainium nesprávná z důvodu neúspěšných aktualizací nebo jiných problémů.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Sdílet adresy URL vybraných aplikací", "resetInstallStatus": "Obnovit stav instalace", "more": "Více", diff --git a/assets/translations/de.json b/assets/translations/de.json index 3c924b4..bbf5352 100644 --- a/assets/translations/de.json +++ b/assets/translations/de.json @@ -73,6 +73,8 @@ "unpinFromTop": "„Oben anheften“ aufheben", "resetInstallStatusForSelectedAppsQuestion": "Installationsstatus für ausgewählte Apps zurücksetzen?", "installStatusOfXWillBeResetExplanation": "Der Installationsstatus der ausgewählten Apps wird zurückgesetzt. Dies kann hilfreich sein, wenn die in Obtainium angezeigte App-Version aufgrund fehlgeschlagener Aktualisierungen oder anderer Probleme falsch ist.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Ausgewählte App-URLs teilen", "resetInstallStatus": "Installationsstatus zurücksetzen", "more": "Mehr", diff --git a/assets/translations/en.json b/assets/translations/en.json index 7f2daf1..d3f92f1 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -73,6 +73,8 @@ "unpinFromTop": "Unpin from top", "resetInstallStatusForSelectedAppsQuestion": "Reset Install Status for Selected Apps?", "installStatusOfXWillBeResetExplanation": "The install status of any selected Apps will be reset.\n\nThis can help when the App version shown in Obtainium is incorrect due to failed updates or other issues.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Share Selected App URLs", "resetInstallStatus": "Reset Install Status", "more": "More", diff --git a/assets/translations/es.json b/assets/translations/es.json index abe6417..9b57cee 100644 --- a/assets/translations/es.json +++ b/assets/translations/es.json @@ -73,6 +73,8 @@ "unpinFromTop": "Desfijar de arriba", "resetInstallStatusForSelectedAppsQuestion": "¿Restuarar estado de instalación para las aplicaciones seleccionadas?", "installStatusOfXWillBeResetExplanation": "El estado de instalación de las aplicaciones seleccionadas será restaurado.\n\nEsto puede ser de útil cuando la versión de la aplicación mostrada en Obtainium es incorrecta por actualizaciones fallidas u otros motivos.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Compartir URLs de las aplicaciones seleccionadas", "resetInstallStatus": "Restaurar Estado de Instalación", "more": "Más", diff --git a/assets/translations/fa.json b/assets/translations/fa.json index 1daffd1..ecef240 100644 --- a/assets/translations/fa.json +++ b/assets/translations/fa.json @@ -73,6 +73,8 @@ "unpinFromTop": "برداشتن پین از بالا", "resetInstallStatusForSelectedAppsQuestion": "وضعیت نصب برنامه‌های انتخابی بازنشانی شود؟", "installStatusOfXWillBeResetExplanation": "وضعیت نصب برنامه‌های انتخاب‌شده بازنشانی می‌شود.\n\nاگر نسخه برنامه نشان‌داده‌شده در Obtainium به دلیل به‌روزرسانی‌های ناموفق یا مشکلات دیگر نادرست باشد، می‌تواند کمک کند.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "اشتراک گذاری آدرس اینترنتی برنامه های انتخاب شده", "resetInstallStatus": "بازنشانی وضعیت نصب", "more": "بیشتر", diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 0a64673..d0acda6 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -73,6 +73,8 @@ "unpinFromTop": "Détacher du haut", "resetInstallStatusForSelectedAppsQuestion": "Réinitialiser l'état d'installation des applications sélectionnées ?", "installStatusOfXWillBeResetExplanation": "L'état d'installation de toutes les applications sélectionnées sera réinitialisé.\n\nCela peut aider lorsque la version de l'application affichée dans Obtainium est incorrecte en raison d'échecs de mises à jour ou d'autres problèmes.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Partager les URL d'application sélectionnées", "resetInstallStatus": "Réinitialiser le statut d'installation", "more": "Plus", diff --git a/assets/translations/hu.json b/assets/translations/hu.json index 504c8f0..faec027 100644 --- a/assets/translations/hu.json +++ b/assets/translations/hu.json @@ -73,6 +73,8 @@ "unpinFromTop": "Eltávolít felülről", "resetInstallStatusForSelectedAppsQuestion": "Visszaállítja a kiválasztott appok telepítési állapotát?", "installStatusOfXWillBeResetExplanation": "A kiválasztott appok telepítési állapota visszaáll.\n\nEz akkor segíthet, ha az Obtainiumban megjelenített app verzió hibás, frissítések vagy egyéb problémák miatt.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Ossza meg a kiválasztott app URL címeit", "resetInstallStatus": "Telepítési állapot visszaállítása", "more": "További", diff --git a/assets/translations/it.json b/assets/translations/it.json index 91dff86..e561991 100644 --- a/assets/translations/it.json +++ b/assets/translations/it.json @@ -73,6 +73,8 @@ "unpinFromTop": "Rimuovi dall'alto", "resetInstallStatusForSelectedAppsQuestion": "Ripristinare lo stato d'installazione delle app selezionate?", "installStatusOfXWillBeResetExplanation": "Lo stato d'installazione di ogni app selezionata sarà ripristinato.\n\nCiò può essere d'aiuto nel caso in cui la versione mostrata dell'app in Obtainium non sia corretta a causa di un aggiornamento fallito o di altri problemi.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Condividi gli URL delle app selezionate", "resetInstallStatus": "Ripristina lo stato d'installazione", "more": "Altro", diff --git a/assets/translations/ja.json b/assets/translations/ja.json index 43101c1..5b9b192 100644 --- a/assets/translations/ja.json +++ b/assets/translations/ja.json @@ -73,6 +73,8 @@ "unpinFromTop": "トップから固定解除", "resetInstallStatusForSelectedAppsQuestion": "選択したアプリのインストール状態をリセットしますか?", "installStatusOfXWillBeResetExplanation": "選択したアプリのインストール状態がリセットされます。\n\nアップデートに失敗した場合など、Obtainiumに表示されるアプリのバージョンが正しくない場合に有効です。", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "選択したアプリのURLを共有する", "resetInstallStatus": "インストール状態をリセットする", "more": "もっと見る", diff --git a/assets/translations/nl.json b/assets/translations/nl.json index 88ae1b4..720782a 100644 --- a/assets/translations/nl.json +++ b/assets/translations/nl.json @@ -73,6 +73,8 @@ "unpinFromTop": "Losmaken van de bovenkant", "resetInstallStatusForSelectedAppsQuestion": "Installatiestatus resetten voor geselecteerde apps?", "installStatusOfXWillBeResetExplanation": "De installatiestatus van alle geselecteerde apps zal worden gereset.\n\nDit kan helpen wanneer de versie van de app die in Obtainium wordt weergegeven onjuist is vanwege mislukte updates of andere problemen.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Deel geselecteerde app URL's", "resetInstallStatus": "Reset installatiestatus", "more": "Meer", diff --git a/assets/translations/pl.json b/assets/translations/pl.json index c602475..27094ce 100644 --- a/assets/translations/pl.json +++ b/assets/translations/pl.json @@ -73,6 +73,8 @@ "unpinFromTop": "Odepnij", "resetInstallStatusForSelectedAppsQuestion": "Zresetować status instalacji dla wybranych aplikacji?", "installStatusOfXWillBeResetExplanation": "Stan instalacji wybranych aplikacji zostanie zresetowany.\n\nMoże być to pomocne, gdy wersja aplikacji wyświetlana w Obtainium jest nieprawidłowa z powodu nieudanych aktualizacji lub innych problemów.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Udostępnij wybrane adresy URL aplikacji", "resetInstallStatus": "Zresetuj stan instalacji", "more": "Więcej", diff --git a/assets/translations/pt.json b/assets/translations/pt.json index 2fe1cb2..2bbc226 100644 --- a/assets/translations/pt.json +++ b/assets/translations/pt.json @@ -73,6 +73,8 @@ "unpinFromTop": "Desafixar do topo", "resetInstallStatusForSelectedAppsQuestion": "Reiniciar status de instalação para aplicativos selecionados?", "installStatusOfXWillBeResetExplanation": "O status de instalação de qualquer aplicativo selecionado será reiniciado.\n\nIsso pode ajudar quando uma versão de um aplicativo mostrada no Obtainium é incorreta devido a falhas ao atualizar ou outros problemas.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Compartilhar URLs de aplicativos selecionados", "resetInstallStatus": "Reiniciar status de Iistalação", "more": "Mais", diff --git a/assets/translations/ru.json b/assets/translations/ru.json index ab25718..f166592 100644 --- a/assets/translations/ru.json +++ b/assets/translations/ru.json @@ -73,6 +73,8 @@ "unpinFromTop": "Открепить", "resetInstallStatusForSelectedAppsQuestion": "Сбросить статус установки для выбранных приложений?", "installStatusOfXWillBeResetExplanation": "Статус установки для выбранных приложений будет сброшен.\n\nЭто может помочь, если версия приложения, отображаемая в Obtainium, некорректная — из-за неудачных обновлений или других проблем", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Поделиться выбранными URL-адресами приложений", "resetInstallStatus": "Сбросить статус установки", "more": "Ещё", diff --git a/assets/translations/sv.json b/assets/translations/sv.json index 6886fdc..11e145b 100644 --- a/assets/translations/sv.json +++ b/assets/translations/sv.json @@ -73,6 +73,8 @@ "unpinFromTop": "Avnåla", "resetInstallStatusForSelectedAppsQuestion": "Återställ Installationsstatus för valda Appar?", "installStatusOfXWillBeResetExplanation": "Installationsstatusen för de markerade apparna kommer återställas.\n\n Detta kan hjälpa när appversionen visad i Obtanium är fel på grund av misslyckade uppdateringar eller andra orsaker.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Dela Valda Appars URL:er", "resetInstallStatus": "Återställ Installationstatus", "more": "Mer", diff --git a/assets/translations/tr.json b/assets/translations/tr.json index 35f8c16..c03ebf0 100644 --- a/assets/translations/tr.json +++ b/assets/translations/tr.json @@ -73,6 +73,8 @@ "unpinFromTop": "Üstten Kaldır", "resetInstallStatusForSelectedAppsQuestion": "Seçilen Uygulamaların Yükleme Durumunu Sıfırlamak İstiyor musunuz?", "installStatusOfXWillBeResetExplanation": "Seçilen Uygulamaların yükleme durumu sıfırlanacak.\n\nBu, Obtainium'da gösterilen uygulama sürümünün başarısız güncellemeler veya diğer sorunlar nedeniyle yanlış olması durumunda yardımcı olabilir.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Seçilen Uygulama URL'larını Paylaş", "resetInstallStatus": "Yükleme Durumunu Sıfırla", "more": "Daha Fazla", diff --git a/assets/translations/vi.json b/assets/translations/vi.json index 9d65204..054a56c 100644 --- a/assets/translations/vi.json +++ b/assets/translations/vi.json @@ -73,6 +73,8 @@ "unpinFromTop": "Bỏ ghim khỏi đầu trang", "resetInstallStatusForSelectedAppsQuestion": "Đặt lại trạng thái cài đặt cho ứng dụng đã chọn?", "installStatusOfXWillBeResetExplanation": "Trạng thái cài đặt của mọi Ứng dụng đã chọn sẽ được đặt lại.\n\nĐiều này có thể hữu ích khi phiên bản Ứng dụng hiển thị trong Obtainium không chính xác do cập nhật không thành công hoặc các sự cố khác.", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "Chia sẻ URL ứng dụng đã chọn", "resetInstallStatus": "Đặt lại trạng thái cài đặt", "more": "Nhiều hơn", diff --git a/assets/translations/zh.json b/assets/translations/zh.json index 094c032..6ed7f0b 100644 --- a/assets/translations/zh.json +++ b/assets/translations/zh.json @@ -73,6 +73,8 @@ "unpinFromTop": "取消置顶", "resetInstallStatusForSelectedAppsQuestion": "是否重置选中应用的安装状态?", "installStatusOfXWillBeResetExplanation": "选中应用的安装状态将会被重置。\n\n当更新安装失败或其他问题导致 Obtainium 中的应用版本显示错误时,可以尝试通过此方法解决。", + "customLinkMessage": "These links work on devices with Obtainium installed", + "shareAppConfigLinks": "Share app configuration as HTML link", "shareSelectedAppURLs": "分享选中应用的 URL", "resetInstallStatus": "重置安装状态", "more": "更多", diff --git a/lib/main.dart b/lib/main.dart index 13a4f63..26be9e2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -7,7 +7,6 @@ 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'; @@ -174,20 +173,7 @@ 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([ - App( - obtainiumId, - 'https://github.com/ImranR98/Obtainium', - 'ImranR98', - 'Obtainium', - currentReleaseTag, - currentReleaseTag, - [], - 0, - {'includePrereleases': true}, - null, - false) - ], onlyIfExists: false); + appsProvider.saveApps([obtainiumApp], onlyIfExists: false); } } if (!supportedLocales diff --git a/lib/pages/apps.dart b/lib/pages/apps.dart index 25f8b72..83b15d7 100644 --- a/lib/pages/apps.dart +++ b/lib/pages/apps.dart @@ -1,3 +1,5 @@ +import 'dart:convert'; + import 'package:easy_localization/easy_localization.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -871,20 +873,44 @@ class AppsPageState extends State { onPressed: () { String urls = ''; for (var a in selectedApps) { - urls += 'obtainium://add/${a.url}\n'; + urls += '${a.url}\n'; } urls = urls.substring(0, urls.length - 1); Share.share(urls, - subject: tr('selectedAppURLsFromObtainium')); + subject: + '${tr('obtainium')} - ${tr('appsString')}'); Navigator.of(context).pop(); }, tooltip: tr('shareSelectedAppURLs'), - icon: const Icon(Icons.share), + icon: const Icon(Icons.share_rounded), ), IconButton( - onPressed: resetSelectedAppsInstallStatuses, - tooltip: tr('resetInstallStatus'), - icon: const Icon(Icons.restore_page_outlined), + onPressed: selectedAppIds.isEmpty + ? null + : () { + String urls = + '

${tr('customLinkMessage')}:

\n\n
    \n'; + for (var a in selectedApps) { + urls += + '
  • ${a.name}
  • \n'; + } + urls += + '
\n\n

${tr('about')}

'; + Share.share(urls, + subject: + '${tr('obtainium')} - ${tr('appsString')}'); + }, + tooltip: tr('shareAppConfigLinks'), + icon: const Icon(Icons.ios_share), ), ]), ), diff --git a/lib/providers/apps_provider.dart b/lib/providers/apps_provider.dart index 071947d..43b1966 100644 --- a/lib/providers/apps_provider.dart +++ b/lib/providers/apps_provider.dart @@ -404,7 +404,7 @@ class AppsProvider with ChangeNotifier { .isNotEmpty; Future canInstallSilently(App app) async { - if (app.id == obtainiumId) { + if (app.id == obtainiumApp.id) { return false; } if (!settingsProvider.enableBackgroundUpdates) { @@ -428,7 +428,7 @@ class AppsProvider with ChangeNotifier { } catch (e) { // Probably not installed - ignore } - if (installerPackageName != obtainiumId) { + if (installerPackageName != obtainiumApp.id) { // If we did not install the app (or it isn't installed), silent install is not possible return false; } @@ -673,7 +673,7 @@ class AppsProvider with ChangeNotifier { // Move Obtainium to the end of the line (let all other apps update first) appsToInstall = - moveStrToEnd(appsToInstall, obtainiumId, strB: obtainiumTempId); + moveStrToEnd(appsToInstall, obtainiumApp.id, strB: obtainiumTempId); Future updateFn(String id, {bool skipInstalls = false}) async { try { @@ -1676,7 +1676,8 @@ 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 == obtainiumId); + var tempObtArr = + toInstall.where((element) => element.key == obtainiumApp.id); 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 c649fb7..fdfb585 100644 --- a/lib/providers/settings_provider.dart +++ b/lib/providers/settings_provider.dart @@ -15,7 +15,22 @@ import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_storage/shared_storage.dart' as saf; String obtainiumTempId = 'imranr98_obtainium_${GitHub().hosts[0]}'; -String obtainiumId = 'dev.imranr.obtainium'; + +App obtainiumApp = App( + 'dev.imranr.obtainium', + 'https://github.com/ImranR98/Obtainium', + 'ImranR98', + 'Obtainium', + currentReleaseTag, + currentReleaseTag, + [], + 0, + { + 'includePrereleases': true, + 'versionDetection': 'standardVersionDetection' + }, + null, + false); enum InstallMethodSettings { normal, shizuku, root } diff --git a/lib/providers/source_provider.dart b/lib/providers/source_provider.dart index 57ea4dd..c66b1d3 100644 --- a/lib/providers/source_provider.dart +++ b/lib/providers/source_provider.dart @@ -276,9 +276,10 @@ class App { json['installedVersion'] == null ? null : json['installedVersion'] as String, - json['latestVersion'] as String, - assumed2DlistToStringMapList(jsonDecode(json['apkUrls'])), - json['preferredApkIndex'] as int, + (json['latestVersion'] ?? tr('unknown')) as String, + assumed2DlistToStringMapList(jsonDecode( + (json['apkUrls'] ?? '[["placeholder", "placeholder"]]'))), + (json['preferredApkIndex'] ?? -1) as int, jsonDecode(json['additionalSettings']) as Map, json['lastUpdateCheck'] == null ? null