Skip to content

Instantly share code, notes, and snippets.

View WSAyan's full-sized avatar
🎯
Focusing

Wahid Sadique Ayan WSAyan

🎯
Focusing
  • Wind Wallet
  • Dhaka,Bangladesh
View GitHub Profile
@WSAyan
WSAyan / DrawRectangleWithTouch.kt
Last active April 20, 2023 20:13
Jetpack compose draw rectangle with touch
package com.wsayan.compose_playground
import android.graphics.RectF
import android.os.Bundle
import android.view.MotionEvent
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
@WSAyan
WSAyan / AndroidManifest.xml
Last active October 4, 2021 05:17
Android 11(api level 30) get real file path from uri
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.example.example">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<application
@WSAyan
WSAyan / bg_off.xml
Last active September 22, 2021 05:33
Android custom radio button example
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="1dp"
android:color="@color/black" />
<corners android:radius="2dp" />
</shape>
@WSAyan
WSAyan / PeriodicWorkmanagerHack.kt
Created April 25, 2021 00:53
In android work manager, minimum time interval between two periodic requests is 15 minutes. This is a hack to ignore the time interval.
package com.wsyan.worker
import android.content.Context
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.widget.Toast
import androidx.work.CoroutineWorker
import androidx.work.Worker
import androidx.work.WorkerParameters
@WSAyan
WSAyan / build.gradle
Last active April 30, 2023 06:47
Product flavor and rename apk example.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.example"
@WSAyan
WSAyan / RoundedCornerImageView.kt
Created December 9, 2020 08:33
Custom android imageview for rounded corner
import android.annotation.TargetApi
import android.content.Context
import android.graphics.*
import android.os.Build
import android.util.AttributeSet
import android.view.View
import android.view.ViewOutlineProvider
import androidx.appcompat.widget.AppCompatImageView
import androidx.core.view.ViewCompat
import com.wsayan.example.R
@WSAyan
WSAyan / TaxCalculationCore.java
Created November 22, 2020 17:22
NBR tax calculation for year 2017-18.
public class TaxCalculationCore {
public static final String GENDER_MALE = "_male";
public static final String GENDER_FEMALE = "_female";
private static final int BASIC_PERCENTAGE = 60;
private static final int HOUSE_RENT_PERCENTAGE = 30;
private static final int CONVEYANCE_ALLOWANCE_PERCENTAGE = 4;
private static final int MEDICAL_ALLOWANCE_PERCENTAGE = 6;
private static final int HOUSE_RENT_DEDUCTABLE = 25000;
private static final int CONVEYANCE_ALLOWANCE_DEDUCTABLE = 2500;
@WSAyan
WSAyan / CustomScrollableRecyclerView.kt
Created August 16, 2020 05:55
Custom RecyclerView with disable touch option.
import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.annotation.Nullable
import androidx.recyclerview.widget.RecyclerView
class CustomScrollableRecyclerView : RecyclerView {
private var isVerticalScrollingEnabled = true
@WSAyan
WSAyan / CustomScrollableLinearLayoutManager.kt
Created August 16, 2020 05:54
Disable/enable default scrolling behavior of RecyclerView
import android.content.Context
import androidx.recyclerview.widget.LinearLayoutManager
class CustomScrollableLinearLayoutManager(context: Context) : LinearLayoutManager(context) {
private var isVerticalScrollEnabled = true
private var isHorizontalScrollEnabled = true
fun setVerticalScrollEnabled(isVerticalScrollEnabled: Boolean) {
this.isVerticalScrollEnabled = isVerticalScrollEnabled
}
@WSAyan
WSAyan / ImageSpannedTextView.kt
Created August 9, 2020 10:44
Android TextView with inline images.
import android.content.Context
import android.text.Spannable
import android.text.style.ImageSpan
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
import java.util.regex.Matcher
import java.util.regex.Pattern
class ImageSpannedTextView : AppCompatTextView {
constructor(