mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 21:30:16 +02:00
Allow entire app config to be shared as link (see https://github.com/ImranR98/apps.obtainium.imranr.dev/issues/5)
This commit is contained in:
@@ -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<Obtainium> {
|
||||
// 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
|
||||
|
@@ -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<AppsPage> {
|
||||
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 =
|
||||
'<p>${tr('customLinkMessage')}:</p>\n\n<ul>\n';
|
||||
for (var a in selectedApps) {
|
||||
urls +=
|
||||
' <li><a href="obtainium://app/${Uri.encodeComponent(jsonEncode({
|
||||
'id': a.id,
|
||||
'url': a.url,
|
||||
'author': a.author,
|
||||
'name': a.name,
|
||||
'preferredApkIndex':
|
||||
a.preferredApkIndex,
|
||||
'additionalSettings':
|
||||
jsonEncode(a.additionalSettings)
|
||||
}))}">${a.name}</a></li>\n';
|
||||
}
|
||||
urls +=
|
||||
'</ul>\n\n<p><a href="${obtainiumApp.url}">${tr('about')}</a></p>';
|
||||
Share.share(urls,
|
||||
subject:
|
||||
'${tr('obtainium')} - ${tr('appsString')}');
|
||||
},
|
||||
tooltip: tr('shareAppConfigLinks'),
|
||||
icon: const Icon(Icons.ios_share),
|
||||
),
|
||||
]),
|
||||
),
|
||||
|
@@ -404,7 +404,7 @@ class AppsProvider with ChangeNotifier {
|
||||
.isNotEmpty;
|
||||
|
||||
Future<bool> 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<void> updateFn(String id, {bool skipInstalls = false}) async {
|
||||
try {
|
||||
@@ -1676,7 +1676,8 @@ Future<void> bgUpdateCheck(String taskId, Map<String, dynamic>? 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;
|
||||
|
@@ -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 }
|
||||
|
||||
|
@@ -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<String, dynamic>,
|
||||
json['lastUpdateCheck'] == null
|
||||
? null
|
||||
|
Reference in New Issue
Block a user