@@ -36,13 +36,15 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
3636 private var mBgColor = 0
3737 private var mTextColor = 0
3838
39+ private var mShowGrid = false
40+
3941 private val binding by viewBinding(WidgetConfigMonthlyBinding ::inflate)
4042 private val topNavigationBinding by lazy { TopNavigationBinding .bind(binding.root) }
4143
4244 public override fun onCreate (savedInstanceState : Bundle ? ) {
4345 useDynamicTheme = false
4446 super .onCreate(savedInstanceState)
45- setResult(Activity . RESULT_CANCELED )
47+ setResult(RESULT_CANCELED )
4648 setContentView(binding.root)
4749 setupEdgeToEdge(padTopSystem = listOf (binding.configHolder), padBottomSystem = listOf (binding.root))
4850 initVariables()
@@ -59,13 +61,16 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
5961 configSave.setOnClickListener { saveConfig() }
6062 configBgColor.setOnClickListener { pickBackgroundColor() }
6163 configTextColor.setOnClickListener { pickTextColor() }
64+ configGrid.setOnClickListener { pickGridShow() }
6265 configBgSeekbar.setColors(mTextColor, primaryColor, primaryColor)
66+ configGrid.isChecked = mShowGrid
6367 }
6468 }
6569
6670 private fun initVariables () {
6771 mBgColor = config.widgetBgColor
6872 mBgAlpha = Color .alpha(mBgColor) / 255f
73+ mShowGrid = config.widgetShowGrid
6974
7075 mBgColorWithoutTransparency = Color .rgb(Color .red(mBgColor), Color .green(mBgColor), Color .blue(mBgColor))
7176 binding.configBgSeekbar.apply {
@@ -84,7 +89,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
8489 }
8590
8691 updateTextColor()
87-
92+ updateGridShow()
8893 MonthlyCalendarImpl (this , this ).updateMonthlyCalendar(DateTime ().withDayOfMonth(1 ))
8994 }
9095
@@ -94,7 +99,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
9499
95100 Intent ().apply {
96101 putExtra(AppWidgetManager .EXTRA_APPWIDGET_ID , mWidgetId)
97- setResult(Activity . RESULT_OK , this )
102+ setResult(RESULT_OK , this )
98103 }
99104 finish()
100105 }
@@ -103,6 +108,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
103108 config.apply {
104109 widgetBgColor = mBgColor
105110 widgetTextColor = mTextColor
111+ widgetShowGrid = mShowGrid
106112 }
107113 }
108114
@@ -111,6 +117,7 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
111117 if (wasPositivePressed) {
112118 mBgColorWithoutTransparency = color
113119 updateBackgroundColor()
120+ updateGridShow()
114121 }
115122 }
116123 }
@@ -125,6 +132,45 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
125132 }
126133 }
127134
135+ private fun pickGridShow () {
136+ mShowGrid = ! mShowGrid
137+ updateGridShow()
138+ }
139+
140+ private fun updateGridShow () {
141+ if (mShowGrid) {
142+ binding.configCalendar.apply {
143+ val tableView = arrayOf(
144+ tableHolder,
145+ monthLineHolder1,
146+ monthLineHolder2,
147+ monthLineHolder3,
148+ monthLineHolder4,
149+ monthLineHolder5,
150+ monthLineHolder6
151+ )
152+ for (i in tableView) {
153+ i.showDividers = LinearLayout .SHOW_DIVIDER_MIDDLE
154+ }
155+ }
156+ return
157+ }
158+ binding.configCalendar.apply {
159+ val tableView = arrayOf(
160+ tableHolder,
161+ monthLineHolder1,
162+ monthLineHolder2,
163+ monthLineHolder3,
164+ monthLineHolder4,
165+ monthLineHolder5,
166+ monthLineHolder6
167+ )
168+ for (i in tableView) {
169+ i.showDividers = LinearLayout .SHOW_DIVIDER_NONE
170+ }
171+ }
172+ }
173+
128174 private fun requestWidgetUpdate () {
129175 Intent (AppWidgetManager .ACTION_APPWIDGET_UPDATE , null , this , MyWidgetMonthlyProvider ::class .java).apply {
130176 putExtra(AppWidgetManager .EXTRA_APPWIDGET_IDS , intArrayOf(mWidgetId))
@@ -145,6 +191,10 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
145191 mBgColor = mBgColorWithoutTransparency.adjustAlpha(mBgAlpha)
146192 binding.configCalendar.root.background.applyColorFilter(mBgColor)
147193 binding.configBgColor.setFillWithStroke(mBgColor, mBgColor)
194+ binding.configGrid.trackTintList = ColorStateList (
195+ arrayOf(intArrayOf(android.R .attr.state_checked), intArrayOf()),
196+ intArrayOf(getProperPrimaryColor(), Color .GRAY )
197+ )
148198 binding.configSave.backgroundTintList = ColorStateList .valueOf(getProperPrimaryColor())
149199 }
150200
@@ -196,7 +246,8 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
196246 }
197247
198248 DayMonthlyNumberViewBinding .inflate(layoutInflater).apply {
199- root.layoutParams = LinearLayout .LayoutParams (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT )
249+ root.layoutParams =
250+ LinearLayout .LayoutParams (ViewGroup .LayoutParams .WRAP_CONTENT , ViewGroup .LayoutParams .WRAP_CONTENT )
200251 linearLayout.addView(root)
201252
202253 dayMonthlyNumberBackground.beVisibleIf(day.isToday)
@@ -213,7 +264,13 @@ class WidgetMonthlyConfigureActivity : SimpleActivity(), MonthlyCalendar {
213264 }
214265 }
215266
216- override fun updateMonthlyCalendar (context : Context , month : String , days : ArrayList <DayMonthly >, checkedEvents : Boolean , currTargetDate : DateTime ) {
267+ override fun updateMonthlyCalendar (
268+ context : Context ,
269+ month : String ,
270+ days : ArrayList <DayMonthly >,
271+ checkedEvents : Boolean ,
272+ currTargetDate : DateTime
273+ ) {
217274 runOnUiThread {
218275 mDays = days
219276 topNavigationBinding.topValue.text = month
0 commit comments