Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Nov 23, 2024
1 parent cf43d35 commit 46f92d0
Show file tree
Hide file tree
Showing 142 changed files with 884 additions and 893 deletions.
1 change: 0 additions & 1 deletion core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ kotlin {
}
jvmMain.dependencies {
api(libs.bundles.kotlinx.coroutines.desktop)
api(libs.bundles.jetbrains.androidx.lifecycle.viewmodel.compose.common)
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import org.michaelbel.movies.common.biometric.BiometricController2
import org.michaelbel.movies.common.biometric.impl.BiometricControllerImpl2

actual val biometricKoinModule2 = module {
singleOf(::BiometricControllerImpl2) { bind<BiometricController2>() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.michaelbel.movies.common.biometric.impl

import android.content.Context
import androidx.biometric.BiometricManager
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.michaelbel.movies.common.biometric.BiometricController2

internal class BiometricControllerImpl2(
private val context: Context
): BiometricController2 {

override val isBiometricAvailable: Flow<Boolean>
get() {
val biometricManager = BiometricManager.from(context)
val authenticators = biometricManager.canAuthenticate(BiometricManager.Authenticators.BIOMETRIC_STRONG or BiometricManager.Authenticators.DEVICE_CREDENTIAL)
return flowOf(authenticators == BiometricManager.BIOMETRIC_SUCCESS)
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.michaelbel.movies.common.biometric

import kotlinx.coroutines.flow.Flow

interface BiometricController2 {

val isBiometricAvailable: Flow<Boolean>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.Module

expect val biometricKoinModule2: Module
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package org.michaelbel.movies.common.viewmodel

import androidx.annotation.CallSuper
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import org.michaelbel.movies.common.dispatchers.uiDispatcher
Expand All @@ -11,6 +13,13 @@ open class BaseViewModel: ViewModel(
viewModelScope = CoroutineScope(uiDispatcher + SupervisorJob())
) {

private val errorHandler = CoroutineExceptionHandler { _, throwable ->
handleError(throwable)
}

val scope: CoroutineScope
get() = CoroutineScope(viewModelScope.coroutineContext + errorHandler)

@CallSuper
protected open fun handleError(throwable: Throwable) {
log(throwable)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import org.michaelbel.movies.common.biometric.BiometricController2
import org.michaelbel.movies.common.biometric.impl.BiometricControllerImpl2

actual val biometricKoinModule2 = module {
singleOf(::BiometricControllerImpl2) { bind<BiometricController2>() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.impl

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.michaelbel.movies.common.biometric.BiometricController2

internal class BiometricControllerImpl2: BiometricController2 {

override val isBiometricAvailable: Flow<Boolean>
get() = flowOf(false)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import org.michaelbel.movies.common.biometric.BiometricController2
import org.michaelbel.movies.common.biometric.impl.BiometricControllerImpl2

actual val biometricKoinModule2 = module {
singleOf(::BiometricControllerImpl2) { bind<BiometricController2>() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.impl

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.michaelbel.movies.common.biometric.BiometricController2

internal class BiometricControllerImpl2: BiometricController2 {

override val isBiometricAvailable: Flow<Boolean>
get() = flowOf(false)
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import org.michaelbel.movies.common.biometric.BiometricController2
import org.michaelbel.movies.common.biometric.impl.BiometricControllerImpl2

actual val biometricKoinModule2 = module {
singleOf(::BiometricControllerImpl2) { bind<BiometricController2>() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.impl

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.michaelbel.movies.common.biometric.BiometricController2

internal class BiometricControllerImpl2: BiometricController2 {

override val isBiometricAvailable: Flow<Boolean>
get() = flowOf(false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.di

import org.koin.core.module.dsl.bind
import org.koin.core.module.dsl.singleOf
import org.koin.dsl.module
import org.michaelbel.movies.common.biometric.BiometricController2
import org.michaelbel.movies.common.biometric.impl.BiometricControllerImpl2

actual val biometricKoinModule2 = module {
singleOf(::BiometricControllerImpl2) { bind<BiometricController2>() }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.michaelbel.movies.common.biometric.impl

import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
import org.michaelbel.movies.common.biometric.BiometricController2

internal class BiometricControllerImpl2: BiometricController2 {

override val isBiometricAvailable: Flow<Boolean>
get() = flowOf(false)
}

This file was deleted.

6 changes: 6 additions & 0 deletions core/notifications/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi

plugins {
alias(libs.plugins.kotlin.multiplatform)
alias(libs.plugins.kotlin.compose)
alias(libs.plugins.android.library)
alias(libs.plugins.compose)
}

kotlin {
Expand Down Expand Up @@ -35,4 +37,8 @@ android {
minSdk = libs.versions.min.sdk.get().toInt()
compileSdk = libs.versions.compile.sdk.get().toInt()
}

buildFeatures {
compose = true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.michaelbel.movies.notifications.ktx

import android.Manifest
import android.app.Activity
import android.os.Build
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import org.michaelbel.movies.ui.ktx.appNotificationSettingsIntent

@Composable
fun rememberPostNotificationsPermissionHandler(
areNotificationsEnabled: Boolean,
onPermissionGranted: () -> Unit,
onPermissionDenied: () -> Unit
): () -> Unit {
val context = LocalContext.current
val postNotificationsPermissionLauncher = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted ->
when {
granted -> onPermissionGranted()
else -> {
if (Build.VERSION.SDK_INT >= 33) {
val shouldRequest = (context as Activity).shouldShowRequestPermissionRationale(
Manifest.permission.POST_NOTIFICATIONS)
if (!shouldRequest) {
onPermissionDenied()
}
}
}
}
}
val resultContract = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {}
return {
if (areNotificationsEnabled) {
val intent = context.appNotificationSettingsIntent
resultContract.launch(intent)
} else if (Build.VERSION.SDK_INT >= 33) {
postNotificationsPermissionLauncher.launch(Manifest.permission.POST_NOTIFICATIONS)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

package org.michaelbel.movies.platform.impl.review

import android.app.Activity
import org.michaelbel.movies.platform.review.ReviewService

actual class ReviewServiceImpl: ReviewService {

override fun requestReview(activity: Activity) {}
}
actual class ReviewServiceImpl: ReviewService
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

package org.michaelbel.movies.platform.impl.update

import android.app.Activity
import org.michaelbel.movies.platform.update.UpdateListener
import org.michaelbel.movies.platform.update.UpdateService

actual class UpdateServiceImpl: UpdateService {

override fun setUpdateAvailableListener(listener: UpdateListener) {}

override fun startUpdate(activity: Activity) {}
}
actual class UpdateServiceImpl: UpdateService
Loading

0 comments on commit 46f92d0

Please sign in to comment.