diff --git a/uhabits-android/build.gradle.kts b/uhabits-android/build.gradle.kts index 2cb5be48a..eaf2b81b4 100644 --- a/uhabits-android/build.gradle.kts +++ b/uhabits-android/build.gradle.kts @@ -42,13 +42,13 @@ kotlin { android { - compileSdk = 32 + compileSdk = 33 defaultConfig { versionCode = 20200 versionName = "2.2.0" minSdk = 28 - targetSdk = 32 + targetSdk = 33 applicationId = "org.isoron.uhabits" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/FrequencyChartTest.kt b/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/FrequencyChartTest.kt index 0c4225f99..390644283 100644 --- a/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/FrequencyChartTest.kt +++ b/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/FrequencyChartTest.kt @@ -18,6 +18,7 @@ */ package org.isoron.uhabits.activities.common.views +import android.view.MotionEvent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import org.isoron.uhabits.BaseViewTest @@ -52,7 +53,12 @@ class FrequencyChartTest : BaseViewTest() { @Test @Throws(Throwable::class) fun testRender_withDataOffset() { - view.onScroll(null, null, -dpToPixels(150), 0f) + view.onScroll( + MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_SCROLL, 0f, 0f, 0), + MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_SCROLL, 0f, 0f, 0), + -dpToPixels(150), + 0f + ) view.invalidate() assertRenders(view, BASE_PATH + "renderDataOffset.png") } diff --git a/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/ScoreChartTest.kt b/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/ScoreChartTest.kt index 4f504d8be..e82693461 100644 --- a/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/ScoreChartTest.kt +++ b/uhabits-android/src/androidTest/java/org/isoron/uhabits/activities/common/views/ScoreChartTest.kt @@ -18,6 +18,7 @@ */ package org.isoron.uhabits.activities.common.views +import android.view.MotionEvent import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.filters.MediumTest import org.isoron.uhabits.BaseViewTest @@ -63,7 +64,12 @@ class ScoreChartTest : BaseViewTest() { @Test @Throws(Throwable::class) fun testRender_withDataOffset() { - view.onScroll(null, null, -dpToPixels(150), 0f) + view.onScroll( + MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_SCROLL, 0f, 0f, 0), + MotionEvent.obtain(0L, 0L, MotionEvent.ACTION_SCROLL, 0f, 0f, 0), + -dpToPixels(150), + 0f + ) view.invalidate() assertRenders(view, BASE_PATH + "renderDataOffset.png") } diff --git a/uhabits-android/src/main/AndroidManifest.xml b/uhabits-android/src/main/AndroidManifest.xml index 9377e42c0..e1d3d1103 100644 --- a/uhabits-android/src/main/AndroidManifest.xml +++ b/uhabits-android/src/main/AndroidManifest.xml @@ -22,6 +22,8 @@ + + diff --git a/uhabits-android/src/main/java/org/isoron/platform/gui/AndroidDataView.kt b/uhabits-android/src/main/java/org/isoron/platform/gui/AndroidDataView.kt index 990314a06..f0dcd378a 100644 --- a/uhabits-android/src/main/java/org/isoron/platform/gui/AndroidDataView.kt +++ b/uhabits-android/src/main/java/org/isoron/platform/gui/AndroidDataView.kt @@ -44,21 +44,21 @@ class AndroidDataView( addUpdateListener(this@AndroidDataView) } - override fun onTouchEvent(event: MotionEvent?) = detector.onTouchEvent(event) - override fun onDown(e: MotionEvent?) = true - override fun onShowPress(e: MotionEvent?) = Unit + override fun onTouchEvent(event: MotionEvent) = detector.onTouchEvent(event) + override fun onDown(e: MotionEvent) = true + override fun onShowPress(e: MotionEvent) = Unit - override fun onSingleTapUp(e: MotionEvent?): Boolean { + override fun onSingleTapUp(e: MotionEvent): Boolean { return handleClick(e, true) } - override fun onLongPress(e: MotionEvent?) { + override fun onLongPress(e: MotionEvent) { handleClick(e) } override fun onScroll( - e1: MotionEvent?, - e2: MotionEvent?, + e1: MotionEvent, + e2: MotionEvent, dx: Float, dy: Float ): Boolean { @@ -79,8 +79,8 @@ class AndroidDataView( } override fun onFling( - e1: MotionEvent?, - e2: MotionEvent?, + e1: MotionEvent, + e2: MotionEvent, velocityX: Float, velocityY: Float ): Boolean { @@ -100,7 +100,7 @@ class AndroidDataView( return false } - override fun onAnimationUpdate(animation: ValueAnimator?) { + override fun onAnimationUpdate(animation: ValueAnimator) { if (!scroller.isFinished) { scroller.computeScrollOffset() updateDataOffset() diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/views/ScrollableChart.kt b/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/views/ScrollableChart.kt index 509acc067..b69e491fe 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/views/ScrollableChart.kt +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/common/views/ScrollableChart.kt @@ -116,7 +116,7 @@ abstract class ScrollableChart : View, GestureDetector.OnGestureListener, Animat return BundleSavedState(superState, bundle) } - override fun onScroll(e1: MotionEvent?, e2: MotionEvent?, dx: Float, dy: Float): Boolean { + override fun onScroll(e1: MotionEvent, e2: MotionEvent, dx: Float, dy: Float): Boolean { var dx = dx if (scrollerBucketSize == 0) return false if (abs(dx) > abs(dy)) { diff --git a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt index a2f329d71..e737deea2 100644 --- a/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt +++ b/uhabits-android/src/main/java/org/isoron/uhabits/activities/habits/edit/EditHabitActivity.kt @@ -23,6 +23,7 @@ import android.annotation.SuppressLint import android.content.res.ColorStateList import android.content.res.Resources import android.graphics.Color +import android.os.Build import android.os.Bundle import android.text.Html import android.text.Spanned @@ -138,6 +139,7 @@ class EditHabitActivity : AppCompatActivity() { binding.targetOuterBox.visibility = View.GONE binding.targetTypeOuterBox.visibility = View.GONE } + HabitType.NUMERICAL -> { binding.nameInput.hint = getString(R.string.measurable_short_example) binding.questionInput.hint = getString(R.string.measurable_question_example) @@ -271,6 +273,14 @@ class EditHabitActivity : AppCompatActivity() { habit.description = binding.notesInput.text.trim().toString() habit.color = color if (reminderHour >= 0) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { + requestPermissions( + arrayOf( + android.Manifest.permission.POST_NOTIFICATIONS + ), + 1 + ) + } habit.reminder = Reminder(reminderHour, reminderMin, reminderDays) } else { habit.reminder = null diff --git a/uhabits-android/src/main/res/xml/locales_config.xml b/uhabits-android/src/main/res/xml/locales_config.xml new file mode 100644 index 000000000..a0fefcb50 --- /dev/null +++ b/uhabits-android/src/main/res/xml/locales_config.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file