Skip to content

Commit 764ecb3

Browse files
committed
Add webview sample
1 parent 819d87f commit 764ecb3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+927
-0
lines changed

webview/android/build.gradle

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
buildscript {
2+
repositories {
3+
jcenter()
4+
mavenCentral()
5+
}
6+
dependencies {
7+
classpath 'com.android.tools.build:gradle:1.3.0'
8+
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
9+
}
10+
}
11+
12+
plugins {
13+
id "me.tatarka.retrolambda" version "3.2.2"
14+
}
15+
apply plugin: 'com.android.application'
16+
apply plugin: 'kotlin-android'
17+
18+
repositories {
19+
jcenter()
20+
mavenCentral()
21+
}
22+
23+
android {
24+
compileSdkVersion 23
25+
buildToolsVersion "23.0.1"
26+
27+
sourceSets {
28+
main.java.srcDirs += 'src/main/kotlin'
29+
}
30+
31+
defaultConfig {
32+
applicationId "com.mycompany.fortune.android"
33+
minSdkVersion 9
34+
targetSdkVersion 23
35+
versionCode 1
36+
versionName "1.0"
37+
}
38+
39+
compileOptions {
40+
sourceCompatibility JavaVersion.VERSION_1_8
41+
targetCompatibility JavaVersion.VERSION_1_8
42+
}
43+
buildTypes {
44+
release {
45+
minifyEnabled false
46+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47+
}
48+
}
49+
}
50+
51+
dependencies {
52+
compile fileTree(dir: 'libs', include: ['*.jar'])
53+
compile 'com.android.support:appcompat-v7:23+'
54+
compile 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version'
55+
compile project(':core')
56+
}

webview/android/proguard-rules.pro

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add project specific ProGuard rules here.
2+
# By default, the flags in this file are appended to flags specified
3+
# in /usr/local/Cellar/android-sdk/24.1.2/tools/proguard/proguard-android.txt
4+
# You can edit the include path and order by changing the proguardFiles
5+
# directive in build.gradle.
6+
#
7+
# For more details, see
8+
# http://developer.android.com/guide/developing/tools/proguard.html
9+
10+
# Add any project specific keep options here:
11+
12+
# If your project uses WebView with JS, uncomment the following
13+
# and specify the fully qualified class name to the JavaScript interface
14+
# class:
15+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16+
# public *;
17+
#}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.prat.webview;
2+
3+
import android.app.Application;
4+
import android.test.ApplicationTestCase;
5+
6+
/**
7+
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
8+
*/
9+
public class ApplicationTest extends ApplicationTestCase<Application> {
10+
public ApplicationTest() {
11+
super(Application.class);
12+
}
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.prat.webview">
4+
5+
<application
6+
android:allowBackup="true"
7+
android:icon="@mipmap/ic_launcher"
8+
android:label="@string/app_name"
9+
android:theme="@style/AppTheme" >
10+
<activity
11+
android:name=".WebviewActivity"
12+
android:label="@string/app_name" >
13+
<intent-filter>
14+
<action android:name="android.intent.action.MAIN" />
15+
<category android:name="android.intent.category.LAUNCHER" />
16+
</intent-filter>
17+
</activity>
18+
</application>
19+
</manifest>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.prat.webview
2+
3+
import android.app.Activity
4+
import android.os.Bundle
5+
import android.widget.Button
6+
import android.widget.TextView
7+
8+
class WebviewActivity : Activity() {
9+
private val counterStore = CounterStore()
10+
11+
override fun onCreate(savedInstanceState: Bundle?) {
12+
super.onCreate(savedInstanceState)
13+
setContentView(R.layout.activity_my)
14+
15+
val counterTextView = findViewById(R.id.counterTextView) as TextView
16+
val counterButton = findViewById(R.id.counterButton) as Button
17+
18+
counterButton.setOnClickListener { view ->
19+
counterStore.add(1)
20+
counterTextView.text = "Click Nr. " + counterStore.get()
21+
}
22+
}
23+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools"
3+
android:layout_width="match_parent"
4+
android:layout_height="match_parent"
5+
tools:context=".MyActivity">
6+
7+
<TextView
8+
android:text=""
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:layout_marginBottom="48dp"
12+
android:id="@+id/counterTextView"
13+
android:textSize="24sp"
14+
android:layout_above="@+id/counterButton"
15+
android:layout_centerInParent="true"/>
16+
17+
<Button
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content"
20+
android:text="Click me!"
21+
android:id="@+id/counterButton"
22+
android:layout_alignParentBottom="false"
23+
android:layout_centerVertical="true"
24+
android:layout_centerHorizontal="true" />
25+
26+
</RelativeLayout>
Loading
Loading
Loading
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<resources>
2+
<string name="app_name">Webview</string>
3+
</resources>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
3+
<!-- Base application theme. -->
4+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
5+
<!-- Customize your theme here. -->
6+
</style>
7+
8+
</resources>

webview/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
allprojects {
2+
buildscript {
3+
ext.kotlin_version = '1.0.0-beta-2423'
4+
repositories {
5+
jcenter()
6+
mavenCentral()
7+
}
8+
dependencies {
9+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
10+
}
11+
}
12+
}
13+
14+
task wrapper(type: Wrapper) {
15+
gradleVersion = '2.8'
16+
}

webview/core/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
buildscript {
2+
repositories {
3+
mavenCentral()
4+
}
5+
}
6+
7+
plugins {
8+
id "me.tatarka.retrolambda" version "3.2.2"
9+
}
10+
apply plugin: 'java'
11+
apply plugin: 'kotlin'
12+
13+
version 'unspecified'
14+
sourceCompatibility = 1.8
15+
targetCompatibility = 1.8
16+
17+
repositories {
18+
mavenCentral()
19+
}
20+
21+
sourceSets {
22+
main.java.srcDirs += 'src/main/kotlin'
23+
}
24+
25+
dependencies {
26+
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
27+
testCompile group: 'junit', name: 'junit', version: '4.11'
28+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.prat.webview
2+
3+
class CounterStore {
4+
private var count: Int = 0
5+
6+
fun add(num: Int) {
7+
count += num
8+
}
9+
10+
fun get(): Int {
11+
return count
12+
}
13+
}

webview/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
org.gradle.daemon=true
2+
org.gradle.jvmargs=-Xms128m -Xmx2000m
3+
org.gradle.configureondemand=true
52.4 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Mon Nov 30 21:13:38 EST 2015
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip

0 commit comments

Comments
 (0)