Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Blueberry ring #249

Merged
merged 3 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
Expand Down
8 changes: 2 additions & 6 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<key>BGTaskSchedulerPermittedIdentifiers</key>
<array>
<string>com.transistorsoft.fetch</string>
<string>com.mxc.axswallet.periodicalTasks</string>
<string>com.mxc.axswallet.dappHooksTasks</string>
<string>com.mxc.axswallet.notificationsTask</string>
<string>com.mxc.axswallet.wifiHooksTask</string>
<string>com.mxc.axswallet.minerAutoClaimTask</string>
</array>
<key>CADisableMinimumFrameDurationOnPhone</key>
Expand Down Expand Up @@ -103,13 +103,10 @@
<string>AXS Wallet needs access to your Biometric data when the app is in use for authentication only. Your Biometric data is not saved or shared with any third parties.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>AXS Wallet needs access to your location for features such as Wi-Fi hooks while the app is in use or running in the background. Your location data is not saved or shared with any third parties.</string>

<key>NSLocationAlwaysUsageDescription</key>
<string>AXS Wallet requires access to your location at all times for services such as Wi-Fi hooks. Your location data is not saved or shared with any third parties.</string>

<key>NSLocationUsageDescription</key>
<string>AXS Wallet needs access to your location to provide services such as Wi-Fi hooks. Your location data is not saved or shared with any third parties.</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>AXS Wallet needs access to your location when the app is in use for services such as Wi-Fi hooks. Your location data is not saved or shared with any third parties.</string>
<key>NSMotionUsageDescription</key>
Expand All @@ -124,7 +121,6 @@
<string>Would you allow AXS Wallet to use the Notification?</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>AXS Wallet needs access to your Bluetooth when the app is in use or running in the background for services such as BluberryRing. Blutooth data is not saved or shared with any third parties.</string>

<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UIBackgroundModes</key>
Expand Down
6 changes: 3 additions & 3 deletions lib/core/src/background_process/axs_background_fetch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ class AXSBackgroundFetch {
}

