mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-17 20:28:10 +02:00
Added share option, saveApp -> saveApps
This commit is contained in:
@@ -109,7 +109,8 @@ class MyApp extends StatelessWidget {
|
|||||||
if (isFirstRun) {
|
if (isFirstRun) {
|
||||||
// If this is the first run, ask for notification permissions and add Obtainium to the Apps list
|
// If this is the first run, ask for notification permissions and add Obtainium to the Apps list
|
||||||
Permission.notification.request();
|
Permission.notification.request();
|
||||||
appsProvider.saveApp(App(
|
appsProvider.saveApps([
|
||||||
|
App(
|
||||||
'imranr98_obtainium_${GitHub().host}',
|
'imranr98_obtainium_${GitHub().host}',
|
||||||
'https://github.com/ImranR98/Obtainium',
|
'https://github.com/ImranR98/Obtainium',
|
||||||
'ImranR98',
|
'ImranR98',
|
||||||
@@ -118,7 +119,8 @@ class MyApp extends StatelessWidget {
|
|||||||
currentReleaseTag,
|
currentReleaseTag,
|
||||||
[],
|
[],
|
||||||
0,
|
0,
|
||||||
['true']));
|
['true'])
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -113,7 +113,8 @@ class _AddAppPageState extends State<AddAppPage> {
|
|||||||
settingsProvider
|
settingsProvider
|
||||||
.getInstallPermission()
|
.getInstallPermission()
|
||||||
.then((_) {
|
.then((_) {
|
||||||
appsProvider.saveApp(app).then((_) {
|
appsProvider
|
||||||
|
.saveApps([app]).then((_) {
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
|
@@ -126,8 +126,8 @@ class _AppPageState extends State<AppPage> {
|
|||||||
.installedVersion =
|
.installedVersion =
|
||||||
updatedApp
|
updatedApp
|
||||||
.latestVersion;
|
.latestVersion;
|
||||||
appsProvider.saveApp(
|
appsProvider.saveApps(
|
||||||
updatedApp);
|
[updatedApp]);
|
||||||
}
|
}
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.pop();
|
.pop();
|
||||||
@@ -167,8 +167,8 @@ class _AppPageState extends State<AppPage> {
|
|||||||
updatedApp
|
updatedApp
|
||||||
.installedVersion =
|
.installedVersion =
|
||||||
null;
|
null;
|
||||||
appsProvider.saveApp(
|
appsProvider.saveApps(
|
||||||
updatedApp);
|
[updatedApp]);
|
||||||
}
|
}
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
.pop();
|
.pop();
|
||||||
@@ -202,7 +202,7 @@ class _AppPageState extends State<AppPage> {
|
|||||||
if (app != null && values != null) {
|
if (app != null && values != null) {
|
||||||
var changedApp = app.app;
|
var changedApp = app.app;
|
||||||
changedApp.additionalData = values;
|
changedApp.additionalData = values;
|
||||||
appsProvider.saveApp(changedApp);
|
appsProvider.saveApps([changedApp]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@@ -7,6 +7,7 @@ import 'package:obtainium/pages/app.dart';
|
|||||||
import 'package:obtainium/providers/apps_provider.dart';
|
import 'package:obtainium/providers/apps_provider.dart';
|
||||||
import 'package:obtainium/providers/settings_provider.dart';
|
import 'package:obtainium/providers/settings_provider.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
import 'package:share_plus/share_plus.dart';
|
||||||
|
|
||||||
class AppsPage extends StatefulWidget {
|
class AppsPage extends StatefulWidget {
|
||||||
const AppsPage({super.key});
|
const AppsPage({super.key});
|
||||||
@@ -194,6 +195,7 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
showDialog<List<String>?>(
|
showDialog<List<String>?>(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -215,6 +217,7 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
icon: const Icon(Icons.delete_outline_outlined),
|
icon: const Icon(Icons.delete_outline_outlined),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
onPressed: appsProvider.areDownloadsRunning() ||
|
onPressed: appsProvider.areDownloadsRunning() ||
|
||||||
selectedIds
|
selectedIds
|
||||||
.where((id) =>
|
.where((id) =>
|
||||||
@@ -301,6 +304,19 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.file_download_outlined,
|
Icons.file_download_outlined,
|
||||||
)),
|
)),
|
||||||
|
IconButton(
|
||||||
|
visualDensity: VisualDensity.compact,
|
||||||
|
onPressed: () {
|
||||||
|
String urls = '';
|
||||||
|
for (var id in selectedIds) {
|
||||||
|
urls += '${appsProvider.apps[id]!.app.url}\n';
|
||||||
|
}
|
||||||
|
urls = urls.substring(0, urls.length - 1);
|
||||||
|
Share.share(urls,
|
||||||
|
subject: 'Selected App URLs from Obtainium');
|
||||||
|
},
|
||||||
|
icon: const Icon(Icons.share),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)),
|
)),
|
||||||
const VerticalDivider(),
|
const VerticalDivider(),
|
||||||
|
@@ -47,7 +47,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
if (appsProvider.apps.containsKey(app.id)) {
|
if (appsProvider.apps.containsKey(app.id)) {
|
||||||
errorsMap.addAll({app.id: 'App already added'});
|
errorsMap.addAll({app.id: 'App already added'});
|
||||||
} else {
|
} else {
|
||||||
await appsProvider.saveApp(app);
|
await appsProvider.saveApps([app]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<List<String>> errors =
|
List<List<String>> errors =
|
||||||
|
@@ -124,7 +124,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
await AppInstaller.installApk(file.file.path, actionRequired: false);
|
await AppInstaller.installApk(file.file.path, actionRequired: false);
|
||||||
apps[file.appId]!.app.installedVersion =
|
apps[file.appId]!.app.installedVersion =
|
||||||
apps[file.appId]!.app.latestVersion;
|
apps[file.appId]!.app.latestVersion;
|
||||||
await saveApp(apps[file.appId]!.app);
|
await saveApps([apps[file.appId]!.app]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Given a list of AppIds, uses stored info about the apps to download APKs and install them
|
// Given a list of AppIds, uses stored info about the apps to download APKs and install them
|
||||||
@@ -171,7 +171,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
int urlInd = apps[id]!.app.apkUrls.indexOf(apkUrl);
|
int urlInd = apps[id]!.app.apkUrls.indexOf(apkUrl);
|
||||||
if (urlInd != apps[id]!.app.preferredApkIndex) {
|
if (urlInd != apps[id]!.app.preferredApkIndex) {
|
||||||
apps[id]!.app.preferredApkIndex = urlInd;
|
apps[id]!.app.preferredApkIndex = urlInd;
|
||||||
await saveApp(apps[id]!.app);
|
await saveApps([apps[id]!.app]);
|
||||||
}
|
}
|
||||||
if (context != null ||
|
if (context != null ||
|
||||||
(await canInstallSilently(apps[id]!.app) &&
|
(await canInstallSilently(apps[id]!.app) &&
|
||||||
@@ -247,11 +247,14 @@ class AppsProvider with ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveApp(App app) async {
|
Future<void> saveApps(List<App> apps) async {
|
||||||
|
for (var app in apps) {
|
||||||
File('${(await getAppsDir()).path}/${app.id}.json')
|
File('${(await getAppsDir()).path}/${app.id}.json')
|
||||||
.writeAsStringSync(jsonEncode(app.toJson()));
|
.writeAsStringSync(jsonEncode(app.toJson()));
|
||||||
apps.update(app.id, (value) => AppInMemory(app, value.downloadProgress),
|
this.apps.update(
|
||||||
|
app.id, (value) => AppInMemory(app, value.downloadProgress),
|
||||||
ifAbsent: () => AppInMemory(app, null));
|
ifAbsent: () => AppInMemory(app, null));
|
||||||
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,7 +292,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
if (currentApp.preferredApkIndex < newApp.apkUrls.length) {
|
if (currentApp.preferredApkIndex < newApp.apkUrls.length) {
|
||||||
newApp.preferredApkIndex = currentApp.preferredApkIndex;
|
newApp.preferredApkIndex = currentApp.preferredApkIndex;
|
||||||
}
|
}
|
||||||
await saveApp(newApp);
|
await saveApps([newApp]);
|
||||||
return newApp;
|
return newApp;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@@ -353,7 +356,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
for (App a in importedApps) {
|
for (App a in importedApps) {
|
||||||
a.installedVersion =
|
a.installedVersion =
|
||||||
apps.containsKey(a.id) ? apps[a]?.app.installedVersion : null;
|
apps.containsKey(a.id) ? apps[a]?.app.installedVersion : null;
|
||||||
await saveApp(a);
|
await saveApps([a]);
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
return importedApps.length;
|
return importedApps.length;
|
||||||
|
49
pubspec.lock
49
pubspec.lock
@@ -324,6 +324,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.8.0"
|
version: "1.8.0"
|
||||||
|
mime:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mime
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.2"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@@ -457,6 +464,48 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "6.0.3"
|
version: "6.0.3"
|
||||||
|
share_plus:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: share_plus
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.4.0"
|
||||||
|
share_plus_linux:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_linux
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
|
share_plus_macos:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_macos
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.1"
|
||||||
|
share_plus_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.3"
|
||||||
|
share_plus_web:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_web
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.1"
|
||||||
|
share_plus_windows:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: share_plus_windows
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.1"
|
||||||
shared_preferences:
|
shared_preferences:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@@ -53,6 +53,7 @@ dependencies:
|
|||||||
file_picker: ^5.1.0
|
file_picker: ^5.1.0
|
||||||
animations: ^2.0.4
|
animations: ^2.0.4
|
||||||
flutter_install_app: ^1.3.0
|
flutter_install_app: ^1.3.0
|
||||||
|
share_plus: ^4.4.0
|
||||||
|
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
Reference in New Issue
Block a user