Skip to content

Commit 1176e05

Browse files
committed
enh: added app updater
- fixes on ui top and bottom bar - moved download process to background - optimization of the download functionality - app performance optimization
1 parent 955c84d commit 1176e05

27 files changed

+2407
-241
lines changed

App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {GestureHandlerRootView} from 'react-native-gesture-handler';
44
import {AppProvider, VideoPlayerProvider, useVideoPlayer} from './src/context';
55
import {AppNavigator} from './src/navigation';
66
import {VideoPlayerSheet} from './src/components/VideoPlayerSheet';
7+
import {UpdateChecker} from './src/components';
78

89
const AppContent: React.FC = () => {
910
const {playerState} = useVideoPlayer();
@@ -12,6 +13,8 @@ const AppContent: React.FC = () => {
1213
<View style={{flex: 1}}>
1314
<AppNavigator />
1415
{playerState.content && <VideoPlayerSheet />}
16+
{/* Auto-check for updates on app startup */}
17+
<UpdateChecker isDarkTheme={true} checkIntervalHours={12} />
1518
</View>
1619
);
1720
};

android/app/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
66
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
77
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
8+
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
89

910
<application
1011
android:name=".MainApplication"
@@ -29,10 +30,27 @@
2930
</intent-filter>
3031
</activity>
3132

33+
<!-- FileProvider for APK installation -->
34+
<provider
35+
android:name="androidx.core.content.FileProvider"
36+
android:authorities="${applicationId}.fileprovider"
37+
android:exported="false"
38+
android:grantUriPermissions="true">
39+
<meta-data
40+
android:name="android.support.FILE_PROVIDER_PATHS"
41+
android:resource="@xml/file_paths" />
42+
</provider>
43+
3244
<!-- Notifee Foreground Service for download notifications -->
3345
<service
3446
android:name="app.notifee.core.ForegroundService"
3547
android:foregroundServiceType="dataSync"
3648
android:exported="false" />
49+
50+
<!-- Background Actions Service for downloads -->
51+
<service
52+
android:name="com.asterinet.react.bgactions.RNBackgroundActionsTask"
53+
android:foregroundServiceType="dataSync"
54+
android:exported="false" />
3755
</application>
3856
</manifest>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.flickv4
2+
3+
import android.content.Intent
4+
import android.net.Uri
5+
import android.os.Build
6+
import androidx.core.content.FileProvider
7+
import com.facebook.react.bridge.Promise
8+
import com.facebook.react.bridge.ReactApplicationContext
9+
import com.facebook.react.bridge.ReactContextBaseJavaModule
10+
import com.facebook.react.bridge.ReactMethod
11+
import java.io.File
12+
13+
class ApkInstallerModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
14+
15+
override fun getName(): String {
16+
return "ApkInstaller"
17+
}
18+
19+
@ReactMethod
20+
fun install(apkPath: String, promise: Promise) {
21+
try {
22+
val file = File(apkPath)
23+
24+
if (!file.exists()) {
25+
promise.reject("FILE_NOT_FOUND", "APK file not found at: $apkPath")
26+
return
27+
}
28+
29+
val intent = Intent(Intent.ACTION_VIEW)
30+
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
31+
32+
val uri: Uri = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
33+
// For Android 7.0+ use FileProvider
34+
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
35+
FileProvider.getUriForFile(
36+
reactApplicationContext,
37+
"${reactApplicationContext.packageName}.fileprovider",
38+
file
39+
)
40+
} else {
41+
// For older versions use file:// URI
42+
Uri.fromFile(file)
43+
}
44+
45+
intent.setDataAndType(uri, "application/vnd.android.package-archive")
46+
47+
val activity = getCurrentActivity()
48+
if (activity != null) {
49+
activity.startActivity(intent)
50+
promise.resolve(true)
51+
} else {
52+
reactApplicationContext.startActivity(intent)
53+
promise.resolve(true)
54+
}
55+
} catch (e: Exception) {
56+
promise.reject("INSTALL_ERROR", "Failed to install APK: ${e.message}", e)
57+
}
58+
}
59+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.flickv4
2+
3+
import com.facebook.react.ReactPackage
4+
import com.facebook.react.bridge.NativeModule
5+
import com.facebook.react.bridge.ReactApplicationContext
6+
import com.facebook.react.uimanager.ViewManager
7+
8+
class ApkInstallerPackage : ReactPackage {
9+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
10+
return listOf(ApkInstallerModule(reactContext))
11+
}
12+
13+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
14+
return emptyList()
15+
}
16+
}

android/app/src/main/java/com/flickv4/MainApplication.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MainApplication : Application(), ReactApplication {
1818
// Packages that cannot be autolinked yet can be added manually here, for example:
1919
// add(MyReactNativePackage())
2020
// add(RNBackgroundDownloaderTurboPackage())
21+
add(ApkInstallerPackage())
2122
},
2223
)
2324
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
3+
<!-- External storage Downloads directory -->
4+
<external-path name="downloads" path="Download/" />
5+
<!-- External storage root -->
6+
<external-path name="external" path="." />
7+
<!-- External files directory -->
8+
<external-files-path name="external_files" path="." />
9+
<!-- Cache directory -->
10+
<cache-path name="cache" path="." />
11+
<!-- Files directory -->
12+
<files-path name="files" path="." />
13+
</paths>
80.3 MB
Binary file not shown.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Flickv4",
3-
"version": "1.1.1",
3+
"version": "1.2.0",
44
"private": true,
55
"scripts": {
66
"clean:android": "cd android && ./gradlew clean",
@@ -29,11 +29,13 @@
2929
"m3u8-parser": "^7.2.0",
3030
"react": "19.1.1",
3131
"react-native": "0.82.1",
32+
"react-native-background-actions": "^4.0.1",
3233
"react-native-fs": "^2.20.0",
3334
"react-native-gesture-handler": "^2.21.2",
3435
"react-native-google-cast": "^4.9.1",
3536
"react-native-linear-gradient": "^2.8.3",
3637
"react-native-orientation-locker": "^1.7.0",
38+
"react-native-quick-base64": "^2.2.2",
3739
"react-native-reanimated": "^4.1.5",
3840
"react-native-reanimated-carousel": "^4.0.3",
3941
"react-native-safe-area-context": "^5.5.2",

0 commit comments

Comments
 (0)