Skip to content
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
6 changes: 5 additions & 1 deletion app/lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -9762,5 +9762,9 @@
"example": "1.5h, 2.0h"
}
}
},
"deviceDoesNotSupportWifiSwitchingToBle": "Device does not support WiFi sync, switching to Bluetooth",
"@deviceDoesNotSupportWifiSwitchingToBle": {
"description": "Message shown when WiFi sync fails because device hardware does not support WiFi, automatically falling back to Bluetooth transfer"
}
}
}
6 changes: 6 additions & 0 deletions app/lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14516,6 +14516,12 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Large time gaps detected ({gaps})'**
String largeTimeGapsDetected(String gaps);

/// Message shown when WiFi sync fails because device hardware does not support WiFi, automatically falling back to Bluetooth transfer
///
/// In en, this message translates to:
/// **'Device does not support WiFi sync, switching to Bluetooth'**
String get deviceDoesNotSupportWifiSwitchingToBle;
}

class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
Expand Down
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7731,4 +7731,7 @@ class AppLocalizationsAr extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'تم اكتشاف فجوات زمنية كبيرة ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_bg.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7818,4 +7818,7 @@ class AppLocalizationsBg extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Открити са големи времеви разлики ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ca.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7834,4 +7834,7 @@ class AppLocalizationsCa extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'S\'han detectat grans intervals de temps ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_cs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7781,4 +7781,7 @@ class AppLocalizationsCs extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Zjištěny velké časové mezery ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_da.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7770,4 +7770,7 @@ class AppLocalizationsDa extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Store tidsgab opdaget ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7852,4 +7852,7 @@ class AppLocalizationsDe extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Große Zeitlücken erkannt ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_el.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7843,4 +7843,7 @@ class AppLocalizationsEl extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Εντοπίστηκαν μεγάλα χρονικά κενά ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7784,4 +7784,7 @@ class AppLocalizationsEn extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Large time gaps detected ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_es.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7800,4 +7800,7 @@ class AppLocalizationsEs extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Se detectaron brechas de tiempo grandes ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_et.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7786,4 +7786,7 @@ class AppLocalizationsEt extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Tuvastati suured ajavahed ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_fi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7785,4 +7785,7 @@ class AppLocalizationsFi extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Havaittu suuria aikavälejä ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_fr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7858,4 +7858,7 @@ class AppLocalizationsFr extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Grands écarts de temps détectés ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_hi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7766,4 +7766,7 @@ class AppLocalizationsHi extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'बड़े समय अंतराल पाए गए ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_hu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7823,4 +7823,7 @@ class AppLocalizationsHu extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Nagy időeltérések észlelve ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_id.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7798,4 +7798,7 @@ class AppLocalizationsId extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Terdeteksi jeda waktu besar ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_it.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7835,4 +7835,7 @@ class AppLocalizationsIt extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Rilevati grandi divari temporali ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ja.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7653,4 +7653,7 @@ class AppLocalizationsJa extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return '大きな時間差が検出されました ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ko.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7655,4 +7655,7 @@ class AppLocalizationsKo extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return '큰 시간 간격들이 감지되었습니다 ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_lt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7791,4 +7791,7 @@ class AppLocalizationsLt extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Aptikti dideli laiko tarpai ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_lv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7804,4 +7804,7 @@ class AppLocalizationsLv extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Konstatētas lielas laika starpības ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7809,4 +7809,7 @@ class AppLocalizationsMs extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Jurang masa besar dikesan ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_nl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7811,4 +7811,7 @@ class AppLocalizationsNl extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Grote tijdsverschillen gedetecteerd ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_no.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7782,4 +7782,7 @@ class AppLocalizationsNo extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Store tidsluker oppdaget ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_pl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7804,4 +7804,7 @@ class AppLocalizationsPl extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Wykryto duże przerwy czasowe ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_pt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7786,4 +7786,7 @@ class AppLocalizationsPt extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Grandes intervalos de tempo detetados ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ro.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7824,4 +7824,7 @@ class AppLocalizationsRo extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Au fost detectate diferențe mari de timp ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_ru.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7811,4 +7811,7 @@ class AppLocalizationsRu extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Обнаружены большие временные разрывы ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_sk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7776,4 +7776,7 @@ class AppLocalizationsSk extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Zistené veľké časové medzery ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_sv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7792,4 +7792,7 @@ class AppLocalizationsSv extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Stora tidsgap upptäckta ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_th.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7749,4 +7749,7 @@ class AppLocalizationsTh extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'ตรวจพบช่วงเวลาห่างมากหลายช่วง ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_tr.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7799,4 +7799,7 @@ class AppLocalizationsTr extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Büyük zaman farkları tespit edildi ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_uk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7798,4 +7798,7 @@ class AppLocalizationsUk extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Виявлено великі часові розриви ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_vi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7789,4 +7789,7 @@ class AppLocalizationsVi extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return 'Phát hiện các khoảng cách thời gian lớn ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
3 changes: 3 additions & 0 deletions app/lib/l10n/app_localizations_zh.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7643,4 +7643,7 @@ class AppLocalizationsZh extends AppLocalizations {
String largeTimeGapsDetected(String gaps) {
return '检测到多个较大时间间隔 ($gaps)';
}

@override
String get deviceDoesNotSupportWifiSwitchingToBle => 'Device does not support WiFi sync, switching to Bluetooth';
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import 'package:omi/models/playback_state.dart';
import 'package:omi/pages/conversations/sync_widgets/fast_transfer_suggestion_dialog.dart';
import 'package:omi/pages/conversations/sync_widgets/location_permission_dialog.dart';
import 'package:omi/providers/sync_provider.dart';
import 'package:omi/services/devices/wifi_sync_error.dart';
import 'package:omi/services/services.dart';
import 'package:omi/services/wals.dart';
import 'package:omi/services/wifi/wifi_network_service.dart';
import 'package:omi/ui/molecules/omi_confirm_dialog.dart';
import 'package:omi/pages/conversations/sync_widgets/wifi_connection_sheet.dart';
import 'package:omi/utils/device.dart';
Expand Down Expand Up @@ -535,7 +537,18 @@ class _WalItemDetailPageState extends State<WalItemDetailPage> {
final preferredMethod = SharedPreferencesUtil().preferredSyncMethod;
final wifiSupported = await ServiceManager.instance().wal.getSyncs().sdcard.isWifiSyncSupported();

if (preferredMethod == 'ble' && wifiSupported && widget.wal.storage == WalStorage.sdcard) {
bool wifiHardwareAvailable = false;
if (wifiSupported && widget.wal.storage == WalStorage.sdcard) {
wifiHardwareAvailable = await _checkWifiHardwareAvailable();
if (!wifiHardwareAvailable && preferredMethod == 'wifi') {
SharedPreferencesUtil().preferredSyncMethod = 'ble';
if (mounted) {
_showSnackBar(context.l10n.deviceDoesNotSupportWifiSwitchingToBle, Colors.orange);
}
}
}

if (preferredMethod == 'ble' && wifiHardwareAvailable && widget.wal.storage == WalStorage.sdcard) {
if (!mounted) return;
final result = await FastTransferSuggestionDialog.show(context);
if (result == null) return;
Expand All @@ -550,7 +563,7 @@ class _WalItemDetailPageState extends State<WalItemDetailPage> {

final currentMethod = SharedPreferencesUtil().preferredSyncMethod;
if (Platform.isIOS && widget.wal.storage == WalStorage.sdcard) {
if (currentMethod == 'wifi' && wifiSupported) {
if (currentMethod == 'wifi' && wifiHardwareAvailable) {
if (!mounted) return;
final hasPermission = await LocationPermissionHelper.checkAndRequest(context);
if (!hasPermission) {
Expand All @@ -564,13 +577,12 @@ class _WalItemDetailPageState extends State<WalItemDetailPage> {
try {
final syncProvider = context.read<SyncProvider>();
final currentMethod = SharedPreferencesUtil().preferredSyncMethod;
final wifiSupported = await ServiceManager.instance().wal.getSyncs().sdcard.isWifiSyncSupported();

// Show WiFi connection sheet if using WiFi for SD card transfer
if (currentMethod == 'wifi' && wifiSupported && widget.wal.storage == WalStorage.sdcard && mounted) {
if (currentMethod == 'wifi' && wifiHardwareAvailable && widget.wal.storage == WalStorage.sdcard && mounted) {
WifiConnectionListenerBridge? listener;

final controller = await WifiConnectionSheet.show(
final sheetController = await WifiConnectionSheet.show(
context,
deviceName: 'Omi',
onCancel: () {
Expand All @@ -583,7 +595,7 @@ class _WalItemDetailPageState extends State<WalItemDetailPage> {
},
);

listener = WifiConnectionListenerBridge(controller);
listener = WifiConnectionListenerBridge(sheetController);
await syncProvider.transferWalToPhone(widget.wal, connectionListener: listener);
} else {
await syncProvider.transferWalToPhone(widget.wal);
Expand All @@ -600,6 +612,33 @@ class _WalItemDetailPageState extends State<WalItemDetailPage> {
}
}

Future<bool> _checkWifiHardwareAvailable() async {
try {
final connection = await ServiceManager.instance().device.ensureConnection(widget.wal.device);
if (connection == null) {
return true;
}

final ssid = WifiNetworkService.generateSsid(widget.wal.device);
final password = WifiNetworkService.generatePassword(widget.wal.device);

final result = await connection.setupWifiSync(ssid, password);

if (!result.success && result.errorCode == WifiSyncErrorCode.wifiHardwareNotAvailable) {
return false;
}

if (result.success) {
await connection.stopWifiSync();
}

return true;
} catch (e) {
debugPrint('Error checking WiFi hardware: $e');
return true;
}
}

void _handleCancelTransfer() {
final syncProvider = context.read<SyncProvider>();
syncProvider.cancelSync();
Expand Down
Loading