Skip to content

Commit

Permalink
Small fixes (notification permissions & other bugs)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElishaAz committed Sep 28, 2023
1 parent cf5cf1b commit f5b4b26
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 5 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
-keep class com.sun.jna.* { *; }
-keepclassmembers class * extends com.sun.jna.* { public *; }

-dontwarn java.awt.Component
-dontwarn java.awt.GraphicsEnvironment
-dontwarn java.awt.HeadlessException
-dontwarn java.awt.Window
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class SettingsActivity : ComponentActivity() {
companion object {
/* Used to handle permission request */
private const val PERMISSIONS_REQUEST_RECORD_AUDIO = 1
public const val PERMISSION_REQUEST_POST_NOTIFICATIONS = 1
}

@Preview
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ public fun GrantPermissionUi(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = Modifier.fillMaxSize(),
) {
Button(onClick = requestMic, enabled = mic.value) {
Button(onClick = requestMic, enabled = !mic.value) {
if (mic.value) {
Text(text = "Grant Microphone Permission")
} else {
Text(text = "Microphone Permission Granted")
} else {
Text(text = "Grant Microphone Permission")
}

}
Button(onClick = requestIme, enabled = ime.value) {
Button(onClick = requestIme, enabled = !ime.value) {
if (ime.value) {
Text(text = "Enable IME")
} else {
Text(text = "IME enabled")
} else {
Text(text = "Enable IME")
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/com/elishaazaria/sayboard/ui/ModelsSettingsUi.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.elishaazaria.sayboard.ui

import android.Manifest
import android.content.pm.PackageManager
import android.os.Build
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
Expand Down Expand Up @@ -38,6 +42,9 @@ import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.DialogProperties
import androidx.core.app.ActivityCompat
import androidx.core.app.NotificationManagerCompat
import androidx.core.content.ContextCompat
import androidx.lifecycle.MutableLiveData
import com.elishaazaria.sayboard.SettingsActivity
import com.elishaazaria.sayboard.Tools
Expand Down Expand Up @@ -188,6 +195,25 @@ class ModelsSettingsUi(private val activity: SettingsActivity) {
) {
FloatingActionButton(onClick = {
showDownloadDialog = true

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val permissionCheck = ContextCompat.checkSelfPermission(
activity.applicationContext,
Manifest.permission.POST_NOTIFICATIONS
)
if (permissionCheck != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(
activity, arrayOf(
Manifest.permission.POST_NOTIFICATIONS
), SettingsActivity.PERMISSION_REQUEST_POST_NOTIFICATIONS
)
Toast.makeText(
activity,
"Notifications recommended for downloader to work properly",
Toast.LENGTH_LONG
).show()
}
}
}) {
Icon(imageVector = Icons.Default.Download, contentDescription = null)
}
Expand Down

0 comments on commit f5b4b26

Please sign in to comment.