Skip to content

Instantly share code, notes, and snippets.

View akexorcist's full-sized avatar
🔥

Akexorcist akexorcist

🔥
View GitHub Profile
@akexorcist
akexorcist / EdgeCurveShape.kt
Created June 30, 2024 07:49
Curve Edge Shape for Jetpack Compose or Compose Multiplatform
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
class EdgeCurveShape(
private val direction: Direction,
) : Shape {
@akexorcist
akexorcist / BeakShape.kt
Last active July 6, 2024 22:34
Beak Shape for Jetpack Compose or Compose Multiplatform
import androidx.annotation.FloatRange
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.graphics.Outline
import androidx.compose.ui.graphics.Path
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.LayoutDirection
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.pow
@akexorcist
akexorcist / prevent_accesssibility.kt
Created February 23, 2023 09:00
Prevent accessibility action in Android views
import android.core.view.AccessibilityDelegateCompat
import android.core.view.ViewCompat
val button: Button = /* ... */
ViewCompat.setAccessibilityDelegate(
button,
object : AccessibilityDelegateCompat() {
override fun performAccessibilityAction(host: View?, action: Int, args: Bundle?): Boolean {
return false
@akexorcist
akexorcist / MainActivity.kt
Created January 6, 2023 11:51
Sample of dialog listener unbinding when device configuration has changed (e.g, dark theme, language, screen orientation)
package com.lmwn.poc.dialogwithconfigchanges
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.DialogFragment
import com.lmwn.poc.dialogwithconfigchanges.databinding.ActivityMainBinding
import com.lmwn.poc.dialogwithconfigchanges.databinding.ViewAwesomeDialogBinding
@akexorcist
akexorcist / move_artifact_from_jfrog_to_nexus.sh
Last active June 30, 2023 10:32
Nexus Artifact Migration for macOS with zsh. In case you need to copy artifact from Nexus to another nexus repository
#!/bin/zsh
# Copy artifact from JFrog to another Nexus
#
# ## Prerequisites: ##
# * macOS
# * zsh
# * jq
# * wget
# * curl
# * JFrog
@akexorcist
akexorcist / Constraint.kt
Created August 5, 2022 14:37
Kotlin utility for condition-based data selection with dynamic condition supports
interface Constraint<INPUT, OUTPUT> {
suspend fun invoke(input: INPUT): OUTPUT?
}
abstract class SatisfyConstraint<INPUT, OUTPUT> : Constraint<INPUT, OUTPUT> {
abstract suspend fun isSatisfied(input: INPUT): Boolean
abstract suspend fun process(input: INPUT): OUTPUT
override suspend fun invoke(input: INPUT): OUTPUT? =
@akexorcist
akexorcist / GroupFocusableEditText.kt
Last active October 8, 2021 00:14
Custom Android UI for prevent the view behind on-screen keyboard when edit text is focused
import android.content.Context
import android.graphics.Point
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import androidx.appcompat.widget.AppCompatEditText
class GroupFocusableEditText : AppCompatEditText {
private var parentRect = Rect()
@akexorcist
akexorcist / QuadGradientView.kt
Created October 5, 2021 15:44
Gradient color view for HSL color picker
class QuadGradientView : FrameLayout {
private var currentHue = 0f
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
setWillNotDraw(false)
}
constructor(context: Context) : super(context) {
setWillNotDraw(false)
}
@akexorcist
akexorcist / MaterialButtonGroup.kt
Last active October 26, 2021 18:05
Material Button Group for Material Button in Android
package com.akexorcist.materialdesign
import android.content.Context
import androidx.core.view.MarginLayoutParamsCompat
import androidx.core.view.ViewCompat
import android.util.AttributeSet
import android.util.Log
import android.view.View
import android.widget.LinearLayout
import com.google.android.material.shape.AbsoluteCornerSize
@akexorcist
akexorcist / view_constraint_layout_issue.xml
Last active April 28, 2021 13:21
Mystery issue in ConstraintLayout 2.0.2
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="16dp"
android:paddingEnd="16dp">
<androidx.constraintlayout.widget.ConstraintLayout