mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-04-24 15:08:49 +02:00
add optional text shadow to widget for better readability
This commit is contained in:
parent
3b5bf64066
commit
c1feb66b91
@ -3,6 +3,7 @@ package com.simplemobiletools.clock.activities
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.simplemobiletools.clock.R
|
import com.simplemobiletools.clock.R
|
||||||
import com.simplemobiletools.clock.extensions.config
|
import com.simplemobiletools.clock.extensions.config
|
||||||
|
import com.simplemobiletools.clock.extensions.updateWidgets
|
||||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_ALARM_REMINDER_SECS
|
||||||
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
import com.simplemobiletools.clock.helpers.DEFAULT_MAX_TIMER_REMINDER_SECS
|
||||||
import com.simplemobiletools.commons.extensions.*
|
import com.simplemobiletools.commons.extensions.*
|
||||||
@ -30,13 +31,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupSnoozeTime()
|
setupSnoozeTime()
|
||||||
setupVibrate()
|
setupVibrate()
|
||||||
setupTimerMaxReminder()
|
setupTimerMaxReminder()
|
||||||
|
setupUseTextShadow()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
setupSectionColors()
|
setupSectionColors()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupSectionColors() {
|
private fun setupSectionColors() {
|
||||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||||
arrayListOf(clock_tab_label, alarm_tab_label, stopwatch_tab_label, timer_tab_label).forEach {
|
arrayListOf(clock_tab_label, alarm_tab_label, stopwatch_tab_label, timer_tab_label, widgets_label).forEach {
|
||||||
it.setTextColor(adjustedPrimaryColor)
|
it.setTextColor(adjustedPrimaryColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,6 +139,15 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupUseTextShadow() {
|
||||||
|
settings_use_text_shadow.isChecked = config.useTextShadow
|
||||||
|
settings_use_text_shadow_holder.setOnClickListener {
|
||||||
|
settings_use_text_shadow.toggle()
|
||||||
|
config.useTextShadow = settings_use_text_shadow.isChecked
|
||||||
|
updateWidgets()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateSnoozeText() {
|
private fun updateSnoozeText() {
|
||||||
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
settings_snooze_time.text = formatMinutesToTimeString(config.snoozeTime)
|
||||||
}
|
}
|
||||||
|
@ -74,6 +74,11 @@ class WidgetDateTimeConfigureActivity : SimpleActivity() {
|
|||||||
val calendar = Calendar.getInstance()
|
val calendar = Calendar.getInstance()
|
||||||
config_time.text = getFormattedTime(calendar, false)
|
config_time.text = getFormattedTime(calendar, false)
|
||||||
config_date.text = getFormattedDate(calendar)
|
config_date.text = getFormattedDate(calendar)
|
||||||
|
|
||||||
|
if (config.useTextShadow) {
|
||||||
|
config_time.setShadowLayer(1f, 0f, 1f, Color.BLACK)
|
||||||
|
config_date.setShadowLayer(1f, 0f, 1f, Color.BLACK)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveConfig() {
|
private fun saveConfig() {
|
||||||
|
@ -4,6 +4,8 @@ import android.annotation.SuppressLint
|
|||||||
import android.app.AlarmManager
|
import android.app.AlarmManager
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
import android.appwidget.AppWidgetManager
|
||||||
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.media.RingtoneManager
|
import android.media.RingtoneManager
|
||||||
@ -156,3 +158,15 @@ fun Context.hideNotification(id: Int) {
|
|||||||
val manager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val manager = applicationContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
manager.cancel(id)
|
manager.cancel(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun Context.updateWidgets() {
|
||||||
|
val widgetsCnt = AppWidgetManager.getInstance(applicationContext).getAppWidgetIds(ComponentName(applicationContext, MyWidgetDateTimeProvider::class.java))
|
||||||
|
if (widgetsCnt.isNotEmpty()) {
|
||||||
|
val ids = intArrayOf(R.xml.widget_date_time_info)
|
||||||
|
Intent(applicationContext, MyWidgetDateTimeProvider::class.java).apply {
|
||||||
|
action = AppWidgetManager.ACTION_APPWIDGET_UPDATE
|
||||||
|
putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, ids)
|
||||||
|
sendBroadcast(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -49,4 +49,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var alarmMaxReminderSecs: Int
|
var alarmMaxReminderSecs: Int
|
||||||
get() = prefs.getInt(ALARM_MAX_REMINDER_SECS, DEFAULT_MAX_ALARM_REMINDER_SECS)
|
get() = prefs.getInt(ALARM_MAX_REMINDER_SECS, DEFAULT_MAX_ALARM_REMINDER_SECS)
|
||||||
set(alarmMaxReminderSecs) = prefs.edit().putInt(ALARM_MAX_REMINDER_SECS, alarmMaxReminderSecs).apply()
|
set(alarmMaxReminderSecs) = prefs.edit().putInt(ALARM_MAX_REMINDER_SECS, alarmMaxReminderSecs).apply()
|
||||||
|
|
||||||
|
var useTextShadow: Boolean
|
||||||
|
get() = prefs.getBoolean(USE_TEXT_SHADOW, true)
|
||||||
|
set(useTextShadow) = prefs.edit().putBoolean(USE_TEXT_SHADOW, useTextShadow).apply()
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ const val TIMER_SOUND_URI = "timer_sound_uri"
|
|||||||
const val TIMER_SOUND_TITLE = "timer_sound_title"
|
const val TIMER_SOUND_TITLE = "timer_sound_title"
|
||||||
const val TIMER_MAX_REMINDER_SECS = "timer_max_reminder_secs"
|
const val TIMER_MAX_REMINDER_SECS = "timer_max_reminder_secs"
|
||||||
const val ALARM_MAX_REMINDER_SECS = "alarm_max_reminder_secs"
|
const val ALARM_MAX_REMINDER_SECS = "alarm_max_reminder_secs"
|
||||||
|
const val USE_TEXT_SHADOW = "use_text_shadow"
|
||||||
|
|
||||||
const val TABS_COUNT = 4
|
const val TABS_COUNT = 4
|
||||||
const val EDITED_TIME_ZONE_SEPARATOR = ":"
|
const val EDITED_TIME_ZONE_SEPARATOR = ":"
|
||||||
|
@ -22,7 +22,8 @@ class MyWidgetDateTimeProvider : AppWidgetProvider() {
|
|||||||
private fun performUpdate(context: Context) {
|
private fun performUpdate(context: Context) {
|
||||||
val appWidgetManager = AppWidgetManager.getInstance(context)
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||||
RemoteViews(context.packageName, R.layout.widget_date_time).apply {
|
val layout = if (context.config.useTextShadow) R.layout.widget_date_time_with_shadow else R.layout.widget_date_time
|
||||||
|
RemoteViews(context.packageName, layout).apply {
|
||||||
updateTexts(context, this)
|
updateTexts(context, this)
|
||||||
updateColors(context, this)
|
updateColors(context, this)
|
||||||
appWidgetManager.updateAppWidget(it, this)
|
appWidgetManager.updateAppWidget(it, this)
|
||||||
|
@ -369,5 +369,45 @@
|
|||||||
android:clickable="false"/>
|
android:clickable="false"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/widgets_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1px"
|
||||||
|
android:background="@color/divider_grey"
|
||||||
|
android:importantForAccessibility="no"/>
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
|
android:id="@+id/widgets_label"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/bigger_margin"
|
||||||
|
android:layout_marginStart="@dimen/bigger_margin"
|
||||||
|
android:layout_marginTop="@dimen/activity_margin"
|
||||||
|
android:text="@string/widgets"
|
||||||
|
android:textAllCaps="true"
|
||||||
|
android:textSize="@dimen/smaller_text_size"/>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_use_text_shadow_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:paddingBottom="@dimen/activity_margin"
|
||||||
|
android:paddingLeft="@dimen/normal_margin"
|
||||||
|
android:paddingRight="@dimen/normal_margin"
|
||||||
|
android:paddingTop="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||||
|
android:id="@+id/settings_use_text_shadow"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@null"
|
||||||
|
android:clickable="false"
|
||||||
|
android:paddingLeft="@dimen/medium_margin"
|
||||||
|
android:paddingStart="@dimen/medium_margin"
|
||||||
|
android:text="@string/use_text_shadow"/>
|
||||||
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
35
app/src/main/res/layout/widget_date_time_with_shadow.xml
Normal file
35
app/src/main/res/layout/widget_date_time_with_shadow.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/widget_date_time_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/widget_time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:shadowColor="@android:color/black"
|
||||||
|
android:shadowDy="1"
|
||||||
|
android:shadowRadius="1"
|
||||||
|
android:textSize="@dimen/widget_time_text_size"
|
||||||
|
tools:text="00:00"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/widget_date"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/widget_time"
|
||||||
|
android:gravity="center_horizontal"
|
||||||
|
android:includeFontPadding="false"
|
||||||
|
android:paddingBottom="@dimen/normal_margin"
|
||||||
|
android:shadowColor="@android:color/black"
|
||||||
|
android:shadowDy="1"
|
||||||
|
android:shadowRadius="1"
|
||||||
|
android:textSize="@dimen/normal_text_size"
|
||||||
|
tools:text="Mon, 1 January"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
@ -13,6 +13,7 @@
|
|||||||
<string name="max_reminder_duration">Max reminder duration</string>
|
<string name="max_reminder_duration">Max reminder duration</string>
|
||||||
<string name="time_expired">Time expired</string>
|
<string name="time_expired">Time expired</string>
|
||||||
<string name="digital_clock_and_date">Digital clock and date</string>
|
<string name="digital_clock_and_date">Digital clock and date</string>
|
||||||
|
<string name="use_text_shadow">Use text shadow</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="clock_tab">Relógio</string>
|
<string name="clock_tab">Relógio</string>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<string name="max_reminder_duration">Maximálna dĺžka upozorňovania</string>
|
<string name="max_reminder_duration">Maximálna dĺžka upozorňovania</string>
|
||||||
<string name="time_expired">Čas vypršal</string>
|
<string name="time_expired">Čas vypršal</string>
|
||||||
<string name="digital_clock_and_date">Digitálne hodiny a dátum</string>
|
<string name="digital_clock_and_date">Digitálne hodiny a dátum</string>
|
||||||
|
<string name="use_text_shadow">Použiť tieňovanie písma</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="clock_tab">Okno s časom</string>
|
<string name="clock_tab">Okno s časom</string>
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
<string name="max_reminder_duration">Max reminder duration</string>
|
<string name="max_reminder_duration">Max reminder duration</string>
|
||||||
<string name="time_expired">Time expired</string>
|
<string name="time_expired">Time expired</string>
|
||||||
<string name="digital_clock_and_date">Digital clock and date</string>
|
<string name="digital_clock_and_date">Digital clock and date</string>
|
||||||
|
<string name="use_text_shadow">Use text shadow</string>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
<string name="clock_tab">Clock tab</string>
|
<string name="clock_tab">Clock tab</string>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user