Skip to content

Instantly share code, notes, and snippets.

@devapro
devapro / EncryptedSettings.kt
Created July 15, 2025 17:51 — forked from AJIEKCX/EncryptedSettings.kt
A secure implementation of SharedPreferences for the MultiplatformSettings library
import android.content.SharedPreferences
import com.google.crypto.tink.Aead
import com.google.crypto.tink.KeysetHandle
import com.google.crypto.tink.RegistryConfiguration
import com.google.crypto.tink.TinkProtoKeysetFormat
import com.google.crypto.tink.aead.AeadConfig
import com.google.crypto.tink.aead.PredefinedAeadParameters
import com.google.crypto.tink.integration.android.AndroidKeystore
import com.google.crypto.tink.subtle.Base64
import com.google.crypto.tink.subtle.Hex
@devapro
devapro / AdbCommands
Created July 10, 2025 11:04 — forked from Pulimet/AdbCommands
Adb useful commands list
Hi All!
I've recently launched a tool that wraps many of the commands here with a user interface. This desktop application is currently available for macOS. There's a roadmap outlining planned features for the near future.
Feel free to request any features you'd like to see, and I'll prioritize them accordingly.
One of the most important aspects of this application is that every command executed behind the scenes is displayed in a special log section. This allows you to see exactly what’s happening and learn from it.
Here's the link to the repository: https://github.com/Pulimet/ADBugger
App Description:
ADBugger is a desktop tool designed for debugging and QA of Android devices and emulators. It simplifies testing, debugging, and performance analysis by offering device management, automated testing, log analysis, and remote control capabilities. This ensures smooth app performance across various setups.
@devapro
devapro / InnerDividerItemDecorator.kt
Created May 30, 2025 22:40
RecyclerView item decorator example
import android.graphics.Canvas
import android.graphics.drawable.Drawable
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView.ItemDecoration
/**
* Divider that doesn't show the divider after the last item.
*/
class InnerDividerItemDecorator(
@devapro
devapro / FragmentViewBindingDelegate.kt
Created May 30, 2025 22:36
Fragment View Binding
import android.view.View
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KProperty
inline fun <reified T : ViewBinding> Fragment.viewBinding() = FragmentViewBindingDelegate(T::class.java, this)
@devapro
devapro / ViewExtensions.kt
Created May 30, 2025 22:34
View extensions
import android.content.Context
import android.graphics.drawable.BitmapDrawable
import android.graphics.drawable.GradientDrawable
import android.text.SpannableString
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.util.DisplayMetrics
import android.util.TypedValue
@devapro
devapro / app_mqtt_mysql_completed.js
Created January 5, 2025 19:44 — forked from smching/app_mqtt_mysql_completed.js
Node.js application: Store messages from Mosquitto MQTT broker into SQL Database (completed)
var mqtt = require('mqtt'); //https://www.npmjs.com/package/mqtt
var Topic = '#'; //subscribe to all topics
var Broker_URL = 'mqtt://192.168.1.123';
var Database_URL = '192.168.1.123';
var options = {
clientId: 'MyMQTT',
port: 1883,
//username: 'mqtt_user',
//password: 'mqtt_password',
@devapro
devapro / AndroidViewToBitmap
Created November 13, 2024 23:58
Android view get bitmap
// Android view get bitmap
private ImageBitmap getBitmapFromViewUsingCanvas(View view) {
// Create a new Bitmap object with the desired width and height
Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
// Create a new Canvas object using the Bitmap
Canvas canvas = new Canvas(bitmap);
// Draw the View into the Canvas
### ~/.bashrc
### set jre path (for example android studio jre)
export JAVA_HOME="/home/user/android-studio/jbr"
export PATH="$PATH:$JAVA_HOME/bin/"
@devapro
devapro / gist:a1a6111809000602eb7d7a7f3b8fec7f
Created March 4, 2024 18:17
Android. Kill app from code
private fun killApp() {
requireActivity().finish()
android.os.Process.killProcess(android.os.Process.myPid())
}
@devapro
devapro / BitmapModifier.kt
Created June 28, 2023 09:32
Bitmap rounded corners
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.PorterDuff
import android.graphics.PorterDuffXfermode
import android.graphics.Rect
import android.graphics.RectF
object BitmapModifier {