mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-30 12:30:16 +02:00
Progress
This commit is contained in:
@@ -27,10 +27,8 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
String userInput = '';
|
||||
String searchQuery = '';
|
||||
AppSource? pickedSource;
|
||||
Map<String, String> sourceSpecificAdditionalData = {};
|
||||
bool sourceSpecificDataIsValid = true;
|
||||
Map<String, String> otherAdditionalData = {};
|
||||
bool otherAdditionalDataIsValid = true;
|
||||
Map<String, String> additionalSettings = {};
|
||||
bool additionalSettingsValid = true;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -43,12 +41,12 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
var source = valid ? sourceProvider.getSource(userInput) : null;
|
||||
if (pickedSource.runtimeType != source.runtimeType) {
|
||||
pickedSource = source;
|
||||
sourceSpecificAdditionalData = source != null
|
||||
additionalSettings = source != null
|
||||
? getDefaultValuesFromFormItems(
|
||||
source.additionalSourceAppSpecificFormItems)
|
||||
source.combinedAppSpecificSettingFormItems)
|
||||
: {};
|
||||
sourceSpecificDataIsValid = source != null
|
||||
? !sourceProvider.ifSourceAppsRequireAdditionalData(source)
|
||||
additionalSettingsValid = source != null
|
||||
? !sourceProvider.ifRequiredAppSpecificSettingsExist(source)
|
||||
: true;
|
||||
}
|
||||
}
|
||||
@@ -68,10 +66,9 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
});
|
||||
var settingsProvider = context.read<SettingsProvider>();
|
||||
() async {
|
||||
var userPickedTrackOnly =
|
||||
otherAdditionalData['trackOnlyFormItemKey'] == 'true';
|
||||
var userPickedTrackOnly = additionalSettings['trackOnly'] == 'true';
|
||||
var userPickedNoVersionDetection =
|
||||
otherAdditionalData['noVersionDetectionKey'] == 'true';
|
||||
additionalSettings['noVersionDetection'] == 'true';
|
||||
var cont = true;
|
||||
if ((userPickedTrackOnly || pickedSource!.enforceTrackOnly) &&
|
||||
await showDialog(
|
||||
@@ -108,14 +105,15 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
HapticFeedback.selectionClick();
|
||||
var trackOnly = pickedSource!.enforceTrackOnly || userPickedTrackOnly;
|
||||
App app = await sourceProvider.getApp(
|
||||
pickedSource!, userInput, sourceSpecificAdditionalData,
|
||||
pickedSource!, userInput, additionalSettings,
|
||||
trackOnlyOverride: trackOnly,
|
||||
noVersionDetectionOverride: userPickedNoVersionDetection);
|
||||
if (!trackOnly) {
|
||||
await settingsProvider.getInstallPermission();
|
||||
}
|
||||
// Only download the APK here if you need to for the package ID
|
||||
if (sourceProvider.isTempId(app.id) && !app.trackOnly) {
|
||||
if (sourceProvider.isTempId(app.id) &&
|
||||
app.additionalSettings['trackOnly'] != 'true') {
|
||||
// ignore: use_build_context_synchronously
|
||||
var apkUrl = await appsProvider.confirmApkUrl(app, context);
|
||||
if (apkUrl == null) {
|
||||
@@ -130,7 +128,7 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
if (appsProvider.apps.containsKey(app.id)) {
|
||||
throw ObtainiumError(tr('appAlreadyAdded'));
|
||||
}
|
||||
if (app.trackOnly) {
|
||||
if (app.additionalSettings['trackOnly'] == 'true') {
|
||||
app.installedVersion = app.latestVersion;
|
||||
}
|
||||
await appsProvider.saveApps([app]);
|
||||
@@ -206,13 +204,9 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
onPressed: gettingAppInfo ||
|
||||
pickedSource == null ||
|
||||
(pickedSource!
|
||||
.additionalSourceAppSpecificFormItems
|
||||
.combinedAppSpecificSettingFormItems
|
||||
.isNotEmpty &&
|
||||
!sourceSpecificDataIsValid) ||
|
||||
(pickedSource!
|
||||
.additionalAppSpecificSourceAgnosticFormItems
|
||||
.isNotEmpty &&
|
||||
!otherAdditionalDataIsValid)
|
||||
!additionalSettingsValid)
|
||||
? null
|
||||
: addApp,
|
||||
child: Text(tr('add')))
|
||||
@@ -305,15 +299,8 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
],
|
||||
),
|
||||
if (pickedSource != null &&
|
||||
(pickedSource!.additionalSourceAppSpecificFormItems
|
||||
.isNotEmpty ||
|
||||
pickedSource!
|
||||
.additionalAppSpecificSourceAgnosticFormItems
|
||||
.where((e) => pickedSource!.enforceTrackOnly
|
||||
? e.key != 'trackOnlyFormItemKey'
|
||||
: true)
|
||||
.map((e) => [e])
|
||||
.isNotEmpty))
|
||||
(pickedSource!
|
||||
.combinedAppSpecificSettingFormItems.isNotEmpty))
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
@@ -329,39 +316,14 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
if (pickedSource!
|
||||
.additionalSourceAppSpecificFormItems
|
||||
.isNotEmpty)
|
||||
GeneratedForm(
|
||||
items: pickedSource!
|
||||
.additionalSourceAppSpecificFormItems,
|
||||
onValueChanges: (values, valid, isBuilding) {
|
||||
if (!isBuilding) {
|
||||
setState(() {
|
||||
sourceSpecificAdditionalData = values;
|
||||
sourceSpecificDataIsValid = valid;
|
||||
});
|
||||
}
|
||||
}),
|
||||
if (pickedSource!
|
||||
.additionalAppSpecificSourceAgnosticFormItems
|
||||
.isNotEmpty)
|
||||
const SizedBox(
|
||||
height: 8,
|
||||
),
|
||||
GeneratedForm(
|
||||
items: pickedSource!
|
||||
.additionalAppSpecificSourceAgnosticFormItems
|
||||
.where((e) => pickedSource!.enforceTrackOnly
|
||||
? e.key != 'trackOnlyFormItemKey'
|
||||
: true)
|
||||
.map((e) => [e])
|
||||
.toList(),
|
||||
.combinedAppSpecificSettingFormItems,
|
||||
onValueChanges: (values, valid, isBuilding) {
|
||||
if (!isBuilding) {
|
||||
setState(() {
|
||||
otherAdditionalData = values;
|
||||
otherAdditionalDataIsValid = valid;
|
||||
additionalSettings = values;
|
||||
additionalSettingsValid = valid;
|
||||
});
|
||||
}
|
||||
}),
|
||||
|
@@ -40,6 +40,7 @@ class _AppPageState extends State<AppPage> {
|
||||
prevApp = app;
|
||||
getUpdate(app.app.id);
|
||||
}
|
||||
var trackOnly = app?.app.additionalSettings['trackOnly'] == 'true';
|
||||
return Scaffold(
|
||||
appBar: settingsProvider.showAppWebpage ? AppBar() : null,
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
@@ -111,7 +112,7 @@ class _AppPageState extends State<AppPage> {
|
||||
Text(
|
||||
'${tr('installedVersionX', args: [
|
||||
app?.app.installedVersion ?? tr('none')
|
||||
])}${app?.app.trackOnly == true ? ' ${tr('estimateInBrackets')}\n\n${tr('xIsTrackOnly', args: [
|
||||
])}${trackOnly ? ' ${tr('estimateInBrackets')}\n\n${tr('xIsTrackOnly', args: [
|
||||
tr('app')
|
||||
])}' : ''}',
|
||||
textAlign: TextAlign.center,
|
||||
@@ -151,7 +152,7 @@ class _AppPageState extends State<AppPage> {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
if (app?.app.installedVersion != null &&
|
||||
app?.app.trackOnly == false &&
|
||||
!trackOnly &&
|
||||
app?.app.installedVersion != app?.app.latestVersion)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null
|
||||
@@ -202,8 +203,8 @@ class _AppPageState extends State<AppPage> {
|
||||
tooltip: 'Mark as Updated',
|
||||
icon: const Icon(Icons.done)),
|
||||
if (source != null &&
|
||||
source.additionalSourceAppSpecificFormItems
|
||||
.isNotEmpty)
|
||||
source
|
||||
.combinedAppSpecificSettingFormItems.isNotEmpty)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null
|
||||
? null
|
||||
@@ -211,14 +212,36 @@ class _AppPageState extends State<AppPage> {
|
||||
showDialog<Map<String, String>>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
var items = source
|
||||
.combinedAppSpecificSettingFormItems
|
||||
.map((row) {
|
||||
row.map((e) {
|
||||
if (app?.app.additionalSettings[
|
||||
e.key] !=
|
||||
null) {
|
||||
e.defaultValue = app?.app
|
||||
.additionalSettings[
|
||||
e.key];
|
||||
}
|
||||
return e;
|
||||
}).toList();
|
||||
return row;
|
||||
}).toList();
|
||||
return GeneratedFormModal(
|
||||
title: 'Additional Options',
|
||||
items: source
|
||||
.additionalSourceAppSpecificFormItems);
|
||||
items: items);
|
||||
}).then((values) {
|
||||
if (app != null && values != null) {
|
||||
var changedApp = app.app;
|
||||
changedApp.additionalData = values;
|
||||
changedApp.additionalSettings =
|
||||
values;
|
||||
if (source.enforceTrackOnly) {
|
||||
changedApp.additionalSettings[
|
||||
'trackOnly'] = 'true';
|
||||
showError(
|
||||
tr('appsFromSourceAreTrackOnly'),
|
||||
context);
|
||||
}
|
||||
appsProvider.saveApps(
|
||||
[changedApp]).then((value) {
|
||||
getUpdate(changedApp.id);
|
||||
@@ -238,7 +261,9 @@ class _AppPageState extends State<AppPage> {
|
||||
? () {
|
||||
HapticFeedback.heavyImpact();
|
||||
() async {
|
||||
if (app?.app.trackOnly != true) {
|
||||
if (app?.app.additionalSettings[
|
||||
'trackOnly'] !=
|
||||
'true') {
|
||||
await settingsProvider
|
||||
.getInstallPermission();
|
||||
}
|
||||
@@ -260,10 +285,10 @@ class _AppPageState extends State<AppPage> {
|
||||
}
|
||||
: null,
|
||||
child: Text(app?.app.installedVersion == null
|
||||
? app?.app.trackOnly == false
|
||||
? !trackOnly
|
||||
? 'Install'
|
||||
: 'Mark Installed'
|
||||
: app?.app.trackOnly == false
|
||||
: !trackOnly
|
||||
? 'Update'
|
||||
: 'Mark Updated'))),
|
||||
const SizedBox(width: 16.0),
|
||||
|
@@ -139,14 +139,16 @@ class AppsPageState extends State<AppsPage> {
|
||||
|
||||
List<String> trackOnlyUpdateIdsAllOrSelected = [];
|
||||
existingUpdateIdsAllOrSelected = existingUpdateIdsAllOrSelected.where((id) {
|
||||
if (appsProvider.apps[id]!.app.trackOnly) {
|
||||
if (appsProvider.apps[id]!.app.additionalSettings['trackOnly'] ==
|
||||
'true') {
|
||||
trackOnlyUpdateIdsAllOrSelected.add(id);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).toList();
|
||||
newInstallIdsAllOrSelected = newInstallIdsAllOrSelected.where((id) {
|
||||
if (appsProvider.apps[id]!.app.trackOnly) {
|
||||
if (appsProvider.apps[id]!.app.additionalSettings['trackOnly'] ==
|
||||
'true') {
|
||||
trackOnlyUpdateIdsAllOrSelected.add(id);
|
||||
return false;
|
||||
}
|
||||
@@ -271,7 +273,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
SizedBox(
|
||||
width: 100,
|
||||
child: Text(
|
||||
'${sortedApps[index].app.installedVersion ?? tr('notInstalled')}${sortedApps[index].app.trackOnly == true ? ' ${tr('estimateInBrackets')}' : ''}',
|
||||
'${sortedApps[index].app.installedVersion ?? tr('notInstalled')}${sortedApps[index].app.additionalSettings['trackOnly'] == 'true' ? ' ${tr('estimateInBrackets')}' : ''}',
|
||||
overflow: TextOverflow.fade,
|
||||
textAlign: TextAlign.end,
|
||||
)),
|
||||
@@ -289,7 +291,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
child: appsProvider.areDownloadsRunning()
|
||||
? Text(tr('pleaseWait'))
|
||||
: Text(
|
||||
'${tr('updateAvailable')}${sortedApps[index].app.trackOnly ? ' ${tr('estimateInBracketsShort')}' : ''}',
|
||||
'${tr('updateAvailable')}${sortedApps[index].app.additionalSettings['trackOnly'] == 'true' ? ' ${tr('estimateInBracketsShort')}' : ''}',
|
||||
style: TextStyle(
|
||||
fontStyle: FontStyle.italic,
|
||||
decoration: changesUrl == null
|
||||
@@ -343,7 +345,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
: IconButton(
|
||||
visualDensity: VisualDensity.compact,
|
||||
onPressed: () {
|
||||
showDialog<List<String>?>(
|
||||
showDialog<Map<String, String>?>(
|
||||
context: context,
|
||||
builder: (BuildContext ctx) {
|
||||
return GeneratedFormModal(
|
||||
|
Reference in New Issue
Block a user