fix: newly added TextView has android:text attribute by default

This commit is contained in:
Akash Yadav
2023-01-01 22:27:55 +05:30
parent b2d6ec9c06
commit 7d70fde7c0
2 changed files with 9 additions and 8 deletions
@@ -17,6 +17,7 @@
package com.itsaky.androidide.inflater.internal.adapters
import android.annotation.SuppressLint
import android.graphics.Typeface
import android.text.TextUtils
import android.text.util.Linkify
@@ -27,9 +28,9 @@ import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner
import com.itsaky.androidide.annotations.uidesigner.IncludeInDesigner.Group.WIDGETS
import com.itsaky.androidide.inflater.AttributeHandlerScope
import com.itsaky.androidide.inflater.IView
import com.itsaky.androidide.resources.R
import com.itsaky.androidide.inflater.models.UiWidget
import com.itsaky.androidide.inflater.utils.newAttribute
import com.itsaky.androidide.resources.R
import java.util.regex.Pattern
/**
@@ -129,9 +130,10 @@ open class TextViewAdapter<T : TextView> : ViewAdapter<T>() {
)
}
@SuppressLint("SetTextI18n")
override fun applyBasic(view: IView) {
super.applyBasic(view)
view.addAttribute(newAttribute(view = view, name = "text", value = "AndroidIDE"))
(view.view as? TextView)?.text = "AndroidIDE"
}
protected open fun parseTextStyle(value: String): Int {
@@ -30,10 +30,10 @@ import com.itsaky.androidide.inflater.internal.utils.IDTable
import com.itsaky.androidide.inflater.utils.newAttribute
import com.itsaky.androidide.projects.ProjectManager
import com.itsaky.androidide.projects.api.AndroidModule
import java.io.File
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import java.io.File
/** @author Akash Yadav */
@RunWith(RobolectricTestRunner::class)
@@ -160,7 +160,6 @@ class LayoutInflaterTest {
val root = inflated[0] as ViewGroupImpl
// verity the inflated layout hierarchy
// this takes care of verifying that the generated XML elements will have proper XML tagsl
assertThat(root.printHierarchy())