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 / Transparent status bar
Created May 2, 2017 08:51
FullScreenAndroid - Transparent status bar
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Window w = getWindow(); // in Activity's onCreate() for instance
//use this to make transparent both status and navigationbar, add 24dp marginTop to toolbar in xml
w.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
// use this to make transparent status bar, No need to add 24dp marginTop to toolbar.
/*w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);*/
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
w.setExitTransition(null);
}
}
@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 / 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 / AESHelper.java
Created June 22, 2017 06:01
AESHelper for Encrypt and decrypt
package com.utils;
import android.util.Base64;
import android.util.Log;
import java.io.UnsupportedEncodingException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
@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 / 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;
/**