Remove JPS support for Android Extensions
This commit is contained in:
@@ -42,7 +42,6 @@ dependencies {
|
||||
testCompile(intellijDep())
|
||||
|
||||
testRuntime(project(":idea:idea-jvm"))
|
||||
testRuntime(project(":plugins:android-extensions-jps"))
|
||||
testRuntime(project(":sam-with-receiver-ide-plugin"))
|
||||
testRuntime(project(":noarg-ide-plugin"))
|
||||
testRuntime(project(":allopen-ide-plugin"))
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testRuntime(intellijDep())
|
||||
|
||||
compile(project(":compiler:util"))
|
||||
compile(project(":jps-plugin"))
|
||||
compile(project(":plugins:android-extensions-compiler"))
|
||||
compileOnly(intellijDep()) { includeJars("openapi", "jps-builders", "jps-model", "jdom") }
|
||||
Platform[181].orHigher {
|
||||
compileOnly(intellijDep()) { includeJars("platform-api") }
|
||||
}
|
||||
compileOnly(intellijPluginDep("android")) { includeJars("jps/android-jps-plugin") }
|
||||
compile(intellijPluginDep("android")) { includeJars("jps/android-jps-plugin") }
|
||||
|
||||
testCompile(projectTests(":jps-plugin"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompile(projectTests(":kotlin-build-common"))
|
||||
testCompileOnly(intellijDep()) { includeJars("openapi", "jps-builders") }
|
||||
testCompileOnly(intellijDep("jps-build-test")) { includeJars("jps-build-test") }
|
||||
testCompileOnly(intellijDep()) { includeJars("jps-model") }
|
||||
|
||||
testRuntime(intellijPluginDep("android"))
|
||||
(Platform[181].orHigher.or(Ide.AS31)) {
|
||||
testRuntime(intellijPluginDep("smali"))
|
||||
}
|
||||
testRuntime(intellijDep("jps-build-test"))
|
||||
testRuntime(intellijDep("jps-standalone"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
Ide.IJ {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
}
|
||||
|
||||
Ide.AS {
|
||||
"main" {}
|
||||
"test" {}
|
||||
}
|
||||
}
|
||||
|
||||
projectTest {
|
||||
workingDir = rootDir
|
||||
useAndroidSdk()
|
||||
}
|
||||
|
||||
testsJar {}
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.jps.android.model.base.impl.AndroidExtensionDataProviderJpsModelSerializerExtension
|
||||
-1
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.android.jps.KotlinAndroidJpsPlugin
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.jps
|
||||
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.jps.android.model.base.AndroidExtensionsDataProvider
|
||||
import org.jetbrains.jps.incremental.CompileContext
|
||||
import org.jetbrains.jps.incremental.ModuleBuildTarget
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.kotlin.jps.build.KotlinJpsCompilerArgumentsProvider
|
||||
import org.w3c.dom.Document
|
||||
import java.io.File
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
|
||||
class KotlinAndroidJpsPlugin : KotlinJpsCompilerArgumentsProvider {
|
||||
override fun getExtraArguments(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
|
||||
val module = moduleBuildTarget.module
|
||||
if (!hasAndroidJpsPlugin() || !isAndroidModuleWithoutGradle(module)) return emptyList()
|
||||
|
||||
val pluginId = ANDROID_COMPILER_PLUGIN_ID
|
||||
val resPath = getAndroidResPath(module)
|
||||
val applicationId = getAndroidManifest(module)?.let { getApplicationPackageFromManifest(it) }
|
||||
|
||||
return if (resPath != null && applicationId != null) {
|
||||
listOf(
|
||||
getPluginOptionString(pluginId, VARIANT_OPTION_NAME, "main;$resPath"),
|
||||
getPluginOptionString(pluginId, PACKAGE_OPTION_NAME, applicationId)
|
||||
)
|
||||
} else emptyList()
|
||||
}
|
||||
|
||||
private fun isAndroidModuleWithoutGradle(module: JpsModule): Boolean {
|
||||
val androidFacet = AndroidExtensionsDataProvider.getExtension(module) ?: return false
|
||||
return !androidFacet.isGradleProject()
|
||||
}
|
||||
|
||||
private fun hasAndroidJpsPlugin(): Boolean {
|
||||
try {
|
||||
Class.forName(ANDROID_JPS_UTIL_CLASS_FQNAME)
|
||||
return true
|
||||
} catch (e: ClassNotFoundException) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
override fun getClasspath(moduleBuildTarget: ModuleBuildTarget, context: CompileContext): List<String> {
|
||||
val module = moduleBuildTarget.module
|
||||
if (!hasAndroidJpsPlugin() || !isAndroidModuleWithoutGradle(module)) return emptyList()
|
||||
|
||||
val manifestFile = getAndroidManifest(moduleBuildTarget.module)
|
||||
|
||||
return if (manifestFile != null) {
|
||||
val jpsPluginJar = File(PathUtil.getJarPathForClass(this::class.java))
|
||||
val compilerPluginJar: File
|
||||
|
||||
if (jpsPluginJar.parentFile?.name == "libs" && jpsPluginJar.parentFile?.parentFile?.name == "build") {
|
||||
// We're in tests now (inside plugins/android-extensions/android-extensions-jps/build/libs)
|
||||
compilerPluginJar = File("dist/kotlinc/lib/$JAR_FILE_NAME")
|
||||
} else {
|
||||
// Inside Kotlin/jps directory (Kotlin plugin)
|
||||
val libDirectory = jpsPluginJar.parentFile.parentFile
|
||||
compilerPluginJar = File(libDirectory, JAR_FILE_NAME)
|
||||
}
|
||||
|
||||
listOf(compilerPluginJar.absolutePath)
|
||||
} else emptyList()
|
||||
}
|
||||
|
||||
private fun getAndroidResPath(module: JpsModule): String? {
|
||||
return AndroidExtensionsDataProvider.getExtension(module)?.getResourceDirForCompilationPath()?.absolutePath
|
||||
}
|
||||
|
||||
private fun getAndroidManifest(module: JpsModule): File? {
|
||||
return AndroidExtensionsDataProvider.getExtension(module)?.getManifestFileForCompilationPath()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val ANDROID_JPS_UTIL_CLASS_FQNAME = "org.jetbrains.jps.android.AndroidJpsUtil"
|
||||
|
||||
private const val JAR_FILE_NAME = "android-extensions-compiler.jar"
|
||||
private const val ANDROID_COMPILER_PLUGIN_ID = "org.jetbrains.kotlin.android"
|
||||
|
||||
private const val VARIANT_OPTION_NAME = "variant"
|
||||
private const val PACKAGE_OPTION_NAME = "package"
|
||||
|
||||
private fun getApplicationPackageFromManifest(manifestFile: File): String? {
|
||||
return try {
|
||||
manifestFile.parseXml().documentElement.getAttribute("package")
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun File.parseXml(): Document {
|
||||
val factory = DocumentBuilderFactory.newInstance()
|
||||
val builder = factory.newDocumentBuilder()
|
||||
return builder.parse(this)
|
||||
}
|
||||
|
||||
private fun getPluginOptionString(pluginId: String, key: String, value: String): String {
|
||||
return "plugin:$pluginId:$key=$value"
|
||||
}
|
||||
}
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jps.android.model.base
|
||||
|
||||
import org.jetbrains.jps.model.JpsElement
|
||||
import org.jetbrains.jps.model.ex.JpsElementChildRoleBase
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import java.io.File
|
||||
|
||||
interface AndroidExtensionsDataProvider : JpsElement {
|
||||
companion object {
|
||||
val KIND: JpsElementChildRoleBase<AndroidExtensionsDataProvider> =
|
||||
JpsElementChildRoleBase.create<AndroidExtensionsDataProvider>("android extensions data provider")
|
||||
|
||||
fun getExtension(module: JpsModule): AndroidExtensionsDataProvider? {
|
||||
return module.container.getChild(KIND)
|
||||
}
|
||||
}
|
||||
|
||||
fun isGradleProject(): Boolean
|
||||
fun getResourceDirForCompilationPath(): File?
|
||||
fun getManifestFileForCompilationPath(): File?
|
||||
}
|
||||
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jps.android.model.base.impl
|
||||
|
||||
import org.jdom.Element
|
||||
import org.jetbrains.jps.android.model.base.AndroidExtensionsDataProvider
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import org.jetbrains.jps.model.serialization.JpsModelSerializerExtension
|
||||
|
||||
class AndroidExtensionDataProviderJpsModelSerializerExtension : JpsModelSerializerExtension() {
|
||||
override fun loadModuleOptions(module: JpsModule, rootElement: Element) {
|
||||
module.container.setChild(AndroidExtensionsDataProvider.KIND, AndroidExtensionsDataProviderImpl())
|
||||
}
|
||||
}
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jps.android.model.base.impl
|
||||
|
||||
import org.jetbrains.jps.android.AndroidJpsUtil
|
||||
import org.jetbrains.jps.android.model.base.AndroidExtensionsDataProvider
|
||||
import org.jetbrains.jps.model.ex.JpsElementBase
|
||||
import org.jetbrains.jps.model.module.JpsModule
|
||||
import java.io.File
|
||||
|
||||
class AndroidExtensionsDataProviderImpl : JpsElementBase<AndroidExtensionsDataProviderImpl>(),
|
||||
AndroidExtensionsDataProvider {
|
||||
private val module
|
||||
get() = super.getParent() as JpsModule
|
||||
|
||||
override fun applyChanges(modified: AndroidExtensionsDataProviderImpl) {
|
||||
fireElementChanged()
|
||||
}
|
||||
|
||||
override fun createCopy(): AndroidExtensionsDataProviderImpl {
|
||||
return AndroidExtensionsDataProviderImpl()
|
||||
}
|
||||
|
||||
private val androidExtension
|
||||
get() = AndroidJpsUtil.getExtension(module)
|
||||
|
||||
override fun isGradleProject(): Boolean {
|
||||
return androidExtension?.isGradleProject ?: false
|
||||
}
|
||||
|
||||
override fun getResourceDirForCompilationPath(): File? {
|
||||
val androidExtension = this.androidExtension ?: return null
|
||||
return AndroidJpsUtil.getResourceDirForCompilationPath(androidExtension)
|
||||
}
|
||||
|
||||
override fun getManifestFileForCompilationPath(): File? {
|
||||
val androidExtension = this.androidExtension ?: return null
|
||||
return AndroidJpsUtil.getManifestFileForCompilationPath(androidExtension)
|
||||
}
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.build.android
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.jps.android.model.JpsAndroidSdkProperties
|
||||
import org.jetbrains.jps.model.JpsSimpleElement
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk
|
||||
import org.jetbrains.jps.android.model.JpsAndroidSdkType
|
||||
import org.jetbrains.jps.model.impl.JpsSimpleElementImpl
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractAndroidJpsTestCase : BaseKotlinJpsBuildTestCase() {
|
||||
|
||||
private val SDK_NAME = "Android API 26 Platform"
|
||||
|
||||
fun doTest(path: String) {
|
||||
addJdkAndAndroidSdk()
|
||||
loadProject(path + getTestName(true) + ".ipr")
|
||||
rebuildAllModules()
|
||||
buildAllModules().assertSuccessful()
|
||||
FileUtil.delete(File(path + "/out"))
|
||||
}
|
||||
|
||||
private fun addJdkAndAndroidSdk(): JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> {
|
||||
val jdkName = "java_sdk"
|
||||
addJdk(jdkName)
|
||||
val properties = JpsAndroidSdkProperties("android-26", jdkName)
|
||||
val sdkPath = KotlinTestUtils.findAndroidSdk().canonicalPath
|
||||
val library = myModel.global.addSdk(SDK_NAME, sdkPath, "", JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties))
|
||||
library.addRoot(File(sdkPath + "/platforms/android-26/android.jar"), JpsOrderRootType.COMPILED)
|
||||
return library.properties
|
||||
}
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.jps.build.android;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("plugins/android-extensions/android-extensions-jps/testData/android")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class AndroidJpsTestCaseGenerated extends AbstractAndroidJpsTestCase {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInAndroid() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("plugins/android-extensions/android-extensions-jps/testData/android"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
@TestMetadata("simple")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("plugins/android-extensions/android-extensions-jps/testData/android/simple/");
|
||||
}
|
||||
}
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="17"/>
|
||||
<application android:label="app_name" >
|
||||
<activity android:name=".MyActivity"
|
||||
android:label="app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/container"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World, MyActivity"
|
||||
android:id="@+id/textField"/>
|
||||
</LinearLayout>
|
||||
|
||||
Vendored
-14
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:id="@+id/fragmentContainer"
|
||||
>
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World, MyActivity"
|
||||
android:id="@+id/textField2"/>
|
||||
</LinearLayout>
|
||||
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="android" name="Android">
|
||||
<configuration>
|
||||
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
|
||||
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
|
||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/AndroidManifest.xml" />
|
||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
|
||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
|
||||
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/libs" />
|
||||
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
|
||||
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="" />
|
||||
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
|
||||
<option name="CUSTOM_COMPILER_MANIFEST" value="" />
|
||||
<option name="APK_PATH" value="" />
|
||||
<option name="LIBRARY_PROJECT" value="false" />
|
||||
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="true" />
|
||||
<option name="GENERATE_UNSIGNED_APK" value="false" />
|
||||
<option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
|
||||
<option name="PACK_TEST_CODE" value="false" />
|
||||
<option name="RUN_PROGUARD" value="false" />
|
||||
<option name="PROGUARD_CFG_PATH" value="/proguard-project.txt" />
|
||||
<resOverlayFolders>
|
||||
<path>/res-overlay</path>
|
||||
</resOverlayFolders>
|
||||
<includeSystemProguardFile>true</includeSystemProguardFile>
|
||||
<includeAssetsFromLibraries>false</includeAssetsFromLibraries>
|
||||
<additionalNativeLibs />
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Android API 26 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
-18
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<excludeFromCompile>
|
||||
<directory url="file://$PROJECT_DIR$/gen" includeSubdirectories="true" />
|
||||
</excludeFromCompile>
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/simple.iml" filepath="$PROJECT_DIR$/simple.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android API 26 Platform" project-jdk-type="Android SDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
package com.example.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Fragment
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import android.view.View
|
||||
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.fragment.*
|
||||
import kotlinx.android.synthetic.main.fragment.view.*
|
||||
|
||||
public class MyActivity : Activity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
textField.setText("test")
|
||||
}
|
||||
}
|
||||
|
||||
public class MyFragment : Fragment() {
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||
return inflater.inflate(R.layout.fragment, container, false)
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
fragmentContainer.textField2.setText("test fragment")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user