mirror of
https://github.com/ImranR98/Obtainium.git
synced 2025-08-22 05:59:30 +02:00
Add auto-remove option (#656) + on-foreground bugfix
This commit is contained in:
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "Benötigt zusätzliche Anmeldedaten (in den Einstellungen)",
|
"requiresCredentialsInSettings": "Benötigt zusätzliche Anmeldedaten (in den Einstellungen)",
|
||||||
"checkOnStart": "Überprüfe einmalig beim Start",
|
"checkOnStart": "Überprüfe einmalig beim Start",
|
||||||
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "App entfernen?",
|
"one": "App entfernen?",
|
||||||
"other": "Apps entfernen?"
|
"other": "Apps entfernen?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
||||||
"checkOnStart": "Check Once on Start",
|
"checkOnStart": "Check Once on Start",
|
||||||
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Remove App?",
|
"one": "Remove App?",
|
||||||
"other": "Remove Apps?"
|
"other": "Remove Apps?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
||||||
"checkOnStart": "Check Once on Start",
|
"checkOnStart": "Check Once on Start",
|
||||||
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "¿Eliminar Aplicación?",
|
"one": "¿Eliminar Aplicación?",
|
||||||
"other": "¿Eliminar Aplicaciones?"
|
"other": "¿Eliminar Aplicaciones?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "این به اعتبارنامه های اضافی نیاز دارد (در تنظیمات)",
|
"requiresCredentialsInSettings": "این به اعتبارنامه های اضافی نیاز دارد (در تنظیمات)",
|
||||||
"checkOnStart": "بررسی در شروع",
|
"checkOnStart": "بررسی در شروع",
|
||||||
"tryInferAppIdFromCode": "شناسه برنامه را از کد منبع استنباط کنید",
|
"tryInferAppIdFromCode": "شناسه برنامه را از کد منبع استنباط کنید",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "برنامه حذف شود؟",
|
"one": "برنامه حذف شود؟",
|
||||||
"other": "برنامه ها حذف شوند؟"
|
"other": "برنامه ها حذف شوند؟"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
"requiresCredentialsInSettings": "This needs additional credentials (in Settings)",
|
||||||
"checkOnStart": "Check Once on Start",
|
"checkOnStart": "Check Once on Start",
|
||||||
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Supprimer l'application ?",
|
"one": "Supprimer l'application ?",
|
||||||
"other": "Supprimer les applications ?"
|
"other": "Supprimer les applications ?"
|
||||||
|
@@ -233,6 +233,7 @@
|
|||||||
"requiresCredentialsInSettings": "Ehhez további hitelesítő adatokra van szükség (a Beállításokban)",
|
"requiresCredentialsInSettings": "Ehhez további hitelesítő adatokra van szükség (a Beállításokban)",
|
||||||
"checkOnStart": "Egyszer az indításkor",
|
"checkOnStart": "Egyszer az indításkor",
|
||||||
"tryInferAppIdFromCode": "Próbálja kikövetkeztetni az app azonosítót a forráskódból",
|
"tryInferAppIdFromCode": "Próbálja kikövetkeztetni az app azonosítót a forráskódból",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Eltávolítja az alkalmazást?",
|
"one": "Eltávolítja az alkalmazást?",
|
||||||
"other": "Eltávolítja az alkalmazást?"
|
"other": "Eltávolítja az alkalmazást?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "Servono credenziali aggiuntive (in Impostazioni)",
|
"requiresCredentialsInSettings": "Servono credenziali aggiuntive (in Impostazioni)",
|
||||||
"checkOnStart": "Controlla una volta all'avvio",
|
"checkOnStart": "Controlla una volta all'avvio",
|
||||||
"tryInferAppIdFromCode": "Prova a dedurre l'ID dell'app dal codice sorgente",
|
"tryInferAppIdFromCode": "Prova a dedurre l'ID dell'app dal codice sorgente",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Rimuovere l'app?",
|
"one": "Rimuovere l'app?",
|
||||||
"other": "Rimuovere le app?"
|
"other": "Rimuovere le app?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "これには追加の認証が必要です (設定にて)",
|
"requiresCredentialsInSettings": "これには追加の認証が必要です (設定にて)",
|
||||||
"checkOnStart": "Check Once on Start",
|
"checkOnStart": "Check Once on Start",
|
||||||
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
"tryInferAppIdFromCode": "Try inferring App ID from source code",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "アプリを削除しますか?",
|
"one": "アプリを削除しますか?",
|
||||||
"other": "アプリを削除しますか?"
|
"other": "アプリを削除しますか?"
|
||||||
|
@@ -238,6 +238,7 @@
|
|||||||
"requiresCredentialsInSettings": "Wymaga to dodatkowych poświadczeń (w Ustawieniach)",
|
"requiresCredentialsInSettings": "Wymaga to dodatkowych poświadczeń (w Ustawieniach)",
|
||||||
"checkOnStart": "Sprawdź raz przy starcie",
|
"checkOnStart": "Sprawdź raz przy starcie",
|
||||||
"tryInferAppIdFromCode": "Spróbuj wywnioskować identyfikator aplikacji z kodu źródłowego",
|
"tryInferAppIdFromCode": "Spróbuj wywnioskować identyfikator aplikacji z kodu źródłowego",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Usunąć aplikację?",
|
"one": "Usunąć aplikację?",
|
||||||
"other": "Usunąć aplikacje?"
|
"other": "Usunąć aplikacje?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "Для этого требуются дополнительные учетные данные (в настройках)",
|
"requiresCredentialsInSettings": "Для этого требуются дополнительные учетные данные (в настройках)",
|
||||||
"checkOnStart": "Проверить один раз при запуске",
|
"checkOnStart": "Проверить один раз при запуске",
|
||||||
"tryInferAppIdFromCode": "Попытаться определить ID приложения из исходного кода",
|
"tryInferAppIdFromCode": "Попытаться определить ID приложения из исходного кода",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "Удалить приложение?",
|
"one": "Удалить приложение?",
|
||||||
"other": "Удалить приложения?"
|
"other": "Удалить приложения?"
|
||||||
|
@@ -234,6 +234,7 @@
|
|||||||
"requiresCredentialsInSettings": "此功能需要额外的凭据(在“设置”中添加)",
|
"requiresCredentialsInSettings": "此功能需要额外的凭据(在“设置”中添加)",
|
||||||
"checkOnStart": "启动时进行一次检查",
|
"checkOnStart": "启动时进行一次检查",
|
||||||
"tryInferAppIdFromCode": "尝试从源代码推断应用 ID",
|
"tryInferAppIdFromCode": "尝试从源代码推断应用 ID",
|
||||||
|
"removeOnExternalUninstall": "Automatically remove externally uninstalled Apps",
|
||||||
"removeAppQuestion": {
|
"removeAppQuestion": {
|
||||||
"one": "是否删除应用?",
|
"one": "是否删除应用?",
|
||||||
"other": "是否删除应用?"
|
"other": "是否删除应用?"
|
||||||
|
@@ -226,9 +226,9 @@ class _ObtainiumState extends State<Obtainium> {
|
|||||||
if (!supportedLocales
|
if (!supportedLocales
|
||||||
.map((e) => e.key.languageCode)
|
.map((e) => e.key.languageCode)
|
||||||
.contains(context.locale.languageCode) ||
|
.contains(context.locale.languageCode) ||
|
||||||
settingsProvider.forcedLocale == null &&
|
(settingsProvider.forcedLocale == null &&
|
||||||
context.deviceLocale.languageCode !=
|
context.deviceLocale.languageCode !=
|
||||||
context.locale.languageCode) {
|
context.locale.languageCode)) {
|
||||||
settingsProvider.resetLocaleSafe(context);
|
settingsProvider.resetLocaleSafe(context);
|
||||||
}
|
}
|
||||||
// Register the background update task according to the user's setting
|
// Register the background update task according to the user's setting
|
||||||
|
@@ -322,6 +322,22 @@ class _SettingsPageState extends State<SettingsPage> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
height16,
|
height16,
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Flexible(
|
||||||
|
child:
|
||||||
|
Text(tr('removeOnExternalUninstall'))),
|
||||||
|
Switch(
|
||||||
|
value: settingsProvider
|
||||||
|
.removeOnExternalUninstall,
|
||||||
|
onChanged: (value) {
|
||||||
|
settingsProvider
|
||||||
|
.removeOnExternalUninstall = value;
|
||||||
|
})
|
||||||
|
],
|
||||||
|
),
|
||||||
|
height16,
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
@@ -335,19 +335,21 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> unzipFile(String filePath, String destinationPath) async {
|
Future<void> unzipFile(String filePath, String destinationPath) async {
|
||||||
await ZipFile.extractToDirectory(zipFile: File(filePath), destinationDir: Directory(destinationPath));
|
await ZipFile.extractToDirectory(
|
||||||
|
zipFile: File(filePath), destinationDir: Directory(destinationPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> installXApkDir(DownloadedXApkDir dir,
|
Future<void> installXApkDir(DownloadedXApkDir dir,
|
||||||
{bool silent = false}) async {
|
{bool silent = false}) async {
|
||||||
try {
|
try {
|
||||||
var somethingInstalled = false;
|
var somethingInstalled = false;
|
||||||
for (var file in dir.extracted.listSync(recursive: true, followLinks: false).whereType<File>()) {
|
for (var file in dir.extracted
|
||||||
|
.listSync(recursive: true, followLinks: false)
|
||||||
|
.whereType<File>()) {
|
||||||
if (file.path.toLowerCase().endsWith('.apk')) {
|
if (file.path.toLowerCase().endsWith('.apk')) {
|
||||||
somethingInstalled = somethingInstalled ||
|
somethingInstalled = somethingInstalled ||
|
||||||
await installApk(DownloadedApk(dir.appId, file), silent: silent);
|
await installApk(DownloadedApk(dir.appId, file), silent: silent);
|
||||||
}
|
} else if (file.path.toLowerCase().endsWith('.obb')) {
|
||||||
else if (file.path.toLowerCase().endsWith('.obb')) {
|
|
||||||
await moveObbFile(file, dir.appId);
|
await moveObbFile(file, dir.appId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -389,7 +391,7 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> moveObbFile(File file, String appId) async {
|
Future<void> moveObbFile(File file, String appId) async {
|
||||||
if(!file.path.toLowerCase().endsWith('.obb')) return;
|
if (!file.path.toLowerCase().endsWith('.obb')) return;
|
||||||
|
|
||||||
// TODO: Does not support Android 11+
|
// TODO: Does not support Android 11+
|
||||||
if ((await DeviceInfoPlugin().androidInfo).version.sdkInt <= 29) {
|
if ((await DeviceInfoPlugin().androidInfo).version.sdkInt <= 29) {
|
||||||
@@ -754,21 +756,37 @@ class AppsProvider with ChangeNotifier {
|
|||||||
}
|
}
|
||||||
loadingApps = false;
|
loadingApps = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
refreshInstallStatuses();
|
|
||||||
|
refreshInstallStatuses(useExistingInstalledInfo: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> refreshInstallStatuses() async {
|
Future<void> refreshInstallStatuses(
|
||||||
|
{bool useExistingInstalledInfo = false}) async {
|
||||||
if (await doesInstalledAppsPluginWork()) {
|
if (await doesInstalledAppsPluginWork()) {
|
||||||
List<App> modifiedApps = [];
|
List<App> modifiedApps = [];
|
||||||
for (var app in apps.values) {
|
for (var app in apps.values) {
|
||||||
var moddedApp =
|
var moddedApp = getCorrectedInstallStatusAppIfPossible(
|
||||||
getCorrectedInstallStatusAppIfPossible(app.app, app.installedInfo);
|
app.app,
|
||||||
|
useExistingInstalledInfo
|
||||||
|
? app.installedInfo
|
||||||
|
: await getInstalledInfo(app.app.id));
|
||||||
if (moddedApp != null) {
|
if (moddedApp != null) {
|
||||||
modifiedApps.add(moddedApp);
|
modifiedApps.add(moddedApp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (modifiedApps.isNotEmpty) {
|
if (modifiedApps.isNotEmpty) {
|
||||||
await saveApps(modifiedApps, attemptToCorrectInstallStatus: false);
|
await saveApps(modifiedApps, attemptToCorrectInstallStatus: false);
|
||||||
|
var removedAppIds = modifiedApps
|
||||||
|
.where((a) => a.installedVersion == null)
|
||||||
|
.map((e) => e.id)
|
||||||
|
.toList();
|
||||||
|
if (removedAppIds.isNotEmpty) {
|
||||||
|
var settingsProvider = SettingsProvider();
|
||||||
|
await settingsProvider.initializeSettings();
|
||||||
|
if (settingsProvider.removeOnExternalUninstall) {
|
||||||
|
await removeApps(removedAppIds);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -273,4 +273,13 @@ class SettingsProvider with ChangeNotifier {
|
|||||||
context.deleteSaveLocale();
|
context.deleteSaveLocale();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get removeOnExternalUninstall {
|
||||||
|
return prefs?.getBool('removeOnExternalUninstall') ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
set removeOnExternalUninstall(bool show) {
|
||||||
|
prefs?.setBool('removeOnExternalUninstall', show);
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user