Skip to content

Instantly share code, notes, and snippets.

View pranavlathigara's full-sized avatar
🤓
Learning

Pranav Lathigara pranavlathigara

🤓
Learning
View GitHub Profile
@pranavlathigara
pranavlathigara / DeCryptor.java
Created November 6, 2019 09:05 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
@pranavlathigara
pranavlathigara / Cryptography.java
Created November 6, 2019 06:22 — forked from Diederikjh/Cryptography.java
Single class that handles encryption and decryption with keys using the Android `Keystore` API. Mostly inspired by this [blog post](https://medium.com/@ericfu/securely-storing-secrets-in-an-android-application-501f030ae5a3). This was tested with API 18 and 25 level emulator (and a level 23 device).
package com.example.yourapp;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.security.KeyPairGeneratorSpec;
import android.security.keystore.KeyGenParameterSpec;
import android.security.keystore.KeyProperties;
import android.support.annotation.RequiresApi;
class SafeClickListener(
private var defaultInterval: Int = 1000,
private val onSafeCLick: (View) -> Unit
) : View.OnClickListener {
private var lastTimeClicked: Long = 0
override fun onClick(v: View) {
if (SystemClock.elapsedRealtime() - lastTimeClicked < defaultInterval) {
return
import android.app.Activity
import android.support.annotation.IdRes
import android.view.View
fun <T : View> Activity.bind(@IdRes idRes: Int): Lazy<T> {
@Suppress("UNCHECKED_CAST")
return unsafeLazy { findViewById(idRes) as T }
}
fun <T : View> View.bind(@IdRes idRes: Int): Lazy<T> {
@pranavlathigara
pranavlathigara / IntroVideoView.java
Created February 11, 2019 07:14 — forked from vishhmakasana/IntroVideoView.java
In Android Play mp4 video as a background intro video in your app like latest freelancer app plays it on their intro page of android app.
package com.example.videointro;
import java.io.IOException;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Build;
import android.util.AttributeSet;
@pranavlathigara
pranavlathigara / README.md
Created January 30, 2019 06:51 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

All hex value from 100% to 0% alpha:

@pranavlathigara
pranavlathigara / AesCipher.java
Created January 24, 2019 09:53 — forked from demisang/AesCipher.java
AES/CBC/PKCS5Padding encrypt/decrypt PHP and JAVA example classes
import android.support.annotation.Nullable;
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;
@pranavlathigara
pranavlathigara / BaseActivity.java
Created January 22, 2019 10:49 — forked from sandeeptengale/BaseActivity.java
Sample code to create BaseActivity for Android
package com.vtuforum.android.views
import android.app.ProgressDialog
import android.os.Bundle
import android.support.design.widget.CoordinatorLayout
import android.support.v7.app.AppCompatActivity
import android.widget.FrameLayout
import android.widget.ImageButton
import android.widget.TextView
import com.vtuforum.vtustudies.R
@pranavlathigara
pranavlathigara / introrx.md
Created December 14, 2018 11:40 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@pranavlathigara
pranavlathigara / ActivityA.java
Created February 3, 2017 13:05
Stackoverflow answer, "Singleton in Android"
package com.example.testSingleton;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
public class ActivityA extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {