Skip to content

Commit 56949fa

Browse files
committed
- Fix apk updater
- Fix desktop updater - Fix header mobile app
1 parent 0611e0e commit 56949fa

4 files changed

Lines changed: 84 additions & 55 deletions

File tree

Lines changed: 24 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,38 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
xmlns:tools="http://schemas.android.com/tools"
3-
>
4-
<uses-permission android:name="android.permission.INTERNET" />
5-
<uses-permission android:name="android.permission.WAKE_LOCK" />
6-
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
7-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
8-
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
9-
10-
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
11-
<uses-permission android:name="android.permission.READ_MEDIA_VIDEOS" />
12-
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
13-
14-
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
2+
<uses-permission android:name="android.permission.INTERNET"/>
3+
<uses-permission android:name="android.permission.WAKE_LOCK"/>
4+
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
5+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
6+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC"/>
7+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES"/>
8+
<uses-permission android:name="android.permission.READ_MEDIA_VIDEOS"/>
9+
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO"/>
10+
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
1511
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
16-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/>
17-
12+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="29"/><!-- Permission required for installing APK updates -->
13+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES"/>
1814
<queries>
1915
<intent>
20-
<action android:name="android.intent.action.VIEW" />
21-
<category android:name="android.intent.category.BROWSABLE" />
22-
<data android:scheme="https" />
16+
<action android:name="android.intent.action.VIEW"/>
17+
<category android:name="android.intent.category.BROWSABLE"/>
18+
<data android:scheme="https"/>
2319
</intent>
2420
</queries>
25-
26-
<application
27-
android:label="Openlib"
28-
android:name="${applicationName}"
29-
android:requestLegacyExternalStorage="true"
30-
android:networkSecurityConfig="@xml/network_security_config"
31-
android:icon="@mipmap/launcher_icon"
32-
android:enableOnBackInvokedCallback="true">
33-
34-
<activity
35-
android:name=".MainActivity"
36-
android:exported="true"
37-
android:launchMode="singleTop"
38-
android:theme="@style/LaunchTheme"
39-
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
40-
android:hardwareAccelerated="true"
41-
android:windowSoftInputMode="adjustResize">
42-
<!-- Specifies an Android theme to apply to this Activity as soon as
21+
<application android:label="Openlib" android:name="${applicationName}" android:requestLegacyExternalStorage="true" android:networkSecurityConfig="@xml/network_security_config" android:icon="@mipmap/launcher_icon" android:enableOnBackInvokedCallback="true">
22+
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"><!-- Specifies an Android theme to apply to this Activity as soon as
4323
the Android process has started. This theme is visible to the user
4424
while the Flutter UI initializes. After that, this theme continues
4525
to determine the Window background behind the Flutter UI. -->
46-
47-
<meta-data
48-
android:name="io.flutter.embedding.android.NormalTheme"
49-
android:resource="@style/NormalTheme"
50-
/>
26+
<meta-data android:name="io.flutter.embedding.android.NormalTheme" android:resource="@style/NormalTheme"/>
5127
<intent-filter>
5228
<action android:name="android.intent.action.MAIN"/>
5329
<category android:name="android.intent.category.LAUNCHER"/>
5430
</intent-filter>
55-
</activity>
56-
<!-- Don't delete the meta-data below.
31+
</activity><!-- Don't delete the meta-data below.
5732
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
58-
<meta-data
59-
android:name="flutterEmbedding"
60-
android:value="2" />
33+
<meta-data android:name="flutterEmbedding" android:value="2"/><!-- FileProvider for sharing files and APK installation -->
34+
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
35+
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"/>
36+
</provider>
6137
</application>
62-
</manifest>
38+
</manifest>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths><!-- Provides access to external storage directory -->
3+
<external-path name="external_files" path="."/><!-- Provides access to files in the app's external files directory -->
4+
<external-files-path name="external_app_files" path="."/><!-- Provides access to cache directory -->
5+
<cache-path name="cache" path="."/><!-- Provides access to external cache directory -->
6+
<external-cache-path name="external_cache" path="."/><!-- Provides access to files directory -->
7+
<files-path name="files" path="."/>
8+
</paths>

