Skip to content

Instantly share code, notes, and snippets.

View yaraki's full-sized avatar
🏠
Working from home

Yuichi Araki yaraki

🏠
Working from home
  • Google, Inc.
  • Tokyo
View GitHub Profile
@yaraki
yaraki / Gap.kt
Created March 5, 2021 05:50
Common interface for Spacers in Column and Row
package com.example.android.codelab.animationdemo.ui
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.ColumnScope
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.width
import androidx.compose.material.Text
// Copyright 2022 Google LLC.
// SPDX-License-Identifier: Apache-2.0
@Composable
fun LifecycleEffect(event: Lifecycle.Event, action: () -> Unit) {
val lifecycleOwner = LocalLifecycleOwner.current
val observer = LifecycleEventObserver { _, e ->
if (event == e) {
action()
}
@yaraki
yaraki / EdgeToEdge.kt
Last active March 29, 2024 07:49
Edge-to-edge setup for Android app in a backward-compatible manner.
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
val sendIntent = Intent(Intent.ACTION_SEND)
.putExtra(Intent.EXTRA_TEXT, "This is my text to send.")
.setType("text/plain")
val shareIntent = Intent.createChooser(sendIntent, null)
context.startActivity(shareIntent)
val sendIntent = Intent(Intent.ACTION_SEND)
.setType("text/plain")
.putExtra(Intent.EXTRA_TEXT, text)
val shareIntent = Intent.createChooser(sendIntent, null)
val customActions = arrayOf(
ChooserAction.Builder(
Icon.createWithResource(context, R.drawable.ic_send_to_devices),
"Send to your devices",
PendingIntent.getBroadcast(
context,