Skip to content

Instantly share code, notes, and snippets.

View Oleur's full-sized avatar
👨‍💻
Doing stuff with the droid!

Julien Salvi Oleur

👨‍💻
Doing stuff with the droid!
View GitHub Profile
<manifest>
<application>
<activity android:name=".MyActivity">
<intent-filter
android:autoVerify="true"
tools:targetApi="m">
<action android:name="android.intent.action.VIEW" />
<actions>
<action intentName="actions.intent.GET_ITEM_LIST">
<fulfillment
fulfillmentMode="actions.fulfillment.SLICE"
urlTemplate="content://test.aircall.todo.slices/todo{?name,category}">
<parameter-mapping urlParameter="name" intentParameter="itemList.name" required="true" />
<parameter-mapping urlParameter="category" intentParameter="itemList.category" />
</fulfillment>
<actions>
<action intentName="actions.intent.CREATE_CALL">
<fulfillment urlTemplate="https://aircall-test.io/call-number{?telephone}">
<!-- Eg. telephone = "0987654321" -->
<parameter-mapping urlParameter="telephone" intentParameter="call.participant.telephone" required="true"/>
</fulfillment>
<fulfillment urlTemplate="https://aircall-test.io/call-name{?name}">
<!-- Eg. contact = "John Doe" -->
<parameter-mapping urlParameter="name" intentParameter="call.participant.name" required="true"/>
class PolyShape(private val sides: Int, private val radius: Float) : Shape {
override fun createOutline(size: Size, layoutDirection: LayoutDirection, density: Density): Outline {
return Outline.Generic(path = Path().apply { polygon(sides, radius, size.center) })
}
}
fun Path.polygon(sides: Int, radius: Float, center: Offset) {
val angle = 2.0 * Math.PI / sides
moveTo(
x = center.x + (radius * cos(0.0)).toFloat(),
@Composable
fun PolygonImageComposable(modifier: Modifier) {
val deltaXAnim = rememberInfiniteTransition()
val dx by deltaXAnim.animateFloat(
initialValue = 3f,
targetValue = 10f,
animationSpec = infiniteRepeatable(
animation = tween(4000, easing = LinearEasing),
repeatMode = RepeatMode.Reverse
)
@Composable
fun TicketWaveComposable(modifier: Modifier) {
val deltaXAnim = rememberInfiniteTransition()
val dx by deltaXAnim.animateFloat(
initialValue = 0f,
targetValue = 1f,
animationSpec = infiniteRepeatable(animation = tween(500, easing = LinearEasing))
)
CoilImage(
@Composable
fun TicketComposable(modifier: Modifier) {
Text(
text = "🎉 CINEMA TICKET 🎉",
style = TextStyle(
color = Color.White,
fontSize = 22.sp,
fontWeight = FontWeight.Black,
),
textAlign = TextAlign.Center,
fun drawTicketPath(size: Size, cornerRadius: Float): Path {
return Path().apply {
reset()
// Top left arc
arcTo(
rect = Rect(
left = -cornerRadius,
top = -cornerRadius,
right = cornerRadius,
bottom = cornerRadius
@Oleur
Oleur / TicketShape.kt
Created April 22, 2021 19:10
Shape that looks like
class TicketShape(private val cornerRadius: Float) : Shape {
override fun createOutline(
size: Size,
layoutDirection: LayoutDirection,
density: Density
): Outline {
return Outline.Generic(
// Draw your custom path here
path = drawTicketPath(size = size, cornerRadius = cornerRadius)
@Oleur
Oleur / CutCornerSample.kt
Created April 22, 2021 15:52
CurCornerShape sample in action
Text(
text = context.getString(R.string.timesup),
style = typography.h3.copy(color = red700),
textAlign = TextAlign.Center,
modifier = Modifier
.fillMaxWidth()
.padding(32.dp)
.border(width = 4.dp, color = red700, CutCornerShape(32.dp))
.graphicsLayer {
shadowElevation = 8.dp.toPx()