Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Hitesh Dhamshaniya hitesh-dhamshaniya

🎯
Focusing
View GitHub Profile
@hitesh-dhamshaniya
hitesh-dhamshaniya / CPFFormatter.java
Created Nov 25, 2021
CPF Formatter for Edit text add as a TextWatcher in Edit text for text change listener.
View CPFFormatter.java
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
public class CPFFormatter implements TextWatcher {
private final String CPF_MASK = "###.###.###-##";
private final char[] CPF_MASK_ARRAY = CPF_MASK.toCharArray();
private boolean isInTextChanged = false;
private boolean isInAfterTextChanged = false;
@hitesh-dhamshaniya
hitesh-dhamshaniya / InAppPurchaseManager.kt
Created Dec 2, 2020
Android Native InAppPurchase Manager, used to implement InApp Purchase in to the android app.
View InAppPurchaseManager.kt
import android.app.Activity
import android.content.Context
import android.util.Log
import com.android.billingclient.api.AcknowledgePurchaseParams
import com.android.billingclient.api.BillingClient
import com.android.billingclient.api.BillingClientStateListener
import com.android.billingclient.api.BillingFlowParams
import com.android.billingclient.api.BillingResult
import com.android.billingclient.api.Purchase
import com.android.billingclient.api.PurchasesUpdatedListener
@hitesh-dhamshaniya
hitesh-dhamshaniya / AutoGenerateBuildName.gradle
Created Sep 26, 2020
AutoGenerateBuildName add this in application build.gradle and generate apk file name suitable instead of app.apk
View AutoGenerateBuildName.gradle
applicationVariants.all { variant ->
variant.resValue "string", "versionName", variant.versionName
variant.outputs.all {
outputFileName = archivesBaseName
outputFileName += "-v" + variant.versionName + "-" + variant.buildType.name + "-" + new Date().format('Mddyyyy')
outputFileName += ".apk"
}
}
@hitesh-dhamshaniya
hitesh-dhamshaniya / ScalingView.kt
Created Jul 13, 2020 — forked from webianks/ScalingView.kt
Achieving scale down/up and the onClick callback on CTA views with Compound Views, Gesture Detector, and ObjectAnimator in Android.
View ScalingView.kt
import android.animation.AnimatorSet
import android.animation.ObjectAnimator
import android.annotation.SuppressLint
import android.content.Context
import android.util.AttributeSet
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import android.widget.FrameLayout
import androidx.core.view.GestureDetectorCompat
@hitesh-dhamshaniya
hitesh-dhamshaniya / FileUriUtils.kt
Created Jun 22, 2020
File URI Utils. kt is used full get exact path of selected file from intent
View FileUriUtils.kt
import android.content.ContentUris
import android.content.Context
import android.database.Cursor
import android.net.Uri
import android.os.Build
import android.os.Environment
import android.provider.DocumentsContract
import android.provider.MediaStore
import java.io.File
import java.io.FileOutputStream
@hitesh-dhamshaniya
hitesh-dhamshaniya / PhoneNumberWatcher.kt
Created Apr 17, 2020
Phone Number Watcher is utility class to format mobile number in android 000-000-0000, In most of application we required phone number formater, so that I created gist, so easily get whenever required. Hope it will help.
View PhoneNumberWatcher.kt
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
/**
* @author Hitesh
* @version 1.0
* @since 14-08-2019
*/
@hitesh-dhamshaniya
hitesh-dhamshaniya / CleanBuildFolderAndroidApp
Created Mar 5, 2020
The gist will help you to remove all build folder from your android project and modules
View CleanBuildFolderAndroidApp
import os
import shutil
import sys
if len(sys.argv)>1:
rootdir = sys.argv[1]
else:
# rootdir = os.path.dirname(os.path.realpath(__file__))
#rootdir = 'D:\\example\\projects\\project name'
rootdir = 'D:\\AndroidStuioWS\\Good-work\\good-work-android'
View AESCBCHelper.java
import android.util.Base64;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
/**
@hitesh-dhamshaniya
hitesh-dhamshaniya / Application.java
Created Sep 4, 2019
Handle System Font Size. Regardless of system font size apply application font size
View Application.java
/*That's how we do it. In Application class override onConfigurationChanged() like this. If you want different behavior for different activities - override onConfigurationChanged() in Activity.
Don't forget to add manifest tag android:configChanges="fontScale" since you are hadnling this configuration change yourself.*/
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// In some cases modifying newConfig leads to unexpected behavior,
// so it's better to edit new instance.
@hitesh-dhamshaniya
hitesh-dhamshaniya / ValidationManager.kt
Created Aug 29, 2019
Kotlin Validation manager class, it will help to easy check validation
View ValidationManager.kt
package com.devdigital.eztp.utils.validator
import com.devdigital.eztp.extensions.getTrimString
import com.google.android.material.textfield.TextInputLayout
import kotlinx.android.synthetic.main.component_edittext.view.*
import java.util.regex.Pattern
/**
* @author Hitesh
* @version 1.0