mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-13 05:16:43 +02:00
Compare commits
3 Commits
v0.8.4-bet
...
v0.8.6-bet
Author | SHA1 | Date | |
---|---|---|---|
a1518480db | |||
fd3ee02e52 | |||
609366675d |
@ -16,17 +16,49 @@ import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:easy_localization/src/easy_localization_controller.dart';
|
||||
// ignore: implementation_imports
|
||||
import 'package:easy_localization/src/localization.dart';
|
||||
|
||||
const String currentVersion = '0.8.4';
|
||||
const String currentVersion = '0.8.6';
|
||||
const String currentReleaseTag =
|
||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
const int bgUpdateCheckAlarmId = 666;
|
||||
|
||||
const supportedLocales = [Locale('en')];
|
||||
const fallbackLocale = Locale('en');
|
||||
const localeDir = 'assets/translations';
|
||||
|
||||
Future<void> loadTranslations() async {
|
||||
// See easy_localization/issues/210
|
||||
await EasyLocalizationController.initEasyLocation();
|
||||
final controller = EasyLocalizationController(
|
||||
saveLocale: true,
|
||||
fallbackLocale: fallbackLocale,
|
||||
supportedLocales: supportedLocales,
|
||||
assetLoader: const RootBundleAssetLoader(),
|
||||
useOnlyLangCode: false,
|
||||
useFallbackTranslations: true,
|
||||
path: localeDir,
|
||||
onLoadError: (FlutterError e) {
|
||||
throw e;
|
||||
},
|
||||
);
|
||||
await controller.loadTranslations();
|
||||
Localization.load(controller.locale,
|
||||
translations: controller.translations,
|
||||
fallbackTranslations: controller.fallbackTranslations);
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await EasyLocalization.ensureInitialized();
|
||||
|
||||
await loadTranslations();
|
||||
|
||||
LogsProvider logs = LogsProvider();
|
||||
logs.add(tr('startedBgUpdateTask'));
|
||||
int? ignoreAfterMicroseconds = params?['ignoreAfterMicroseconds'];
|
||||
@ -116,9 +148,9 @@ void main() async {
|
||||
Provider(create: (context) => LogsProvider())
|
||||
],
|
||||
child: EasyLocalization(
|
||||
supportedLocales: const [Locale('en')],
|
||||
path: 'assets/translations',
|
||||
fallbackLocale: const Locale('en'),
|
||||
supportedLocales: supportedLocales,
|
||||
path: localeDir,
|
||||
fallbackLocale: fallbackLocale,
|
||||
child: const Obtainium()),
|
||||
));
|
||||
}
|
||||
@ -162,7 +194,6 @@ class _ObtainiumState extends State<Obtainium> {
|
||||
['true'],
|
||||
null,
|
||||
false,
|
||||
false,
|
||||
false)
|
||||
]);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ class _AppPageState extends State<AppPage> {
|
||||
height: 32,
|
||||
),
|
||||
Text(
|
||||
'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}${app?.app.enhancedVersionDetection == true ? '\n\nThis App has enhanced version detection.' : ''}',
|
||||
'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}',
|
||||
textAlign: TextAlign.center,
|
||||
style: const TextStyle(
|
||||
fontStyle: FontStyle.italic, fontSize: 12),
|
||||
@ -141,9 +141,7 @@ class _AppPageState extends State<AppPage> {
|
||||
children: [
|
||||
if (app?.app.installedVersion != null &&
|
||||
app?.app.trackOnly == false &&
|
||||
app?.app.installedVersion !=
|
||||
app?.app.latestVersion &&
|
||||
app?.app.enhancedVersionDetection != true)
|
||||
app?.app.installedVersion != app?.app.latestVersion)
|
||||
IconButton(
|
||||
onPressed: app?.downloadProgress != null
|
||||
? null
|
||||
|
@ -526,8 +526,8 @@ class AppsPageState extends State<AppsPage> {
|
||||
.selectionClick();
|
||||
appsProvider
|
||||
.saveApps(selectedApps.map((a) {
|
||||
if (a.installedVersion != null &&
|
||||
!a.enhancedVersionDetection) {
|
||||
if (a.installedVersion !=
|
||||
null) {
|
||||
a.installedVersion = a.latestVersion;
|
||||
}
|
||||
return a;
|
||||
|
@ -9,6 +9,7 @@ import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:easy_localization/easy_localization.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
import 'package:install_plugin_v2/install_plugin_v2.dart';
|
||||
import 'package:installed_apps/app_info.dart';
|
||||
import 'package:installed_apps/installed_apps.dart';
|
||||
@ -400,9 +401,9 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
// If the App says it is installed but installedInfo is null, set it to not installed
|
||||
// If the App says is is not installed but installedInfo exists, set it to the real installed version
|
||||
// If the internal version does not match the real one, sync them if the App supports enhanced version detection
|
||||
// Enhanced version detection will be true if the version extracted from source matches the standard version format
|
||||
// If the App says is is not installed but installedInfo exists, try to set it to installed as latest version...
|
||||
// ...if the latestVersion seems to match the version in installedInfo (not guaranteed)
|
||||
// If that fails, just set it to the actual version string (all we can do at that point)
|
||||
// Don't save changes, just return the object if changes were made (else null)
|
||||
// If in a background isolate, return null straight away as the required plugin won't work anyways
|
||||
App? getCorrectedInstallStatusAppIfPossible(App app, AppInfo? installedInfo) {
|
||||
@ -415,22 +416,30 @@ class AppsProvider with ChangeNotifier {
|
||||
!app.trackOnly) {
|
||||
app.installedVersion = null;
|
||||
modded = true;
|
||||
} else if (installedInfo != null && app.installedVersion == null) {
|
||||
if (app.enhancedVersionDetection) {
|
||||
app.installedVersion = installedInfo.versionName;
|
||||
}
|
||||
if (installedInfo != null && app.installedVersion == null) {
|
||||
if (app.latestVersion.characters
|
||||
.where((p0) => [
|
||||
// TODO: Won't work for other charsets
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'.'
|
||||
].contains(p0))
|
||||
.join('') ==
|
||||
installedInfo.versionName) {
|
||||
app.installedVersion = app.latestVersion;
|
||||
} else {
|
||||
if (app.latestVersion.contains(installedInfo.versionName!)) {
|
||||
app.installedVersion = app.latestVersion;
|
||||
} else {
|
||||
app.installedVersion = installedInfo.versionName;
|
||||
}
|
||||
app.installedVersion = installedInfo.versionName;
|
||||
}
|
||||
modded = true;
|
||||
} else if (installedInfo?.versionName != app.installedVersion &&
|
||||
app.enhancedVersionDetection &&
|
||||
!app.trackOnly) {
|
||||
app.installedVersion = installedInfo?.versionName;
|
||||
modded = true;
|
||||
}
|
||||
return modded ? app : null;
|
||||
}
|
||||
|
@ -27,15 +27,9 @@ class AppNames {
|
||||
|
||||
class APKDetails {
|
||||
late String version;
|
||||
late String versionFromSource;
|
||||
late bool isStandardVersion;
|
||||
late List<String> apkUrls;
|
||||
|
||||
APKDetails(this.versionFromSource, this.apkUrls) {
|
||||
var temp = extractStandardVersionName(versionFromSource);
|
||||
isStandardVersion = temp != null;
|
||||
version = temp ?? versionFromSource;
|
||||
}
|
||||
APKDetails(this.version, this.apkUrls);
|
||||
}
|
||||
|
||||
class App {
|
||||
@ -51,7 +45,6 @@ class App {
|
||||
late DateTime? lastUpdateCheck;
|
||||
bool pinned = false;
|
||||
bool trackOnly = false;
|
||||
bool enhancedVersionDetection = false;
|
||||
App(
|
||||
this.id,
|
||||
this.url,
|
||||
@ -64,8 +57,7 @@ class App {
|
||||
this.additionalData,
|
||||
this.lastUpdateCheck,
|
||||
this.pinned,
|
||||
this.trackOnly,
|
||||
this.enhancedVersionDetection);
|
||||
this.trackOnly);
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
@ -94,8 +86,7 @@ class App {
|
||||
? null
|
||||
: DateTime.fromMicrosecondsSinceEpoch(json['lastUpdateCheck']),
|
||||
json['pinned'] ?? false,
|
||||
json['trackOnly'] ?? false,
|
||||
json['enhancedVersionDetection'] ?? false);
|
||||
json['trackOnly'] ?? false);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
@ -109,8 +100,7 @@ class App {
|
||||
'additionalData': jsonEncode(additionalData),
|
||||
'lastUpdateCheck': lastUpdateCheck?.microsecondsSinceEpoch,
|
||||
'pinned': pinned,
|
||||
'trackOnly': trackOnly,
|
||||
'enhancedVersionDetection': enhancedVersionDetection
|
||||
'trackOnly': trackOnly
|
||||
};
|
||||
}
|
||||
|
||||
@ -200,13 +190,6 @@ ObtainiumError getObtainiumHttpError(Response res) {
|
||||
tr('errorWithHttpStatusCode', args: [res.statusCode.toString()]));
|
||||
}
|
||||
|
||||
String? extractStandardVersionName(String version, {bool strict = false}) {
|
||||
var match =
|
||||
RegExp('${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+${strict ? '\$' : ''}')
|
||||
.firstMatch(version);
|
||||
return match != null ? version.substring(match.start, match.end) : null;
|
||||
}
|
||||
|
||||
abstract class MassAppUrlSource {
|
||||
late String name;
|
||||
late List<String> requiredArgs;
|
||||
@ -285,12 +268,6 @@ class SourceProvider {
|
||||
if (apk.apkUrls.isEmpty && !trackOnly) {
|
||||
throw NoAPKError();
|
||||
}
|
||||
bool enhancedVersionDetection = apk.isStandardVersion &&
|
||||
installedVersion != null &&
|
||||
extractStandardVersionName(installedVersion, strict: true) != null;
|
||||
if (!enhancedVersionDetection) {
|
||||
apk.version = apk.versionFromSource;
|
||||
}
|
||||
String apkVersion = apk.version.replaceAll('/', '-');
|
||||
return App(
|
||||
id ??
|
||||
@ -308,8 +285,7 @@ class SourceProvider {
|
||||
additionalData,
|
||||
DateTime.now(),
|
||||
pinned,
|
||||
trackOnly,
|
||||
enhancedVersionDetection);
|
||||
trackOnly);
|
||||
}
|
||||
|
||||
// Returns errors in [results, errors] instead of throwing them
|
||||
|
@ -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.8.4+67 # When changing this, update the tag in main() accordingly
|
||||
version: 0.8.5+69 # When changing this, update the tag in main() accordingly
|
||||
|
||||
environment:
|
||||
sdk: '>=2.18.2 <3.0.0'
|
||||
|
Reference in New Issue
Block a user