Skip to content

Instantly share code, notes, and snippets.

View abir-hasan's full-sized avatar
🏠
Concentrating

Abir Hasan abir-hasan

🏠
Concentrating
View GitHub Profile
@abir-hasan
abir-hasan / draggable_content_final.kt
Created January 14, 2025 12:28 — forked from fvilarino/draggable_content_final.kt
Draggable Contente - Final
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
PlaygroundTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
Box {
@abir-hasan
abir-hasan / multiple_ssh_setting.md
Created September 8, 2024 17:38 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"
@abir-hasan
abir-hasan / ColoredShadow.kt
Created November 19, 2022 19:50 — forked from cedrickring/ColoredShadow.kt
Draw a colored shadow in Android Jetpack Compose
/*
Copyright 2020 Cedric Kring.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@abir-hasan
abir-hasan / APIResponse.kt
Created March 12, 2022 12:37
Generic API Response Model for UI Class
enum class Status {
SUCCESS,
ERROR,
LOADING
}
data class APIResponse<out T>(val status: Status, val data: T?, val message: String?) {
companion object {
fun <T> success(data: T): APIResponse<T> = APIResponse(
@abir-hasan
abir-hasan / DeviceSpecifications.kt
Created December 23, 2021 05:42
Find Device Network Specifications and Manufacturer
fun MainActivity.findDeviceModelManufacturerAndOS() {
val status = StringBuilder()
.append("\nOS Version: ${Build.VERSION.SDK_INT}")
.append("\nMANUFACTURER: ${Build.MANUFACTURER}")
.append("\nMODEL: ${Build.MODEL}")
"findDeviceModelManufacturerAndOS() $status".logWarn(TAG)
}
/**
@abir-hasan
abir-hasan / CreateKeyHashFromSHA.kt
Last active September 20, 2020 11:58
Creating Key Hash From SHA fingerprint
private fun generateKeyHashFromSHA() {
try {
val info = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
for (signature in info.signatures) {
val md = MessageDigest.getInstance("SHA")
md.update(signature.toByteArray())
val hashKey = String(Base64.getEncoder().encode(md.digest()))
"key: $hashKey".logDebug(TAG)
Log.d(TAG, "generateSha1: $hashKey")
}
@abir-hasan
abir-hasan / LogExtentions.kt
Created March 18, 2020 16:42
Log Extension methods for all log levels. Only for Debug mode. So One can call a log method on any string.
const val APP_TAG = "Test App"
fun String.logVerbose(tag: String = APP_TAG) {
if (BuildConfig.DEBUG)
Log.v(tag, this)
}
fun String.logDebug(tag: String = APP_TAG) {
if (BuildConfig.DEBUG)
Log.d(tag, this)
@abir-hasan
abir-hasan / MainActivity.kt
Created January 7, 2020 07:19
Translucent Statusbar and whole UI over the navigation buttons
private fun translucentStatusBarWithFixedNavigationButtons() {
window.apply {
clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
statusBarColor = Color.TRANSPARENT
}
}
@abir-hasan
abir-hasan / RunTimePermissionMethodsActivity.kt
Created April 4, 2019 12:31
Proper way to show run-time permission in an activity with camera permission example
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.xyz)
checkCameraPermission()
}
private fun checkCameraPermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
@abir-hasan
abir-hasan / DatePickerDialogUtils.kt
Created March 31, 2019 09:23
show a DatePickerDialog from fragment
private fun showDatePickerDialog() {
val c = Calendar.getInstance()
val year = c.get(Calendar.YEAR)
val month = c.get(Calendar.MONTH)
val day = c.get(Calendar.DAY_OF_MONTH)
getContext()?.let { it ->
// Create a new instance of DatePickerDialog and return it
val dpd = DatePickerDialog(
it,