Skip to content

Commit 1c446d8

Browse files
committed
added updates feature
bumped dependencies
1 parent f1f277f commit 1c446d8

31 files changed

+753
-43
lines changed

app/build.gradle

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
plugins {
22
id 'com.android.application'
33
id 'org.jetbrains.kotlin.android'
4+
id 'org.jetbrains.kotlin.kapt'
45
id 'org.jetbrains.kotlin.plugin.serialization'
56
}
67

78
android {
8-
compileSdk 32
9+
compileSdk 33
910

1011
defaultConfig {
1112
applicationId "com.github.capntrips.kernelflasher"
1213
minSdk 30
13-
targetSdk 32
14-
versionCode 9
15-
versionName "1.0.0-alpha09"
14+
targetSdk 33
15+
versionCode 10
16+
versionName "1.0.0-alpha10"
1617

1718
vectorDrawables {
1819
useSupportLibrary true
@@ -46,6 +47,7 @@ android {
4647

4748
dependencies {
4849
implementation "androidx.activity:activity-compose:$activity_version"
50+
implementation "androidx.appcompat:appcompat:$appcompat_version"
4951
implementation "androidx.compose.material3:material3:$material3_version"
5052
implementation "androidx.compose.foundation:foundation:$compose_version"
5153
implementation "androidx.compose.ui:ui:$compose_version"
@@ -54,16 +56,16 @@ dependencies {
5456
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
5557
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle_version"
5658
implementation "androidx.navigation:navigation-compose:$nav_version"
59+
implementation "androidx.room:room-runtime:$room_version"
60+
annotationProcessor "androidx.room:room-compiler:$room_version"
61+
kapt "androidx.room:room-compiler:$room_version"
5762
implementation "com.github.topjohnwu.libsu:core:$libsu_version"
5863
implementation "com.github.topjohnwu.libsu:io:$libsu_version"
5964
implementation "com.github.topjohnwu.libsu:nio:$libsu_version"
6065
implementation "com.github.topjohnwu.libsu:service:$libsu_version"
6166
implementation "com.google.accompanist:accompanist-navigation-animation:$accompanist_version"
6267
implementation "com.google.accompanist:accompanist-swiperefresh:$accompanist_version"
6368
implementation "com.google.android.material:material:$material_version"
64-
implementation "androidx.appcompat:appcompat:$appcompat_version"
65-
implementation "androidx.constraintlayout:constraintlayout:$constraintlayout_version"
69+
implementation("com.squareup.okhttp3:okhttp:$okhttp_version")
6670
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version"
67-
debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
68-
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
6971
}

app/src/main/AndroidManifest.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.github.capntrips.kernelflasher" >
55

6+
<uses-permission android:name="android.permission.INTERNET" />
7+
68
<application
79
android:allowBackup="true"
810
android:dataExtractionRules="@xml/data_extraction_rules"
@@ -12,7 +14,7 @@
1214
android:roundIcon="@mipmap/ic_launcher_round"
1315
android:supportsRtl="true"
1416
android:theme="@style/Theme.KernelFlasher"
15-
tools:targetApi="s">
17+
tools:targetApi="33">
1618
<activity
1719
android:name=".MainActivity"
1820
android:exported="true"

app/src/main/java/com/github/capntrips/kernelflasher/MainActivity.kt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ import com.github.capntrips.kernelflasher.ui.screens.error.ErrorScreen
3030
import com.github.capntrips.kernelflasher.ui.screens.main.MainContent
3131
import com.github.capntrips.kernelflasher.ui.screens.main.MainViewModel
3232
import com.github.capntrips.kernelflasher.ui.screens.reboot.RebootContent
33-
import com.github.capntrips.kernelflasher.ui.screens.reboot.RebootViewModel
3433
import com.github.capntrips.kernelflasher.ui.screens.slot.SlotContent
3534
import com.github.capntrips.kernelflasher.ui.screens.slot.SlotFlashContent
35+
import com.github.capntrips.kernelflasher.ui.screens.updates.UpdatesAddContent
36+
import com.github.capntrips.kernelflasher.ui.screens.updates.UpdatesChangelogContent
37+
import com.github.capntrips.kernelflasher.ui.screens.updates.UpdatesContent
38+
import com.github.capntrips.kernelflasher.ui.screens.updates.UpdatesViewContent
3639
import com.github.capntrips.kernelflasher.ui.theme.KernelFlasherTheme
3740
import com.google.accompanist.navigation.animation.AnimatedNavHost
3841
import com.google.accompanist.navigation.animation.composable
@@ -48,6 +51,7 @@ import java.io.File
4851
@ExperimentalAnimationApi
4952
class MainActivity : ComponentActivity() {
5053
companion object {
54+
const val TAG: String = "MainActivity"
5155
init {
5256
Shell.setDefaultBuilder(Shell.Builder.create().setFlags(Shell.FLAG_MOUNT_MASTER))
5357
}
@@ -145,7 +149,7 @@ class MainActivity : ComponentActivity() {
145149
copyAsset("lptools_static")
146150
copyAsset("httools_static")
147151
} catch (e: Exception) {
148-
Log.e(RebootViewModel.TAG, e.message, e)
152+
Log.e(TAG, e.message, e)
149153
setContent {
150154
KernelFlasherTheme {
151155
ErrorScreen(e.message!!)
@@ -167,6 +171,7 @@ class MainActivity : ComponentActivity() {
167171
val slotViewModelA = mainViewModel.slotA
168172
val slotViewModelB = mainViewModel.slotB
169173
val backupsViewModel = mainViewModel.backups
174+
val updatesViewModel = mainViewModel.updates
170175
val rebootViewModel = mainViewModel.reboot
171176
BackHandler(enabled = mainViewModel.isRefreshing, onBack = {})
172177
AnimatedNavHost(navController = navController, startDestination = "main") {
@@ -234,6 +239,37 @@ class MainActivity : ComponentActivity() {
234239
}
235240
}
236241
}
242+
composable("updates") {
243+
updatesViewModel.clearCurrent()
244+
RefreshableScreen(mainViewModel, navController) {
245+
UpdatesContent(updatesViewModel, navController)
246+
}
247+
}
248+
composable("updates/add") {
249+
RefreshableScreen(mainViewModel, navController) {
250+
UpdatesAddContent(updatesViewModel, navController)
251+
}
252+
}
253+
composable("updates/view/{updateId}") { backStackEntry ->
254+
val updateId = backStackEntry.arguments?.getString("updateId")!!.toInt()
255+
val currentUpdate = updatesViewModel.updates.firstOrNull { it.id == updateId }
256+
updatesViewModel.currentUpdate = currentUpdate
257+
if (updatesViewModel.currentUpdate != null) {
258+
RefreshableScreen(mainViewModel, navController) {
259+
UpdatesViewContent(updatesViewModel, navController)
260+
}
261+
}
262+
}
263+
composable("updates/view/{updateId}/changelog") { backStackEntry ->
264+
val updateId = backStackEntry.arguments?.getString("updateId")!!.toInt()
265+
val currentUpdate = updatesViewModel.updates.firstOrNull { it.id == updateId }
266+
updatesViewModel.currentUpdate = currentUpdate
267+
if (updatesViewModel.currentUpdate != null) {
268+
RefreshableScreen(mainViewModel, navController) {
269+
UpdatesChangelogContent(updatesViewModel, navController)
270+
}
271+
}
272+
}
237273
composable("reboot") {
238274
RefreshableScreen(mainViewModel, navController) {
239275
RebootContent(rebootViewModel, navController)

app/src/main/java/com/github/capntrips/kernelflasher/common/PartitionUtil.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.github.capntrips.kernelflasher.common
22

33
import android.content.Context
4-
import com.github.capntrips.kernelflasher.common.types.FstabEntry
4+
import com.github.capntrips.kernelflasher.common.types.partitions.FstabEntry
55
import com.topjohnwu.superuser.Shell
66
import com.topjohnwu.superuser.io.SuFile
77
import com.topjohnwu.superuser.nio.FileSystemManager

app/src/main/java/com/github/capntrips/kernelflasher/common/types/Backup.kt renamed to app/src/main/java/com/github/capntrips/kernelflasher/common/types/backups/Backup.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
package com.github.capntrips.kernelflasher.common.types
1+
package com.github.capntrips.kernelflasher.common.types.backups
22

3+
import com.github.capntrips.kernelflasher.common.types.partitions.Partitions
34
import kotlinx.serialization.Serializable
45

56
@Serializable

app/src/main/java/com/github/capntrips/kernelflasher/common/types/FsMgrFlags.kt renamed to app/src/main/java/com/github/capntrips/kernelflasher/common/types/partitions/FsMgrFlags.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.capntrips.kernelflasher.common.types
1+
package com.github.capntrips.kernelflasher.common.types.partitions
22

33
import kotlinx.serialization.Serializable
44

app/src/main/java/com/github/capntrips/kernelflasher/common/types/FstabEntry.kt renamed to app/src/main/java/com/github/capntrips/kernelflasher/common/types/partitions/FstabEntry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.capntrips.kernelflasher.common.types
1+
package com.github.capntrips.kernelflasher.common.types.partitions
22

33
import kotlinx.serialization.Serializable
44

app/src/main/java/com/github/capntrips/kernelflasher/common/types/Partitions.kt renamed to app/src/main/java/com/github/capntrips/kernelflasher/common/types/partitions/Partitions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.github.capntrips.kernelflasher.common.types
1+
package com.github.capntrips.kernelflasher.common.types.partitions
22

33
import kotlinx.serialization.Serializable
44

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.github.capntrips.kernelflasher.common.types.room
2+
3+
import androidx.room.Database
4+
import androidx.room.RoomDatabase
5+
import androidx.room.TypeConverters
6+
import com.github.capntrips.kernelflasher.common.types.room.updates.Update
7+
import com.github.capntrips.kernelflasher.common.types.room.updates.UpdateDao
8+
9+
@Database(entities = [Update::class], version = 1)
10+
@TypeConverters(Converters::class)
11+
abstract class AppDatabase : RoomDatabase() {
12+
abstract fun updateDao(): UpdateDao
13+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.github.capntrips.kernelflasher.common.types.room
2+
3+
import androidx.room.TypeConverter
4+
import java.util.Date
5+
6+
class Converters {
7+
@TypeConverter
8+
fun fromTimestamp(value: Long?): Date? {
9+
return value?.let { Date(it) }
10+
}
11+
12+
@TypeConverter
13+
fun dateToTimestamp(date: Date?): Long? {
14+
return date?.time
15+
}
16+
}

0 commit comments

Comments
 (0)