-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New deeplink for open update/mfkey32 screen (#715)
**Background** User can scan QR Code and open app **Changes** * New deep link model + parser + handler * Wait Flipper connection on mfkey **Test plan** Try go to https://flpr.app/o/mfkey32 https://flpr.app/o/update Co-authored: @Programistich --------- Co-authored-by: Dzhos Oleksii <[email protected]>
- Loading branch information
Showing
21 changed files
with
463 additions
and
64 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
90 changes: 90 additions & 0 deletions
90
...a/com/flipperdevices/core/ui/flippermockup/internal/ComposableFlipperMockupInternalRaw.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,90 @@ | ||
package com.flipperdevices.core.ui.flippermockup.internal | ||
|
||
import androidx.annotation.DrawableRes | ||
import androidx.compose.foundation.Image | ||
import androidx.compose.foundation.background | ||
import androidx.compose.foundation.layout.Box | ||
import androidx.compose.foundation.layout.BoxWithConstraints | ||
import androidx.compose.foundation.layout.Column | ||
import androidx.compose.foundation.layout.aspectRatio | ||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.layout.size | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.res.painterResource | ||
import androidx.compose.ui.res.stringResource | ||
import androidx.compose.ui.tooling.preview.Preview | ||
import com.flipperdevices.core.ui.flippermockup.R | ||
import com.flipperdevices.core.ui.theme.FlipperThemeInternal | ||
|
||
private const val IMAGE_WIDTH_PADDING_PERCENT = 60.56f / FLIPPER_DEFAULT_WIDTH | ||
private const val IMAGE_HEIGHT_PADDING_PERCENT = 10.54f / FLIPPER_DEFAULT_HEIGHT | ||
private const val IMAGE_WIDTH_PERCENT = 85.33f / FLIPPER_DEFAULT_WIDTH | ||
private const val IMAGE_HEIGHT_PERCENT = 46.96f / FLIPPER_DEFAULT_HEIGHT | ||
private const val IMAGE_ROUND_CORNER_PERCENT = 3.4f / FLIPPER_DEFAULT_WIDTH | ||
|
||
@Composable | ||
fun ComposableFlipperMockupInternalRaw( | ||
@DrawableRes templatePicId: Int, | ||
modifier: Modifier = Modifier, | ||
content: @Composable () -> Unit | ||
) { | ||
BoxWithConstraints( | ||
modifier | ||
.aspectRatio( | ||
ratio = FLIPPER_RATIO | ||
) | ||
) { | ||
Image( | ||
modifier = Modifier.fillMaxSize(), | ||
painter = painterResource(templatePicId), | ||
contentDescription = stringResource(R.string.flippermockup_template_desc) | ||
) | ||
Box( | ||
modifier = Modifier | ||
.padding( | ||
start = remember(maxWidth) { maxWidth * IMAGE_WIDTH_PADDING_PERCENT }, | ||
top = remember(maxHeight) { maxHeight * IMAGE_HEIGHT_PADDING_PERCENT } | ||
) | ||
.size( | ||
width = remember(maxWidth) { maxWidth * IMAGE_WIDTH_PERCENT }, | ||
height = remember(maxHeight) { maxHeight * IMAGE_HEIGHT_PERCENT } | ||
) | ||
.clip( | ||
RoundedCornerShape( | ||
size = remember(maxWidth) { maxWidth * IMAGE_ROUND_CORNER_PERCENT } | ||
) | ||
), | ||
) { | ||
content() | ||
} | ||
} | ||
} | ||
|
||
@Preview( | ||
showSystemUi = true, | ||
showBackground = true | ||
) | ||
@Composable | ||
private fun ComposableFlipperMockupInternalPreview() { | ||
FlipperThemeInternal { | ||
Column { | ||
ComposableFlipperMockupInternalRaw( | ||
modifier = Modifier.fillMaxWidth(), | ||
templatePicId = R.drawable.template_white_flipper_active | ||
) { | ||
Box( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.background(Color.Red) | ||
) | ||
} | ||
} | ||
} | ||
} |
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
36 changes: 36 additions & 0 deletions
36
...ink/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkMfKey.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,36 @@ | ||
package com.flipperdevices.deeplink.impl.parser.delegates | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.core.log.LogTagProvider | ||
import com.flipperdevices.deeplink.api.DeepLinkParserDelegate | ||
import com.flipperdevices.deeplink.impl.utils.Constants | ||
import com.flipperdevices.deeplink.model.DeepLinkParserDelegatePriority | ||
import com.flipperdevices.deeplink.model.Deeplink | ||
import com.squareup.anvil.annotations.ContributesMultibinding | ||
import javax.inject.Inject | ||
|
||
private val PATHS = listOf("o", "mfkey32") | ||
|
||
@ContributesMultibinding(AppGraph::class, DeepLinkParserDelegate::class) | ||
class DeepLinkMfKey @Inject constructor() : DeepLinkParserDelegate, LogTagProvider { | ||
override val TAG = "DeepLinkFap" | ||
|
||
override fun getPriority( | ||
context: Context, | ||
intent: Intent | ||
): DeepLinkParserDelegatePriority? { | ||
val pathSegment = intent.data?.pathSegments | ||
|
||
return when { | ||
intent.data == null -> null | ||
!Constants.SUPPORTED_HOSTS.contains(intent.data?.host) -> null | ||
pathSegment == null -> null | ||
pathSegment == PATHS -> DeepLinkParserDelegatePriority.HIGH | ||
else -> null | ||
} | ||
} | ||
|
||
override suspend fun fromIntent(context: Context, intent: Intent) = Deeplink.OpenMfKey | ||
} |
36 changes: 36 additions & 0 deletions
36
...nk/impl/src/main/java/com/flipperdevices/deeplink/impl/parser/delegates/DeepLinkUpdate.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,36 @@ | ||
package com.flipperdevices.deeplink.impl.parser.delegates | ||
|
||
import android.content.Context | ||
import android.content.Intent | ||
import com.flipperdevices.core.di.AppGraph | ||
import com.flipperdevices.core.log.LogTagProvider | ||
import com.flipperdevices.deeplink.api.DeepLinkParserDelegate | ||
import com.flipperdevices.deeplink.impl.utils.Constants | ||
import com.flipperdevices.deeplink.model.DeepLinkParserDelegatePriority | ||
import com.flipperdevices.deeplink.model.Deeplink | ||
import com.squareup.anvil.annotations.ContributesMultibinding | ||
import javax.inject.Inject | ||
|
||
private val PATHS = listOf("o", "update") | ||
|
||
@ContributesMultibinding(AppGraph::class, DeepLinkParserDelegate::class) | ||
class DeepLinkUpdate @Inject constructor() : DeepLinkParserDelegate, LogTagProvider { | ||
override val TAG = "DeepLinkFap" | ||
|
||
override fun getPriority( | ||
context: Context, | ||
intent: Intent | ||
): DeepLinkParserDelegatePriority? { | ||
val pathSegment = intent.data?.pathSegments | ||
|
||
return when { | ||
intent.data == null -> null | ||
!Constants.SUPPORTED_HOSTS.contains(intent.data?.host) -> null | ||
pathSegment == null -> null | ||
pathSegment == PATHS -> DeepLinkParserDelegatePriority.HIGH | ||
else -> null | ||
} | ||
} | ||
|
||
override suspend fun fromIntent(context: Context, intent: Intent) = Deeplink.OpenUpdate | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...nfc/mfkey32/api/src/main/java/com/flipperdevices/nfc/mfkey32/api/MfKey32HandleDeeplink.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,7 @@ | ||
package com.flipperdevices.nfc.mfkey32.api | ||
|
||
import android.content.Intent | ||
|
||
interface MfKey32HandleDeeplink { | ||
fun handleDeepLink(intent: 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
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.