Skip to content

Instantly share code, notes, and snippets.

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

rackadev racka98

🏠
Working from home
View GitHub Profile
@racka98
racka98 / am2320.c
Last active December 31, 2022 09:45
AM2320 Sensor failing example
#include "am2320.h"
static uint16_t readRegister16(uint8_t reg);
static uint16_t crc16(uint8_t *buffer, uint8_t nbytes);
static void sensor_read() {
sleep_ms(3000);
am2320_data values;
while (true) {
@racka98
racka98 / ModalBottomSheet.kt
Created December 5, 2022 07:25 — forked from LouisCAD/ModalBottomSheet.kt
Put this in its own Gradle module to have ModalBottomSheet in Material3 (or even without Material Design at all).
package com.louiscad.splitties.eap.bottomsheet
import android.app.Activity
import android.view.ViewGroup
import androidx.activity.compose.BackHandler
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.ModalBottomSheetLayout
import androidx.compose.runtime.Composable
import androidx.compose.runtime.DisposableEffect
import androidx.compose.runtime.getValue
@racka98
racka98 / AndroidHapticFeedback.kt
Last active August 7, 2022 14:13
Using VibrationEffect.Composition on Android 12+ for custom vibrations. VibrationEffect also works on Android 8+ with some missing features.
import android.content.Context
import android.os.*
class AndroidHapticFeedback(private val context: Context) {
fun tick() {
val durationMillis = 20L
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
val vibrationEffect = VibrationEffect.createPredefined(VibrationEffect.EFFECT_TICK)
vibrate(durationMillis, vibrationEffect)
} else vibrate(durationMillis)
@racka98
racka98 / BarsVisibility.kt
Last active June 20, 2022 20:44
Bars Visibility utilities in Jetpack Compose. For cases when you want to hide a bottom navigation bar or top bar on a screen that does not need them.
/**
* The base properties and methods that each item will need.
* Just to make it easier to add more bars item that can need hiding.
* Eg. scroll bars, navigation rails, etc.
*/
@Stable
interface BarVisibilityState {
val isVisible: Boolean
fun hide()
fun show()
@racka98
racka98 / CollapsingToolbarBase.kt
Last active September 9, 2022 11:33
Collapsing Toolbar with Jetpack Compose using NestedScrollConnection
/**
* Collapsing Toolbar that can be used in a topBar slot of Scaffold.
* It has a back button, default bottom rounded corners
* & a box scope which holds content centered by default.
* You need to implement nestedScrollConnection to set the offset values
* See Usage of this in DashboardScreen or TasksScreen or GoalsScreen
*
* To use this Toolbar without a heading text just make toolbarHeading `null`
* To Disable the back button at the top set showBackButton to false
*
@racka98
racka98 / app-build.gradle.kts
Last active October 10, 2021 19:33
Android 12 Splash Screen Demo Gist
android {
compileSdk = 31
}
dependencies {
val splahScreenVersion = "1.0.0-alpha01"
// Use: def instead of val if you are not using Kotlin Gradle(.kts)
implementation("androidx.core:core-splashscreen:$splashScreenVersion")
}