Skip to content

Instantly share code, notes, and snippets.

@frestoinc
frestoinc / DeCryptor.java
Created February 28, 2019 04:43 — forked from JosiasSena/DeCryptor.java
Encryptor and Decryptor for data encryption.decryption using the Android KeyStore.
/**
_____ _____ _
| __ \ / ____| | |
| | | | ___| | _ __ _ _ _ __ | |_ ___ _ __
| | | |/ _ \ | | '__| | | | '_ \| __/ _ \| '__|
| |__| | __/ |____| | | |_| | |_) | || (_) | |
|_____/ \___|\_____|_| \__, | .__/ \__\___/|_|
__/ | |
|___/|_|
*/
public class PhoneBookManager {
private final ContentResolver contentResolver;
public PhoneBookManager(final Context context) {
contentResolver = context.getContentResolver();
}
private boolean isContactWithNumberExists(@NonNull final String number) {
@frestoinc
frestoinc / AndroidManifest.xml
Created February 28, 2019 04:48 — forked from JosiasSena/AndroidManifest.xml
Sync Adapter example
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.packagename">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<application
<service
android:name="com.example.AuthenticatorService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name="android.accounts.AccountAuthenticator" />
</intent-filter>
<meta-data
android:name="android.accounts.AccountAuthenticator"
@frestoinc
frestoinc / UnitTestsSuite.kt
Created March 4, 2020 01:32
Suite classes
import com.github.shchurov.gitterclient.unit_tests.tests.*
import org.junit.runner.RunWith
import org.junit.runners.Suite
@RunWith(Suite::class)
@Suite.SuiteClasses(
GetRoomMessagesInteractorTest::class,
GetRoomsInteractorTest::class
class UnitTestsSuite
@frestoinc
frestoinc / NestedConverter
Created March 4, 2020 01:33
Converter for room conversion in kotlin
class NestedConverter {
companion object {
@TypeConverter
@JvmStatic //needed
fun stringToList(data: String?): List<NestedRepo> {
if (data == null) {
return emptyList()
}
val type = object : TypeToken<List<NestedRepo>>() {}.type
private fun hasInternetConnection(): Boolean {
val connectivityManager = getApplication<NewsApplication>().getSystemService(
Context.CONNECTIVITY_SERVICE
) as ConnectivityManager
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val activeNetwork = connectivityManager.activeNetwork ?: return false
val capabilities = connectivityManager.getNetworkCapabilities(activeNetwork) ?: return false
return when {
capabilities.hasTransport(TRANSPORT_WIFI) -> true
capabilities.hasTransport(TRANSPORT_CELLULAR) -> true
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="root"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
@frestoinc
frestoinc / AdbCommands
Created August 11, 2020 05:27 — forked from Pulimet/AdbCommands
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
@frestoinc
frestoinc / SharedPreferencesSingletonEnumKeyTemplate.java
Created September 14, 2020 01:26 — forked from alphamu/SharedPreferencesSingletonEnumKeyTemplate.java
A SharedPreferences singleton that can be used to centralise and simplify reading and writing of SharedPerferences in your Android app. There are 2 versions, one that uses static String for Keys and an other that uses enums. Which one you use comes down to your preference, enums I feel provides better control when you have multiple programmers w…
#if (${PACKAGE_NAME} != "")package ${PACKAGE_NAME};#end
import android.content.Context;
import android.content.SharedPreferences;
/*
* A Singleton for managing your SharedPreferences.
*
* You should make sure to change the SETTINGS_NAME to what you want
* and choose the operating made that suits your needs, the default is