Skip to content

Commit

Permalink
Merge pull request #4 from lucka-me/dev
Browse files Browse the repository at this point in the history
Merge for v1.5.0
  • Loading branch information
lucka-me authored Jun 20, 2023
2 parents 8e043e6 + 0e5b8af commit 9c1db9c
Show file tree
Hide file tree
Showing 42 changed files with 936 additions and 681 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "labs.lucka.refrain"
minSdk 28
targetSdk 33
versionCode 6
versionName "1.4.0"
versionCode 7
versionName "1.5.0"
vectorDrawables {
useSupportLibrary true
}
Expand Down Expand Up @@ -47,7 +47,7 @@ android {
}

dependencies {
implementation 'androidx.activity:activity-compose:1.7.1'
implementation 'androidx.activity:activity-compose:1.7.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation "androidx.compose.material:material-icons-extended:1.4.3"
implementation 'androidx.compose.material3:material3:1.1.0'
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

<service
android:name=".service.TraceService"
android:foregroundServiceType="location" />
android:foregroundServiceType="location"
android:stopWithTask="false"/>
</application>

</manifest>
27 changes: 21 additions & 6 deletions app/src/main/java/labs/lucka/refrain/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
package labs.lucka.refrain

import android.os.Bundle
import android.view.WindowManager
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.get
import androidx.activity.viewModels
import androidx.compose.runtime.CompositionLocalProvider
import androidx.lifecycle.lifecycleScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import labs.lucka.refrain.common.preferences.Keys
import labs.lucka.refrain.common.preferencesDataStore
import labs.lucka.refrain.ui.LocalRefrainModel
import labs.lucka.refrain.ui.RefrainApp
import labs.lucka.refrain.ui.RefrainModel

class MainActivity : ComponentActivity() {

private lateinit var model: RefrainModel
private val model: RefrainModel by viewModels()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
model = ViewModelProvider(this).get()
model.onCreate(this)
setContent {
RefrainApp(model)
CompositionLocalProvider(
LocalRefrainModel provides model
) {
RefrainApp()
}
}
}

Expand All @@ -29,5 +39,10 @@ class MainActivity : ComponentActivity() {
override fun onResume() {
super.onResume()
model.onResume(this)
lifecycleScope.launch {
if (preferencesDataStore.data.map { it[Keys.Power.KeepScreenOn] == true }.first()) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@ import androidx.datastore.preferences.core.stringPreferencesKey
object Keys {
object Filter {
val Accuracy = floatPreferencesKey("preference.filter.accuracy")
val IgnoreDuplicated = booleanPreferencesKey("preference.filter.ignoreDuplicated")
}

object Interval {
val Time = longPreferencesKey("preference.interval.time")
val Distance = floatPreferencesKey("preference.interval.distance")
}

object Notification {
val NotifyWhenGnssStops = booleanPreferencesKey("preference.notification.notifyWhenGnssStops")
}

object OutputFormat {
val CSV = booleanPreferencesKey("preference.outputFormat.csv")
val GPX = booleanPreferencesKey("preference.outputFormat.gpx")
val KML = booleanPreferencesKey("preference.outputFormat.kml")
}

object Power {
val KeepScreenOn = booleanPreferencesKey("preference.power.keepScreenOn")
val WakeLock = booleanPreferencesKey("preference.power.wakeLock")
}

Expand Down
Loading

0 comments on commit 9c1db9c

Please sign in to comment.