mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02: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
@ -17,20 +17,23 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
bool isInstalled = false;
|
bool isInstalled = false;
|
||||||
|
|
||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
await FlutterBackground.initialize(
|
try {
|
||||||
androidConfig: const FlutterBackgroundAndroidConfig(
|
await FlutterBackground.initialize(
|
||||||
notificationTitle: 'Patching',
|
androidConfig: const FlutterBackgroundAndroidConfig(
|
||||||
notificationText: 'ReVanced Manager is patching',
|
notificationTitle: 'Patching',
|
||||||
notificationImportance: AndroidNotificationImportance.Default,
|
notificationText: 'ReVanced Manager is patching',
|
||||||
notificationIcon: AndroidResource(
|
notificationImportance: AndroidNotificationImportance.Default,
|
||||||
name: 'ic_notification',
|
notificationIcon: AndroidResource(
|
||||||
defType: 'drawable',
|
name: 'ic_notification',
|
||||||
|
defType: 'drawable',
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
await FlutterBackground.enableBackgroundExecution();
|
||||||
await FlutterBackground.enableBackgroundExecution();
|
} finally {
|
||||||
await locator<PatcherAPI>().handlePlatformChannelMethods();
|
await locator<PatcherAPI>().handlePlatformChannelMethods();
|
||||||
await runPatcher();
|
await runPatcher();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateProgress(double value) {
|
void updateProgress(double value) {
|
||||||
@ -95,8 +98,11 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
} else {
|
} else {
|
||||||
updateLog('No app or patches selected! Aborting');
|
updateLog('No app or patches selected! Aborting');
|
||||||
}
|
}
|
||||||
await FlutterBackground.disableBackgroundExecution();
|
try {
|
||||||
isPatching = false;
|
await FlutterBackground.disableBackgroundExecution();
|
||||||
|
} finally {
|
||||||
|
isPatching = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void installResult() async {
|
void installResult() async {
|
||||||
|
@ -55,7 +55,9 @@ class PatcherView extends StatelessWidget {
|
|||||||
? (model.dimPatchesCard() ? 0.5 : 1)
|
? (model.dimPatchesCard() ? 0.5 : 1)
|
||||||
: (model.dimPatchesCard() ? 0.75 : 1),
|
: (model.dimPatchesCard() ? 0.75 : 1),
|
||||||
child: PatchSelectorCard(
|
child: PatchSelectorCard(
|
||||||
onPressed: model.navigateToPatchesSelector,
|
onPressed: model.dimPatchesCard()
|
||||||
|
? () => {}
|
||||||
|
: model.navigateToPatchesSelector,
|
||||||
color: Theme.of(context).colorScheme.primary,
|
color: Theme.of(context).colorScheme.primary,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -49,12 +49,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
'revanced',
|
'revanced',
|
||||||
'revanced-patcher',
|
'revanced-patcher',
|
||||||
),
|
),
|
||||||
initialData: FlutterI18n.translate(
|
|
||||||
context,
|
|
||||||
'latestCommitCard.loadingLabel',
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) => Text(
|
builder: (context, snapshot) => Text(
|
||||||
snapshot.data!.isNotEmpty
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||||
? FlutterI18n.translate(
|
? FlutterI18n.translate(
|
||||||
context,
|
context,
|
||||||
'latestCommitCard.timeagoLabel',
|
'latestCommitCard.timeagoLabel',
|
||||||
@ -86,12 +82,8 @@ class _LatestCommitCardState extends State<LatestCommitCard> {
|
|||||||
'revanced',
|
'revanced',
|
||||||
'revanced-manager',
|
'revanced-manager',
|
||||||
),
|
),
|
||||||
initialData: FlutterI18n.translate(
|
|
||||||
context,
|
|
||||||
'latestCommitCard.loadingLabel',
|
|
||||||
),
|
|
||||||
builder: (context, snapshot) => Text(
|
builder: (context, snapshot) => Text(
|
||||||
snapshot.data!.isNotEmpty
|
snapshot.hasData && snapshot.data!.isNotEmpty
|
||||||
? FlutterI18n.translate(
|
? FlutterI18n.translate(
|
||||||
context,
|
context,
|
||||||
'latestCommitCard.timeagoLabel',
|
'latestCommitCard.timeagoLabel',
|
||||||
|
Loading…
Reference in New Issue
Block a user