Skip to content

Instantly share code, notes, and snippets.

View happysingh23828's full-sized avatar
🎯
Focusing

Happy Singh happysingh23828

🎯
Focusing
View GitHub Profile
@happysingh23828
happysingh23828 / BaseSectionFragment.kt
Last active September 4, 2020 06:39
set view height when show soft keyboard is open
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
mView = inflater.inflate(R.layout.fragment_base_section, container, false)
KeyboardUtil(requireActivity(), mView.coordinatorLayout)
return mView
}
@happysingh23828
happysingh23828 / Extensions.kt
Last active January 24, 2023 07:46
Kotlin extension for applying Spannable text on any textview and getting callback for onclick.
import android.text.SpannableStringBuilder
import android.text.Spanned
import android.text.TextPaint
import android.text.method.LinkMovementMethod
import android.text.style.ClickableSpan
import android.view.View
import androidx.appcompat.widget.AppCompatTextView
fun AppCompatTextView.highLightWord(word: String, onClick: () -> Unit) {
val ssBuilder = SpannableStringBuilder(this.text)
@happysingh23828
happysingh23828 / install
Created January 4, 2021 07:09
Install Android bundle on connected device using bundletool.jar
// generate app-release.apks
java -jar bundletool-all-1.4.0.jar build-apks --local-testing --bundle=app-release.aab --output=app-release.apks --connected-device
// Install apk from genrated app-release apks
java -jar bundletool-all-1.4.0.jar install-apks --apks app-release.apks
@happysingh23828
happysingh23828 / ContentScrapper.kt
Created January 15, 2021 13:02
Utils for getting the HTML code from any website or Weblink. (Android)
import androidx.appcompat.app.AppCompatActivity
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.MalformedURLException
import java.net.URL
object ContentScrapper {
fun getHTMLData(activity: AppCompatActivity,url: String, scrapListener: ScrapListener) {
@happysingh23828
happysingh23828 / IndiaStatesList.dart
Created February 21, 2022 05:06
Indian States and Union Territories List [Array]
List<String> getListOfStates() {
return [
"Andhra Pradesh",
"Arunachal Pradesh",
"Assam",
"Bihar",
"Chhattisgarh",
"Goa",
"Gujarat",
"Haryana",
@happysingh23828
happysingh23828 / adb-connect-over-tcp
Last active February 21, 2022 05:10
ADB Connect with WIFI - Android
// Get Your Device IP
adb shell "ip addr show wlan0 | grep -e wlan0$ | cut -d\" \" -f 6 | cut -d/ -f 1"
// Connect over 5555
adb tcpip 5555
// Connect device over TCP.
adb connect 192.168.1.81:5555
@happysingh23828
happysingh23828 / extension.kt
Created April 6, 2022 08:19
ViewModel Factory Extension
fun <T : ViewModel?> T.createFactory(): ViewModelProvider.Factory {
val viewModel = this
return object : ViewModelProvider.Factory {
@Suppress("UNCHECKED_CAST")
override fun <T : ViewModel?> create(modelClass: Class<T>): T = viewModel as T
}
}
@happysingh23828
happysingh23828 / sms_retriever_hash_v9.sh
Created May 3, 2022 13:09
sms-retriever-hash-generator-auto-read-otp-google
#!/bin/sh
# ------------------------------------------------------------------
# [Author] Title
# Description
# ------------------------------------------------------------------
VERSION=0.1.0
SUBJECT=sms-retriever-hash-generator
USAGE="Usage: sms_retriever_hash_v9.sh --package package_name --keystore keystore_file"
@happysingh23828
happysingh23828 / AndroidManifest.xml
Last active September 23, 2022 05:06
Add logs to .txt file for Android.
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/filepaths"
tools:replace="android:resource" />
</provider>
@happysingh23828
happysingh23828 / ViewExtensions.kt
Last active October 13, 2022 12:26
Find hypertext link in textview and get Callback when user clicks on it.
/**
* Enables click support for a TextView from a [fullText] String, which one containing one or multiple URLs.
* The [callback] will be called when a click is triggered.
*/
fun MaterialTextView.setTextWithLinkSupport(
fullText: Spannable,
callback: (String) -> Unit
) {
val spannable = SpannableString(fullText)
val matcher = Patterns.WEB_URL.matcher(spannable)