6.6.1 - Alpha2 - 支持更多的包名前缀省略形式 (如 RecyclerView)
This commit is contained in:
@@ -16,17 +16,54 @@ object ClassNameFilter {
|
||||
|
||||
}
|
||||
|
||||
val extendedClassNameMap = mapOf(
|
||||
"CardView" to "androidx.cardview.widget.CardView",
|
||||
"ConstraintLayout" to "androidx.constraintlayout.widget.ConstraintLayout",
|
||||
"CoordinatorLayout" to "androidx.coordinatorlayout.widget.CoordinatorLayout",
|
||||
"NestedScrollView" to "androidx.core.widget.NestedScrollView",
|
||||
"DrawerLayout" to "androidx.drawerlayout.widget.DrawerLayout",
|
||||
"FragmentContainerView" to "androidx.fragment.app.FragmentContainerView",
|
||||
"RecyclerView" to "androidx.recyclerview.widget.RecyclerView",
|
||||
"SwipeRefreshLayout" to "androidx.swiperefreshlayout.widget.SwipeRefreshLayout",
|
||||
"ViewPager" to "androidx.viewpager.widget.ViewPager",
|
||||
"ViewPager2" to "androidx.viewpager2.widget.ViewPager2",
|
||||
"AppBarLayout" to "com.google.android.material.appbar.AppBarLayout",
|
||||
"MaterialToolbar" to "com.google.android.material.appbar.MaterialToolbar",
|
||||
"BottomNavigationView" to "com.google.android.material.bottomnavigation.BottomNavigationView",
|
||||
"BottomSheetDialog" to "com.google.android.material.bottomsheet.BottomSheetDialog",
|
||||
"MaterialButton" to "com.google.android.material.button.MaterialButton",
|
||||
"Chip" to "com.google.android.material.chip.Chip",
|
||||
"MaterialCalendarGridView" to "com.google.android.material.datepicker.MaterialCalendarGridView",
|
||||
"FloatingActionButton" to "com.google.android.material.floatingactionbutton.FloatingActionButton",
|
||||
"BaselineLayout" to "com.google.android.material.internal.BaselineLayout",
|
||||
"CheckableImageButton" to "com.google.android.material.internal.CheckableImageButton",
|
||||
"ClippableRoundedCornerLayout" to "com.google.android.material.internal.ClippableRoundedCornerLayout",
|
||||
"NavigationMenuItemView" to "com.google.android.material.internal.NavigationMenuItemView",
|
||||
"NavigationMenuView" to "com.google.android.material.internal.NavigationMenuView",
|
||||
"TouchObserverFrameLayout" to "com.google.android.material.internal.TouchObserverFrameLayout",
|
||||
"VisibilityAwareImageButton" to "com.google.android.material.internal.VisibilityAwareImageButton",
|
||||
"NavigationView" to "com.google.android.material.navigation.NavigationView",
|
||||
"Snackbar" to "com.google.android.material.snackbar.Snackbar",
|
||||
"TabLayout" to "com.google.android.material.tabs.TabLayout",
|
||||
"TextInputEditText" to "com.google.android.material.textfield.TextInputEditText",
|
||||
"TextInputLayout" to "com.google.android.material.textfield.TextInputLayout",
|
||||
"ChipTextInputComboView" to "com.google.android.material.timepicker.ChipTextInputComboView",
|
||||
"ClockFaceView" to "com.google.android.material.timepicker.ClockFaceView",
|
||||
"ClockHandView" to "com.google.android.material.timepicker.ClockHandView",
|
||||
"TimePickerView" to "com.google.android.material.timepicker.TimePickerView",
|
||||
)
|
||||
|
||||
@Suppress("CovariantEquals")
|
||||
fun equals(text: String) = when (text.contains(".")) {
|
||||
true -> text
|
||||
else -> "android.widget.$text"
|
||||
else -> extendedClassNameMap[text] ?: "android.widget.$text"
|
||||
}.let { StringEqualsFilter(it, CLASS_NAME_GETTER) }
|
||||
|
||||
fun contains(str: String) = StringContainsFilter(str, CLASS_NAME_GETTER)
|
||||
|
||||
fun startsWith(prefix: String) = when (prefix.contains(".")) {
|
||||
true -> prefix
|
||||
else -> "android.widget.$prefix"
|
||||
else -> extendedClassNameMap[prefix] ?: "android.widget.$prefix"
|
||||
}.let { StringStartsWithFilter(it, CLASS_NAME_GETTER) }
|
||||
|
||||
fun endsWith(suffix: String) = StringEndsWithFilter(suffix, CLASS_NAME_GETTER)
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.view.ViewGroup
|
||||
import android.widget.Space
|
||||
import org.autojs.autojs.annotation.ScriptInterface
|
||||
import org.autojs.autojs.app.GlobalAppContext
|
||||
import org.autojs.autojs.core.automator.filter.ClassNameFilter
|
||||
import org.autojs.autojs.core.ui.inflater.inflaters.BaseViewInflater
|
||||
import org.autojs.autojs.core.ui.inflater.inflaters.JsActionMenuViewInflater
|
||||
import org.autojs.autojs.core.ui.inflater.inflaters.JsAppBarLayoutInflater
|
||||
@@ -355,7 +356,7 @@ open class DynamicLayoutInflater {
|
||||
return View(context)
|
||||
}
|
||||
if (!niceName.contains(".") && !androidWidgetPrefixBlacklist.contains(niceName)) {
|
||||
niceName = "android.widget.$niceName"
|
||||
niceName = ClassNameFilter.extendedClassNameMap[niceName] ?: "android.widget.$niceName"
|
||||
}
|
||||
val creator = mViewCreators[niceName]
|
||||
if (creator != null) {
|
||||
|
||||
Reference in New Issue
Block a user