-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f62bbe
commit a5e5e35
Showing
51 changed files
with
510 additions
and
492 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
core/common/src/androidMain/kotlin/org/michaelbel/movies/common/ktx/PackageInfoKtx.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,23 @@ | ||
@file:Suppress("DEPRECATION") | ||
|
||
package org.michaelbel.movies.common.ktx | ||
|
||
import android.content.Context | ||
import android.content.pm.PackageInfo | ||
import android.content.pm.PackageManager | ||
import android.os.Build | ||
|
||
private val Context.packageInfo: PackageInfo | ||
get() { | ||
return if (Build.VERSION.SDK_INT >= 33) { | ||
packageManager.getPackageInfo(packageName, PackageManager.PackageInfoFlags.of(0L)) | ||
} else { | ||
packageManager.getPackageInfo(packageName, 0) | ||
} | ||
} | ||
|
||
val Context.versionName: String | ||
get() = packageInfo.versionName.orEmpty() | ||
|
||
val Context.versionCode: Long | ||
get() = if (Build.VERSION.SDK_INT >= 28) packageInfo.longVersionCode else packageInfo.versionCode.toLong() |
24 changes: 24 additions & 0 deletions
24
core/common/src/androidMain/kotlin/org/michaelbel/movies/common/ktx/SettingsKtx.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,24 @@ | ||
package org.michaelbel.movies.common.ktx | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import android.os.Build | ||
import android.provider.Settings | ||
|
||
val Context.appNotificationSettingsIntent: Intent | ||
get() { | ||
val intent = Intent() | ||
when { | ||
Build.VERSION.SDK_INT >= 26 -> { | ||
intent.action = Settings.ACTION_APP_NOTIFICATION_SETTINGS | ||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, packageName) | ||
} | ||
else -> { | ||
intent.action = "android.settings.APP_NOTIFICATION_SETTINGS" | ||
intent.putExtra("app_package", packageName) | ||
intent.putExtra("app_uid", applicationInfo.uid) | ||
} | ||
} | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) | ||
return intent | ||
} |
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
17 changes: 17 additions & 0 deletions
17
...actor/src/androidMain/kotlin/org/michaelbel/movies/interactor/impl/AboutInteractorImpl.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,17 @@ | ||
package org.michaelbel.movies.interactor.impl | ||
|
||
import android.content.Context | ||
import org.michaelbel.movies.common.ktx.versionCode | ||
import org.michaelbel.movies.common.ktx.versionName | ||
import org.michaelbel.movies.interactor.AboutInteractor | ||
|
||
class AboutInteractorImpl( | ||
private val context: Context | ||
): AboutInteractor { | ||
|
||
override val versionName: String | ||
get() = context.versionName | ||
|
||
override val versionCode: Long | ||
get() = context.versionCode | ||
} |
108 changes: 108 additions & 0 deletions
108
.../src/androidMain/kotlin/org/michaelbel/movies/interactor/impl/SettingsUiInteractorImpl.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,108 @@ | ||
package org.michaelbel.movies.interactor.impl | ||
|
||
import android.Manifest | ||
import android.app.Activity | ||
import android.os.Build | ||
import androidx.activity.compose.rememberLauncherForActivityResult | ||
import androidx.activity.result.contract.ActivityResultContracts | ||
import androidx.annotation.ChecksSdkIntAtLeast | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.LocalContext | ||
import org.michaelbel.movies.common.ktx.appNotificationSettingsIntent | ||
import org.michaelbel.movies.interactor.SettingsUiInteractor | ||
|
||
class SettingsUiInteractorImpl: SettingsUiInteractor { | ||
|
||
override val isNavigationIconVisible: Boolean | ||
get() = false | ||
|
||
override val isLanguageFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isThemeFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isFeedViewFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isMovieListFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isGenderFeatureEnabled: Boolean | ||
@ChecksSdkIntAtLeast(34) get() = Build.VERSION.SDK_INT >= 34 | ||
|
||
override val isNotificationsFeatureEnabled: Boolean | ||
@ChecksSdkIntAtLeast(33) get() = Build.VERSION.SDK_INT >= 33 | ||
|
||
override val isBiometricFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isWidgetFeatureEnabled: Boolean | ||
@ChecksSdkIntAtLeast(26) get() = Build.VERSION.SDK_INT >= 26 | ||
|
||
override val isTileFeatureEnabled: Boolean | ||
@ChecksSdkIntAtLeast(33) get() = Build.VERSION.SDK_INT >= 33 | ||
|
||
override val isAppIconFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isScreenshotFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isGithubFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isReviewAppFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isUpdateAppFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val isAboutFeatureEnabled: Boolean | ||
get() = true | ||
|
||
override val bottomBarModifier: Modifier | ||
get() = Modifier | ||
|
||
@Composable | ||
override fun navigateToAppNotificationSettings(): () -> Unit { | ||
val resultContract = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {} | ||
val context = LocalContext.current | ||
return { resultContract.launch(context.appNotificationSettingsIntent) } | ||
} | ||
|
||
@Composable | ||
override 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) | ||
} | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
core/interactor/src/commonMain/kotlin/org/michaelbel/movies/interactor/AboutInteractor.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,8 @@ | ||
package org.michaelbel.movies.interactor | ||
|
||
interface AboutInteractor { | ||
|
||
val versionName: String | ||
|
||
val versionCode: Long | ||
} |
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
51 changes: 51 additions & 0 deletions
51
...interactor/src/commonMain/kotlin/org/michaelbel/movies/interactor/SettingsUiInteractor.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,51 @@ | ||
package org.michaelbel.movies.interactor | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.Modifier | ||
|
||
interface SettingsUiInteractor { | ||
|
||
val isNavigationIconVisible: Boolean | ||
|
||
val isLanguageFeatureEnabled: Boolean | ||
|
||
val isThemeFeatureEnabled: Boolean | ||
|
||
val isFeedViewFeatureEnabled: Boolean | ||
|
||
val isMovieListFeatureEnabled: Boolean | ||
|
||
val isGenderFeatureEnabled: Boolean | ||
|
||
val isNotificationsFeatureEnabled: Boolean | ||
|
||
val isBiometricFeatureEnabled: Boolean | ||
|
||
val isWidgetFeatureEnabled: Boolean | ||
|
||
val isTileFeatureEnabled: Boolean | ||
|
||
val isAppIconFeatureEnabled: Boolean | ||
|
||
val isScreenshotFeatureEnabled: Boolean | ||
|
||
val isGithubFeatureEnabled: Boolean | ||
|
||
val isReviewAppFeatureEnabled: Boolean | ||
|
||
val isUpdateAppFeatureEnabled: Boolean | ||
|
||
val isAboutFeatureEnabled: Boolean | ||
|
||
val bottomBarModifier: Modifier | ||
|
||
@Composable | ||
fun navigateToAppNotificationSettings(): () -> Unit | ||
|
||
@Composable | ||
fun rememberPostNotificationsPermissionHandler( | ||
areNotificationsEnabled: Boolean, | ||
onPermissionGranted: () -> Unit, | ||
onPermissionDenied: () -> Unit | ||
): () -> Unit | ||
} |
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
5 changes: 0 additions & 5 deletions
5
...r/src/commonMain/kotlin/org/michaelbel/movies/interactor/di/InteractorLocaleKoinModule.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.