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 / build.gradle.kts
Created February 23, 2024 07:21 — forked from mileskrell/build.gradle.kts
Example of declaring Android signing configs using Gradle Kotlin DSL
android {
signingConfigs {
getByName("debug") {
keyAlias = "debug"
keyPassword = "my debug key password"
storeFile = file("/home/miles/keystore.jks")
storePassword = "my keystore password"
}
create("release") {
keyAlias = "release"
@happysingh23828
happysingh23828 / ViewExtensions.kt
Created May 3, 2023 17:04
View visible in Scrollview
fun View.isPartiallyOrFullyVisible(horizontalScrollView: HorizontalScrollView) : Boolean {
val scrollBounds = Rect()
horizontalScrollView.getHitRect(scrollBounds)
return getLocalVisibleRect(scrollBounds)
}
fun View.isPartiallyOrFullyVisible(scrollView: ScrollView) : Boolean {
val scrollBounds = Rect()
scrollView.getHitRect(scrollBounds)
return getLocalVisibleRect(scrollBounds)
@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)
@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 / 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 / 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 / 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 / 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 / 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 / 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