Skip to content

Commit 6116ef9

Browse files
committed
Merge branch 'hotfix/2.1.3'
2 parents 69b5ed3 + 8801960 commit 6116ef9

File tree

10 files changed

+69
-9
lines changed

10 files changed

+69
-9
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changelog
22

3+
## [2.1.3] -- 2023-08-28
4+
### Fixed
5+
- Use text input on Samsung devices (@iSoron, #1719)
6+
- Prevent crash if alarm permission is revoked (@iSoron)
7+
- Adjust widget colors (@iSoron)
8+
- Fix bug preventing screens from updating at midnight (@iSoron)
9+
- Fix skip button in locales that use comma instead of dot (@iSoron, #1721)
10+
311
## [2.1.2] -- 2023-05-26
412
### Fixed
513
- Fix bug that caused widget to enter checkmark on wrong date (@iSoron, #1541)

uhabits-android/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ android {
3535
compileSdk = 31
3636

3737
defaultConfig {
38-
versionCode = 20102
39-
versionName = "2.1.2"
38+
versionCode = 20103
39+
versionName = "2.1.3"
4040
minSdk = 23
4141
targetSdk = 31
4242
applicationId = "org.isoron.uhabits"

uhabits-android/src/main/java/org/isoron/uhabits/activities/common/dialogs/NumberDialog.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package org.isoron.uhabits.activities.common.dialogs
22

33
import android.app.Dialog
44
import android.os.Bundle
5+
import android.provider.Settings
56
import android.text.method.DigitsKeyListener
67
import android.view.KeyEvent
78
import android.view.LayoutInflater
89
import android.view.MotionEvent
910
import android.view.View
11+
import android.view.inputmethod.EditorInfo
1012
import androidx.appcompat.app.AppCompatDialogFragment
1113
import org.isoron.uhabits.HabitsApplication
1214
import org.isoron.uhabits.R
@@ -65,7 +67,7 @@ class NumberDialog : AppCompatDialogFragment() {
6567
save()
6668
}
6769
view.skipBtnNumber.setOnClickListener {
68-
view.value.setText((Entry.SKIP.toDouble() / 1000).toString())
70+
view.value.setText(DecimalFormat("#.###").format((Entry.SKIP.toDouble() / 1000)))
6971
save()
7072
}
7173
view.notes.setOnEditorActionListener { v, actionId, event ->
@@ -86,6 +88,15 @@ class NumberDialog : AppCompatDialogFragment() {
8688
// https://stackoverflow.com/a/34256139
8789
val separator = DecimalFormatSymbols.getInstance().decimalSeparator
8890
view.value.keyListener = DigitsKeyListener.getInstance("0123456789$separator")
91+
92+
// https://github.com/flutter/flutter/issues/61175
93+
val currKeyboard = Settings.Secure.getString(
94+
requireContext().contentResolver,
95+
Settings.Secure.DEFAULT_INPUT_METHOD
96+
)
97+
if (currKeyboard.contains("swiftkey") || currKeyboard.contains("samsung")) {
98+
view.value.inputType = EditorInfo.TYPE_CLASS_TEXT
99+
}
89100
}
90101

91102
fun save() {

uhabits-android/src/main/java/org/isoron/uhabits/intents/IntentScheduler.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import android.app.AlarmManager.RTC_WAKEUP
2525
import android.app.PendingIntent
2626
import android.content.Context
2727
import android.content.Context.ALARM_SERVICE
28+
import android.os.Build
2829
import android.util.Log
2930
import org.isoron.uhabits.core.AppScope
3031
import org.isoron.uhabits.core.models.Habit
@@ -56,6 +57,10 @@ class IntentScheduler
5657
)
5758
return SchedulerResult.IGNORED
5859
}
60+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && !manager.canScheduleExactAlarms()) {
61+
Log.e("IntentScheduler", "No permission to schedule exact alarms")
62+
return SchedulerResult.IGNORED
63+
}
5964
manager.setExactAndAllowWhileIdle(alarmType, timestamp, intent)
6065
return SchedulerResult.OK
6166
}

uhabits-android/src/main/res/layout/checkmark_popup.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:layout_height="0dp"
3737
android:layout_weight="1"
3838
android:gravity="center"
39-
android:inputType="textCapSentences"
39+
android:inputType="textCapSentences|textMultiLine"
4040
android:textSize="@dimen/smallTextSize"
4141
android:padding="4dp"
4242
android:background="@color/transparent"

uhabits-android/src/main/res/layout/widget_graph.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
android:layout_height="wrap_content"
4545
android:gravity="center"
4646
android:textSize="@dimen/smallTextSize"
47+
android:maxLines="2"
4748
android:textColor="@color/white"/>
4849

4950
</LinearLayout>

uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/ui/views/Themes.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,30 @@ class WidgetTheme : LightTheme() {
125125
override val highContrastTextColor = Color.WHITE
126126
override val mediumContrastTextColor = Color.WHITE.withAlpha(0.50)
127127
override val lowContrastTextColor = Color.WHITE.withAlpha(0.10)
128+
129+
override fun color(paletteIndex: Int): Color {
130+
return when (paletteIndex) {
131+
0 -> Color(0xD32F2F)
132+
1 -> Color(0xE64A19)
133+
2 -> Color(0xF57C00)
134+
3 -> Color(0xFF8F00)
135+
4 -> Color(0xF9A825)
136+
5 -> Color(0xAFB42B)
137+
6 -> Color(0x7CB342)
138+
7 -> Color(0x388E3C)
139+
8 -> Color(0x00897B)
140+
9 -> Color(0x00ACC1)
141+
10 -> Color(0x039BE5)
142+
11 -> Color(0x1976D2)
143+
12 -> Color(0x6275f0)
144+
13 -> Color(0x5E35B1)
145+
14 -> Color(0x8E24AA)
146+
15 -> Color(0xD81B60)
147+
16 -> Color(0x5D4037)
148+
17 -> Color(0x757575)
149+
18 -> Color(0x757575)
150+
19 -> Color(0x9E9E9E)
151+
else -> Color(0x000000)
152+
}
153+
}
128154
}

uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/utils/DateUtils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ abstract class DateUtils {
227227
fun getStartOfTodayWithOffset(): Long = getStartOfDayWithOffset(getLocalTime())
228228

229229
@JvmStatic
230-
fun millisecondsUntilTomorrowWithOffset(): Long = getStartOfTomorrowWithOffset() - getLocalTime()
230+
fun millisecondsUntilTomorrowWithOffset(): Long = getStartOfTomorrowWithOffset() - applyTimezone(getLocalTime())
231231

232232
@JvmStatic
233233
fun getStartOfTodayCalendar(): GregorianCalendar = getCalendar(getStartOfToday())

uhabits-core/src/jvmMain/java/org/isoron/uhabits/core/utils/MidnightTimer.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.isoron.uhabits.core.utils
2020

2121
import org.isoron.uhabits.core.AppScope
22+
import org.isoron.uhabits.core.io.Logging
2223
import java.util.LinkedList
2324
import java.util.concurrent.Executors
2425
import java.util.concurrent.ScheduledExecutorService
@@ -29,27 +30,33 @@ import javax.inject.Inject
2930
* A class that emits events when a new day starts.
3031
*/
3132
@AppScope
32-
open class MidnightTimer @Inject constructor() {
33+
open class MidnightTimer @Inject constructor(logging: Logging) {
3334
private val listeners: MutableList<MidnightListener> = LinkedList()
3435
private lateinit var executor: ScheduledExecutorService
36+
private val logger = logging.getLogger("MidnightTimer")
3537

3638
@Synchronized
3739
fun addListener(listener: MidnightListener) {
3840
this.listeners.add(listener)
3941
}
4042

4143
@Synchronized
42-
fun onPause(): MutableList<Runnable>? = executor.shutdownNow()
44+
fun onPause(): MutableList<Runnable>? {
45+
logger.info("Pausing timer")
46+
return executor.shutdownNow()
47+
}
4348

4449
@Synchronized
4550
fun onResume(
4651
delayOffsetInMillis: Long = DateUtils.SECOND_LENGTH,
4752
testExecutor: ScheduledExecutorService? = null
4853
) {
4954
executor = testExecutor ?: Executors.newSingleThreadScheduledExecutor()
55+
val initialDelay = DateUtils.millisecondsUntilTomorrowWithOffset() + delayOffsetInMillis
56+
logger.info("Scheduling refresh for $initialDelay ms from now")
5057
executor.scheduleAtFixedRate(
5158
{ notifyListeners() },
52-
DateUtils.millisecondsUntilTomorrowWithOffset() + delayOffsetInMillis,
59+
initialDelay,
5360
DateUtils.DAY_LENGTH,
5461
TimeUnit.MILLISECONDS
5562
)
@@ -60,6 +67,7 @@ open class MidnightTimer @Inject constructor() {
6067

6168
@Synchronized
6269
private fun notifyListeners() {
70+
logger.info("Midnight refresh")
6371
for (l in listeners) {
6472
l.atMidnight()
6573
}

uhabits-core/src/jvmTest/java/org/isoron/uhabits/core/utils/MidnightTimerTest.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import kotlinx.coroutines.asCoroutineDispatcher
44
import kotlinx.coroutines.runBlocking
55
import kotlinx.coroutines.withContext
66
import org.isoron.uhabits.core.BaseUnitTest
7+
import org.isoron.uhabits.core.io.StandardLogging
78
import org.junit.Test
89
import java.util.Calendar
910
import java.util.TimeZone
@@ -34,7 +35,7 @@ class MidnightTimerTest : BaseUnitTest() {
3435
)
3536

3637
val suspendedListener = suspendCoroutine<Boolean> { continuation ->
37-
MidnightTimer().apply {
38+
MidnightTimer(StandardLogging()).apply {
3839
addListener { continuation.resume(true) }
3940
// When
4041
onResume(1, executor)

0 commit comments

Comments
 (0)