lib/main.dart

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,12 @@ class _MainScreenState extends ConsumerState<MainScreen> {
326326
final isDarkMode = Theme.of(context).brightness == Brightness.dark;
327327
final selectedIndex = ref.watch(selectedIndexProvider);
328328

329+
// Calculate proper header height including status bar on mobile
330+
final statusBarHeight = MediaQuery.of(context).padding.top;
331+
final expandedHeaderHeight = PlatformUtils.isMobile
332+
? kToolbarHeight + statusBarHeight
333+
: kToolbarHeight;
334+
329335
return Scaffold(
330336
body: NotificationListener<UserScrollNotification>(
331337
onNotification: (notification) {
@@ -342,8 +348,9 @@ class _MainScreenState extends ConsumerState<MainScreen> {
342348
children: [
343349
AnimatedContainer(
344350
duration: const Duration(milliseconds: 200),
345-
height: _showExpandedHeader ? kToolbarHeight : 0,
351+
height: _showExpandedHeader ? expandedHeaderHeight : 0,
346352
child: AppBar(
353+
toolbarHeight: kToolbarHeight,
347354
backgroundColor: Theme.of(context).colorScheme.surface,
348355
title: const Text("Openlib"),
349356
titleTextStyle: Theme.of(context).textTheme.displayLarge,

lib/services/update_checker.dart

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,29 @@ class ReleaseInfo {
6868
downloadUrls["ios"] = url;
6969
} else if (name.contains("windows") ||
7070
name.endsWith(".exe") ||
71-
name.endsWith("-windows-x64.zip")) {
71+
name.endsWith(".msix") ||
72+
(name.endsWith(".zip") &&
73+
(name.contains("win") || name.contains("x64")))) {
7274
downloadUrls["windows"] = url;
73-
} else if (name.contains("linux")) {
75+
} else if (name.contains("linux") ||
76+
name.endsWith(".AppImage") ||
77+
name.endsWith(".flatpak")) {
7478
if (name.endsWith(".AppImage")) {
7579
downloadUrls["linux-appimage"] = url;
7680
} else if (name.endsWith(".flatpak")) {
7781
downloadUrls["linux-flatpak"] = url;
7882
} else if (name.endsWith(".tar.gz")) {
7983
downloadUrls["linux-tar"] = url;
84+
} else if (name.endsWith(".deb")) {
85+
downloadUrls["linux-deb"] = url;
86+
} else if (name.endsWith(".rpm")) {
87+
downloadUrls["linux-rpm"] = url;
8088
} else {
8189
downloadUrls["linux"] = url;
8290
}
83-
} else if (name.endsWith(".dmg") || name.contains("macos")) {
91+
} else if (name.endsWith(".dmg") ||
92+
name.contains("macos") ||
93+
name.contains("darwin")) {
8494
downloadUrls["macos"] = url;
8595
}
8696
}
@@ -244,6 +254,8 @@ class UpdateCheckerService {
244254
} else if (Platform.isLinux) {
245255
return release.downloadUrls["linux-appimage"] ??
246256
release.downloadUrls["linux-tar"] ??
257+
release.downloadUrls["linux-deb"] ??
258+
release.downloadUrls["linux-flatpak"] ??
247259
release.downloadUrls["linux"];
248260
} else if (Platform.isMacOS) {
249261
return release.downloadUrls["macos"];
@@ -527,11 +539,11 @@ class UpdateCheckerService {
527539
),
528540
),
529541
),
530-
if (downloadUrl != null)
542+
// Show download button for mobile when URL exists
543+
if (downloadUrl != null && (Platform.isAndroid || Platform.isIOS))
531544
TextButton(
532545
onPressed: () async {
533546
Navigator.of(context).pop();
534-
// Show download progress dialog
535547
if (context.mounted) {
536548
await _showUpdateDownloadDialog(context, release);
537549
}
@@ -544,7 +556,33 @@ class UpdateCheckerService {
544556
),
545557
),
546558
),
547-
if (downloadUrl == null)
559+
// Show download button for desktop (direct download or open GitHub)
560+
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS)
561+
TextButton(
562+
onPressed: () async {
563+
Navigator.of(context).pop();
564+
if (downloadUrl != null && context.mounted) {
565+
await _showUpdateDownloadDialog(context, release);
566+
} else {
567+
final uri = Uri.parse(release.htmlUrl);
568+
if (await canLaunchUrl(uri)) {
569+
await launchUrl(uri,
570+
mode: LaunchMode.externalApplication);
571+
}
572+
}
573+
},
574+
child: Text(
575+
downloadUrl != null
576+
? "Download & Install"
577+
: "Download from GitHub",
578+
style: TextStyle(
579+
fontWeight: FontWeight.bold,
580+
color: Theme.of(context).colorScheme.secondary,
581+
),
582+
),
583+
),
584+
// Fallback for mobile when no download URL
585+
if (downloadUrl == null && (Platform.isAndroid || Platform.isIOS))
548586
TextButton(
549587
onPressed: () async {
550588
Navigator.of(context).pop();

0 commit comments

Comments
 (0)