Skip to content

Commit

Permalink
Add webview sample
Browse files Browse the repository at this point in the history
  • Loading branch information
pt2121 committed Dec 1, 2015
1 parent 819d87f commit 764ecb3
Show file tree
Hide file tree
Showing 49 changed files with 927 additions and 0 deletions.
56 changes: 56 additions & 0 deletions webview/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
}
}

plugins {
id "me.tatarka.retrolambda" version "3.2.2"
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

repositories {
jcenter()
mavenCentral()
}

android {
compileSdkVersion 23
buildToolsVersion "23.0.1"

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

defaultConfig {
applicationId "com.mycompany.fortune.android"
minSdkVersion 9
targetSdkVersion 23
versionCode 1
versionName "1.0"
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23+'
compile 'org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version'
compile project(':core')
}
17 changes: 17 additions & 0 deletions webview/android/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /usr/local/Cellar/android-sdk/24.1.2/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.prat.webview;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
19 changes: 19 additions & 0 deletions webview/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.prat.webview">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".WebviewActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.prat.webview

import android.app.Activity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView

class WebviewActivity : Activity() {
private val counterStore = CounterStore()

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_my)

val counterTextView = findViewById(R.id.counterTextView) as TextView
val counterButton = findViewById(R.id.counterButton) as Button

counterButton.setOnClickListener { view ->
counterStore.add(1)
counterTextView.text = "Click Nr. " + counterStore.get()
}
}
}
26 changes: 26 additions & 0 deletions webview/android/src/main/res/layout/activity_my.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity">

<TextView
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="48dp"
android:id="@+id/counterTextView"
android:textSize="24sp"
android:layout_above="@+id/counterButton"
android:layout_centerInParent="true"/>

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click me!"
android:id="@+id/counterButton"
android:layout_alignParentBottom="false"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />

</RelativeLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions webview/android/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Webview</string>
</resources>
8 changes: 8 additions & 0 deletions webview/android/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<resources>

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
</style>

</resources>
16 changes: 16 additions & 0 deletions webview/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
allprojects {
buildscript {
ext.kotlin_version = '1.0.0-beta-2423'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
}

task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
28 changes: 28 additions & 0 deletions webview/core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
buildscript {
repositories {
mavenCentral()
}
}

plugins {
id "me.tatarka.retrolambda" version "3.2.2"
}
apply plugin: 'java'
apply plugin: 'kotlin'

version 'unspecified'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenCentral()
}

sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
13 changes: 13 additions & 0 deletions webview/core/src/main/kotlin/com/prat/webview/CounterStore.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.prat.webview

class CounterStore {
private var count: Int = 0

fun add(num: Int) {
count += num
}

fun get(): Int {
return count
}
}
3 changes: 3 additions & 0 deletions webview/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx2000m
org.gradle.configureondemand=true
Binary file added webview/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
6 changes: 6 additions & 0 deletions webview/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Mon Nov 30 21:13:38 EST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip
Loading

0 comments on commit 764ecb3

Please sign in to comment.