mirror of
https://github.com/KDE/kdeconnect-android
synced 2025-09-03 23:55:08 +00:00
Improvements from code review
This commit is contained in:
@@ -27,6 +27,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
|||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.unit.*
|
import androidx.compose.ui.unit.*
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import com.google.accompanist.themeadapter.material3.Mdc3Theme
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import org.kde.kdeconnect.BackgroundService
|
import org.kde.kdeconnect.BackgroundService
|
||||||
import org.kde.kdeconnect.Device
|
import org.kde.kdeconnect.Device
|
||||||
@@ -39,7 +40,6 @@ import org.kde.kdeconnect.Plugins.MprisPlugin.MprisPlugin
|
|||||||
import org.kde.kdeconnect.Plugins.Plugin
|
import org.kde.kdeconnect.Plugins.Plugin
|
||||||
import org.kde.kdeconnect.Plugins.PresenterPlugin.PresenterPlugin
|
import org.kde.kdeconnect.Plugins.PresenterPlugin.PresenterPlugin
|
||||||
import org.kde.kdeconnect.Plugins.RunCommandPlugin.RunCommandPlugin
|
import org.kde.kdeconnect.Plugins.RunCommandPlugin.RunCommandPlugin
|
||||||
import org.kde.kdeconnect.UserInterface.compose.AppTheme
|
|
||||||
import org.kde.kdeconnect_tp.R
|
import org.kde.kdeconnect_tp.R
|
||||||
import org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding
|
import org.kde.kdeconnect_tp.databinding.ActivityDeviceBinding
|
||||||
import org.kde.kdeconnect_tp.databinding.ViewPairErrorBinding
|
import org.kde.kdeconnect_tp.databinding.ViewPairErrorBinding
|
||||||
@@ -284,7 +284,7 @@ class DeviceFragment : Fragment() {
|
|||||||
requireDeviceBinding().deviceView.visibility = View.VISIBLE
|
requireDeviceBinding().deviceView.visibility = View.VISIBLE
|
||||||
requireDeviceBinding().deviceViewCompose.apply {
|
requireDeviceBinding().deviceViewCompose.apply {
|
||||||
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
||||||
setContent { AppTheme { PluginList(device) } }
|
setContent { Mdc3Theme { PluginList(device) } }
|
||||||
}
|
}
|
||||||
displayBatteryInfoIfPossible()
|
displayBatteryInfoIfPossible()
|
||||||
} else {
|
} else {
|
||||||
@@ -383,7 +383,7 @@ class DeviceFragment : Fragment() {
|
|||||||
fun PluginButton(plugin : Plugin, modifier: Modifier) {
|
fun PluginButton(plugin : Plugin, modifier: Modifier) {
|
||||||
Card(
|
Card(
|
||||||
shape = MaterialTheme.shapes.medium,
|
shape = MaterialTheme.shapes.medium,
|
||||||
modifier = modifier.height(height = 120.dp),
|
modifier = modifier,
|
||||||
onClick = { plugin.startMainActivity(mActivity) }
|
onClick = { plugin.startMainActivity(mActivity) }
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
@@ -398,6 +398,7 @@ class DeviceFragment : Fragment() {
|
|||||||
Text(
|
Text(
|
||||||
text = plugin.actionName,
|
text = plugin.actionName,
|
||||||
maxLines = 2,
|
maxLines = 2,
|
||||||
|
minLines = 2,
|
||||||
fontSize = 18.sp,
|
fontSize = 18.sp,
|
||||||
overflow = TextOverflow.Ellipsis
|
overflow = TextOverflow.Ellipsis
|
||||||
)
|
)
|
||||||
@@ -406,8 +407,7 @@ class DeviceFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PluginButtons(plugins: Iterator<Plugin>, numColumns: Int)
|
fun PluginButtons(plugins: Iterator<Plugin>, numColumns: Int) {
|
||||||
{
|
|
||||||
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
Column(modifier = Modifier.padding(horizontal = 16.dp)) {
|
||||||
while (plugins.hasNext()) {
|
while (plugins.hasNext()) {
|
||||||
Row(
|
Row(
|
||||||
@@ -432,8 +432,7 @@ class DeviceFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PluginsWithoutPermissions(title : String, plugins: Collection<Plugin>, action : (plugin: Plugin) -> Unit)
|
fun PluginsWithoutPermissions(title : String, plugins: Collection<Plugin>, action : (plugin: Plugin) -> Unit) {
|
||||||
{
|
|
||||||
Text(
|
Text(
|
||||||
text = title,
|
text = title,
|
||||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 6.dp)
|
modifier = Modifier.padding(horizontal = 16.dp, vertical = 6.dp)
|
||||||
@@ -448,6 +447,7 @@ class DeviceFragment : Fragment() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun PluginList(device : Device) {
|
fun PluginList(device : Device) {
|
||||||
|
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
package org.kde.kdeconnect.UserInterface.compose
|
|
||||||
|
|
||||||
import android.os.Build
|
|
||||||
import androidx.compose.foundation.isSystemInDarkTheme
|
|
||||||
import androidx.compose.material3.MaterialTheme
|
|
||||||
import androidx.compose.material3.darkColorScheme
|
|
||||||
import androidx.compose.material3.dynamicDarkColorScheme
|
|
||||||
import androidx.compose.material3.dynamicLightColorScheme
|
|
||||||
import androidx.compose.material3.lightColorScheme
|
|
||||||
import androidx.compose.runtime.Composable
|
|
||||||
import androidx.compose.ui.platform.LocalContext
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
fun AppTheme(
|
|
||||||
content: @Composable () -> Unit) {
|
|
||||||
val darkTheme = isSystemInDarkTheme()
|
|
||||||
val dynamicColor = Build.VERSION.SDK_INT >= Build.VERSION_CODES.S
|
|
||||||
val colorScheme = when {
|
|
||||||
dynamicColor && darkTheme -> dynamicDarkColorScheme(LocalContext.current)
|
|
||||||
dynamicColor && !darkTheme -> dynamicLightColorScheme(LocalContext.current)
|
|
||||||
darkTheme -> darkColorScheme()
|
|
||||||
else -> lightColorScheme()
|
|
||||||
}
|
|
||||||
MaterialTheme(
|
|
||||||
colorScheme = colorScheme,
|
|
||||||
content = content
|
|
||||||
)
|
|
||||||
}
|
|
Reference in New Issue
Block a user