Skip to content

Commit 748e3c6

Browse files
committed
#88 "Text shadow" option added to Colors section with these values: "No shadow" (default, nothing changes for existing widgets), "Dark shadow" and "Light shadow". For simplicity the same shadow applies to all parts of the widget.
1 parent 3446931 commit 748e3c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1299
-33
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,16 @@ In particular, see these solutions:
8585

8686
## Changelog
8787

88-
<a id="next"/>
89-
90-
### 2024- ...
91-
* Added settings to limit maximum number of lines for an event's title and for details (i.e. for time and location)
92-
[#109](https://github.com/andstatus/todoagenda/issues/109).
93-
* Event details -> "Description" option added to show Calendar event Description. [#78](https://github.com/andstatus/todoagenda/issues/78)
88+
<a id="v4.9"/>
89+
90+
### 2024-01-08 v4.9.0 Text shadow and Event description
91+
* "Text shadow" option added to Colors section with these values: "No shadow" (default, nothing changes for existing widgets),
92+
"Dark shadow" and "Light shadow". For simplicity the same shadow applies to all parts of the widget.
93+
[#88](https://github.com/andstatus/todoagenda/issues/88)
94+
* Event details -> "Description" option added to show Calendar event Description.
95+
[#78](https://github.com/andstatus/todoagenda/issues/78)
96+
* Added settings to limit maximum number of lines for an event's title and for details (i.e. for time,
97+
location and description). [#109](https://github.com/andstatus/todoagenda/issues/109).
9498

9599
<a id="v4.8"/>
96100

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
}
1313

1414
defaultConfig {
15-
versionCode 704
16-
versionName '4.8.0'
15+
versionCode 705
16+
versionName '4.9.0'
1717
minSdkVersion rootProject.minSdkVersion
1818
targetSdkVersion rootProject.targetSdkVersion
1919

app/src/main/kotlin/org/andstatus/todoagenda/EnvironmentChangedReceiver.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.andstatus.todoagenda.util.CalendarIntentUtil
1717
import org.andstatus.todoagenda.util.DateUtil
1818
import org.andstatus.todoagenda.util.PermissionsUtil
1919
import org.andstatus.todoagenda.widget.WidgetEntry
20+
import org.andstatus.todoagenda.widget.WidgetLayout
2021
import org.joda.time.DateTime
2122
import java.util.concurrent.TimeUnit
2223
import java.util.concurrent.atomic.AtomicReference
@@ -118,7 +119,8 @@ class EnvironmentChangedReceiver : BroadcastReceiver() {
118119
private fun gotoPosition(context: Context, widgetId: Int, position: Int) {
119120
if (widgetId == 0 || position < 0) return
120121
val appWidgetManager = AppWidgetManager.getInstance(context)
121-
val rv = RemoteViews(context.packageName, R.layout.widget_initial)
122+
val settings = AllSettings.instanceFromId(context, widgetId)
123+
val rv = RemoteViews(context.packageName, WidgetLayout.WIDGET_INITIAL.shadowed(settings.textShadow))
122124
Log.d(TAG, "gotoPosition, Scrolling widget $widgetId to position $position")
123125
rv.setScrollPosition(R.id.event_list, position)
124126
appWidgetManager.updateAppWidget(widgetId, rv)

app/src/main/kotlin/org/andstatus/todoagenda/RemoteViewsFactory.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import org.andstatus.todoagenda.widget.WidgetEntry
2929
import org.andstatus.todoagenda.widget.WidgetEntryPosition
3030
import org.andstatus.todoagenda.widget.WidgetEntryVisualizer
3131
import org.andstatus.todoagenda.widget.WidgetHeaderLayout
32+
import org.andstatus.todoagenda.widget.WidgetLayout
3233
import org.joda.time.DateTime
3334
import java.util.Locale
3435
import java.util.concurrent.ConcurrentHashMap
@@ -295,7 +296,7 @@ class RemoteViewsFactory(val context: Context, private val widgetId: Int, create
295296
return
296297
}
297298
val settings = AllSettings.instanceFromId(context, widgetId)
298-
val rv = RemoteViews(context.packageName, R.layout.widget_initial)
299+
val rv = RemoteViews(context.packageName, WidgetLayout.WIDGET_INITIAL.shadowed(settings.textShadow))
299300
settings.clock().updateZone()
300301
configureWidgetHeader(settings, rv)
301302
configureWidgetEntriesList(settings, rv)
@@ -311,7 +312,7 @@ class RemoteViewsFactory(val context: Context, private val widgetId: Int, create
311312
if (settings.widgetHeaderLayout != WidgetHeaderLayout.HIDDEN) {
312313
val headerView = RemoteViews(
313314
settings.context.packageName,
314-
settings.widgetHeaderLayout.layoutId
315+
settings.widgetHeaderLayout.widgetLayout?.shadowed(settings.textShadow) ?: 0
315316
)
316317
rv.addView(R.id.header_parent, headerView)
317318
RemoteViewsUtil.setBackgroundColor(

app/src/main/kotlin/org/andstatus/todoagenda/prefs/ApplicationPreferences.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package org.andstatus.todoagenda.prefs
33
import android.content.Context
44
import android.text.TextUtils
55
import androidx.preference.PreferenceManager
6+
import org.andstatus.todoagenda.prefs.InstanceSettings.Companion.PREF_TEXT_SHADOW
67
import org.andstatus.todoagenda.prefs.colors.BackgroundColorPref
78
import org.andstatus.todoagenda.prefs.colors.ColorThemeType
89
import org.andstatus.todoagenda.prefs.colors.TextColorPref
@@ -11,6 +12,7 @@ import org.andstatus.todoagenda.prefs.colors.ThemeColors
1112
import org.andstatus.todoagenda.prefs.dateformat.DateFormatValue
1213
import org.andstatus.todoagenda.util.StringUtil
1314
import org.andstatus.todoagenda.widget.EventEntryLayout
15+
import org.andstatus.todoagenda.widget.TextShadow
1416
import org.andstatus.todoagenda.widget.WidgetHeaderLayout
1517

1618
object ApplicationPreferences {
@@ -34,6 +36,7 @@ object ApplicationPreferences {
3436
setFillAllDayEvents(context, settings.fillAllDayEvents)
3537
setHideBasedOnKeywords(context, settings.hideBasedOnKeywords)
3638
setShowBasedOnKeywords(context, settings.showBasedOnKeywords)
39+
3740
val colors = settings.colors()
3841
setString(context, PREF_COLOR_THEME_TYPE, colors.colorThemeType.value)
3942
setBoolean(context, PREF_DIFFERENT_COLORS_FOR_DARK, colors.colorThemeType != ColorThemeType.SINGLE)
@@ -45,6 +48,8 @@ object ApplicationPreferences {
4548
setString(context, pref.shadingPreferenceName, colors.getTextShadingStored(pref).shading.themeName)
4649
setInt(context, pref.colorPreferenceName, colors.getTextColorStored(pref).color)
4750
}
51+
setString(context, PREF_TEXT_SHADOW, settings.textShadow.value)
52+
4853
setShowDaysWithoutEvents(context, settings.showDaysWithoutEvents)
4954
setShowDayHeaders(context, settings.showDayHeaders)
5055
setDateFormat(context, InstanceSettings.PREF_DAY_HEADER_DATE_FORMAT, settings.dayHeaderDateFormat)
@@ -209,6 +214,16 @@ object ApplicationPreferences {
209214
)
210215
}
211216

217+
fun getTextShadow(context: Context): TextShadow {
218+
return TextShadow.fromValue(
219+
getString(
220+
context,
221+
PREF_TEXT_SHADOW,
222+
TextShadow.NO_SHADOW.value
223+
)
224+
)
225+
}
226+
212227
fun getHorizontalLineBelowDayHeader(context: Context?): Boolean {
213228
return getBoolean(context, InstanceSettings.PREF_HORIZONTAL_LINE_BELOW_DAY_HEADER, false)
214229
}

app/src/main/kotlin/org/andstatus/todoagenda/prefs/InstanceSettings.kt

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import org.andstatus.todoagenda.util.MyClock
1515
import org.andstatus.todoagenda.util.StringUtil
1616
import org.andstatus.todoagenda.widget.Alignment
1717
import org.andstatus.todoagenda.widget.EventEntryLayout
18+
import org.andstatus.todoagenda.widget.TextShadow
1819
import org.andstatus.todoagenda.widget.WidgetHeaderLayout
1920
import org.joda.time.DateTime
2021
import org.json.JSONException
@@ -67,6 +68,11 @@ class InstanceSettings(private val contextIn: Context?, val widgetId: Int, propo
6768
// Colors
6869
private var defaultColors: ThemeColors
6970
private var darkColors: ThemeColors = ThemeColors.EMPTY
71+
var textShadow: TextShadow = TextShadow.NO_SHADOW
72+
private set
73+
74+
// ----------------------------------------------------------------------------------
75+
// ,,,
7076
var showEndTime = PREF_SHOW_END_TIME_DEFAULT
7177
private set
7278
var showLocation = PREF_SHOW_LOCATION_DEFAULT
@@ -165,6 +171,10 @@ class InstanceSettings(private val contextIn: Context?, val widgetId: Int, propo
165171
PREF_DARK_THEME
166172
)
167173
) else ThemeColors.EMPTY
174+
if (json.has(PREF_TEXT_SHADOW)) {
175+
textShadow = TextShadow.fromValue(json.getString(PREF_TEXT_SHADOW))
176+
}
177+
168178
if (json.has(PREF_SHOW_DAYS_WITHOUT_EVENTS)) {
169179
showDaysWithoutEvents = json.getBoolean(PREF_SHOW_DAYS_WITHOUT_EVENTS)
170180
}
@@ -326,6 +336,8 @@ class InstanceSettings(private val contextIn: Context?, val widgetId: Int, propo
326336
)
327337
}
328338
}
339+
textShadow = ApplicationPreferences.getTextShadow(context)
340+
329341
showDaysWithoutEvents = ApplicationPreferences.getShowDaysWithoutEvents(context)
330342
showDayHeaders = ApplicationPreferences.getShowDayHeaders(context)
331343
dayHeaderDateFormat = ApplicationPreferences.getDayHeaderDateFormat(context)
@@ -372,7 +384,11 @@ class InstanceSettings(private val contextIn: Context?, val widgetId: Int, propo
372384
}
373385

374386
init {
375-
widgetInstanceName = if (contextIn == null) "(empty)" else AllSettings.uniqueInstanceName(context, widgetId, proposedInstanceName)
387+
widgetInstanceName = if (contextIn == null) "(empty)" else AllSettings.uniqueInstanceName(
388+
context,
389+
widgetId,
390+
proposedInstanceName
391+
)
376392
defaultColors = if (contextIn == null) ThemeColors.EMPTY else ThemeColors(context, ColorThemeType.SINGLE)
377393
}
378394

@@ -419,6 +435,7 @@ class InstanceSettings(private val contextIn: Context?, val widgetId: Int, propo
419435
if (!darkColors.isEmpty) {
420436
json.put(PREF_DARK_THEME, darkColors.toJson(JSONObject()))
421437
}
438+
json.put(PREF_TEXT_SHADOW, textShadow.value)
422439
json.put(PREF_SHOW_DAYS_WITHOUT_EVENTS, showDaysWithoutEvents)
423440
json.put(PREF_SHOW_DAY_HEADERS, showDayHeaders)
424441
json.put(PREF_DAY_HEADER_DATE_FORMAT, dayHeaderDateFormat.save())
@@ -634,6 +651,11 @@ ${toJson()}"""
634651
const val PREF_MAXLINES_DETAILS_DEFAULT = 5
635652
const val PREF_DARK_THEME = "darkTheme"
636653

654+
// ----------------------------------------------------------------------------------
655+
// Color
656+
const val PREF_TEXT_SHADOW = "textShadow"
657+
val PREF_TEXT_SHADOW_DEFAULT = TextShadow.NO_SHADOW.name
658+
637659
// ----------------------------------------------------------------------------------
638660
// Event details
639661
const val PREF_SHOW_END_TIME = "showEndTime"

app/src/main/kotlin/org/andstatus/todoagenda/prefs/colors/ColorsPreferencesFragment.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import org.andstatus.todoagenda.R
1515
import org.andstatus.todoagenda.WidgetConfigurationActivity
1616
import org.andstatus.todoagenda.prefs.ApplicationPreferences
1717
import org.andstatus.todoagenda.prefs.InstanceSettings
18+
import org.andstatus.todoagenda.prefs.InstanceSettings.Companion.PREF_TEXT_SHADOW
1819
import org.andstatus.todoagenda.prefs.MyPreferenceFragment
20+
import org.andstatus.todoagenda.widget.TextShadow
1921
import org.andstatus.todoagenda.widget.TimeSection
2022
import java.util.Arrays
2123
import java.util.stream.Collectors
@@ -41,6 +43,7 @@ class ColorsPreferencesFragment : MyPreferenceFragment(), OnSharedPreferenceChan
4143
removeUnavailablePreferences()
4244
preferenceManager.sharedPreferences!!.registerOnSharedPreferenceChangeListener(this)
4345
showTextSources()
46+
showTextShadow()
4447
}
4548

4649
private fun showTextSources() {
@@ -133,10 +136,17 @@ class ColorsPreferencesFragment : MyPreferenceFragment(), OnSharedPreferenceChan
133136
}
134137
}
135138

139+
private fun showTextShadow() {
140+
findPreference<ListPreference>(PREF_TEXT_SHADOW)?.let { preference ->
141+
TextShadow.fromValue(preference.value).let { textShadow ->
142+
preference.summary = requireActivity().getString(textShadow.titleResId)
143+
}
144+
}
145+
}
146+
136147
private fun showShadings() {
137148
for (shadingPref in TextColorPref.entries) {
138-
val preference = findPreference<ListPreference>(shadingPref.shadingPreferenceName)
139-
if (preference != null) {
149+
findPreference<ListPreference>(shadingPref.shadingPreferenceName)?.let { preference ->
140150
val shading: Shading = Shading.fromThemeName(preference.value, shadingPref.defaultShading)
141151
preference.summary = requireActivity().getString(shading.titleResId)
142152
}
@@ -180,6 +190,7 @@ class ColorsPreferencesFragment : MyPreferenceFragment(), OnSharedPreferenceChan
180190
else -> {
181191
saveSettings()
182192
showTextSources()
193+
showTextShadow()
183194
}
184195
}
185196
}

app/src/main/kotlin/org/andstatus/todoagenda/widget/DayHeaderVisualizer.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ class DayHeaderVisualizer(context: Context, widgetId: Int) :
2828
val entry = eventEntry as DayHeader
2929
val rv = RemoteViews(
3030
context.packageName,
31-
if (horizontalLineBelowDayHeader) R.layout.day_header_separator_below else R.layout.day_header_separator_above
31+
if (horizontalLineBelowDayHeader) WidgetLayout.DAY_HEADER_SEPARATOR_BELOW.shadowed(settings.textShadow)
32+
else WidgetLayout.DAY_HEADER_SEPARATOR_ABOVE.shadowed(settings.textShadow)
3233
)
3334
rv.setInt(R.id.day_header_title_wrapper, "setGravity", alignment.gravity)
3435
val textColorPref: TextColorPref = TextColorPref.forDayHeader(entry)

app/src/main/kotlin/org/andstatus/todoagenda/widget/EventEntryLayout.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
package org.andstatus.todoagenda.widget
22

3-
import androidx.annotation.LayoutRes
43
import androidx.annotation.StringRes
54
import org.andstatus.todoagenda.R
65

76
/**
87
* @author yvolk@yurivolkov.com
98
*/
109
enum class EventEntryLayout(
11-
@field:LayoutRes @param:LayoutRes val layoutId: Int,
10+
val widgetLayout: WidgetLayout,
1211
val value: String,
1312
@field:StringRes val summaryResId: Int
1413
) {
15-
DEFAULT(R.layout.event_entry, "DEFAULT", R.string.default_multiline_layout),
16-
ONE_LINE(R.layout.event_entry_one_line, "ONE_LINE", R.string.single_line_layout);
14+
DEFAULT(WidgetLayout.EVENT_ENTRY_DEFAULT, "DEFAULT", R.string.default_multiline_layout),
15+
ONE_LINE(WidgetLayout.EVENT_ENTRY_ONE_LINE, "ONE_LINE", R.string.single_line_layout);
1716

1817
companion object {
1918
const val SPACE_PIPE_SPACE = " | "

app/src/main/kotlin/org/andstatus/todoagenda/widget/LastEntry.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.andstatus.todoagenda.widget
22

3-
import org.andstatus.todoagenda.R
43
import org.andstatus.todoagenda.prefs.InstanceSettings
54
import org.andstatus.todoagenda.prefs.OrderedEventSource
65
import org.andstatus.todoagenda.util.PermissionsUtil
@@ -13,11 +12,11 @@ class LastEntry(settings: InstanceSettings, val type: LastEntryType, date: DateT
1312
override val source: OrderedEventSource
1413
get() = OrderedEventSource.LAST_ENTRY
1514

16-
enum class LastEntryType(val layoutId: Int) {
17-
NOT_LOADED(R.layout.item_not_loaded),
18-
NO_PERMISSIONS(R.layout.item_no_permissions),
19-
EMPTY(R.layout.item_empty_list),
20-
LAST(R.layout.item_last)
15+
enum class LastEntryType(val widgetLayout: WidgetLayout) {
16+
NOT_LOADED(WidgetLayout.ITEM_NOT_LOADED),
17+
NO_PERMISSIONS(WidgetLayout.ITEM_NO_PERMISSIONS),
18+
EMPTY(WidgetLayout.ITEM_EMPTY_LIST),
19+
LAST(WidgetLayout.ITEM_LAST)
2120
}
2221

2322
companion object {

0 commit comments

Comments
 (0)