Prevent R8 from removing appthemehelper classes

This commit is contained in:
tomaThomas 2024-10-17 22:31:40 +02:00
parent 2bcce6977d
commit 46544e000e
No known key found for this signature in database
GPG key ID: DEE963DC84059108
2 changed files with 2 additions and 33 deletions

View file

@ -19,3 +19,5 @@
# If you keep the line number information, uncomment this to # If you keep the line number information, uncomment this to
# hide the original source file name. # hide the original source file name.
#-renamesourcefileattribute SourceFile #-renamesourcefileattribute SourceFile
-keep class code.name.monkey.appthemehelper.** { *; }

View file

@ -1,33 +0,0 @@
package code.name.monkey.appthemehelper.util
import android.content.res.ColorStateList
import androidx.annotation.ColorInt
import com.google.android.material.textfield.TextInputLayout
/**
* @author Aidan Follestad (afollestad)
*/
object TextInputLayoutUtil {
fun setHint(view: TextInputLayout, @ColorInt hintColor: Int) {
try {
val mDefaultTextColorField = TextInputLayout::class.java.getDeclaredField("mDefaultTextColor")
mDefaultTextColorField.isAccessible = true
mDefaultTextColorField.set(view, ColorStateList.valueOf(hintColor))
} catch (t: Throwable) {
throw RuntimeException("Failed to set TextInputLayout hint (collapsed) color: " + t.localizedMessage, t)
}
}
fun setAccent(view: TextInputLayout, @ColorInt accentColor: Int) {
try {
val mFocusedTextColorField = TextInputLayout::class.java.getDeclaredField("mFocusedTextColor")
mFocusedTextColorField.isAccessible = true
mFocusedTextColorField.set(view, ColorStateList.valueOf(accentColor))
} catch (t: Throwable) {
throw RuntimeException("Failed to set TextInputLayout accent (expanded) color: " + t.localizedMessage, t)
}
}
}