refactor: clean up dead code
This commit is contained in:
6
.idea/deploymentTargetSelector.xml
generated
6
.idea/deploymentTargetSelector.xml
generated
@@ -2,6 +2,12 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="deploymentTargetSelector">
|
<component name="deploymentTargetSelector">
|
||||||
<selectionStates>
|
<selectionStates>
|
||||||
|
<SelectionState runConfigName="Unnamed">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
</SelectionState>
|
||||||
|
<SelectionState runConfigName="lbjconsole_android">
|
||||||
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
|
</SelectionState>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
</SelectionState>
|
</SelectionState>
|
||||||
|
|||||||
@@ -41,13 +41,6 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
|
||||||
android:name=".SettingsActivity"
|
|
||||||
android:exported="false"
|
|
||||||
android:label="Settings"
|
|
||||||
android:parentActivityName=".MainActivity"
|
|
||||||
android:theme="@style/Theme.LBJConsole" />
|
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".BackgroundService"
|
android:name=".BackgroundService"
|
||||||
android:enabled="true"
|
android:enabled="true"
|
||||||
|
|||||||
@@ -364,11 +364,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
},
|
},
|
||||||
appVersion = getAppVersion(),
|
appVersion = getAppVersion(),
|
||||||
locoInfoUtil = locoInfoUtil,
|
locoInfoUtil = locoInfoUtil,
|
||||||
trainTypeUtil = trainTypeUtil,
|
trainTypeUtil = trainTypeUtil
|
||||||
onOpenSettings = {
|
|
||||||
val intent = Intent(this@MainActivity, SettingsActivity::class.java)
|
|
||||||
startActivity(intent)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (showConnectionDialog) {
|
if (showConnectionDialog) {
|
||||||
@@ -877,9 +873,7 @@ fun MainContent(
|
|||||||
mapCenterPosition: Pair<Double, Double>?,
|
mapCenterPosition: Pair<Double, Double>?,
|
||||||
mapZoomLevel: Double,
|
mapZoomLevel: Double,
|
||||||
mapRailwayLayerVisible: Boolean,
|
mapRailwayLayerVisible: Boolean,
|
||||||
onMapStateChange: (Pair<Double, Double>?, Double, Boolean) -> Unit,
|
onMapStateChange: (Pair<Double, Double>?, Double, Boolean) -> Unit
|
||||||
|
|
||||||
onOpenSettings: () -> Unit
|
|
||||||
) {
|
) {
|
||||||
val statusColor = if (isConnected) Color(0xFF4CAF50) else Color(0xFFFF5722)
|
val statusColor = if (isConnected) Color(0xFF4CAF50) else Color(0xFFFF5722)
|
||||||
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class NotificationService(private val context: Context) {
|
|||||||
context,
|
context,
|
||||||
0,
|
0,
|
||||||
intent,
|
intent,
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
|
PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_MUTABLE
|
||||||
)
|
)
|
||||||
|
|
||||||
val remoteViews = RemoteViews(context.packageName, R.layout.notification_train_record)
|
val remoteViews = RemoteViews(context.packageName, R.layout.notification_train_record)
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
package org.noxylva.lbjconsole
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.os.Bundle
|
|
||||||
import android.widget.Switch
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
|
||||||
import androidx.lifecycle.lifecycleScope
|
|
||||||
import kotlinx.coroutines.launch
|
|
||||||
import org.noxylva.lbjconsole.database.AppSettingsRepository
|
|
||||||
|
|
||||||
class SettingsActivity : AppCompatActivity() {
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
suspend fun isBackgroundServiceEnabled(context: Context): Boolean {
|
|
||||||
val repository = AppSettingsRepository(context)
|
|
||||||
return repository.getSettings().backgroundServiceEnabled
|
|
||||||
}
|
|
||||||
|
|
||||||
suspend fun setBackgroundServiceEnabled(context: Context, enabled: Boolean) {
|
|
||||||
val repository = AppSettingsRepository(context)
|
|
||||||
repository.updateBackgroundServiceEnabled(enabled)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private lateinit var backgroundServiceSwitch: Switch
|
|
||||||
private lateinit var appSettingsRepository: AppSettingsRepository
|
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
|
||||||
super.onCreate(savedInstanceState)
|
|
||||||
setContentView(R.layout.activity_settings)
|
|
||||||
|
|
||||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
|
||||||
supportActionBar?.title = "Settings"
|
|
||||||
|
|
||||||
appSettingsRepository = AppSettingsRepository(this)
|
|
||||||
|
|
||||||
initViews()
|
|
||||||
setupListeners()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun initViews() {
|
|
||||||
backgroundServiceSwitch = findViewById(R.id.switch_background_service)
|
|
||||||
lifecycleScope.launch {
|
|
||||||
backgroundServiceSwitch.isChecked = isBackgroundServiceEnabled(this@SettingsActivity)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setupListeners() {
|
|
||||||
backgroundServiceSwitch.setOnCheckedChangeListener { _, isChecked ->
|
|
||||||
lifecycleScope.launch {
|
|
||||||
setBackgroundServiceEnabled(this@SettingsActivity, isChecked)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isChecked) {
|
|
||||||
BackgroundService.startService(this)
|
|
||||||
} else {
|
|
||||||
BackgroundService.stopService(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSupportNavigateUp(): Boolean {
|
|
||||||
onBackPressed()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -19,7 +19,7 @@ import kotlinx.coroutines.launch
|
|||||||
import org.noxylva.lbjconsole.model.MergeSettings
|
import org.noxylva.lbjconsole.model.MergeSettings
|
||||||
import org.noxylva.lbjconsole.model.GroupBy
|
import org.noxylva.lbjconsole.model.GroupBy
|
||||||
import org.noxylva.lbjconsole.model.TimeWindow
|
import org.noxylva.lbjconsole.model.TimeWindow
|
||||||
import org.noxylva.lbjconsole.SettingsActivity
|
import org.noxylva.lbjconsole.database.AppSettingsRepository
|
||||||
import org.noxylva.lbjconsole.BackgroundService
|
import org.noxylva.lbjconsole.BackgroundService
|
||||||
import org.noxylva.lbjconsole.NotificationService
|
import org.noxylva.lbjconsole.NotificationService
|
||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
@@ -199,7 +199,8 @@ fun SettingsScreen(
|
|||||||
val coroutineScope = rememberCoroutineScope()
|
val coroutineScope = rememberCoroutineScope()
|
||||||
|
|
||||||
LaunchedEffect(context) {
|
LaunchedEffect(context) {
|
||||||
backgroundServiceEnabled = SettingsActivity.isBackgroundServiceEnabled(context)
|
val repository = AppSettingsRepository(context)
|
||||||
|
backgroundServiceEnabled = repository.getSettings().backgroundServiceEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
var notificationEnabled by remember(context, notificationService) {
|
var notificationEnabled by remember(context, notificationService) {
|
||||||
@@ -231,7 +232,8 @@ fun SettingsScreen(
|
|||||||
onCheckedChange = { enabled ->
|
onCheckedChange = { enabled ->
|
||||||
backgroundServiceEnabled = enabled
|
backgroundServiceEnabled = enabled
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
SettingsActivity.setBackgroundServiceEnabled(context, enabled)
|
val repository = AppSettingsRepository(context)
|
||||||
|
repository.updateBackgroundServiceEnabled(enabled)
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
BackgroundService.startService(context)
|
BackgroundService.startService(context)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:width="24dp"
|
|
||||||
android:height="24dp"
|
|
||||||
android:viewportWidth="24"
|
|
||||||
android:viewportHeight="24">
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:pathData="M12,6m-4,0a4,4 0,1 1,8 0a4,4 0,1 1,-8 0" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#FFFFFF"
|
|
||||||
android:pathData="M12,10L12,10c-2.2,0 -4,1.8 -4,4v6h8v-6C16,11.8 14.2,10 12,10z" />
|
|
||||||
</vector>
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:padding="16dp">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:padding="16dp"
|
|
||||||
android:background="?android:attr/selectableItemBackground"
|
|
||||||
android:clickable="true">
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_weight="1"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Background Service"
|
|
||||||
android:textSize="16sp"
|
|
||||||
android:textColor="@android:color/black"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="Keep app running in background"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@android:color/darker_gray"
|
|
||||||
android:layout_marginTop="4dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<Switch
|
|
||||||
android:id="@+id/switch_background_service"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="16dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="1dp"
|
|
||||||
android:background="@android:color/darker_gray"
|
|
||||||
android:layout_marginHorizontal="16dp" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
Reference in New Issue
Block a user