Compare commits
No commits in common. "843786507f9f6287d28f257c73b4ed8ab158134b" and "82b491921bd566018e5bc2b9a790089d3b295cad" have entirely different histories.
843786507f
...
82b491921b
2 changed files with 30 additions and 77 deletions
|
|
@ -251,7 +251,7 @@ private fun ClockSettingsSheet(onDismiss: () -> Unit) {
|
||||||
style = MaterialTheme.typography.bodyLarge,
|
style = MaterialTheme.typography.bodyLarge,
|
||||||
)
|
)
|
||||||
Text(
|
Text(
|
||||||
text = "Remove the widget background. May not work on all launchers.",
|
text = "Remove the widget background. May not work on all launchers. Re-add the widget after changing.",
|
||||||
style = MaterialTheme.typography.bodySmall,
|
style = MaterialTheme.typography.bodySmall,
|
||||||
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
color = MaterialTheme.colorScheme.onSurfaceVariant,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,9 @@ import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.provider.AlarmClock
|
import android.provider.AlarmClock
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.unit.DpSize
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.compose.ui.unit.sp
|
import androidx.compose.ui.unit.sp
|
||||||
import androidx.glance.ColorFilter
|
|
||||||
import androidx.glance.Image
|
|
||||||
import androidx.glance.ImageProvider
|
|
||||||
import androidx.glance.GlanceId
|
import androidx.glance.GlanceId
|
||||||
import androidx.glance.GlanceModifier
|
import androidx.glance.GlanceModifier
|
||||||
import androidx.glance.GlanceTheme
|
import androidx.glance.GlanceTheme
|
||||||
|
|
@ -21,8 +18,8 @@ import androidx.glance.appwidget.GlanceAppWidgetReceiver
|
||||||
import androidx.glance.appwidget.SizeMode
|
import androidx.glance.appwidget.SizeMode
|
||||||
import androidx.glance.appwidget.action.actionStartActivity
|
import androidx.glance.appwidget.action.actionStartActivity
|
||||||
import androidx.glance.appwidget.provideContent
|
import androidx.glance.appwidget.provideContent
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.glance.background
|
import androidx.glance.background
|
||||||
import androidx.glance.color.ColorProvider
|
|
||||||
import androidx.glance.color.DynamicThemeColorProviders
|
import androidx.glance.color.DynamicThemeColorProviders
|
||||||
import space.darkest.nova.android.data.WidgetPreferences
|
import space.darkest.nova.android.data.WidgetPreferences
|
||||||
import androidx.glance.layout.Alignment
|
import androidx.glance.layout.Alignment
|
||||||
|
|
@ -33,7 +30,6 @@ import androidx.glance.layout.Spacer
|
||||||
import androidx.glance.layout.fillMaxSize
|
import androidx.glance.layout.fillMaxSize
|
||||||
import androidx.glance.layout.height
|
import androidx.glance.layout.height
|
||||||
import androidx.glance.layout.padding
|
import androidx.glance.layout.padding
|
||||||
import androidx.glance.layout.size
|
|
||||||
import androidx.glance.layout.width
|
import androidx.glance.layout.width
|
||||||
import androidx.glance.text.FontWeight
|
import androidx.glance.text.FontWeight
|
||||||
import androidx.glance.text.Text
|
import androidx.glance.text.Text
|
||||||
|
|
@ -80,7 +76,7 @@ class ClockWidget : GlanceAppWidget() {
|
||||||
"$day, $date"
|
"$day, $date"
|
||||||
}
|
}
|
||||||
val alarmStr = if (alarmTime != null && alarmDate != null) {
|
val alarmStr = if (alarmTime != null && alarmDate != null) {
|
||||||
formatAlarm(alarmTime, alarmDate)
|
"\u23F0 ${formatAlarm(alarmTime, alarmDate)}"
|
||||||
} else null
|
} else null
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
|
|
@ -95,143 +91,100 @@ class ClockWidget : GlanceAppWidget() {
|
||||||
contentAlignment = Alignment.CenterStart,
|
contentAlignment = Alignment.CenterStart,
|
||||||
) {
|
) {
|
||||||
if (compact) {
|
if (compact) {
|
||||||
CompactLayout(hours, minutes, dateStr, alarmStr, transparentBg)
|
CompactLayout(hours, minutes, dateStr, alarmStr)
|
||||||
} else {
|
} else {
|
||||||
FullLayout(hours, minutes, dateStr, alarmStr, transparentBg)
|
FullLayout(hours, minutes, dateStr, alarmStr)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// text with a dark shadow layer behind it for readability on wallpapers
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ShadowText(
|
private fun TimeRow(hours: String, minutes: String, fontSize: Int = 48) {
|
||||||
text: String,
|
|
||||||
style: TextStyle,
|
|
||||||
shadow: Boolean,
|
|
||||||
maxLines: Int = Int.MAX_VALUE,
|
|
||||||
) {
|
|
||||||
if (shadow) {
|
|
||||||
Box {
|
|
||||||
Text(
|
|
||||||
text = text,
|
|
||||||
style = style.copy(
|
|
||||||
color = ColorProvider(Color(0x90000000)),
|
|
||||||
),
|
|
||||||
maxLines = maxLines,
|
|
||||||
modifier = GlanceModifier.padding(start = 1.dp, top = 1.dp),
|
|
||||||
)
|
|
||||||
Text(text = text, style = style, maxLines = maxLines)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Text(text = text, style = style, maxLines = maxLines)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun TimeRow(hours: String, minutes: String, fontSize: Int = 48, shadow: Boolean = false) {
|
|
||||||
Row(verticalAlignment = Alignment.Bottom) {
|
Row(verticalAlignment = Alignment.Bottom) {
|
||||||
ShadowText(
|
Text(
|
||||||
text = hours,
|
text = hours,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.primary,
|
color = GlanceTheme.colors.primary,
|
||||||
fontSize = fontSize.sp,
|
fontSize = fontSize.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
ShadowText(
|
Text(
|
||||||
text = ":",
|
text = ":",
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.onSurfaceVariant,
|
color = GlanceTheme.colors.onSurfaceVariant,
|
||||||
fontSize = fontSize.sp,
|
fontSize = fontSize.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
ShadowText(
|
Text(
|
||||||
text = minutes,
|
text = minutes,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.tertiary,
|
color = GlanceTheme.colors.tertiary,
|
||||||
fontSize = fontSize.sp,
|
fontSize = fontSize.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun CompactLayout(
|
private fun CompactLayout(hours: String, minutes: String, dateStr: String, alarmStr: String?) {
|
||||||
hours: String, minutes: String, dateStr: String, alarmStr: String?, shadow: Boolean,
|
|
||||||
) {
|
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = GlanceModifier.fillMaxSize(),
|
modifier = GlanceModifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
TimeRow(hours, minutes, fontSize = 36, shadow = shadow)
|
TimeRow(hours, minutes, fontSize = 36)
|
||||||
Spacer(GlanceModifier.width(12.dp))
|
Spacer(GlanceModifier.width(12.dp))
|
||||||
Column {
|
Column {
|
||||||
ShadowText(
|
Text(
|
||||||
text = dateStr,
|
text = dateStr,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.onSurfaceVariant,
|
color = GlanceTheme.colors.onSurfaceVariant,
|
||||||
fontSize = 12.sp,
|
fontSize = 12.sp,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
if (alarmStr != null) {
|
if (alarmStr != null) {
|
||||||
Spacer(GlanceModifier.height(2.dp))
|
Spacer(GlanceModifier.height(2.dp))
|
||||||
AlarmRow(alarmStr, 11, shadow)
|
Text(
|
||||||
|
text = alarmStr,
|
||||||
|
style = TextStyle(
|
||||||
|
color = GlanceTheme.colors.secondary,
|
||||||
|
fontSize = 11.sp,
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun FullLayout(
|
private fun FullLayout(hours: String, minutes: String, dateStr: String, alarmStr: String?) {
|
||||||
hours: String, minutes: String, dateStr: String, alarmStr: String?, shadow: Boolean,
|
|
||||||
) {
|
|
||||||
Column {
|
Column {
|
||||||
TimeRow(hours, minutes, shadow = shadow)
|
TimeRow(hours, minutes)
|
||||||
|
|
||||||
Spacer(GlanceModifier.height(2.dp))
|
Spacer(GlanceModifier.height(2.dp))
|
||||||
|
|
||||||
ShadowText(
|
Text(
|
||||||
text = dateStr,
|
text = dateStr,
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.onSurfaceVariant,
|
color = GlanceTheme.colors.onSurfaceVariant,
|
||||||
fontSize = 14.sp,
|
fontSize = 14.sp,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if (alarmStr != null) {
|
if (alarmStr != null) {
|
||||||
Spacer(GlanceModifier.height(4.dp))
|
Spacer(GlanceModifier.height(4.dp))
|
||||||
AlarmRow(alarmStr, 12, shadow)
|
Text(
|
||||||
}
|
text = alarmStr,
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
|
||||||
private fun AlarmRow(text: String, fontSize: Int, shadow: Boolean) {
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
|
||||||
Image(
|
|
||||||
provider = ImageProvider(android.R.drawable.ic_lock_idle_alarm),
|
|
||||||
contentDescription = "Alarm",
|
|
||||||
modifier = GlanceModifier.size(fontSize.dp),
|
|
||||||
colorFilter = ColorFilter.tint(GlanceTheme.colors.secondary),
|
|
||||||
)
|
|
||||||
Spacer(GlanceModifier.width(4.dp))
|
|
||||||
ShadowText(
|
|
||||||
text = text,
|
|
||||||
style = TextStyle(
|
style = TextStyle(
|
||||||
color = GlanceTheme.colors.secondary,
|
color = GlanceTheme.colors.secondary,
|
||||||
fontSize = fontSize.sp,
|
fontSize = 12.sp,
|
||||||
),
|
),
|
||||||
shadow = shadow,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun formatAlarm(time: LocalTime, date: LocalDate): String {
|
private fun formatAlarm(time: LocalTime, date: LocalDate): String {
|
||||||
val today = LocalDate.now()
|
val today = LocalDate.now()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue