-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into production-server-migration
# Conflicts: # app/src/main/java/tech/relaycorp/letro/contacts/ui/ManageContactScreen.kt
- Loading branch information
Showing
13 changed files
with
211 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/src/main/java/tech/relaycorp/letro/di/NotificationModule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package tech.relaycorp.letro.di | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import tech.relaycorp.letro.notification.NotificationPermissionManager | ||
import tech.relaycorp.letro.notification.NotificationPermissionManagerImpl | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
interface NotificationModule { | ||
|
||
@Binds | ||
@Singleton | ||
fun bindNotificationPermissionManager( | ||
impl: NotificationPermissionManagerImpl, | ||
): NotificationPermissionManager | ||
} |
26 changes: 26 additions & 0 deletions
26
app/src/main/java/tech/relaycorp/letro/notification/NotificationPermissionManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package tech.relaycorp.letro.notification | ||
|
||
import android.Manifest | ||
import android.content.Context | ||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import javax.inject.Inject | ||
|
||
interface NotificationPermissionManager { | ||
|
||
fun isPermissionGranted(): Boolean | ||
} | ||
|
||
class NotificationPermissionManagerImpl @Inject constructor( | ||
@ApplicationContext private val context: Context, | ||
) : NotificationPermissionManager { | ||
|
||
override fun isPermissionGranted(): Boolean { | ||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
context.checkSelfPermission(Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED | ||
} else { | ||
true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
app/src/main/java/tech/relaycorp/letro/utils/permission/PermissionUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package tech.relaycorp.letro.utils.permission | ||
|
||
import android.Manifest | ||
import android.os.Build | ||
import androidx.compose.runtime.Composable | ||
import com.google.accompanist.permissions.ExperimentalPermissionsApi | ||
import com.google.accompanist.permissions.PermissionState | ||
import com.google.accompanist.permissions.PermissionStatus | ||
import com.google.accompanist.permissions.rememberPermissionState | ||
|
||
@OptIn(ExperimentalPermissionsApi::class) | ||
@Composable | ||
fun rememberNotificationPermissionStateCompat( | ||
onPermissionResult: (Boolean) -> Unit, | ||
) = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { | ||
rememberPermissionState( | ||
permission = Manifest.permission.POST_NOTIFICATIONS, | ||
onPermissionResult = onPermissionResult, | ||
) | ||
} else { | ||
object : PermissionState { | ||
override val permission: String | ||
get() = "Mock_For_Api_Before_33" | ||
|
||
override val status: PermissionStatus | ||
get() = PermissionStatus.Granted | ||
|
||
override fun launchPermissionRequest() { | ||
// Do nothing | ||
} | ||
} | ||
} |
Oops, something went wrong.