mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-13 05:16:43 +02:00
Compare commits
2 Commits
v0.2.0-bet
...
v0.2.1-bet
Author | SHA1 | Date | |
---|---|---|---|
9e21f2d6e6 | |||
6f11f850e0 |
@ -12,7 +12,7 @@ import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
const String currentReleaseTag =
|
||||
'v0.2.0-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
'v0.2.1-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
void bgTaskCallback() {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@ -7,6 +8,7 @@ import 'package:obtainium/providers/apps_provider.dart';
|
||||
import 'package:obtainium/providers/settings_provider.dart';
|
||||
import 'package:obtainium/providers/source_provider.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
|
||||
class ImportExportPage extends StatefulWidget {
|
||||
const ImportExportPage({super.key});
|
||||
@ -16,7 +18,7 @@ class ImportExportPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ImportExportPageState extends State<ImportExportPage> {
|
||||
bool gettingAppInfo = false;
|
||||
bool importInProgress = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -47,7 +49,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: appsProvider.apps.isEmpty || gettingAppInfo
|
||||
onPressed: appsProvider.apps.isEmpty || importInProgress
|
||||
? null
|
||||
: () {
|
||||
HapticFeedback.lightImpact();
|
||||
@ -62,42 +64,44 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
height: 8,
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: gettingAppInfo
|
||||
onPressed: importInProgress
|
||||
? null
|
||||
: () {
|
||||
HapticFeedback.lightImpact();
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
title: 'Obtainium Import',
|
||||
items: [
|
||||
GeneratedFormItem(
|
||||
'Obtainium Export JSON Data', true, 7)
|
||||
]);
|
||||
}).then((values) {
|
||||
if (values != null) {
|
||||
FilePicker.platform.pickFiles().then((result) {
|
||||
setState(() {
|
||||
importInProgress = true;
|
||||
});
|
||||
if (result != null) {
|
||||
String data = File(result.files.single.path!)
|
||||
.readAsStringSync();
|
||||
try {
|
||||
jsonDecode(values[0]);
|
||||
jsonDecode(data);
|
||||
} catch (e) {
|
||||
throw 'Invalid input';
|
||||
}
|
||||
appsProvider.importApps(values[0]).then((value) {
|
||||
appsProvider.importApps(data).then((value) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
'$value App${value == 1 ? '' : 's'} Imported')),
|
||||
);
|
||||
});
|
||||
} else {
|
||||
// User canceled the picker
|
||||
}
|
||||
}).catchError((e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString())),
|
||||
);
|
||||
}).whenComplete(() {
|
||||
setState(() {
|
||||
importInProgress = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
child: const Text('Obtainium Import')),
|
||||
if (gettingAppInfo)
|
||||
if (importInProgress)
|
||||
Column(
|
||||
children: const [
|
||||
SizedBox(
|
||||
@ -114,7 +118,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
height: 32,
|
||||
),
|
||||
TextButton(
|
||||
onPressed: gettingAppInfo
|
||||
onPressed: importInProgress
|
||||
? null
|
||||
: () {
|
||||
showDialog(
|
||||
@ -130,7 +134,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
if (values != null) {
|
||||
var urls = (values[0] as String).split('\n');
|
||||
setState(() {
|
||||
gettingAppInfo = true;
|
||||
importInProgress = true;
|
||||
});
|
||||
addApps(urls).then((errors) {
|
||||
if (errors.isEmpty) {
|
||||
@ -154,7 +158,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
);
|
||||
}).whenComplete(() {
|
||||
setState(() {
|
||||
gettingAppInfo = false;
|
||||
importInProgress = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -167,7 +171,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
children: [
|
||||
const SizedBox(height: 8),
|
||||
TextButton(
|
||||
onPressed: gettingAppInfo
|
||||
onPressed: importInProgress
|
||||
? null
|
||||
: () {
|
||||
showDialog(
|
||||
@ -184,7 +188,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
if (values != null) {
|
||||
source.getUrls(values).then((urls) {
|
||||
setState(() {
|
||||
gettingAppInfo = true;
|
||||
importInProgress = true;
|
||||
});
|
||||
addApps(urls).then((errors) {
|
||||
if (errors.isEmpty) {
|
||||
@ -207,7 +211,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
||||
}
|
||||
}).whenComplete(() {
|
||||
setState(() {
|
||||
gettingAppInfo = false;
|
||||
importInProgress = false;
|
||||
});
|
||||
});
|
||||
}).catchError((e) {
|
||||
|
14
pubspec.lock
14
pubspec.lock
@ -162,6 +162,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "6.1.4"
|
||||
file_picker:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: file_picker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.1.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -209,6 +216,13 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "5.0.0"
|
||||
flutter_plugin_android_lifecycle:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: flutter_plugin_android_lifecycle
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.7"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
|
@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
# In Windows, build-name is used as the major, minor, and patch parts
|
||||
# of the product and file versions while build-number is used as the build suffix.
|
||||
version: 0.2.0+11 # When changing this, update the tag in main() accordingly
|
||||
version: 0.2.1+12 # When changing this, update the tag in main() accordingly
|
||||
|
||||
environment:
|
||||
sdk: '>=2.19.0-79.0.dev <3.0.0'
|
||||
@ -51,6 +51,7 @@ dependencies:
|
||||
permission_handler: ^10.0.0
|
||||
fluttertoast: ^8.0.9
|
||||
device_info_plus: ^4.1.2
|
||||
file_picker: ^5.1.0
|
||||
|
||||
|
||||
dev_dependencies:
|
||||
|
Reference in New Issue
Block a user