manager: Optimizing SuSFS Feature Status Display

- Use labels instead of Text

Signed-off-by: ShirkNeko <109797057+ShirkNeko@users.noreply.github.com>
This commit is contained in:
ShirkNeko
2025-06-14 22:35:36 +08:00
parent 85f5459c1d
commit ef4101cbf9
2 changed files with 23 additions and 14 deletions

View File

@@ -45,6 +45,7 @@ import androidx.compose.material3.MenuAnchorType
import androidx.compose.material3.OutlinedButton import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.OutlinedTextField import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.ScrollableTabRow import androidx.compose.material3.ScrollableTabRow
import androidx.compose.material3.Surface
import androidx.compose.material3.Switch import androidx.compose.material3.Switch
import androidx.compose.material3.Tab import androidx.compose.material3.Tab
import androidx.compose.material3.Text import androidx.compose.material3.Text
@@ -60,6 +61,7 @@ import androidx.compose.runtime.rememberCoroutineScope
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.font.FontWeight
@@ -1515,18 +1517,20 @@ private fun FeatureStatusCard(
modifier = Modifier.weight(1f) modifier = Modifier.weight(1f)
) )
} }
Surface(
shape = RoundedCornerShape(4.dp),
color = when {
feature.isEnabled -> MaterialTheme.colorScheme.primary
else -> Color.Gray
},
modifier = Modifier
) {
Text( Text(
text = if (feature.isEnabled) text = feature.statusText,
stringResource(R.string.susfs_feature_enabled) style = MaterialTheme.typography.labelMedium,
else modifier = Modifier.padding(horizontal = 6.dp, vertical = 2.dp)
stringResource(R.string.susfs_feature_disabled),
style = MaterialTheme.typography.bodySmall,
color = if (feature.isEnabled)
MaterialTheme.colorScheme.primary
else
MaterialTheme.colorScheme.error,
fontWeight = FontWeight.Medium
) )
} }
} }
} }
}

View File

@@ -4,6 +4,9 @@ import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.content.SharedPreferences import android.content.SharedPreferences
import android.widget.Toast import android.widget.Toast
import androidx.compose.ui.res.stringResource
import com.dergoogler.mmrl.platform.Platform
import com.dergoogler.mmrl.platform.Platform.Companion.context
import com.sukisu.ultra.R import com.sukisu.ultra.R
import com.topjohnwu.superuser.Shell import com.topjohnwu.superuser.Shell
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
@@ -59,7 +62,8 @@ object SuSFSManager {
*/ */
data class EnabledFeature( data class EnabledFeature(
val name: String, val name: String,
val isEnabled: Boolean val isEnabled: Boolean,
val statusText: String = if (isEnabled) context.getString(R.string.susfs_feature_enabled) else context.getString(R.string.susfs_feature_disabled)
) )
/** /**
@@ -587,7 +591,8 @@ object SuSFSManager {
featureMappings.forEach { mapping -> featureMappings.forEach { mapping ->
val displayName = featureNameMap[mapping.id] ?: mapping.id val displayName = featureNameMap[mapping.id] ?: mapping.id
val isEnabled = outputLines.contains(mapping.config) val isEnabled = outputLines.contains(mapping.config)
features.add(EnabledFeature(displayName, isEnabled)) val statusText = if (isEnabled) context.getString(R.string.susfs_feature_enabled) else context.getString(R.string.susfs_feature_disabled)
features.add(EnabledFeature(displayName, isEnabled, statusText))
} }
return features.sortedBy { it.name } return features.sortedBy { it.name }