Add imports for XML widget tags, support.v4 fake package files

This commit is contained in:
Yan Zhulanow
2015-03-25 01:22:22 +03:00
parent d0e4f86790
commit 1f16328070
25 changed files with 261 additions and 124 deletions
@@ -85,8 +85,13 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
public fun parse(generateCommonFiles: Boolean = true): List<String> {
val commonFiles = if (generateCommonFiles) {
val clearCacheFile = renderLayoutFile(AndroidConst.SYNTHETIC_PACKAGE) {} +
renderClearCacheFunction("Activity") + renderClearCacheFunction("Fragment")
listOf(clearCacheFile, FLEXIBLE_TYPE_FILE)
renderClearCacheFunction("android.app.Activity") + renderClearCacheFunction("android.app.Fragment")
listOf(clearCacheFile,
FLEXIBLE_TYPE_FILE,
FAKE_SUPPORT_V4_APP_FILE,
FAKE_SUPPORT_V4_VIEW_FILE,
FAKE_SUPPORT_V4_WIDGET_FILE)
} else listOf()
return resourceManager.getLayoutXmlFiles().flatMap { entry ->
@@ -96,12 +101,12 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
val layoutPackage = files[0].genSyntheticPackageName()
val mainLayoutFile = renderLayoutFile(layoutPackage, widgets) {
writeSyntheticProperty("Activity", it, "findViewById(0)")
writeSyntheticProperty("Fragment", it, "getView().findViewById(0)")
writeSyntheticProperty("android.app.Activity", it, "findViewById(0)")
writeSyntheticProperty("android.app.Fragment", it, "getView().findViewById(0)")
}
val viewLayoutFile = renderLayoutFile("$layoutPackage.view", widgets) {
writeSyntheticProperty("View", it, "findViewById(0)")
writeSyntheticProperty("android.view.View", it, "findViewById(0)")
}
listOf(mainLayoutFile, viewLayoutFile)
@@ -170,13 +175,25 @@ public abstract class AndroidUIXmlProcessor(protected val project: Project) {
private val EXPLICIT_FLEXIBLE_CLASS_NAME = Flexibility.FLEXIBLE_TYPE_CLASSIFIER.getRelativeClassName().asString()
private val ANDROID_IMPORTS = listOf(
"android.app.Activity",
"android.app.Fragment",
"android.view.View",
"android.app.*",
"android.view.*",
"android.widget.*",
"android.webkit.*",
"android.inputmethodservice.*",
"android.opengl.*",
"android.appwidget.*",
"android.support.v4.app.*",
"android.support.v4.view.*",
"android.support.v4.widget.*",
Flexibility.FLEXIBLE_TYPE_CLASSIFIER.asSingleFqName().asString())
private val FLEXIBLE_TYPE_FILE = "package $EXPLICIT_FLEXIBLE_PACKAGE\n\nclass $EXPLICIT_FLEXIBLE_CLASS_NAME<L, U>"
private val FAKE_SUPPORT_V4_WIDGET_FILE = "package android.support.v4.widget"
private val FAKE_SUPPORT_V4_VIEW_FILE = "package android.support.v4.view"
private val FAKE_SUPPORT_V4_APP_FILE = "package android.support.v4.app"
}
}
@@ -1,14 +1,20 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.app.Activity.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = findViewById(0) as org.my.cool.Button
val Fragment.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.app.Fragment.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = getView().findViewById(0) as org.my.cool.Button
@@ -1,11 +1,17 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.view.View.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = findViewById(0) as org.my.cool.Button
@@ -1,14 +1,20 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.app.Activity.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = findViewById(0) as org.my.cool.Button
val Fragment.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.app.Fragment.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = getView().findViewById(0) as org.my.cool.Button
@@ -1,11 +1,17 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
val android.view.View.MyButton: ft<org.my.cool.Button, org.my.cool.Button?>
get() = findViewById(0) as org.my.cool.Button
@@ -1,14 +1,20 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.button: ft<View, View?>
val android.app.Activity.button: ft<View, View?>
get() = findViewById(0) : View
val Fragment.button: ft<View, View?>
val android.app.Fragment.button: ft<View, View?>
get() = getView().findViewById(0) : View
@@ -1,11 +1,17 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.button: ft<View, View?>
val android.view.View.button: ft<View, View?>
get() = findViewById(0) : View
@@ -1,32 +1,38 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.app.Activity.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val Fragment.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.app.Fragment.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = getView().findViewById(0) as FrameLayout
val Activity.textView1: ft<TextView, TextView?>
val android.app.Activity.textView1: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val Fragment.textView1: ft<TextView, TextView?>
val android.app.Fragment.textView1: ft<TextView, TextView?>
get() = getView().findViewById(0) as TextView
val Activity.password: ft<EditText, EditText?>
val android.app.Activity.password: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val Fragment.password: ft<EditText, EditText?>
val android.app.Fragment.password: ft<EditText, EditText?>
get() = getView().findViewById(0) as EditText
val Activity.login: ft<Button, Button?>
val android.app.Activity.login: ft<Button, Button?>
get() = findViewById(0) as Button
val Fragment.login: ft<Button, Button?>
val android.app.Fragment.login: ft<Button, Button?>
get() = getView().findViewById(0) as Button
@@ -1,20 +1,26 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.view.View.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val View.textView1: ft<TextView, TextView?>
val android.view.View.textView1: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val View.password: ft<EditText, EditText?>
val android.view.View.password: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val View.login: ft<Button, Button?>
val android.view.View.login: ft<Button, Button?>
get() = findViewById(0) as Button
@@ -1,32 +1,38 @@
package kotlinx.android.synthetic.layout1
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.frameLayout: ft<FrameLayout, FrameLayout?>
val android.app.Activity.frameLayout: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val Fragment.frameLayout: ft<FrameLayout, FrameLayout?>
val android.app.Fragment.frameLayout: ft<FrameLayout, FrameLayout?>
get() = getView().findViewById(0) as FrameLayout
val Activity.passwordField: ft<TextView, TextView?>
val android.app.Activity.passwordField: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val Fragment.passwordField: ft<TextView, TextView?>
val android.app.Fragment.passwordField: ft<TextView, TextView?>
get() = getView().findViewById(0) as TextView
val Activity.passwordCaption: ft<EditText, EditText?>
val android.app.Activity.passwordCaption: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val Fragment.passwordCaption: ft<EditText, EditText?>
val android.app.Fragment.passwordCaption: ft<EditText, EditText?>
get() = getView().findViewById(0) as EditText
val Activity.loginButton: ft<Button, Button?>
val android.app.Activity.loginButton: ft<Button, Button?>
get() = findViewById(0) as Button
val Fragment.loginButton: ft<Button, Button?>
val android.app.Fragment.loginButton: ft<Button, Button?>
get() = getView().findViewById(0) as Button
@@ -1,20 +1,26 @@
package kotlinx.android.synthetic.layout1.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.frameLayout: ft<FrameLayout, FrameLayout?>
val android.view.View.frameLayout: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val View.passwordField: ft<TextView, TextView?>
val android.view.View.passwordField: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val View.passwordCaption: ft<EditText, EditText?>
val android.view.View.passwordCaption: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val View.loginButton: ft<Button, Button?>
val android.view.View.loginButton: ft<Button, Button?>
get() = findViewById(0) as Button
@@ -1,8 +1,14 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
@@ -1,8 +1,14 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
@@ -1,20 +1,26 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.textView1: ft<View, View?>
val android.app.Activity.textView1: ft<View, View?>
get() = findViewById(0) : View
val Fragment.textView1: ft<View, View?>
val android.app.Fragment.textView1: ft<View, View?>
get() = getView().findViewById(0) : View
val Activity.textView2: ft<TextView, TextView?>
val android.app.Activity.textView2: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val Fragment.textView2: ft<TextView, TextView?>
val android.app.Fragment.textView2: ft<TextView, TextView?>
get() = getView().findViewById(0) as TextView
@@ -1,14 +1,20 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.textView1: ft<View, View?>
val android.view.View.textView1: ft<View, View?>
get() = findViewById(0) : View
val View.textView2: ft<TextView, TextView?>
val android.view.View.textView2: ft<TextView, TextView?>
get() = findViewById(0) as TextView
@@ -1,32 +1,38 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.app.Activity.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val Fragment.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.app.Fragment.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = getView().findViewById(0) as FrameLayout
val Activity.textView1: ft<TextView, TextView?>
val android.app.Activity.textView1: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val Fragment.textView1: ft<TextView, TextView?>
val android.app.Fragment.textView1: ft<TextView, TextView?>
get() = getView().findViewById(0) as TextView
val Activity.password: ft<EditText, EditText?>
val android.app.Activity.password: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val Fragment.password: ft<EditText, EditText?>
val android.app.Fragment.password: ft<EditText, EditText?>
get() = getView().findViewById(0) as EditText
val Activity.login: ft<Button, Button?>
val android.app.Activity.login: ft<Button, Button?>
get() = findViewById(0) as Button
val Fragment.login: ft<Button, Button?>
val android.app.Fragment.login: ft<Button, Button?>
get() = getView().findViewById(0) as Button
@@ -1,20 +1,26 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.item_detail_container: ft<FrameLayout, FrameLayout?>
val android.view.View.item_detail_container: ft<FrameLayout, FrameLayout?>
get() = findViewById(0) as FrameLayout
val View.textView1: ft<TextView, TextView?>
val android.view.View.textView1: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val View.password: ft<EditText, EditText?>
val android.view.View.password: ft<EditText, EditText?>
get() = findViewById(0) as EditText
val View.login: ft<Button, Button?>
val android.view.View.login: ft<Button, Button?>
get() = findViewById(0) as Button
@@ -1,26 +1,32 @@
package kotlinx.android.synthetic.layout
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val Activity.includeTag: ft<View, View?>
val android.app.Activity.includeTag: ft<View, View?>
get() = findViewById(0) : View
val Fragment.includeTag: ft<View, View?>
val android.app.Fragment.includeTag: ft<View, View?>
get() = getView().findViewById(0) : View
val Activity.fragmentTag: ft<View, View?>
val android.app.Activity.fragmentTag: ft<View, View?>
get() = findViewById(0) : View
val Fragment.fragmentTag: ft<View, View?>
val android.app.Fragment.fragmentTag: ft<View, View?>
get() = getView().findViewById(0) : View
val Activity.`fun`: ft<TextView, TextView?>
val android.app.Activity.`fun`: ft<TextView, TextView?>
get() = findViewById(0) as TextView
val Fragment.`fun`: ft<TextView, TextView?>
val android.app.Fragment.`fun`: ft<TextView, TextView?>
get() = getView().findViewById(0) as TextView
@@ -1,17 +1,23 @@
package kotlinx.android.synthetic.layout.view
import android.app.Activity
import android.app.Fragment
import android.view.View
import android.app.*
import android.view.*
import android.widget.*
import android.webkit.*
import android.inputmethodservice.*
import android.opengl.*
import android.appwidget.*
import android.support.v4.app.*
import android.support.v4.view.*
import android.support.v4.widget.*
import kotlin.internal.flexible.ft
val View.includeTag: ft<View, View?>
val android.view.View.includeTag: ft<View, View?>
get() = findViewById(0) : View
val View.fragmentTag: ft<View, View?>
val android.view.View.fragmentTag: ft<View, View?>
get() = findViewById(0) : View
val View.`fun`: ft<TextView, TextView?>
val android.view.View.`fun`: ft<TextView, TextView?>
get() = findViewById(0) as TextView