mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-01 05:10:15 +02:00
Bugfix #405 + general categories bugfixes
This commit is contained in:
@@ -21,7 +21,7 @@ import 'package:easy_localization/src/easy_localization_controller.dart';
|
|||||||
// ignore: implementation_imports
|
// ignore: implementation_imports
|
||||||
import 'package:easy_localization/src/localization.dart';
|
import 'package:easy_localization/src/localization.dart';
|
||||||
|
|
||||||
const String currentVersion = '0.11.18';
|
const String currentVersion = '0.11.19';
|
||||||
const String currentReleaseTag =
|
const String currentReleaseTag =
|
||||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||||
|
|
||||||
|
@@ -448,7 +448,8 @@ class AppsPageState extends State<AppsPage> {
|
|||||||
.app
|
.app
|
||||||
.categories
|
.categories
|
||||||
.map((e) =>
|
.map((e) =>
|
||||||
Color(settingsProvider.categories[e]!).withAlpha(255))
|
Color(settingsProvider.categories[e] ?? transparent)
|
||||||
|
.withAlpha(255))
|
||||||
.toList(),
|
.toList(),
|
||||||
Color(transparent)
|
Color(transparent)
|
||||||
])),
|
])),
|
||||||
|
@@ -133,7 +133,7 @@ class _ImportExportPageState extends State<ImportExportPage> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
settingsProvider.categories = cats;
|
appsProvider.addMissingCategories(settingsProvider);
|
||||||
showError(tr('importedX', args: [plural('apps', value)]), context);
|
showError(tr('importedX', args: [plural('apps', value)]), context);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@@ -6,6 +6,7 @@ import 'package:obtainium/components/custom_app_bar.dart';
|
|||||||
import 'package:obtainium/components/generated_form.dart';
|
import 'package:obtainium/components/generated_form.dart';
|
||||||
import 'package:obtainium/custom_errors.dart';
|
import 'package:obtainium/custom_errors.dart';
|
||||||
import 'package:obtainium/main.dart';
|
import 'package:obtainium/main.dart';
|
||||||
|
import 'package:obtainium/providers/apps_provider.dart';
|
||||||
import 'package:obtainium/providers/logs_provider.dart';
|
import 'package:obtainium/providers/logs_provider.dart';
|
||||||
import 'package:obtainium/providers/settings_provider.dart';
|
import 'package:obtainium/providers/settings_provider.dart';
|
||||||
import 'package:obtainium/providers/source_provider.dart';
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
@@ -444,6 +445,7 @@ class _CategoryEditorSelectorState extends State<CategoryEditorSelector> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var settingsProvider = context.watch<SettingsProvider>();
|
var settingsProvider = context.watch<SettingsProvider>();
|
||||||
|
var appsProvider = context.watch<AppsProvider>();
|
||||||
storedValues = settingsProvider.categories.map((key, value) => MapEntry(
|
storedValues = settingsProvider.categories.map((key, value) => MapEntry(
|
||||||
key,
|
key,
|
||||||
MapEntry(value,
|
MapEntry(value,
|
||||||
@@ -467,8 +469,9 @@ class _CategoryEditorSelectorState extends State<CategoryEditorSelector> {
|
|||||||
if (!isBuilding) {
|
if (!isBuilding) {
|
||||||
storedValues =
|
storedValues =
|
||||||
values['categories'] as Map<String, MapEntry<int, bool>>;
|
values['categories'] as Map<String, MapEntry<int, bool>>;
|
||||||
settingsProvider.categories =
|
settingsProvider.setCategories(
|
||||||
storedValues.map((key, value) => MapEntry(key, value.key));
|
storedValues.map((key, value) => MapEntry(key, value.key)),
|
||||||
|
appsProvider: appsProvider);
|
||||||
if (widget.onSelected != null) {
|
if (widget.onSelected != null) {
|
||||||
widget.onSelected!(storedValues.keys
|
widget.onSelected!(storedValues.keys
|
||||||
.where((k) => storedValues[k]!.value)
|
.where((k) => storedValues[k]!.value)
|
||||||
|
@@ -757,6 +757,18 @@ class AppsProvider with ChangeNotifier {
|
|||||||
await intent.launch();
|
await intent.launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addMissingCategories(SettingsProvider settingsProvider) {
|
||||||
|
var cats = settingsProvider.categories;
|
||||||
|
apps.forEach((key, value) {
|
||||||
|
for (var c in value.app.categories) {
|
||||||
|
if (!cats.containsKey(c)) {
|
||||||
|
cats[c] = generateRandomLightColor().value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
settingsProvider.setCategories(cats, appsProvider: this);
|
||||||
|
}
|
||||||
|
|
||||||
Future<App?> checkUpdate(String appId) async {
|
Future<App?> checkUpdate(String appId) async {
|
||||||
App? currentApp = apps[appId]!.app;
|
App? currentApp = apps[appId]!.app;
|
||||||
SourceProvider sourceProvider = SourceProvider();
|
SourceProvider sourceProvider = SourceProvider();
|
||||||
|
@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:fluttertoast/fluttertoast.dart';
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:obtainium/app_sources/github.dart';
|
import 'package:obtainium/app_sources/github.dart';
|
||||||
import 'package:obtainium/main.dart';
|
import 'package:obtainium/main.dart';
|
||||||
|
import 'package:obtainium/providers/apps_provider.dart';
|
||||||
|
import 'package:obtainium/providers/source_provider.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
import 'package:permission_handler/permission_handler.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
@@ -160,7 +162,22 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
Map<String, int> get categories =>
|
Map<String, int> get categories =>
|
||||||
Map<String, int>.from(jsonDecode(prefs?.getString('categories') ?? '{}'));
|
Map<String, int>.from(jsonDecode(prefs?.getString('categories') ?? '{}'));
|
||||||
|
|
||||||
set categories(Map<String, int> cats) {
|
void setCategories(Map<String, int> cats, {AppsProvider? appsProvider}) {
|
||||||
|
if (appsProvider != null) {
|
||||||
|
List<App> changedApps = appsProvider.apps.values
|
||||||
|
.map((a) {
|
||||||
|
var n1 = a.app.categories.length;
|
||||||
|
a.app.categories.removeWhere((c) => cats.keys.contains(c));
|
||||||
|
return n1 > a.app.categories.length ? a.app : null;
|
||||||
|
})
|
||||||
|
.where((element) => element != null)
|
||||||
|
.map((e) => e as App)
|
||||||
|
.toList();
|
||||||
|
if (changedApps.isNotEmpty) {
|
||||||
|
appsProvider.saveApps(changedApps,
|
||||||
|
attemptToCorrectInstallStatus: false);
|
||||||
|
}
|
||||||
|
}
|
||||||
prefs?.setString('categories', jsonEncode(cats));
|
prefs?.setString('categories', jsonEncode(cats));
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
@@ -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
|
# 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
|
# 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.
|
# of the product and file versions while build-number is used as the build suffix.
|
||||||
version: 0.11.18+140 # When changing this, update the tag in main() accordingly
|
version: 0.11.19+141 # When changing this, update the tag in main() accordingly
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=2.18.2 <3.0.0'
|
sdk: '>=2.18.2 <3.0.0'
|
||||||
|
Reference in New Issue
Block a user