static void handleCallBackDispatcher(String taskId) async {
if (taskId == BackgroundExecutionConfig.axsPeriodicalTask) {
if (taskId == BackgroundExecutionConfig.notificationsTask) {
NotificationsService.notificationsCallbackDispatcher(taskId);
} else if (taskId == BackgroundExecutionConfig.dappHookTasks) {
} else if (taskId == BackgroundExecutionConfig.wifiHooksTask) {
DAppHooksService.dappHooksServiceCallBackDispatcherForeground(taskId);
} else if (taskId == BackgroundExecutionConfig.minerAutoClaimTask) {
DAppHooksService.autoClaimServiceCallBackDispatcherForeground(taskId);
Expand All @@ -40,7 +40,7 @@ class AXSBackgroundFetch {

static bool turnOffAll(
DAppHooksModel dAppHooksData, PeriodicalCallData periodicalCallData) {
return !dAppHooksData.enabled &&
return !dAppHooksData.wifiHooks.enabled &&
!periodicalCallData.serviceEnabled &&
!dAppHooksData.minerHooks.enabled;
}
Expand Down
12 changes: 5 additions & 7 deletions lib/core/src/background_process/dapp_hooks_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ class DAppHooksService {

final isLoggedIn = authUseCase.loggedIn;
final account = accountUseCase.account.value;
final serviceEnabled = dappHooksData.enabled;
final wifiHooksEnabled = dappHooksData.wifiHooks.enabled;

// Make sure user is logged in
if (isLoggedIn && MXCChains.isMXCChains(chainId) && serviceEnabled) {
if (isLoggedIn && MXCChains.isMXCChains(chainId) && wifiHooksEnabled) {
await AXSNotification()
.setupFlutterNotifications(shouldInitFirebase: false);
await contextLessTranslationUseCase.setupTranslator();

if (wifiHooksEnabled) {
await dAppHooksUseCase.sendWifiInfo(
account!,
);
}
await dAppHooksUseCase.sendWifiInfo(
account!,
);

BackgroundFetch.finish(taskId);
} else {
// terminate background fetch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -884,8 +884,9 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {

final uInt8List = Uint8List.fromList(value);

collectLog('characteristicValueStreamSubscription:value $value');
collectLog('characteristicValueStreamSubscription:uInt8List ${uInt8List.toString()}');
collectLog('characteristicValueStreamSubscription:value $value');
collectLog(
'characteristicValueStreamSubscription:uInt8List ${uInt8List.toString()}');

return uInt8List;
}
Expand All @@ -906,7 +907,8 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
final uInt8List = Uint8List.fromList(event);
print(uInt8List);
collectLog('characteristicValueStreamSubscription:event $event');
collectLog('characteristicValueStreamSubscription:uInt8List ${uInt8List.toString()}');
collectLog(
'characteristicValueStreamSubscription:uInt8List ${uInt8List.toString()}');
final script = '''
navigator.bluetooth.updateCharacteristicValue('${characteristic.uuid.str}', ${uInt8List.toString()},);
''';
Expand All @@ -932,7 +934,7 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
await state.webviewController!.injectJavascriptFileFromAsset(
assetFilePath: 'assets/js/bluetooth/bluetooth.js');

// There is a gap for detecting the axs object in webview, It's intermittent after adding function structure to the scripts
// There is a gap for detecting the axs object in webview, It's intermittent after adding function structure to the scripts
Future.delayed(
const Duration(milliseconds: 500),
() async {
Expand Down
97 changes: 15 additions & 82 deletions lib/features/settings/subfeatures/dapp_hooks/dapp_hooks_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ class DAppHooksPage extends HookConsumerWidget {
final dappHooksPresenter = ref.read(presenter);

final frequency = getPeriodicalCallDurationFromInt(
dappHooksState.dAppHooksData!.duration);
dappHooksState.dAppHooksData!.wifiHooks.duration);

final isMXCChains = MXCChains.isMXCChains(dappHooksState.network!.chainId);
final dappHooksServiceServiceEnabled =
dappHooksState.dAppHooksData!.enabled;

final isSettingsChangeEnabled =
isMXCChains && dappHooksServiceServiceEnabled;

final minerAutoClaimDateTime =
dappHooksState.dAppHooksData!.minerHooks.time;
Expand All @@ -52,9 +47,10 @@ class DAppHooksPage extends HookConsumerWidget {
),
children: [
MXCSwitchRowItem(
title: translate('dapp_hooks'),
value: dappHooksState.dAppHooksData!.enabled,
onChanged: dappHooksPresenter.changeDAppHooksEnabled,
key: const Key('wifiHookSwitch'),
title: translate('wifi_hexagon_location_hooks'),
value: dappHooksState.dAppHooksData!.wifiHooks.enabled,
onChanged: dappHooksPresenter.changeWiFiHooksEnabled,
enabled: true,
textTrailingWidget: MXCInformationButton(texts: [
TextSpan(
Expand Down Expand Up @@ -94,6 +90,13 @@ class DAppHooksPage extends HookConsumerWidget {
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text: FlutterI18n.translate(context, 'wifi_hooks_solutions'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text: FlutterI18n.translate(context, 'need_further_assistant'),
style: FontTheme.of(context)
Expand All @@ -105,80 +108,10 @@ class DAppHooksPage extends HookConsumerWidget {
),
const SizedBox(height: Sizes.spaceNormal),
MXCDropDown(
key: const Key('dappHooksFrequencyDropDown'),
onTap: dappHooksPresenter.showDAppHooksFrequency,
key: const Key('wifiHooksFrequencyDropDown'),
onTap: dappHooksPresenter.showWiFiHooksFrequency,
selectedItem: frequency.toStringFormatted(),
enabled:
isSettingsChangeEnabled && dappHooksState.dAppHooksData!.enabled,
),
const SizedBox(height: Sizes.spaceXLarge),
Padding(
padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceLarge),
child: Column(
children: [
MXCSwitchRowItem(
key: const Key('wifiHookSwitch'),
title: translate('wifi_hexagon_location_hooks'),
value: dappHooksState.dAppHooksData!.wifiHooks.enabled,
onChanged: dappHooksPresenter.changeWifiHooksEnabled,
enabled: isSettingsChangeEnabled,
textTrailingWidget: MXCInformationButton(texts: [
TextSpan(
text: FlutterI18n.translate(context, 'experiencing_issues'),
style: FontTheme.of(context)
.subtitle2()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text: FlutterI18n.translate(
context, 'background_service_solution_1_title'),
style: FontTheme.of(context)
.subtitle2()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
TextSpan(
text: FlutterI18n.translate(
context, 'background_service_solution_1_text'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text: FlutterI18n.translate(
context, 'background_service_solution_2_title'),
style: FontTheme.of(context)
.subtitle2()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
TextSpan(
text: FlutterI18n.translate(
context, 'background_service_solution_2_text'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text:
FlutterI18n.translate(context, 'wifi_hooks_solutions'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
const TextSpan(text: '\n\n'),
TextSpan(
text: FlutterI18n.translate(
context, 'need_further_assistant'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).textPrimary),
),
]),
),
],
),
enabled: isMXCChains,
),
const SizedBox(height: Sizes.spaceLarge),
MXCSwitchRowItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:geolocator/geolocator.dart' as geo;
import 'package:mxc_logic/mxc_logic.dart';

import 'dapp_hooks_state.dart';
import 'widgets/dapp_hooks_frequency_dialog.dart';
import 'widgets/wifi_hooks_frequency_bottom_sheet.dart';

final notificationsContainer =
PresenterContainer<DAppHooksPresenter, DAppHooksState>(
Expand Down Expand Up @@ -39,18 +39,19 @@ class DAppHooksPresenter extends CompletePresenter<DAppHooksState>
backgroundFetchConfigUseCase: _backgroundFetchConfigUseCase);

WiFiHooksHelper get wifiHooksHelper => WiFiHooksHelper(
translate: translate,
context: context,
dAppHooksUseCase: _dAppHooksUseCase,
state: state,
geoLocatorPlatform: _geoLocatorPlatform);
translate: translate,
context: context,
dAppHooksUseCase: _dAppHooksUseCase,
state: state,
geoLocatorPlatform: _geoLocatorPlatform,
backgroundFetchConfigUseCase: _backgroundFetchConfigUseCase,
);

DAppHooksHelper get dappHooksHelper => DAppHooksHelper(
translate: translate,
context: context,
dAppHooksUseCase: _dAppHooksUseCase,
state: state,
backgroundFetchConfigUseCase: _backgroundFetchConfigUseCase);
translate: translate,
context: context,
state: state,
);

@override
void initState() {
Expand All @@ -75,20 +76,17 @@ class DAppHooksPresenter extends CompletePresenter<DAppHooksState>
);
}

void changeDAppHooksEnabled(bool value) =>
dappHooksHelper.changeDAppHooksEnabled(value);

void changeWifiHooksEnabled(bool value) =>
wifiHooksHelper.changeWifiHooksEnabled(value);
void changeWiFiHooksEnabled(bool value) =>
wifiHooksHelper.changeWiFiHooksEnabled(value);

void changeMinerHooksEnabled(bool value) =>
minerHooksHelper.changeMinerHooksEnabled(value);

void showDAppHooksFrequency() {
showDAppHooksFrequencyDialog(context!,
onTap: dappHooksHelper.handleFrequencyChange,
selectedFrequency:
getPeriodicalCallDurationFromInt(state.dAppHooksData!.duration));
void showWiFiHooksFrequency() {
showWiFiHooksFrequencyBottomSheet(context!,
onTap: wifiHooksHelper.handleFrequencyChange,
selectedFrequency: getPeriodicalCallDurationFromInt(
state.dAppHooksData!.wifiHooks.duration));
}

void showTimePickerDialog() async {
Expand Down
Loading
Loading