mirror of
https://github.com/revanced/revanced-manager
synced 2024-05-14 13:56:57 +02:00
chore: merge dev
to main
(#1425)
This commit is contained in:
commit
cfb8980e3a
@ -1,6 +1,7 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:device_apps/device_apps.dart';
|
import 'package:device_apps/device_apps.dart';
|
||||||
|
import 'package:device_info_plus/device_info_plus.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||||
@ -33,6 +34,7 @@ class ManagerAPI {
|
|||||||
Patch? selectedPatch;
|
Patch? selectedPatch;
|
||||||
BuildContext? ctx;
|
BuildContext? ctx;
|
||||||
bool isRooted = false;
|
bool isRooted = false;
|
||||||
|
bool isDynamicThemeAvailable = false;
|
||||||
String storedPatchesFile = '/selected-patches.json';
|
String storedPatchesFile = '/selected-patches.json';
|
||||||
String keystoreFile =
|
String keystoreFile =
|
||||||
'/sdcard/Android/data/app.revanced.manager.flutter/files/revanced-manager.keystore';
|
'/sdcard/Android/data/app.revanced.manager.flutter/files/revanced-manager.keystore';
|
||||||
@ -59,10 +61,16 @@ class ManagerAPI {
|
|||||||
Future<void> initialize() async {
|
Future<void> initialize() async {
|
||||||
_prefs = await SharedPreferences.getInstance();
|
_prefs = await SharedPreferences.getInstance();
|
||||||
isRooted = await _rootAPI.isRooted();
|
isRooted = await _rootAPI.isRooted();
|
||||||
|
isDynamicThemeAvailable = (await getSdkVersion()) >= 31; // ANDROID_12_SDK_VERSION = 31
|
||||||
storedPatchesFile =
|
storedPatchesFile =
|
||||||
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
|
(await getApplicationDocumentsDirectory()).path + storedPatchesFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<int> getSdkVersion() async {
|
||||||
|
final AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
||||||
|
return info.version.sdkInt;
|
||||||
|
}
|
||||||
|
|
||||||
String getApiUrl() {
|
String getApiUrl() {
|
||||||
return _prefs.getString('apiUrl') ?? defaultApiUrl;
|
return _prefs.getString('apiUrl') ?? defaultApiUrl;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,6 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
final info = await AboutInfo.getInfo();
|
final info = await AboutInfo.getInfo();
|
||||||
|
|
||||||
final formattedLogs = [
|
final formattedLogs = [
|
||||||
'```',
|
|
||||||
'- Device Info',
|
'- Device Info',
|
||||||
'ReVanced Manager: ${info['version']}',
|
'ReVanced Manager: ${info['version']}',
|
||||||
'Build: ${info['flavor']}',
|
'Build: ${info['flavor']}',
|
||||||
@ -206,7 +205,6 @@ class InstallerViewModel extends BaseViewModel {
|
|||||||
|
|
||||||
'\n- Logs',
|
'\n- Logs',
|
||||||
logs,
|
logs,
|
||||||
'```',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
|
Clipboard.setData(ClipboardData(text: formattedLogs.join('\n')));
|
||||||
|
@ -6,46 +6,98 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_i18n/widgets/I18nText.dart';
|
import 'package:flutter_i18n/widgets/I18nText.dart';
|
||||||
import 'package:revanced_manager/app/app.locator.dart';
|
import 'package:revanced_manager/app/app.locator.dart';
|
||||||
import 'package:revanced_manager/services/manager_api.dart';
|
import 'package:revanced_manager/services/manager_api.dart';
|
||||||
import 'package:revanced_manager/ui/views/settings/settings_viewmodel.dart';
|
|
||||||
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
import 'package:revanced_manager/ui/widgets/settingsView/settings_section.dart';
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
|
||||||
|
|
||||||
final _settingViewModel = SettingsViewModel();
|
class SUpdateThemeUI extends StatefulWidget {
|
||||||
|
const SUpdateThemeUI({super.key});
|
||||||
|
|
||||||
// ignore: constant_identifier_names
|
@override
|
||||||
const int ANDROID_12_SDK_VERSION = 31;
|
State<SUpdateThemeUI> createState() => _SUpdateThemeUIState();
|
||||||
|
}
|
||||||
|
|
||||||
class SUpdateTheme extends BaseViewModel {
|
class _SUpdateThemeUIState extends State<SUpdateThemeUI> {
|
||||||
final ManagerAPI _managerAPI = locator<ManagerAPI>();
|
final ManagerAPI managerAPI = locator<ManagerAPI>();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return SettingsSection(
|
||||||
|
title: 'settingsView.appearanceSectionTitle',
|
||||||
|
children: <Widget>[
|
||||||
|
ListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
title: I18nText(
|
||||||
|
'settingsView.themeModeLabel',
|
||||||
|
child: const Text(
|
||||||
|
'',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
trailing: CustomMaterialButton(
|
||||||
|
label: getThemeModeName(),
|
||||||
|
onPressed: () => {showThemeDialog(context)},
|
||||||
|
),
|
||||||
|
onTap: () => {showThemeDialog(context)},
|
||||||
|
),
|
||||||
|
if (managerAPI.isDynamicThemeAvailable)
|
||||||
|
SwitchListTile(
|
||||||
|
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
||||||
|
title: I18nText(
|
||||||
|
'settingsView.dynamicThemeLabel',
|
||||||
|
child: const Text(
|
||||||
|
'',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
subtitle: I18nText('settingsView.dynamicThemeHint'),
|
||||||
|
value: getDynamicThemeStatus(),
|
||||||
|
onChanged: (value) => {
|
||||||
|
setUseDynamicTheme(
|
||||||
|
context,
|
||||||
|
value,
|
||||||
|
),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bool getDynamicThemeStatus() {
|
bool getDynamicThemeStatus() {
|
||||||
return _managerAPI.getUseDynamicTheme();
|
return managerAPI.getUseDynamicTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setUseDynamicTheme(BuildContext context, bool value) async {
|
Future<void> setUseDynamicTheme(BuildContext context, bool value) async {
|
||||||
await _managerAPI.setUseDynamicTheme(value);
|
await managerAPI.setUseDynamicTheme(value);
|
||||||
final int currentTheme = (DynamicTheme.of(context)!.themeId ~/ 2) * 2;
|
final int currentTheme = (DynamicTheme.of(context)!.themeId ~/ 2) * 2;
|
||||||
await DynamicTheme.of(context)!.setTheme(currentTheme + (value ? 1 : 0));
|
await DynamicTheme.of(context)!.setTheme(currentTheme + (value ? 1 : 0));
|
||||||
notifyListeners();
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
int getThemeMode() {
|
int getThemeMode() {
|
||||||
return _managerAPI.getThemeMode();
|
return managerAPI.getThemeMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> setThemeMode(BuildContext context, int value) async {
|
Future<void> setThemeMode(BuildContext context, int value) async {
|
||||||
await _managerAPI.setThemeMode(value);
|
await managerAPI.setThemeMode(value);
|
||||||
final bool isDynamicTheme = DynamicTheme.of(context)!.themeId.isEven;
|
final bool isDynamicTheme = DynamicTheme.of(context)!.themeId.isEven;
|
||||||
await DynamicTheme.of(context)!.setTheme(value * 2 + (isDynamicTheme ? 0 : 1));
|
await DynamicTheme.of(context)!
|
||||||
final bool isLight = value != 2 && (value == 1 || DynamicTheme.of(context)!.theme.brightness == Brightness.light);
|
.setTheme(value * 2 + (isDynamicTheme ? 0 : 1));
|
||||||
|
final bool isLight = value != 2 &&
|
||||||
|
(value == 1 ||
|
||||||
|
DynamicTheme.of(context)!.theme.brightness == Brightness.light);
|
||||||
SystemChrome.setSystemUIOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(
|
||||||
SystemUiOverlayStyle(
|
SystemUiOverlayStyle(
|
||||||
systemNavigationBarIconBrightness:
|
systemNavigationBarIconBrightness:
|
||||||
isLight ? Brightness.dark : Brightness.light,
|
isLight ? Brightness.dark : Brightness.light,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
notifyListeners();
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
I18nText getThemeModeName() {
|
I18nText getThemeModeName() {
|
||||||
@ -131,63 +183,3 @@ class SUpdateTheme extends BaseViewModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final sUpdateTheme = SUpdateTheme();
|
|
||||||
class SUpdateThemeUI extends StatelessWidget {
|
|
||||||
const SUpdateThemeUI({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return SettingsSection(
|
|
||||||
title: 'settingsView.appearanceSectionTitle',
|
|
||||||
children: <Widget>[
|
|
||||||
ListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
title: I18nText(
|
|
||||||
'settingsView.themeModeLabel',
|
|
||||||
child: const Text(
|
|
||||||
'',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
trailing: CustomMaterialButton(
|
|
||||||
label: sUpdateTheme.getThemeModeName(),
|
|
||||||
onPressed: () => { sUpdateTheme.showThemeDialog(context) },
|
|
||||||
),
|
|
||||||
onTap: () => { sUpdateTheme.showThemeDialog(context) },
|
|
||||||
),
|
|
||||||
FutureBuilder<int>(
|
|
||||||
future: _settingViewModel.getSdkVersion(),
|
|
||||||
builder: (context, snapshot) => Visibility(
|
|
||||||
visible:
|
|
||||||
snapshot.hasData && snapshot.data! >= ANDROID_12_SDK_VERSION,
|
|
||||||
child: SwitchListTile(
|
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 20.0),
|
|
||||||
title: I18nText(
|
|
||||||
'settingsView.dynamicThemeLabel',
|
|
||||||
child: const Text(
|
|
||||||
'',
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: FontWeight.w500,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
subtitle: I18nText('settingsView.dynamicThemeHint'),
|
|
||||||
value: _settingViewModel.sUpdateTheme.getDynamicThemeStatus(),
|
|
||||||
onChanged: (value) => {
|
|
||||||
_settingViewModel.sUpdateTheme.setUseDynamicTheme(
|
|
||||||
context,
|
|
||||||
value,
|
|
||||||
),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:cr_file_saver/file_saver.dart';
|
import 'package:cr_file_saver/file_saver.dart';
|
||||||
import 'package:device_info_plus/device_info_plus.dart';
|
|
||||||
import 'package:file_picker/file_picker.dart';
|
import 'package:file_picker/file_picker.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@ -14,7 +13,6 @@ import 'package:revanced_manager/services/toast.dart';
|
|||||||
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/patcher/patcher_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
import 'package:revanced_manager/ui/views/patches_selector/patches_selector_viewmodel.dart';
|
||||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart';
|
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_language.dart';
|
||||||
import 'package:revanced_manager/ui/views/settings/settingsFragment/settings_update_theme.dart';
|
|
||||||
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
import 'package:revanced_manager/ui/widgets/shared/custom_material_button.dart';
|
||||||
import 'package:share_extend/share_extend.dart';
|
import 'package:share_extend/share_extend.dart';
|
||||||
import 'package:stacked/stacked.dart';
|
import 'package:stacked/stacked.dart';
|
||||||
@ -29,7 +27,6 @@ class SettingsViewModel extends BaseViewModel {
|
|||||||
final Toast _toast = locator<Toast>();
|
final Toast _toast = locator<Toast>();
|
||||||
|
|
||||||
final SUpdateLanguage sUpdateLanguage = SUpdateLanguage();
|
final SUpdateLanguage sUpdateLanguage = SUpdateLanguage();
|
||||||
final SUpdateTheme sUpdateTheme = SUpdateTheme();
|
|
||||||
|
|
||||||
void navigateToContributors() {
|
void navigateToContributors() {
|
||||||
_navigationService.navigateTo(Routes.contributorsView);
|
_navigationService.navigateTo(Routes.contributorsView);
|
||||||
@ -256,11 +253,6 @@ class SettingsViewModel extends BaseViewModel {
|
|||||||
_toast.showBottom('settingsView.resetStoredPatches');
|
_toast.showBottom('settingsView.resetStoredPatches');
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<int> getSdkVersion() async {
|
|
||||||
final AndroidDeviceInfo info = await DeviceInfoPlugin().androidInfo;
|
|
||||||
return info.version.sdkInt;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteLogs() async {
|
Future<void> deleteLogs() async {
|
||||||
final Directory appCacheDir = await getTemporaryDirectory();
|
final Directory appCacheDir = await getTemporaryDirectory();
|
||||||
final Directory logsDir = Directory('${appCacheDir.path}/logs');
|
final Directory logsDir = Directory('${appCacheDir.path}/logs');
|
||||||
|
@ -4,7 +4,7 @@ homepage: https://github.com/revanced/revanced-manager
|
|||||||
|
|
||||||
publish_to: 'none'
|
publish_to: 'none'
|
||||||
|
|
||||||
version: 1.14.0+101400000
|
version: 1.14.1+101400100
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.0 <4.0.0'
|
sdk: '>=3.0.0 <4.0.0'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user