Skip to content

Commit

Permalink
Resolve all lint issues + enable lint action
Browse files Browse the repository at this point in the history
  • Loading branch information
Codel1417 committed Apr 5, 2024
1 parent 9ac64da commit 724b90c
Show file tree
Hide file tree
Showing 43 changed files with 443 additions and 397 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build_apk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,26 @@ concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
static_analysis:
name: Build Android Artifact
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.19.2'
cache: true
- name: Run build script
id: build
run: bash ${GITHUB_WORKSPACE}/Scripts/build.sh
working-directory: Scripts
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
SKIP_BUILD: true # Checks if it exists, not the value
- name: Analyze Dart
uses: zgosalvez/github-actions-analyze-dart@v2
build_android:
name: Build Android Artifact
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_ios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Generate localizations
run: flutter gen-l10n
- name: Generate configs
run: dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intnDefs.dart lib/l10n/*.arb && flutter pub run build_runner build --delete-conflicting-outputs
run: dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb && flutter pub run build_runner build --delete-conflicting-outputs
- name: Build app
run: flutter build ipa --release --no-codesign
- name: Upload debug symbols
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/localization_strings_update.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
paths:
- 'lib/Frontend/intnDefs.dart'
- 'lib/Frontend/intn_defs.dart'
jobs:
build_android:
name: Update Localization Files
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install packages
run: flutter config --no-cli-animations && flutter pub get
- name: Generate intl_translation
run: dart run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/intnDefs.dart
run: dart run intl_translation:extract_to_arb --locale=en --output-file='./lib/l10n/messages_en.arb' ./lib/Frontend/intn_defs.dart
- name: Stage Changes
run: git config user.email "github-actions[bot]@users.noreply.github.com" && git config user.name "github-actions[bot]" && git commit -am "Update EN language file"
- name: Push changes
Expand Down
17 changes: 17 additions & 0 deletions .run/Generate l10n.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Generate l10n" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="flutter gen-l10n &amp;&amp; dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>
17 changes: 17 additions & 0 deletions .run/Run Dart Generator.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Dart Generator" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="flutter pub run build_runner build --delete-conflicting-outputs" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs />
<method v="2" />
</configuration>
</component>
19 changes: 11 additions & 8 deletions Scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/usr/bin/env bash
set -e
set -x
# We want to be in the project root folder, not the scripts folder
if [[ "$(pwd)" == *"/Scripts" ]]; then
cd ..
fi
VERSION="$(cat VERSION)"
BUILD_NUMBER="$(git rev-list HEAD --count)"
# Gets the release tag from github if it exists (Github Actions)
# Assumes tags start with V
if [[ -v RELEASE_TAG ]] && [[ -n $RELEASE_TAG ]]; then
TAG="${RELEASE_TAG,,}"
Expand All @@ -14,12 +16,13 @@ fi
flutter config --no-cli-animations
flutter pub get
flutter gen-l10n
dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intnDefs.dart lib/l10n/*.arb
dart run intl_translation:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/Frontend/intn_defs.dart lib/l10n/*.arb
flutter pub run build_runner build --delete-conflicting-outputs
flutter build apk --split-per-abi --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION"
flutter build appbundle --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION"
if [[ -v GITHUB_OUTPUT ]]; then
echo "SENTRY_DIST=$BUILD_NUMBER" >> "$GITHUB_OUTPUT"
echo "SENTRY_RELEASE=$VERSION" >> "$GITHUB_OUTPUT"
fi
echo
if [[ -v SKIP_BUILD ]]; then
flutter build apk --split-per-abi --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION"
flutter build appbundle --split-debug-info=./symbols --build-number="$BUILD_NUMBER" --build-name="$VERSION"
if [[ -v GITHUB_OUTPUT ]]; then
echo "SENTRY_DIST=$BUILD_NUMBER" >> "$GITHUB_OUTPUT"
echo "SENTRY_RELEASE=$VERSION" >> "$GITHUB_OUTPUT"
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:tail_app/Backend/Sensors.dart';
import 'package:tail_app/Backend/sensors.dart';
import 'package:tail_app/main.dart';
import 'package:wakelock_plus/wakelock_plus.dart';

import '../../constants.dart';
import '../AutoMove.dart';
import '../Definitions/Device/BaseDeviceDefinition.dart';
import '../DeviceRegistry.dart';
import '../FirmwareUpdate.dart';
import 'btMessage.dart';
import '../Definitions/Device/device_definition.dart';
import '../auto_move.dart';
import '../device_registry.dart';
import '../firmware_update.dart';
import 'bluetooth_message.dart';

part 'BluetoothManager.g.dart';
part 'bluetooth_manager.g.dart';

final log.Logger bluetoothLog = log.Logger('Bluetooth');

@Riverpod(dependencies: [reactiveBLE, KnownDevices])
@riverpod
Stream<DiscoveredDevice> scanForDevices(ScanForDevicesRef ref) {
bluetoothLog.fine("Starting scan");
final FlutterReactiveBle bluetoothManagerRef = ref.watch(reactiveBLEProvider);
Expand Down Expand Up @@ -202,7 +202,7 @@ class KnownDevices extends _$KnownDevices {
statefulDevice.commandQueue.addCommand(BluetoothMessage(message: "VER", device: statefulDevice, priority: Priority.low, type: Type.system));
statefulDevice.commandQueue.addCommand(BluetoothMessage(message: "HWVER", device: statefulDevice, priority: Priority.low, type: Type.system));
if (statefulDevice.baseStoredDevice.autoMove) {
ChangeAutoMove(statefulDevice);
changeAutoMove(statefulDevice);
}
}
},
Expand All @@ -219,12 +219,14 @@ class KnownDevices extends _$KnownDevices {
}
}

@Riverpod(keepAlive: true, dependencies: [reactiveBLE])
@Riverpod(
keepAlive: true,
)
Stream<BleStatus> btStatus(BtStatusRef ref) {
return ref.read(reactiveBLEProvider).statusStream;
}

@Riverpod(keepAlive: true, dependencies: [reactiveBLE, KnownDevices, TriggerList])
@Riverpod(keepAlive: true)
StreamSubscription<ConnectionStateUpdate> btConnectStateHandler(BtConnectStateHandlerRef ref) {
return ref.read(reactiveBLEProvider).connectedDeviceStream.listen((ConnectionStateUpdate event) async {
bluetoothLog.info("ConnectedDevice::$event");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:core';

import 'package:tail_app/Backend/Definitions/Device/BaseDeviceDefinition.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';

enum Priority { low, normal, high }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import 'package:hive/hive.dart';
import 'package:tail_app/Frontend/intnDefs.dart';
import 'package:tail_app/Frontend/intn_defs.dart';

import '../Device/BaseDeviceDefinition.dart';
import '../Device/device_definition.dart';

part 'BaseAction.g.dart';
part 'base_action.g.dart';

@HiveType(typeId: 7)
enum ActionCategory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import 'package:flutter/material.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:hive/hive.dart';
import 'package:tail_app/Backend/Bluetooth/BluetoothManager.dart';
import 'package:tail_app/Backend/FirmwareUpdate.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_manager.dart';
import 'package:tail_app/Backend/firmware_update.dart';

import '../../../Frontend/intnDefs.dart';
import '../../../Frontend/intn_defs.dart';

part 'BaseDeviceDefinition.g.dart';
part 'device_definition.g.dart';

@HiveType(typeId: 6)
enum DeviceType {
Expand Down Expand Up @@ -219,8 +219,8 @@ class BaseStoredDevice {
}
}

String getNameFromBTName(String BTName) {
switch (BTName) {
String getNameFromBTName(String bluetoothDeviceName) {
switch (bluetoothDeviceName) {
case 'EarGear':
return 'EarGear';
case 'EG2':
Expand All @@ -234,5 +234,5 @@ String getNameFromBTName(String BTName) {
case '(!)Tail1':
return 'DigiTail';
}
return BTName;
return bluetoothDeviceName;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'package:hive/hive.dart';
import 'package:logging_flutter/logging_flutter.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:tail_app/Backend/moveLists.dart';
import 'package:tail_app/Backend/move_lists.dart';

import '../constants.dart';
import 'Bluetooth/BluetoothManager.dart';
import 'Definitions/Action/BaseAction.dart';
import 'Definitions/Device/BaseDeviceDefinition.dart';
import 'Bluetooth/bluetooth_manager.dart';
import 'Definitions/Action/base_action.dart';
import 'Definitions/Device/device_definition.dart';

part 'ActionRegistry.g.dart';
part 'action_registry.g.dart';

@immutable
class ActionRegistry {
Expand Down Expand Up @@ -135,7 +135,7 @@ class ActionRegistry {
};
}

@Riverpod(dependencies: [KnownDevices], keepAlive: false)
@Riverpod(keepAlive: false)
Map<ActionCategory, Set<BaseAction>> getAvailableActions(GetAvailableActionsRef ref) {
Map<String, BaseStatefulDevice> knownDevices = ref.watch(knownDevicesProvider);
Map<ActionCategory, Set<BaseAction>> sortedActions = {};
Expand All @@ -160,7 +160,7 @@ Map<ActionCategory, Set<BaseAction>> getAvailableActions(GetAvailableActionsRef
return sortedActions;
}

@Riverpod(dependencies: [KnownDevices])
@riverpod
Map<ActionCategory, Set<BaseAction>> getAllActions(GetAllActionsRef ref, Set<DeviceType> deviceType) {
Map<ActionCategory, Set<BaseAction>> sortedActions = {};
for (BaseAction baseAction in List.from(ActionRegistry.allCommands)..addAll(ref.read(moveListsProvider))) {
Expand Down
6 changes: 3 additions & 3 deletions lib/Backend/AutoMove.dart → lib/Backend/auto_move.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:tail_app/Backend/Bluetooth/btMessage.dart';
import 'package:tail_app/Backend/Definitions/Device/BaseDeviceDefinition.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';

void ChangeAutoMove(BaseStatefulDevice device) {
void changeAutoMove(BaseStatefulDevice device) {
String cmd = '';
if (device.baseDeviceDefinition.deviceType == DeviceType.ears) {
if (device.baseStoredDevice.autoMove) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:logging_flutter/logging_flutter.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:tail_app/Backend/Bluetooth/BluetoothManager.dart';
import 'package:tail_app/Backend/Definitions/Action/BaseAction.dart';
import 'package:tail_app/Backend/Definitions/Device/BaseDeviceDefinition.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_manager.dart';
import 'package:tail_app/Backend/Definitions/Action/base_action.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';

part 'DeviceRegistry.g.dart';
part 'device_registry.g.dart';

@immutable
class DeviceRegistry {
Expand Down Expand Up @@ -94,7 +94,7 @@ class DeviceRegistry {
}
}

@Riverpod(dependencies: [KnownDevices])
@Riverpod()
Set<BaseStatefulDevice> getByAction(GetByActionRef ref, BaseAction baseAction) {
Flogger.i("Getting devices for action::$baseAction");
Set<BaseStatefulDevice> foundDevices = {};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:json_annotation/json_annotation.dart';

part 'FirmwareUpdate.g.dart';
part 'firmware_update.g.dart';

@JsonSerializable()
class FWInfo {
Expand Down
10 changes: 5 additions & 5 deletions lib/Backend/moveLists.dart → lib/Backend/move_lists.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import 'package:hive/hive.dart';
import 'package:logging_flutter/logging_flutter.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:tail_app/Backend/Bluetooth/btMessage.dart';
import 'package:tail_app/Backend/Definitions/Action/BaseAction.dart';
import 'package:tail_app/Backend/Definitions/Device/BaseDeviceDefinition.dart';
import 'package:tail_app/Frontend/intnDefs.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart';
import 'package:tail_app/Backend/Definitions/Action/base_action.dart';
import 'package:tail_app/Backend/Definitions/Device/device_definition.dart';
import 'package:tail_app/Frontend/intn_defs.dart';

import '../main.dart';

part 'moveLists.g.dart';
part 'move_lists.g.dart';

@HiveType(typeId: 10)
enum EasingType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import 'package:install_referrer/install_referrer.dart';
import 'package:plausible_analytics/plausible_analytics.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:tail_app/Backend/moveLists.dart';
import 'package:tail_app/Backend/move_lists.dart';

import '../constants.dart';
import '../main.dart';
import 'Definitions/Device/BaseDeviceDefinition.dart';
import 'Sensors.dart';
import 'Definitions/Device/device_definition.dart';
import 'sensors.dart';

class PlausibleDio extends Plausible {
PlausibleDio(super.serverUrl, super.domain);
Expand Down
22 changes: 12 additions & 10 deletions lib/Backend/Sensors.dart → lib/Backend/sensors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ import 'package:proximity_sensor/proximity_sensor.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:sentry_hive/sentry_hive.dart';
import 'package:shake/shake.dart';
import 'package:tail_app/Backend/ActionRegistry.dart';
import 'package:tail_app/Backend/Bluetooth/btMessage.dart';
import 'package:tail_app/Backend/Bluetooth/bluetooth_message.dart';
import 'package:tail_app/Backend/action_registry.dart';

import '../Frontend/intnDefs.dart';
import '../Frontend/intn_defs.dart';
import '../constants.dart';
import 'Bluetooth/BluetoothManager.dart';
import 'Definitions/Action/BaseAction.dart';
import 'Definitions/Device/BaseDeviceDefinition.dart';
import 'DeviceRegistry.dart';
import 'moveLists.dart';
import 'Bluetooth/bluetooth_manager.dart';
import 'Definitions/Action/base_action.dart';
import 'Definitions/Device/device_definition.dart';
import 'device_registry.dart';
import 'move_lists.dart';

part 'Sensors.g.dart';
part 'sensors.g.dart';

@HiveType(typeId: 2)
class Trigger extends ChangeNotifier {
Expand Down Expand Up @@ -556,7 +556,9 @@ class TriggerAction {
int get hashCode => uuid.hashCode;
}

@Riverpod(keepAlive: true, dependencies: [TriggerDefinitionList])
@Riverpod(
keepAlive: true,
)
class TriggerList extends _$TriggerList {
@override
List<Trigger> build() {
Expand Down
Loading

0 comments on commit 724b90c

Please sign in to comment.