Skip to content

Instantly share code, notes, and snippets.

View hitesh-dhamshaniya's full-sized avatar
🎯
Focusing

Hitesh Dhamshaniya hitesh-dhamshaniya

🎯
Focusing
View GitHub Profile
@hitesh-dhamshaniya
hitesh-dhamshaniya / CPFFormatter.java
Created November 25, 2021 13:36
CPF Formatter for Edit text add as a TextWatcher in Edit text for text change listener.
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 December 2, 2020 10:50
Android Native InAppPurchase Manager, used to implement InApp Purchase in to the android app.
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 September 26, 2020 08:16
AutoGenerateBuildName add this in application build.gradle and generate apk file name suitable instead of app.apk
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 July 13, 2020 13:42 — 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.
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 June 22, 2020 07:13
File URI Utils. kt is used full get exact path of selected file from intent
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 April 17, 2020 09:05
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.
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 March 5, 2020 05:47
The gist will help you to remove all build folder from your android project and modules
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'
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 September 4, 2019 09:15
Handle System Font Size. Regardless of system font size apply application font size
/*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 August 29, 2019 13:17
Kotlin Validation manager class, it will help to easy check validation
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