-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB-14089: (android) Add Kotlin support #441
Changes from all commits
68ce9a8
c704191
8f72c43
478450f
9291077
67d6dff
bbcbaff
53b3a9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -18,16 +18,25 @@ | |||||
*/ | ||||||
|
||||||
apply plugin: 'com.android.application' | ||||||
if (cdvHelpers.getConfigPreference('EnableKotlin', 'false').toBoolean()) { | ||||||
apply plugin: 'kotlin-android' | ||||||
} | ||||||
|
||||||
buildscript { | ||||||
ext.kotlin_version = '1.3.31' | ||||||
repositories { | ||||||
mavenCentral() | ||||||
google() | ||||||
jcenter() | ||||||
} | ||||||
|
||||||
dependencies { | ||||||
apply from: '../../framework/cordova.gradle' | ||||||
|
||||||
classpath 'com.android.tools.build:gradle:3.3.0' | ||||||
if (cdvHelpers.getConfigPreference('EnableKotlin', 'false').toBoolean()) { | ||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
@@ -291,6 +300,11 @@ android { | |||||
|
||||||
dependencies { | ||||||
implementation fileTree(dir: 'libs', include: '*.jar') | ||||||
|
||||||
if (cdvHelpers.getConfigPreference('EnableKotlin', 'false').toBoolean()) { | ||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we require the
Suggested change
|
||||||
} | ||||||
|
||||||
// SUB-PROJECT DEPENDENCIES START | ||||||
debugCompile(project(path: ":CordovaLib", configuration: "debug")) | ||||||
releaseCompile(project(path: ":CordovaLib", configuration: "release")) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ | |||||
*/ | ||||||
|
||||||
apply plugin: 'com.android.application' | ||||||
apply plugin: 'kotlin-android' | ||||||
|
||||||
android { | ||||||
compileSdkVersion 28 | ||||||
|
@@ -51,4 +52,8 @@ dependencies { | |||||
implementation 'com.android.support:appcompat-v7:26.1.0' | ||||||
testImplementation 'junit:junit:4.12' | ||||||
testImplementation 'org.json:json:20140107' | ||||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above
Suggested change
|
||||||
} | ||||||
repositories { | ||||||
mavenCentral() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See https://blog.bintray.com/2015/02/09/android-studio-migration-from-maven-central-to-jcenter/ why jcenter should be used
Suggested change
|
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you 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.apache.cordova.unittests | ||
|
||
import android.content.Intent | ||
import android.support.test.rule.ActivityTestRule | ||
import android.support.test.runner.AndroidJUnit4 | ||
|
||
import org.apache.cordova.engine.SystemWebView | ||
import org.junit.Before | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import junit.framework.Assert.assertEquals | ||
|
||
/** | ||
* The purpose of this test is to test the default application that is generated by Cordova itself | ||
* | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
public class KotlinStandardActivityTest { | ||
|
||
// Don't launch the activity, we're going to send it intents | ||
@get:Rule | ||
var mActivityRule = ActivityTestRule( | ||
StandardActivity::class.java, true, false) | ||
|
||
@Before | ||
fun launchApplicationWithIntent() { | ||
val intent = Intent() | ||
intent.putExtra("startUrl", FALSE_URI) | ||
intent.putExtra("backgroundcolor", "#0000ff") | ||
mActivityRule.launchActivity(intent) | ||
} | ||
|
||
@Test | ||
fun webViewCheck() { | ||
val activity = mActivityRule.getActivity() as StandardActivity | ||
//Fish the webview out of the mostly locked down Activity using the Android SDK | ||
val view = activity.getWindow().getCurrentFocus() | ||
assertEquals(SystemWebView::class, view::class) | ||
} | ||
|
||
companion object { | ||
private val FALSE_URI = "http://www.google.com" | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ | |||||
// Top-level build file where you can add configuration options common to all sub-projects/modules. | ||||||
|
||||||
buildscript { | ||||||
ext.kotlin_version = '1.3.31' | ||||||
timbru31 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
repositories { | ||||||
google() | ||||||
jcenter() | ||||||
|
@@ -29,6 +30,7 @@ buildscript { | |||||
// in the individual module build.gradle files | ||||||
|
||||||
classpath 'com.android.tools.build:gradle:3.3.0' | ||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" | ||||||
} | ||||||
} | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.