Skip to content

Commit

Permalink
Prompt for notification permission
Browse files Browse the repository at this point in the history
Preparation for the SDK upgrade from 32 to 33.
  • Loading branch information
hiqua committed Sep 21, 2023
1 parent 8a9b719 commit d97178d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions uhabits-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>


<application
android:name=".HabitsApplication"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d97178d

Please sign in to comment.