Skip to content

Commit

Permalink
Update project
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbel committed Dec 25, 2024
1 parent 851f27e commit 0941b61
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<vector
xmlns:android="http://schemas.android.com/apk/res/android"
android:width="200dp"
android:height="80dp"
android:viewportWidth="200"
android:viewportHeight="80">
xmlns:tools="http://schemas.android.com/tools"
android:width="180dp"
android:height="64dp"
android:viewportWidth="180"
android:viewportHeight="64">
<path
android:fillColor="@color/primary"
android:pathData="M37.47,58L27.6,29.38H27.39C27.44,30.02 27.49,30.9 27.55,32.01C27.62,33.12 27.67,34.3 27.72,35.57C27.77,36.84 27.79,38.05 27.79,39.2V58H22.68V23.73H30.58L40.07,51.09H40.21L50.03,23.73H57.91V58H52.54V38.92C52.54,37.88 52.55,36.74 52.59,35.52C52.63,34.3 52.68,33.15 52.73,32.05C52.79,30.96 52.84,30.09 52.87,29.43H52.68L42.44,58H37.47ZM89.34,44.97C89.34,47.13 89.05,49.04 88.49,50.71C87.93,52.38 87.11,53.8 86.03,54.95C84.95,56.09 83.66,56.97 82.14,57.58C80.63,58.17 78.91,58.47 77.01,58.47C75.23,58.47 73.59,58.17 72.11,57.58C70.63,56.97 69.34,56.09 68.24,54.95C67.16,53.8 66.33,52.38 65.73,50.71C65.14,49.04 64.84,47.13 64.84,44.97C64.84,42.11 65.34,39.69 66.32,37.7C67.32,35.7 68.74,34.18 70.59,33.13C72.43,32.09 74.63,31.56 77.17,31.56C79.56,31.56 81.67,32.09 83.5,33.13C85.33,34.18 86.76,35.7 87.79,37.7C88.82,39.7 89.34,42.13 89.34,44.97ZM70.52,44.97C70.52,46.86 70.74,48.48 71.2,49.82C71.66,51.16 72.38,52.2 73.35,52.91C74.32,53.62 75.57,53.97 77.1,53.97C78.63,53.97 79.88,53.62 80.85,52.91C81.82,52.2 82.53,51.16 82.98,49.82C83.44,48.48 83.66,46.86 83.66,44.97C83.66,43.08 83.44,41.48 82.98,40.16C82.53,38.84 81.82,37.83 80.85,37.14C79.88,36.44 78.63,36.09 77.08,36.09C74.8,36.09 73.13,36.85 72.09,38.38C71.04,39.91 70.52,42.11 70.52,44.97ZM101.59,58L91.73,32.05H97.56L102.91,47.29C103.25,48.26 103.56,49.3 103.84,50.43C104.13,51.55 104.32,52.5 104.43,53.27H104.62C104.73,52.47 104.94,51.52 105.25,50.41C105.56,49.28 105.88,48.24 106.21,47.29L111.56,32.05H117.37L107.5,58H101.59ZM126.81,32.05V58H121.31V32.05H126.81ZM124.09,22.12C124.94,22.12 125.66,22.34 126.27,22.8C126.9,23.25 127.21,24.03 127.21,25.14C127.21,26.23 126.9,27.02 126.27,27.48C125.66,27.94 124.94,28.16 124.09,28.16C123.22,28.16 122.48,27.94 121.87,27.48C121.27,27.02 120.98,26.23 120.98,25.14C120.98,24.03 121.27,23.25 121.87,22.8C122.48,22.34 123.22,22.12 124.09,22.12ZM145.05,31.56C147.36,31.56 149.34,32.04 151,32.99C152.66,33.95 153.93,35.3 154.82,37.05C155.71,38.8 156.16,40.89 156.16,43.33V46.28H138.84C138.9,48.8 139.57,50.73 140.85,52.09C142.15,53.45 143.96,54.13 146.29,54.13C147.95,54.13 149.43,53.98 150.74,53.66C152.07,53.34 153.44,52.86 154.84,52.23V56.71C153.55,57.32 152.23,57.77 150.88,58.05C149.54,58.33 147.93,58.47 146.05,58.47C143.51,58.47 141.27,57.98 139.33,56.99C137.41,55.99 135.9,54.51 134.8,52.54C133.73,50.57 133.19,48.13 133.19,45.2C133.19,42.3 133.68,39.83 134.66,37.8C135.65,35.77 137.03,34.22 138.81,33.16C140.59,32.09 142.67,31.56 145.05,31.56ZM145.05,35.71C143.31,35.71 141.91,36.27 140.83,37.4C139.77,38.52 139.14,40.17 138.95,42.34H150.77C150.75,41.05 150.53,39.9 150.11,38.9C149.7,37.9 149.08,37.12 148.23,36.55C147.41,35.99 146.34,35.71 145.05,35.71ZM179.8,50.59C179.8,52.3 179.39,53.73 178.56,54.91C177.73,56.08 176.52,56.97 174.93,57.58C173.35,58.17 171.41,58.47 169.12,58.47C167.3,58.47 165.74,58.34 164.43,58.07C163.13,57.82 161.91,57.43 160.75,56.9V52.14C161.98,52.72 163.37,53.22 164.9,53.64C166.45,54.06 167.91,54.27 169.28,54.27C171.09,54.27 172.4,53.99 173.2,53.43C173.99,52.85 174.39,52.09 174.39,51.13C174.39,50.57 174.23,50.07 173.9,49.63C173.59,49.18 172.99,48.72 172.12,48.25C171.26,47.77 169.99,47.19 168.32,46.52C166.68,45.86 165.3,45.2 164.17,44.55C163.05,43.89 162.2,43.1 161.62,42.18C161.04,41.24 160.75,40.05 160.75,38.59C160.75,36.3 161.66,34.55 163.47,33.37C165.3,32.16 167.71,31.56 170.71,31.56C172.3,31.56 173.8,31.73 175.21,32.05C176.63,32.37 178.02,32.83 179.38,33.44L177.65,37.59C176.48,37.07 175.3,36.65 174.11,36.32C172.94,35.98 171.74,35.8 170.52,35.8C169.1,35.8 168.02,36.02 167.27,36.46C166.53,36.9 166.16,37.52 166.16,38.34C166.16,38.95 166.34,39.46 166.7,39.88C167.06,40.3 167.68,40.73 168.55,41.15C169.45,41.57 170.68,42.09 172.26,42.72C173.8,43.31 175.14,43.94 176.27,44.59C177.41,45.23 178.28,46.02 178.89,46.96C179.5,47.9 179.8,49.11 179.8,50.59Z" />
android:pathData="M75.97,41.01C74.67,41.91 73.45,42.36 72.31,42.36C71.17,42.36 70.36,42.09 69.88,41.55C69.42,41.01 69.19,40.3 69.19,39.42C69.19,38.54 69.66,36.28 70.6,32.64C71.54,28.98 72.01,26.71 72.01,25.83C72.01,24.73 71.62,24.18 70.84,24.18C70.06,24.18 69,24.76 67.66,25.92C67.62,26.08 67.29,27.3 66.67,29.58C65.31,34.58 64.58,38.61 64.48,41.67C63.7,41.97 62.29,42.12 60.25,42.12H59.86C59.86,40.88 60.39,38.02 61.45,33.54C62.51,29.06 63.04,26.45 63.04,25.71C63.04,24.69 62.63,24.18 61.81,24.18C60.93,24.18 59.78,24.8 58.36,26.04C58.36,30.12 57.64,33.94 56.2,37.5C55.52,39.18 54.63,40.55 53.53,41.61C52.45,42.65 51.33,43.17 50.17,43.17C49.03,43.17 48.13,42.82 47.47,42.12C46.83,41.44 46.51,40.49 46.51,39.27C46.51,38.03 46.95,36.58 47.83,34.92C48.71,33.24 49.64,31.81 50.62,30.63C51.62,29.43 52.64,28.35 53.68,27.39C53.68,25.55 53.46,24.44 53.02,24.06C52.8,23.88 52.48,23.79 52.06,23.79C51.66,23.79 51.06,23.97 50.26,24.33C49.48,24.69 48.73,25.18 48.01,25.8L47.26,24.75C47.96,23.89 49.01,23.06 50.41,22.26C51.81,21.46 53.05,21.06 54.13,21.06C55.23,21.06 56.09,21.35 56.71,21.93C57.35,22.49 57.8,23.21 58.06,24.09C60.82,21.83 63,20.7 64.6,20.7C65.4,20.7 66.08,20.95 66.64,21.45C67.22,21.95 67.59,22.7 67.75,23.7C70.11,21.7 72.08,20.7 73.66,20.7C74.54,20.7 75.28,21.05 75.88,21.75C76.5,22.45 76.81,23.4 76.81,24.6C76.81,25.78 76.32,28.17 75.34,31.77C74.36,35.37 73.87,37.65 73.87,38.61C73.87,39.55 74.17,40.02 74.77,40.02C74.97,40.02 75.22,39.97 75.52,39.87L75.97,41.01ZM49.6,40.32C50.4,40.32 51.19,39.33 51.97,37.35C52.77,35.35 53.31,32.85 53.59,29.85C52.31,31.17 51.16,32.74 50.14,34.56C49.12,36.36 48.61,37.77 48.61,38.79C48.61,39.81 48.94,40.32 49.6,40.32ZM82.8,42.36C81.42,42.36 80.34,41.88 79.56,40.92C78.78,39.94 78.39,38.58 78.39,36.84C78.39,34.62 78.98,32.71 80.16,31.11C81.36,29.51 83.01,28.71 85.11,28.71L86.19,28.77C86.53,28.59 86.91,28.5 87.33,28.5C88.91,28.5 89.7,29.99 89.7,32.97C90.52,32.93 91.35,32.82 92.19,32.64L92.67,32.52L92.85,33.69C92.19,33.97 91.3,34.22 90.18,34.44L89.58,34.56C89.2,36.66 88.43,38.49 87.27,40.05C86.11,41.59 84.62,42.36 82.8,42.36ZM84.42,39.78C85.26,39.78 86.01,39.24 86.67,38.16C87.35,37.08 87.82,35.94 88.08,34.74C85.94,34.74 84.87,33.94 84.87,32.34C84.87,31.7 85,31.1 85.26,30.54L85.41,30.24C85.33,30.2 85.23,30.18 85.11,30.18C84.99,30.18 84.9,30.2 84.84,30.24C84.34,30.56 83.87,31.31 83.43,32.49C82.99,33.67 82.77,35.02 82.77,36.54C82.77,38.7 83.32,39.78 84.42,39.78ZM93.93,28.71C94.81,28.71 95.46,28.89 95.88,29.25C96.32,29.61 96.54,30.35 96.54,31.47C96.54,32.07 96.36,33.3 96,35.16C95.64,37 95.46,38.12 95.46,38.52C95.46,39.32 95.62,39.72 95.94,39.72C96.7,39.72 97.53,39.16 98.43,38.04C99.35,36.9 99.83,35.95 99.87,35.19L97.83,32.91C97.91,32.05 98.12,31.27 98.46,30.57C98.8,29.87 99.12,29.38 99.42,29.1L99.84,28.71C100.7,28.71 101.35,28.94 101.79,29.4C102.23,29.86 102.45,30.4 102.45,31.02C102.45,32.6 102.06,34.27 101.28,36.03C100.5,37.79 99.46,39.29 98.16,40.53C96.86,41.75 95.54,42.36 94.2,42.36C93.36,42.36 92.71,42.1 92.25,41.58C91.81,41.06 91.59,40.38 91.59,39.54C91.59,38.68 91.65,37.53 91.77,36.09C91.91,34.65 91.98,33.22 91.98,31.8C91.98,31.48 91.86,31.1 91.62,30.66C91.4,30.22 91.17,29.87 90.93,29.61L91.02,29.25C92.1,28.89 93.07,28.71 93.93,28.71ZM109.04,30.57C109.04,31.41 108.77,32.86 108.23,34.92C107.69,36.96 107.42,38.3 107.42,38.94C107.42,39.56 107.51,39.87 107.69,39.87C107.81,39.87 108.27,39.68 109.07,39.3L109.43,39.12L109.94,40.17C109.76,40.33 109.52,40.53 109.22,40.77C108.92,41.01 108.36,41.34 107.54,41.76C106.72,42.16 105.96,42.36 105.26,42.36C104.56,42.36 104.01,42.15 103.61,41.73C103.21,41.29 103.01,40.71 103.01,39.99C103.01,39.25 103.26,37.95 103.76,36.09C104.26,34.21 104.51,32.99 104.51,32.43C104.51,31.59 104.25,30.8 103.73,30.06L103.46,29.7L103.49,29.31C104.55,29.01 106.27,28.86 108.65,28.86C108.91,29.16 109.04,29.73 109.04,30.57ZM105.62,25.59C105.22,25.19 105.02,24.66 105.02,24C105.02,23.34 105.29,22.76 105.83,22.26C106.39,21.76 107.03,21.51 107.75,21.51C108.47,21.51 109.03,21.71 109.43,22.11C109.83,22.51 110.03,23.04 110.03,23.7C110.03,24.34 109.74,24.91 109.16,25.41C108.6,25.91 107.97,26.16 107.27,26.16C106.57,26.16 106.02,25.97 105.62,25.59ZM110.88,36.81C110.88,34.31 111.63,32.34 113.13,30.9C114.65,29.44 116.37,28.71 118.29,28.71C119.47,28.71 120.44,29 121.2,29.58C121.96,30.16 122.34,30.94 122.34,31.92C122.34,32.88 122.09,33.69 121.59,34.35C121.11,35.01 120.52,35.52 119.82,35.88C118.4,36.58 117.1,37.02 115.92,37.2L115.2,37.29C115.34,39.17 116.11,40.11 117.51,40.11C117.99,40.11 118.5,39.99 119.04,39.75C119.58,39.51 120,39.27 120.3,39.03L120.75,38.67L121.47,39.63C121.31,39.85 120.99,40.14 120.51,40.5C120.03,40.86 119.58,41.16 119.16,41.4C118,42.04 116.73,42.36 115.35,42.36C113.97,42.36 112.88,41.87 112.08,40.89C111.28,39.91 110.88,38.55 110.88,36.81ZM115.17,35.82C116.19,35.64 117,35.21 117.6,34.53C118.2,33.85 118.5,32.97 118.5,31.89C118.5,30.81 118.18,30.27 117.54,30.27C116.78,30.27 116.19,30.92 115.77,32.22C115.37,33.5 115.17,34.7 115.17,35.82ZM132.55,38.07C132.55,39.33 131.99,40.36 130.87,41.16C129.77,41.96 128.51,42.36 127.09,42.36C125.67,42.36 124.54,42.06 123.7,41.46C122.88,40.86 122.47,40.33 122.47,39.87C122.47,39.59 122.82,39.14 123.52,38.52C124.22,37.88 124.81,37.49 125.29,37.35C126.29,38.09 127.11,39.26 127.75,40.86C128.49,40.8 128.86,40.45 128.86,39.81C128.86,38.89 128.05,37.59 126.43,35.91C124.81,34.21 124,32.86 124,31.86C124,30.86 124.45,30.09 125.35,29.55C126.25,28.99 127.33,28.71 128.59,28.71C129.87,28.71 130.83,28.94 131.47,29.4C132.11,29.84 132.43,30.45 132.43,31.23C132.43,31.99 131.82,33.05 130.6,34.41C130.74,34.55 130.92,34.74 131.14,34.98C131.36,35.2 131.65,35.63 132.01,36.27C132.37,36.91 132.55,37.51 132.55,38.07ZM129.67,33.36C130.51,32.64 130.93,31.93 130.93,31.23C130.93,30.53 130.45,30.18 129.49,30.18C129.03,30.18 128.65,30.28 128.35,30.48C128.05,30.66 127.9,30.87 127.9,31.11C127.9,31.55 128.34,32.17 129.22,32.97L129.67,33.36Z"
tools:ignore="VectorPath" />
</vector>
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

