mirror of
https://github.com/ReVanced/revanced-manager.git
synced 2024-11-10 01:01:56 +01:00
fix: use a try-finally while handling background task creation, prevent opening patches while disabled and fix loading label
This commit is contained in:
parent
a929851662
commit
95a0bcf5d8
3 changed files with 26 additions and 26 deletions
|
@ -17,20 +17,23 @@ class InstallerViewModel extends BaseViewModel {
|
|||
bool isInstalled = false;
|
||||
|
||||
Future<void> initialize() async {
|
||||
await FlutterBackground.initialize(
|
||||
androidConfig: const FlutterBackgroundAndroidConfig(
|
||||
notificationTitle: 'Patching',
|
||||
notificationText: 'ReVanced Manager is patching',
|
||||
notificationImportance: AndroidNotificationImportance.Default,
|
||||
notificationIcon: AndroidResource(
|
||||
name: 'ic_notification',
|
||||
defType: 'drawable',
|
||||
try {
|
||||
await FlutterBackground.initialize(
|
||||
androidConfig: const FlutterBackgroundAndroidConfig(
|
||||
notificationTitle: 'Patching',
|
||||
notificationText: 'ReVanced Manager is patching',
|
||||
notificationImportance: AndroidNotificationImportance.Default,
|
||||
notificationIcon: AndroidResource(
|
||||
name: 'ic_notification',
|
||||
defType: 'drawable',
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await FlutterBackground.enableBackgroundExecution();
|
||||
await locator<PatcherAPI>().handlePlatformChannelMethods();
|
||||
await runPatcher();
|
||||
);
|
||||
await FlutterBackground.enableBackgroundExecution();
|
||||
} finally {
|
||||
await locator<PatcherAPI>().handlePlatformChannelMethods();
|
||||
await runPatcher();
|
||||
}
|
||||
}
|
||||
|
||||
void updateProgress(double value) {
|
||||
|
@ -95,8 +98,11 @@ class InstallerViewModel extends BaseViewModel {
|
|||
} else {
|
||||
updateLog('No app or patches selected! Aborting');
|
||||
}
|
||||
await FlutterBackground.disableBackgroundExecution();
|
||||
isPatching = false;
|
||||
try {
|
||||
await FlutterBackground.disableBackgroundExecution();
|
||||
} finally {
|
||||
isPatching = false;
|
||||
}
|
||||
}
|
||||
|
||||
void installResult() async {
|
||||
|
|
|
@ -55,7 +55,9 @@ class PatcherView extends StatelessWidget {
|
|||
? (model.dimPatchesCard() ? 0.5 : 1)
|
||||
: (model.dimPatchesCard() ? 0.75 : 1),
|
||||
child: PatchSelectorCard(
|
||||
onPressed: model.navigateToPatchesSelector,
|
||||
onPressed: model.dimPatchesCard()
|
||||
? () => {}
|
||||
: model.navigateToPatchesSelector,
|
||||
color: Theme.of(context).colorScheme.primary,
|
||||
),
|
||||
),
|
||||
|
|
|
@ -49,12 +49,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||
'revanced',
|
||||
'revanced-patcher',
|
||||
),
|
||||
initialData: FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.loadingLabel',
|
||||
),
|
||||
builder: (context, snapshot) => Text(
|
||||
snapshot.data!.isNotEmpty
|
||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||
? FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.timeagoLabel',
|
||||
|
@ -86,12 +82,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||
'revanced',
|
||||
'revanced-manager',
|
||||
),
|
||||
initialData: FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.loadingLabel',
|
||||
),
|
||||
builder: (context, snapshot) => Text(
|
||||
snapshot.data!.isNotEmpty
|
||||
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||
? FlutterI18n.translate(
|
||||
context,
|
||||
'latestCommitCard.timeagoLabel',
|
||||
|
|
Loading…
Reference in a new issue