Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Nov 26, 2024
1 parent 2752c7c commit 80cfa2e
Show file tree
Hide file tree
Showing 51 changed files with 137 additions and 310 deletions.
1 change: 1 addition & 0 deletions core/interactor/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ kotlin {
commonMain.dependencies {
api(project(":core:analytics"))
api(project(":core:repository"))
api(project(":core:ui"))
implementation(libs.bundles.room.paging.common)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@ package org.michaelbel.movies.interactor.impl

import android.Manifest
import android.app.Activity
import android.content.Context
import android.os.Build
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.annotation.ChecksSdkIntAtLeast
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import com.google.android.material.color.DynamicColors
import org.michaelbel.movies.common.SealedString
import org.michaelbel.movies.common.ktx.appNotificationSettingsIntent
import org.michaelbel.movies.interactor.SettingsUiInteractor
import org.michaelbel.movies.ui.appicon.IconAlias
import org.michaelbel.movies.ui.appicon.enabledIcon
import org.michaelbel.movies.ui.appicon.setIcon
import org.michaelbel.movies.ui.ktx.currentGrammaticalGender
import org.michaelbel.movies.ui.ktx.displayCutoutWindowInsets
import org.michaelbel.movies.ui.ktx.supportSetRequestedApplicationGrammaticalGender

class SettingsUiInteractorImpl: SettingsUiInteractor {
class SettingsUiInteractorImpl(
private val context: Context
): SettingsUiInteractor {

override val isNavigationIconVisible: Boolean
get() = false
Expand All @@ -32,6 +44,12 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isGenderFeatureEnabled: Boolean
@ChecksSdkIntAtLeast(34) get() = Build.VERSION.SDK_INT >= 34

override val isDynamicColorsFeatureEnabled: Boolean
get() = DynamicColors.isDynamicColorAvailable()

override val isPaletteColorsFeatureEnabled: Boolean
get() = true

override val isNotificationsFeatureEnabled: Boolean
@ChecksSdkIntAtLeast(33) get() = Build.VERSION.SDK_INT >= 33

Expand Down Expand Up @@ -62,6 +80,9 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isAboutFeatureEnabled: Boolean
get() = true

override val settingsWindowInsets: WindowInsets
@Composable get() = displayCutoutWindowInsets

override val bottomBarModifier: Modifier
get() = Modifier

Expand Down Expand Up @@ -105,4 +126,18 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
}
}
}

override val enabledIcon: IconAlias
get() = context.enabledIcon

override fun setIcon(iconAlias: IconAlias) {
context.setIcon(iconAlias)
}

override val grammaticalGender: SealedString
get() = context.currentGrammaticalGender

override fun setGrammaticalGender(grammaticalGender: Int) {
context.supportSetRequestedApplicationGrammaticalGender(grammaticalGender)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.michaelbel.movies.interactor

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import org.michaelbel.movies.common.SealedString
import org.michaelbel.movies.ui.appicon.IconAlias

interface SettingsUiInteractor {

Expand All @@ -17,6 +20,10 @@ interface SettingsUiInteractor {

val isGenderFeatureEnabled: Boolean

val isDynamicColorsFeatureEnabled: Boolean

val isPaletteColorsFeatureEnabled: Boolean

val isNotificationsFeatureEnabled: Boolean

val isBiometricFeatureEnabled: Boolean
Expand All @@ -37,6 +44,9 @@ interface SettingsUiInteractor {

val isAboutFeatureEnabled: Boolean

@get:Composable
val settingsWindowInsets: WindowInsets

val bottomBarModifier: Modifier

@Composable
Expand All @@ -48,4 +58,12 @@ interface SettingsUiInteractor {
onPermissionGranted: () -> Unit,
onPermissionDenied: () -> Unit
): () -> Unit

val enabledIcon: IconAlias

fun setIcon(iconAlias: IconAlias)

val grammaticalGender: SealedString

fun setGrammaticalGender(grammaticalGender: Int)
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package org.michaelbel.movies.interactor.impl

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.navigationBarsPadding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.michaelbel.movies.common.SealedString
import org.michaelbel.movies.common.gender.GrammaticalGender
import org.michaelbel.movies.interactor.SettingsUiInteractor
import org.michaelbel.movies.ui.appicon.IconAlias

class SettingsUiInteractorImpl: SettingsUiInteractor {

Expand All @@ -25,6 +30,12 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isGenderFeatureEnabled: Boolean
get() = false

override val isDynamicColorsFeatureEnabled: Boolean
get() = false

override val isPaletteColorsFeatureEnabled: Boolean
get() = false

override val isNotificationsFeatureEnabled: Boolean
get() = false

Expand Down Expand Up @@ -55,6 +66,9 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isAboutFeatureEnabled: Boolean
get() = true

override val settingsWindowInsets: WindowInsets
@Composable get() = WindowInsets(0.dp, 0.dp, 0.dp, 0.dp)

override val bottomBarModifier: Modifier
get() = Modifier.navigationBarsPadding()

Expand All @@ -71,4 +85,14 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
): () -> Unit {
return {}
}

override val enabledIcon: IconAlias
get() = IconAlias.Red

override fun setIcon(iconAlias: IconAlias) {}

override val grammaticalGender: SealedString
get() = GrammaticalGender.NotSpecified()

override fun setGrammaticalGender(grammaticalGender: Int) {}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.michaelbel.movies.interactor.impl

import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import org.michaelbel.movies.common.SealedString
import org.michaelbel.movies.common.gender.GrammaticalGender
import org.michaelbel.movies.interactor.SettingsUiInteractor
import org.michaelbel.movies.ui.appicon.IconAlias

class SettingsUiInteractorImpl: SettingsUiInteractor {

Expand All @@ -24,6 +29,12 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isGenderFeatureEnabled: Boolean
get() = false

override val isDynamicColorsFeatureEnabled: Boolean
get() = false

override val isPaletteColorsFeatureEnabled: Boolean
get() = false

override val isNotificationsFeatureEnabled: Boolean
get() = false

Expand Down Expand Up @@ -54,6 +65,9 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
override val isAboutFeatureEnabled: Boolean
get() = true

override val settingsWindowInsets: WindowInsets
@Composable get() = WindowInsets(0.dp, 0.dp, 0.dp, 0.dp)

override val bottomBarModifier: Modifier
get() = Modifier

Expand All @@ -70,4 +84,14 @@ class SettingsUiInteractorImpl: SettingsUiInteractor {
): () -> Unit {
return {}
}

override val enabledIcon: IconAlias
get() = IconAlias.Red

override fun setIcon(iconAlias: IconAlias) {}

override val grammaticalGender: SealedString
get() = GrammaticalGender.NotSpecified()

override fun setGrammaticalGender(grammaticalGender: Int) {}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
import org.michaelbel.movies.settings_impl.R
import org.michaelbel.movies.ui.R

internal actual val SettingsGenderText: String
actual val SettingsGenderText: String
@Composable get() = stringResource(R.string.settings_gender)
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import android.app.GrammaticalInflectionManager
import android.content.Context
import android.os.Build
import org.michaelbel.movies.common.gender.GrammaticalGender

internal val Context.currentGrammaticalGender: GrammaticalGender
val Context.currentGrammaticalGender: GrammaticalGender
get() {
return if (Build.VERSION.SDK_INT >= 34) {
val grammaticalInflectionManager = getSystemService(GrammaticalInflectionManager::class.java)
Expand All @@ -16,7 +16,7 @@ internal val Context.currentGrammaticalGender: GrammaticalGender
}
}

internal fun Context.supportSetRequestedApplicationGrammaticalGender(grammaticalGender: Int) {
fun Context.supportSetRequestedApplicationGrammaticalGender(grammaticalGender: Int) {
if (Build.VERSION.SDK_INT >= 34) {
val grammaticalInflectionManager = getSystemService(GrammaticalInflectionManager::class.java)
grammaticalInflectionManager.setRequestedApplicationGrammaticalGender(grammaticalGender)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import android.app.StatusBarManager
import android.content.ComponentName
Expand Down
1 change: 1 addition & 0 deletions core/ui/src/androidMain/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<string name="share_via">Поделиться через</string>
<string name="tile_title">Movies</string>
<string name="tile_added">Плитка добавлена</string>
<string name="settings_gender">Род</string>
</resources>
1 change: 1 addition & 0 deletions core/ui/src/androidMain/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@
<string name="share_via">Share via</string>
<string name="tile_title">Movies</string>
<string name="tile_added">Movies Tile added</string>
<string name="settings_gender">Gender</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.michaelbel.movies.ui.ktx

expect val SettingsGenderText: String
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable
import org.jetbrains.compose.resources.stringResource
import org.michaelbel.movies.ui.strings.MoviesStrings

internal actual val SettingsGenderText: String
actual val SettingsGenderText: String
@Composable get() = stringResource(MoviesStrings.settings_gender)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable
import org.jetbrains.compose.resources.stringResource
import org.michaelbel.movies.ui.strings.MoviesStrings

internal actual val SettingsGenderText: String
actual val SettingsGenderText: String
@Composable get() = stringResource(MoviesStrings.settings_gender)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.ui.ktx

import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.widget.ktx

import android.appwidget.AppWidgetManager
import android.os.Build
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import org.michaelbel.movies.widget.ktx.pin

@Composable
actual fun rememberAndPinAppWidgetProvider(): () -> Unit {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.widget.ktx

import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.widget.ktx

import androidx.compose.runtime.Composable

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.michaelbel.movies.settings.ktx
package org.michaelbel.movies.widget.ktx

import androidx.compose.runtime.Composable

Expand Down

This file was deleted.

Loading

0 comments on commit 80cfa2e

Please sign in to comment.