package org.michaelbel.movies.ui.compose

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.animation.core.LinearEasing
import androidx.compose.animation.core.RepeatMode
import androidx.compose.animation.core.animateFloat
Expand Down Expand Up @@ -36,38 +32,25 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.graphics.TransformOrigin
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import org.jetbrains.compose.ui.tooling.preview.Preview
import org.michaelbel.movies.ui.R
import org.michaelbel.movies.ui.accessibility.MoviesContentDescription
import org.michaelbel.movies.ui.icons.MoviesIcons
import org.michaelbel.movies.ui.ktx.appNotificationSettingsIntent
import org.michaelbel.movies.ui.ktx.rememberNavigateToAppSettings
import org.michaelbel.movies.ui.ktx.rememberRequestNotificationPermission
import org.michaelbel.movies.ui.theme.MoviesTheme

@Composable
fun NotificationBottomSheet(
onDismissRequest: () -> Unit,
modifier: Modifier = Modifier
) {
val context = LocalContext.current
val activityContract = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {}

val permissionContract = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted ->
val shouldRequest = (context as Activity).shouldShowRequestPermissionRationale(
Manifest.permission.POST_NOTIFICATIONS
)
if (!granted && !shouldRequest) {
activityContract.launch(context.appNotificationSettingsIntent)
}
}

