Skip to content

Commit 6f5b5c8

Browse files
committed
bugfix[#35]: browse variables under net
1 parent 9df1a3c commit 6f5b5c8

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ dependencies {
129129

130130
implementation(Dependencies.koinAndroid)
131131
implementation(Dependencies.libSuCore)
132+
implementation(Dependencies.libSuIo)
132133
implementation(Dependencies.liveEvent)
133134
implementation(Dependencies.tapTargetView)
134135
}

app/src/main/kotlin/com/androidvip/sysctlgui/ui/params/browse/BrowseParamsViewModel.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.androidvip.sysctlgui.domain.repository.AppPrefs
77
import com.androidvip.sysctlgui.domain.usecase.GetParamsFromFilesUseCase
88
import com.androidvip.sysctlgui.utils.BaseViewModel
99
import com.androidvip.sysctlgui.utils.Consts
10+
import com.topjohnwu.superuser.io.SuFile
1011
import kotlinx.coroutines.CoroutineDispatcher
1112
import kotlinx.coroutines.Dispatchers
1213
import kotlinx.coroutines.launch
@@ -103,7 +104,7 @@ class BrowseParamsViewModel(
103104

104105
private suspend fun getCurrentPathFiles(path: String) = withContext(dispatcher) {
105106
runCatching {
106-
File(path).listFiles()?.toList()
107+
SuFile.open(path).listFiles()?.toList()
107108
}.getOrDefault(emptyList())
108109
}
109110

app/src/main/kotlin/com/androidvip/sysctlgui/ui/params/browse/KernelParamBrowseFragment.kt

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ import com.androidvip.sysctlgui.ui.params.OnParamItemClickedListener
4848
import com.androidvip.sysctlgui.ui.params.edit.EditKernelParamActivity
4949
import com.androidvip.sysctlgui.utils.ComposeTheme
5050
import com.androidvip.sysctlgui.utils.Consts
51-
import com.google.android.material.color.MaterialColors
52-
import java.io.File
5351
import kotlinx.coroutines.launch
5452
import org.koin.android.ext.android.inject
53+
import java.io.File
5554

5655
class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListener {
5756
private var actionBarMenu: Menu? = null
@@ -194,6 +193,7 @@ class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListen
194193
val swipeLayout: SwipeRefreshLayout = dialog.findViewById(R.id.webDialogSwipeLayout)
195194

196195
val webView = dialog.findViewById<WebView>(R.id.webDialogWebView).apply {
196+
val colorRoles = getColorRoles()
197197
settings.apply {
198198
javaScriptEnabled = true
199199
cacheMode = WebSettings.LOAD_CACHE_ELSE_NETWORK
@@ -206,14 +206,8 @@ class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListen
206206
super.onPageFinished(view, url)
207207
swipeLayout.isRefreshing = false
208208

209-
val containerColorInt = MaterialColors.getColor(
210-
swipeLayout,
211-
R.attr.colorPrimaryContainer
212-
)
213-
val colorInt = MaterialColors.getColor(
214-
swipeLayout,
215-
R.attr.colorOnPrimaryContainer
216-
)
209+
val containerColorInt = colorRoles.accentContainer
210+
val colorInt = colorRoles.onAccentContainer
217211

218212
val containerColorHex = "#%06X".format(0xFFFFFF and containerColorInt)
219213
val colorHex = "#%06X".format(0xFFFFFF and colorInt)
@@ -222,8 +216,8 @@ class KernelParamBrowseFragment : BaseSearchFragment(), OnParamItemClickedListen
222216
"""
223217
|javascript:(
224218
|function() {
225-
|document.querySelector('body').style.color='$containerColorHex';
226-
|document.querySelector('body').style.background='$colorHex';
219+
|document.querySelector('body').style.color='$colorHex';
220+
|document.querySelector('body').style.background='$containerColorHex';
227221
|}
228222
|)()
229223
""".trimMargin()

app/src/main/kotlin/com/androidvip/sysctlgui/ui/params/edit/EditParamScreen.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.androidvip.sysctlgui.ui.params.edit
22

33
import androidx.annotation.DrawableRes
4+
import androidx.compose.animation.AnimatedVisibility
45
import androidx.compose.foundation.layout.Arrangement
56
import androidx.compose.foundation.layout.Column
67
import androidx.compose.foundation.layout.Row
@@ -162,7 +163,7 @@ private fun FloatingActionButtonColumn(
162163
horizontalAlignment = Alignment.End,
163164
modifier = Modifier.padding(bottom = 8.dp)
164165
) {
165-
if (hasApplied) {
166+
AnimatedVisibility(hasApplied) {
166167
SmallFloatingActionButton(
167168
onClick = onReset,
168169
containerColor = MaterialTheme.colorScheme.tertiaryContainer,
@@ -180,7 +181,8 @@ private fun FloatingActionButtonColumn(
180181
text = {
181182
Text(
182183
text = stringResource(id = R.string.apply_param),
183-
color = MaterialTheme.colorScheme.onSecondaryContainer
184+
color = MaterialTheme.colorScheme.onSecondaryContainer,
185+
fontWeight = FontWeight.Medium
184186
)
185187
},
186188
icon = {

buildSrc/src/main/kotlin/Dependencies.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ object Dependencies {
77
const val coroutinesCore = "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3"
88
const val tapTargetView = "com.getkeepsafe.taptargetview:taptargetview:1.13.3"
99
const val libSuCore = "com.github.topjohnwu.libsu:core:2.5.1"
10+
const val libSuIo = "com.github.topjohnwu.libsu:io:2.5.1"
1011
const val liveEvent = "com.github.hadilq:live-event:1.3.0"
1112
}

0 commit comments

Comments
 (0)