mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-07-13 21:36:42 +02:00
Compare commits
9 Commits
v0.6.2-bet
...
v0.6.5-bet
Author | SHA1 | Date | |
---|---|---|---|
76e98feeb7 | |||
03da23f77a | |||
9b99e2b302 | |||
e746ca890a | |||
9c00a7da14 | |||
4df0dd64ad | |||
7cf7ffe0de | |||
b1953435af | |||
fc7d7d11d6 |
@ -69,9 +69,10 @@ class GitHub implements AppSource {
|
||||
if (!includePrereleases && releases[i]['prerelease'] == true) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (regexFilter != null &&
|
||||
!RegExp(regexFilter)
|
||||
.hasMatch((releases[i]['name'] as String).trim())) {
|
||||
.hasMatch((releases[i]['tag_name'] as String).trim())) {
|
||||
continue;
|
||||
}
|
||||
var apkUrls = getReleaseAPKUrls(releases[i]);
|
||||
|
@ -14,7 +14,7 @@ import 'package:workmanager/workmanager.dart';
|
||||
import 'package:dynamic_color/dynamic_color.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
|
||||
const String currentVersion = '0.6.2';
|
||||
const String currentVersion = '0.6.5';
|
||||
const String currentReleaseTag =
|
||||
'v$currentVersion-beta'; // KEEP THIS IN SYNC WITH GITHUB RELEASES
|
||||
|
||||
|
@ -121,8 +121,10 @@ class _AddAppPageState extends State<AddAppPage> {
|
||||
app.preferredApkIndex =
|
||||
app.apkUrls.indexOf(apkUrl);
|
||||
var downloadedApk =
|
||||
await appsProvider
|
||||
.downloadApp(app);
|
||||
await appsProvider.downloadApp(
|
||||
app,
|
||||
showOccasionalProgressToast:
|
||||
true);
|
||||
app.id = downloadedApk.appId;
|
||||
if (appsProvider.apps
|
||||
.containsKey(app.id)) {
|
||||
|
@ -62,10 +62,14 @@ class _AppPageState extends State<AppPage> {
|
||||
children: [
|
||||
Image.memory(
|
||||
app!.installedInfo!.icon!,
|
||||
scale: 1.5,
|
||||
height: 150,
|
||||
gaplessPlayback: true,
|
||||
)
|
||||
])
|
||||
: Container(),
|
||||
const SizedBox(
|
||||
height: 25,
|
||||
),
|
||||
Text(
|
||||
app?.installedInfo?.name ?? app?.app.name ?? 'App',
|
||||
textAlign: TextAlign.center,
|
||||
|
@ -23,6 +23,7 @@ class AppsPageState extends State<AppsPage> {
|
||||
var updatesOnlyFilter =
|
||||
AppsFilter(includeUptodate: false, includeNonInstalled: false);
|
||||
Set<String> selectedIds = {};
|
||||
DateTime? refreshingSince;
|
||||
|
||||
clearSelected() {
|
||||
if (selectedIds.isNotEmpty) {
|
||||
@ -119,8 +120,9 @@ class AppsPageState extends State<AppsPage> {
|
||||
sortedApps = sortedApps.reversed.toList();
|
||||
}
|
||||
|
||||
var existingUpdateIdsAllOrSelected = appsProvider
|
||||
.getExistingUpdates(installedOnly: true)
|
||||
var existingUpdates = appsProvider.getExistingUpdates(installedOnly: true);
|
||||
|
||||
var existingUpdateIdsAllOrSelected = existingUpdates
|
||||
.where((element) => selectedIds.isEmpty
|
||||
? sortedApps.where((a) => a.app.id == element).isNotEmpty
|
||||
: selectedIds.contains(element))
|
||||
@ -132,15 +134,34 @@ class AppsPageState extends State<AppsPage> {
|
||||
: selectedIds.contains(element))
|
||||
.toList();
|
||||
|
||||
if (settingsProvider.pinUpdates) {
|
||||
var temp = [];
|
||||
sortedApps = sortedApps.where((sa) {
|
||||
if (existingUpdates.contains(sa.app.id)) {
|
||||
temp.add(sa);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}).toList();
|
||||
sortedApps = [...temp, ...sortedApps];
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () {
|
||||
HapticFeedback.lightImpact();
|
||||
setState(() {
|
||||
refreshingSince = DateTime.now();
|
||||
});
|
||||
return appsProvider.checkUpdates().catchError((e) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(e.toString())),
|
||||
);
|
||||
}).whenComplete(() {
|
||||
setState(() {
|
||||
refreshingSince = null;
|
||||
});
|
||||
});
|
||||
},
|
||||
child: CustomScrollView(slivers: <Widget>[
|
||||
@ -157,6 +178,17 @@ class AppsPageState extends State<AppsPage> {
|
||||
style: Theme.of(context).textTheme.headlineMedium,
|
||||
textAlign: TextAlign.center,
|
||||
))),
|
||||
if (refreshingSince != null)
|
||||
SliverToBoxAdapter(
|
||||
child: LinearProgressIndicator(
|
||||
value: appsProvider.apps.values
|
||||
.where((element) => !(element.app.lastUpdateCheck
|
||||
?.isBefore(refreshingSince!) ??
|
||||
true))
|
||||
.length /
|
||||
appsProvider.apps.length,
|
||||
),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
@ -168,7 +200,10 @@ class AppsPageState extends State<AppsPage> {
|
||||
toggleAppSelected(sortedApps[index].app.id);
|
||||
},
|
||||
leading: sortedApps[index].installedInfo != null
|
||||
? Image.memory(sortedApps[index].installedInfo!.icon!)
|
||||
? Image.memory(
|
||||
sortedApps[index].installedInfo!.icon!,
|
||||
gaplessPlayback: true,
|
||||
)
|
||||
: null,
|
||||
title: Text(sortedApps[index].installedInfo?.name ??
|
||||
sortedApps[index].app.name),
|
||||
@ -212,8 +247,15 @@ class AppsPageState extends State<AppsPage> {
|
||||
)),
|
||||
],
|
||||
)
|
||||
: Text(sortedApps[index].app.installedVersion ??
|
||||
'Not Installed')),
|
||||
: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
width: 80,
|
||||
child: Text(
|
||||
sortedApps[index].app.installedVersion ??
|
||||
'Not Installed',
|
||||
overflow: TextOverflow.fade,
|
||||
textAlign: TextAlign.end,
|
||||
)))),
|
||||
onTap: () {
|
||||
if (selectedIds.isNotEmpty) {
|
||||
toggleAppSelected(sortedApps[index].app.id);
|
||||
|
@ -155,6 +155,20 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||
})
|
||||
],
|
||||
),
|
||||
const SizedBox(
|
||||
height: 16,
|
||||
),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
const Text('Pin Updates to Top of Apps View'),
|
||||
Switch(
|
||||
value: settingsProvider.pinUpdates,
|
||||
onChanged: (value) {
|
||||
settingsProvider.pinUpdates = value;
|
||||
})
|
||||
],
|
||||
),
|
||||
const Divider(
|
||||
height: 16,
|
||||
),
|
||||
|
@ -8,6 +8,7 @@ import 'dart:io';
|
||||
import 'package:device_info_plus/device_info_plus.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';
|
||||
@ -115,7 +116,9 @@ class AppsProvider with ChangeNotifier {
|
||||
// Downloads the App (preferred URL) and returns an ApkFile object
|
||||
// If the app was already saved, updates it's download progress % in memory
|
||||
// But also works for Apps that are not saved
|
||||
Future<DownloadedApp> downloadApp(App app) async {
|
||||
Future<DownloadedApp> downloadApp(App app,
|
||||
{bool showOccasionalProgressToast = false}) async {
|
||||
int? prevProg;
|
||||
var fileName = '${app.id}-${app.latestVersion}-${app.preferredApkIndex}';
|
||||
File downloadFile = await downloadApk(app.apkUrls[app.preferredApkIndex],
|
||||
'${app.id}-${app.latestVersion}-${app.preferredApkIndex}',
|
||||
@ -123,6 +126,14 @@ class AppsProvider with ChangeNotifier {
|
||||
if (apps[app.id] != null) {
|
||||
apps[app.id]!.downloadProgress = progress;
|
||||
}
|
||||
int? prog = progress?.ceil();
|
||||
if (showOccasionalProgressToast &&
|
||||
(prog == 25 || prog == 50 || prog == 75) &&
|
||||
prevProg != prog) {
|
||||
Fluttertoast.showToast(
|
||||
msg: 'Progress: $prog%', toastLength: Toast.LENGTH_SHORT);
|
||||
}
|
||||
prevProg = prog;
|
||||
notifyListeners();
|
||||
}, SourceProvider().getSource(app.url).apkUrlPrefetchModifier);
|
||||
// Delete older versions of the APK if any
|
||||
@ -291,7 +302,7 @@ class AppsProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
// If Obtainium is being installed, it should be the last one
|
||||
List<DownloadedApp> moveObtainiumToEnd(List<DownloadedApp> items) {
|
||||
List<DownloadedApp> moveObtainiumToStart(List<DownloadedApp> items) {
|
||||
String obtainiumId = 'imranr98_obtainium_${GitHub().host}';
|
||||
DownloadedApp? temp;
|
||||
items.removeWhere((element) {
|
||||
@ -302,7 +313,7 @@ class AppsProvider with ChangeNotifier {
|
||||
return res;
|
||||
});
|
||||
if (temp != null) {
|
||||
items.add(temp!);
|
||||
items = [temp!, ...items];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
@ -310,8 +321,8 @@ class AppsProvider with ChangeNotifier {
|
||||
// TODO: Remove below line if silentupdates are ever figured out
|
||||
regularInstalls.addAll(silentUpdates);
|
||||
|
||||
silentUpdates = moveObtainiumToEnd(silentUpdates);
|
||||
regularInstalls = moveObtainiumToEnd(regularInstalls);
|
||||
silentUpdates = moveObtainiumToStart(silentUpdates);
|
||||
regularInstalls = moveObtainiumToStart(regularInstalls);
|
||||
|
||||
// TODO: Uncomment below if silentupdates are ever figured out
|
||||
// for (var u in silentUpdates) {
|
||||
|
@ -123,6 +123,15 @@ class SettingsProvider with ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get pinUpdates {
|
||||
return prefs?.getBool('pinUpdates') ?? true;
|
||||
}
|
||||
|
||||
set pinUpdates(bool show) {
|
||||
prefs?.setBool('pinUpdates', show);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
String? getSettingString(String settingId) {
|
||||
return prefs?.getString(settingId);
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ class SourceProvider {
|
||||
? name
|
||||
: names.name[0].toUpperCase() + names.name.substring(1),
|
||||
null,
|
||||
apk.version,
|
||||
apk.version.replaceAll('/', '-'),
|
||||
apk.apkUrls,
|
||||
apk.apkUrls.length - 1,
|
||||
additionalData,
|
||||
|
@ -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.6.2+46 # When changing this, update the tag in main() accordingly
|
||||
version: 0.6.5+49 # When changing this, update the tag in main() accordingly
|
||||
|
||||
environment:
|
||||
sdk: '>=2.18.2 <3.0.0'
|
||||
|
Reference in New Issue
Block a user