val requestNotificationPermission = rememberRequestNotificationPermission()
val navigateToAppSettings = rememberNavigateToAppSettings()
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)

val value by rememberInfiniteTransition(label = "")
.animateFloat(
initialValue = 15F,
Expand Down Expand Up @@ -107,7 +90,7 @@ fun NotificationBottomSheet(
modifier = Modifier.graphicsLayer(
transformOrigin = TransformOrigin(
pivotFractionX = 0.5F,
pivotFractionY = 0.0F,
pivotFractionY = 0.0F
),
rotationZ = value
),
Expand All @@ -133,12 +116,8 @@ fun NotificationBottomSheet(
onClick = {
onDismissRequest()
when {
Build.VERSION.SDK_INT >= 33 -> {
permissionContract.launch(Manifest.permission.POST_NOTIFICATIONS)
}
else -> {
activityContract.launch(context.appNotificationSettingsIntent)
}
Build.VERSION.SDK_INT >= 33 -> requestNotificationPermission()
else -> navigateToAppSettings()
}
},
colors = ButtonDefaults.buttonColors(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package org.michaelbel.movies.ui.ktx

import android.Manifest
import android.app.Activity
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Build
import android.provider.Settings
import android.speech.RecognizerIntent
import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.platform.LocalContext
import androidx.core.content.ContextCompat
import androidx.core.net.toUri

@Composable
fun rememberSpeechRecognitionLauncher(onInputText: (String) -> Unit): () -> Unit {
Expand Down Expand Up @@ -41,4 +48,49 @@ fun rememberConnectivityClickHandler(): () -> Unit {
} else {
return {}
}
}

@Composable
fun rememberNavigateToAppSettings(): () -> Unit {
val context = LocalContext.current
val appSettingsContract = rememberLauncherForActivityResult(ActivityResultContracts.StartActivityForResult()) {}
val intent = Intent(
Settings.ACTION_APPLICATION_DETAILS_SETTINGS,
"package:${context.packageName}".toUri()
).apply {
addCategory(Intent.CATEGORY_DEFAULT)
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
}
return remember { { appSettingsContract.launch(intent) } }
}

@Composable
fun rememberRequestNotificationPermission(
onGranted: () -> Unit = {}
): () -> Unit {
if (Build.VERSION.SDK_INT >= 33) {
val context = LocalContext.current
val navigateToAppSettings = rememberNavigateToAppSettings()
val cameraPermissionContract = rememberLauncherForActivityResult(
ActivityResultContracts.RequestPermission()
) { granted ->
val shouldRequest = (context as Activity).shouldShowRequestPermissionRationale(Manifest.permission.POST_NOTIFICATIONS)
when {
granted -> onGranted()
!granted && !shouldRequest -> navigateToAppSettings()
}
}
return remember {
{
when {
ContextCompat.checkSelfPermission(context, Manifest.permission.POST_NOTIFICATIONS) != PackageManager.PERMISSION_GRANTED -> {
cameraPermissionContract.launch(Manifest.permission.POST_NOTIFICATIONS)
}
else -> onGranted()
}
}
}
} else {
return {}
}
}
2 changes: 1 addition & 1 deletion desktopApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ kotlin {

sourceSets {
jvmMain.dependencies {
implementation(projects.core.platformServices.injectDesktop)
implementation(projects.core.platformServices.injectJvm)
implementation(projects.feature.mainImpl)
}
}
Expand Down
2 changes: 1 addition & 1 deletion feature/main-impl/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ kotlin {
api(projects.feature.debug)
}
jvmMain.dependencies {
implementation(projects.core.platformServices.injectDesktop)
implementation(projects.core.platformServices.injectJvm)
}
iosMain.dependencies {
implementation(projects.core.platformServices.injectIos)
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ include(
":core:platform-services:hms",
":core:platform-services:foss",
":core:platform-services:inject-android",
":core:platform-services:inject-macos",
":core:platform-services:inject-jvm",
":core:platform-services:inject-ios",
":core:platform-services:inject-web",
":core:platform-services:interactor",
Expand Down

0 comments on commit 0941b61

Please sign in to comment.