Skip to content

Instantly share code, notes, and snippets.

View nicemak's full-sized avatar
👨‍💻
Working

Mohsin Ahmed Khan nicemak

👨‍💻
Working
  • Sr. Android Developer @ Bosch Pharma Pvt. Ltd.
  • Karachi, Pakistan
View GitHub Profile
@nicemak
nicemak / Plugins.txt
Last active November 24, 2021 10:16
Use Full Plugins Android Studio
Android Drawable Preview
Android WiFiADB
ChroMATERIAL
Json To Kotlin Class
Kotlin Fill Class
MAD Scorecard
Material Design Icon Generator
Material Theme UI
Rainbow Brackets
Regex Rename Files
If you want install application programmatically in Android 10, You need to give permission to install app for your application
==============================================================================
Steps 1: Give permission in Manifest
==============================================================================
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
==============================================================================
Step 2: Write provider in Android Manifest
@nicemak
nicemak / Screenshot + PDF File
Created June 17, 2022 07:49
Get screenshot and save it to PDF
saveImageToPDF(layout, layout.getScreenShot(), fileName)
fun View.getScreenShot(): Bitmap {
val returnedBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val canvas = Canvas(returnedBitmap)
val bgDrawable = background
if (bgDrawable != null) bgDrawable.draw(canvas)
else canvas.drawColor(Color.WHITE)
draw(canvas)
return returnedBitmap
@nicemak
nicemak / ExpandableTextView.kt
Created June 27, 2022 04:39 — forked from typebrook/ExpandableTextView.kt
Simple Android Expandable TextView #android #textview
package com.geothings.geobingan.ui
import android.animation.Animator
import android.animation.AnimatorListenerAdapter
import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Color
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
@nicemak
nicemak / DownloadProgressLiveData.kt
Created June 27, 2022 04:40 — forked from typebrook/DownloadProgressLiveData.kt
Observe Download manager progress using LiveData and Coroutine #android #kotlin #livedata
data class DownloadItem(
val bytesDownloadedSoFar: Long = -1,
val totalSizeBytes: Long = -1,
val status: Int,
val uri: String
)
class DownloadProgressLiveData(private val activity: Activity) :
LiveData<List<DownloadItem>>(),
CoroutineScope {
@nicemak
nicemak / CircularTimerListener.kt
Last active October 25, 2022 05:56
CircularTimerView
interface CircularTimerListener {
fun updateDataOnTick(remainingTimeInMs: Long): String?
fun onTimerFinished()
}
@nicemak
nicemak / fix-duplicate-class-android-studio.md
Created June 21, 2024 04:49 — forked from danielcshn/fix-duplicate-class-android-studio.md
Fix Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-* Android Studio | 2022.2.1

📜 Info:

  • Android Studio Flamingo | 2022.2.1
  • Build #AI-222.4459.24.2221.9862592, built on March 31, 2023
  • Gradle JDK: jbr-17 (JetBrains Runtime version 17.0.6)
  • Windows 11 (version 10.0.22000.1817)

🐛 Bug/Error log:

@nicemak
nicemak / NumberTextWatcher.kt
Created December 7, 2024 04:32 — forked from ahulyk/NumberTextWatcher.kt
Format number in android EditText after editing
package com.toastme.widget
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import java.math.BigDecimal
import java.text.DecimalFormat
class NumberTextWatcher(private val editText: EditText) : TextWatcher {
import android.text.Editable
import android.text.TextWatcher
import android.view.View
import android.widget.EditText
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 18.09.17.
*/
class SmartField<T: Any>(
private val editText: EditText,
@nicemak
nicemak / MakingPasswordDialog.kt
Created December 7, 2024 04:37 — forked from brownsoo/MakingPasswordDialog.kt
Making a input password dialog programmatically
// activity with android:windowSoftInputMode="stateHidden"
private fun showPasswordDialog() {
val context = this.context ?: return
val editText = EditText(context)
editText.inputType = InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_VARIATION_PASSWORD
editText.filters = arrayOf(InputFilter.LengthFilter(4))
val frame = FrameLayout(context)
frame.addView(editText)