Skip to content

Commit 3e805ef

Browse files
authored
Merge pull request #220 from dexsper/master
Minor bug fixes
2 parents 624055a + c84f677 commit 3e805ef

3 files changed

Lines changed: 34 additions & 23 deletions

File tree

lib/main.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
4949

5050
/// Checks if the app is running on an emulator/simulator
5151
Future<bool> _isRunningOnEmulator() async {
52+
if (kDebugMode) return false;
5253
if (kIsWeb) return false;
5354
if (!Platform.isAndroid && !Platform.isIOS) return false;
5455

@@ -127,14 +128,10 @@ class _EmulatorWarningScreen extends StatelessWidget {
127128
void main() async {
128129
WidgetsFlutterBinding.ensureInitialized();
129130

130-
// Check if running on emulator (mobile only)
131-
if (!kIsWeb && (Platform.isAndroid || Platform.isIOS)) {
132-
final isEmulator = await _isRunningOnEmulator();
133-
if (isEmulator) {
134-
// Show emulator warning and don't load the actual app
135-
runApp(const _EmulatorWarningScreen());
136-
return;
137-
}
131+
final isEmulator = await _isRunningOnEmulator();
132+
if (isEmulator) {
133+
runApp(const _EmulatorWarningScreen());
134+
return;
138135
}
139136

140137
JustAudioMediaKit.ensureInitialized(linux: true, windows: false);

lib/screens/now_playing_screen.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,18 @@ class _NowPlayingScreenState extends State<NowPlayingScreen>
135135

136136
void _onHorizontalDragStart(DragStartDetails details) {
137137
if (_showLyrics || _isSwipeAnimating) return;
138+
139+
if (!kIsWeb && Platform.isAndroid) {
140+
final mediaQuery = MediaQuery.of(context);
141+
final sysInsets = mediaQuery.systemGestureInsets;
142+
final screenWidth = mediaQuery.size.width;
143+
const kEdgeBuffer = 8.0;
144+
final dx = details.globalPosition.dx;
145+
final inLeftZone = dx < sysInsets.left + kEdgeBuffer;
146+
final inRightZone = dx > screenWidth - sysInsets.right - kEdgeBuffer;
147+
if (inLeftZone || inRightZone) return;
148+
}
149+
138150
_isHorizontalDragging = true;
139151
_hasTriggeredHaptic = false;
140152
}

lib/services/subsonic_service.dart

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ class SubsonicService {
169169
}
170170

171171
HttpClient createClient() {
172+
HttpClient buildClient(SecurityContext context) {
173+
return HttpOverrides.runWithHttpOverrides(() {
174+
final client = HttpClient(context: context);
175+
client.connectionTimeout = const Duration(seconds: 15);
176+
client.idleTimeout = const Duration(seconds: 15);
177+
if (allowSelfSigned) {
178+
client.badCertificateCallback = (cert, host, port) => true;
179+
}
180+
return client;
181+
}, _RealHttpOverrides());
182+
}
183+
172184
try {
173185
final context = SecurityContext(withTrustedRoots: true);
174186

@@ -185,23 +197,10 @@ class SubsonicService {
185197
context.usePrivateKeyBytes(clientCertBytes, password: password);
186198
}
187199

188-
final client = HttpClient(context: context);
189-
client.connectionTimeout = const Duration(seconds: 15);
190-
client.idleTimeout = const Duration(seconds: 15);
191-
if (allowSelfSigned) {
192-
client.badCertificateCallback = (cert, host, port) => true;
193-
}
194-
return client;
200+
return buildClient(context);
195201
} catch (e) {
196202
debugPrint('Failed to configure TLS: $e');
197-
198-
final client = HttpClient();
199-
client.connectionTimeout = const Duration(seconds: 15);
200-
client.idleTimeout = const Duration(seconds: 15);
201-
if (allowSelfSigned) {
202-
client.badCertificateCallback = (cert, host, port) => true;
203-
}
204-
return client;
203+
return buildClient(SecurityContext(withTrustedRoots: true));
205204
}
206205
}
207206

@@ -1111,3 +1110,6 @@ class _TlsHttpOverrides extends HttpOverrides {
11111110
@override
11121111
HttpClient createHttpClient(SecurityContext? context) => _factory();
11131112
}
1113+
1114+
/// Bypasses [HttpOverrides.global] to create a real [HttpClient].
1115+
class _RealHttpOverrides extends HttpOverrides {}

0 commit comments

Comments
 (0)