Compare commits

...

8 Commits

Author SHA1 Message Date
Imran Remtulla
609366675d Fix translation error in BG check task 2022-12-07 19:48:59 -05:00
Imran Remtulla
fbff498ae1 Addresses #139 2022-12-05 20:10:42 -05:00
Imran Remtulla
bb4e470760 Slight tweaks 2022-12-05 20:09:16 -05:00
Imran Remtulla
15183c3a95 Simplified EVD (only xx.yy.zz) 2022-12-05 16:31:43 -05:00
Imran Remtulla
b496a416ff Increment version 2022-12-05 15:56:43 -05:00
Imran Remtulla
6ac7ba204f EVD bugfix 2022-12-05 15:46:47 -05:00
Imran Remtulla
0951c007d1 Bugfix for enhanced version detection 2022-12-05 15:39:36 -05:00
Imran Remtulla
d835beec76 Bugfix for localization error in BG 2022-12-05 14:57:38 -05:00
5 changed files with 65 additions and 20 deletions

View File

@@ -16,19 +16,52 @@ import 'package:dynamic_color/dynamic_color.dart';
import 'package:device_info_plus/device_info_plus.dart'; import 'package:device_info_plus/device_info_plus.dart';
import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart'; import 'package:android_alarm_manager_plus/android_alarm_manager_plus.dart';
import 'package:easy_localization/easy_localization.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.2'; const String currentVersion = '0.8.5';
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
const int bgUpdateCheckAlarmId = 666; 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') @pragma('vm:entry-point')
Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async { Future<void> bgUpdateCheck(int taskId, Map<String, dynamic>? params) async {
WidgetsFlutterBinding.ensureInitialized();
await EasyLocalization.ensureInitialized();
await loadTranslations();
LogsProvider logs = LogsProvider(); LogsProvider logs = LogsProvider();
logs.add(tr('startedBgUpdateTask')); logs.add(tr('startedBgUpdateTask'));
int? ignoreAfterMicroseconds = params?['ignoreAfterMicroseconds']; int? ignoreAfterMicroseconds = params?['ignoreAfterMicroseconds'];
WidgetsFlutterBinding.ensureInitialized();
await AndroidAlarmManager.initialize(); await AndroidAlarmManager.initialize();
DateTime? ignoreAfter = ignoreAfterMicroseconds != null DateTime? ignoreAfter = ignoreAfterMicroseconds != null
? DateTime.fromMicrosecondsSinceEpoch(ignoreAfterMicroseconds) ? DateTime.fromMicrosecondsSinceEpoch(ignoreAfterMicroseconds)
@@ -115,9 +148,9 @@ void main() async {
Provider(create: (context) => LogsProvider()) Provider(create: (context) => LogsProvider())
], ],
child: EasyLocalization( child: EasyLocalization(
supportedLocales: const [Locale('en')], supportedLocales: supportedLocales,
path: 'assets/translations', path: localeDir,
fallbackLocale: const Locale('en'), fallbackLocale: fallbackLocale,
child: const Obtainium()), child: const Obtainium()),
)); ));
} }

View File

@@ -114,7 +114,7 @@ class _AppPageState extends State<AppPage> {
height: 32, height: 32,
), ),
Text( Text(
'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}', 'Last Update Check: ${app?.app.lastUpdateCheck == null ? 'Never' : '\n${app?.app.lastUpdateCheck?.toLocal()}'}${app?.app.enhancedVersionDetection == true ? '\n\nThis App has enhanced version detection.' : ''}',
textAlign: TextAlign.center, textAlign: TextAlign.center,
style: const TextStyle( style: const TextStyle(
fontStyle: FontStyle.italic, fontSize: 12), fontStyle: FontStyle.italic, fontSize: 12),

View File

@@ -416,7 +416,15 @@ class AppsProvider with ChangeNotifier {
app.installedVersion = null; app.installedVersion = null;
modded = true; modded = true;
} else if (installedInfo != null && app.installedVersion == null) { } else if (installedInfo != null && app.installedVersion == null) {
app.installedVersion = installedInfo.versionName; if (app.enhancedVersionDetection) {
app.installedVersion = installedInfo.versionName;
} else {
if (app.latestVersion.contains(installedInfo.versionName!)) {
app.installedVersion = app.latestVersion;
} else {
app.installedVersion = installedInfo.versionName;
}
}
modded = true; modded = true;
} else if (installedInfo?.versionName != app.installedVersion && } else if (installedInfo?.versionName != app.installedVersion &&
app.enhancedVersionDetection && app.enhancedVersionDetection &&

View File

@@ -27,13 +27,14 @@ class AppNames {
class APKDetails { class APKDetails {
late String version; late String version;
late String versionFromSource;
late bool isStandardVersion;
late List<String> apkUrls; late List<String> apkUrls;
late bool isStandardVersionName;
APKDetails(version, this.apkUrls) { APKDetails(this.versionFromSource, this.apkUrls) {
var standardVersion = extractStandardVersionName(version); var temp = extractStandardVersionName(versionFromSource);
isStandardVersionName = standardVersion != null; isStandardVersion = temp != null;
this.version = standardVersion ?? version; version = temp ?? versionFromSource;
} }
} }
@@ -200,9 +201,9 @@ ObtainiumError getObtainiumHttpError(Response res) {
} }
String? extractStandardVersionName(String version, {bool strict = false}) { String? extractStandardVersionName(String version, {bool strict = false}) {
var match = RegExp( var match =
'${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+(-(alpha|beta)\\+?[0-9]+)?${strict ? '\$' : ''}') RegExp('${strict ? '^' : ''}[0-9]+(\\.[0-9]+)+${strict ? '\$' : ''}')
.firstMatch(version); .firstMatch(version);
return match != null ? version.substring(match.start, match.end) : null; return match != null ? version.substring(match.start, match.end) : null;
} }
@@ -284,6 +285,12 @@ class SourceProvider {
if (apk.apkUrls.isEmpty && !trackOnly) { if (apk.apkUrls.isEmpty && !trackOnly) {
throw NoAPKError(); throw NoAPKError();
} }
bool enhancedVersionDetection = apk.isStandardVersion &&
installedVersion != null &&
extractStandardVersionName(installedVersion, strict: true) != null;
if (!enhancedVersionDetection) {
apk.version = apk.versionFromSource;
}
String apkVersion = apk.version.replaceAll('/', '-'); String apkVersion = apk.version.replaceAll('/', '-');
return App( return App(
id ?? id ??
@@ -302,10 +309,7 @@ class SourceProvider {
DateTime.now(), DateTime.now(),
pinned, pinned,
trackOnly, trackOnly,
apk.isStandardVersionName && enhancedVersionDetection);
(installedVersion == null ||
extractStandardVersionName(installedVersion, strict: true) !=
null));
} }
// Returns errors in [results, errors] instead of throwing them // Returns errors in [results, errors] instead of throwing them

View File

@@ -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.8.2+65 # When changing this, update the tag in main() accordingly version: 0.8.5+68 # 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'