Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
18a57d9
convert Marquee java to kt and apply kotlin plugin
lynring24 Jul 22, 2017
7132a98
convert text.LogTextBox1 java to kt
lynring24 Jul 22, 2017
9d24dc9
convert LogTextBox && Link java to kt
lynring24 Jul 22, 2017
92054df
found </a> missing
lynring24 Jul 22, 2017
48bfdd1
modified a depreciated Html.fromHtml() by version
lynring24 Jul 22, 2017
eb2138c
convert SeekBar java to kt
lynring24 Jul 29, 2017
2d22fac
converted AlarmController java to kt
lynring24 Jul 29, 2017
4baef90
removed comment
lynring24 Aug 11, 2017
01b8e36
used by lazy for t2(textView)
lynring24 Aug 11, 2017
b1d8c18
used lazy for t3 (textView)
lynring24 Aug 11, 2017
fed790f
used lazy for val t4
lynring24 Aug 11, 2017
88ec3ae
used lazy to init var mText and removed !!.apend
lynring24 Aug 11, 2017
3793084
use Kotlin synthetic property instead of java calendar.set()
lynring24 Aug 11, 2017
f965748
apply plugin: 'kotlin-android-extensions'
lynring24 Aug 11, 2017
b3a28ad
used extention code instead of findViewById
lynring24 Aug 11, 2017
1ae905e
convert AlarmService to kt
lynring24 Aug 11, 2017
aa830bf
FragmentAlertDialog converted to kt
lynring24 Aug 12, 2017
294f902
simplify DialogInterface.OnClickListener with Lamda
lynring24 Aug 12, 2017
5c595f5
add string resource for Fragment Alert Dialog msg
lynring24 Aug 12, 2017
9fd3753
used extention code instead of findViewById
lynring24 Aug 12, 2017
957b74d
applied lamda to onClickListener
lynring24 Aug 12, 2017
fe87cba
used kotlin properies instead
lynring24 Aug 12, 2017
829252c
fixed FragmentAlertDialog::doPositiceClick to (activity as Fragment) …
lynring24 Aug 12, 2017
dad4a72
Convert AlarmService_service to kotlin
lynring24 Aug 26, 2017
94cabb8
Convert IsolatedService to Kotlin
lynring24 Aug 26, 2017
f186edd
Convert IsolatedService2 to Kotlin
lynring24 Aug 26, 2017
df13761
Convert LocalService to Kotlin
lynring24 Aug 26, 2017
5f54bf2
Import Context
lynring24 Aug 26, 2017
45480b8
Convert LocalServiceActivies to Kotlin
lynring24 Aug 26, 2017
61d55d8
Convert NotificationBackgroundService to Kotlin
lynring24 Aug 26, 2017
a5e599a
changed to extension code
lynring24 Aug 26, 2017
c980368
Convert NotifyingController to Kotlin
lynring24 Aug 26, 2017
a0398a3
Convert NotifyingService to Kotlin
lynring24 Aug 26, 2017
9c90694
Convert ServiceStartArguments to Kotlin
lynring24 Aug 26, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
// vim: ts=4 sts=4 sw=4 expandtab

buildscript {
ext.kotlin_version = '1.1.3-2'
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
5 changes: 5 additions & 0 deletions mobile/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 26
Expand Down Expand Up @@ -27,4 +28,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:26.0.0-beta2'
compile 'com.android.support:appcompat-v7:26.0.0-beta2'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}
repositories {
mavenCentral()
}
84 changes: 0 additions & 84 deletions mobile/src/main/java/com/example/android/apis/text/Link.java

This file was deleted.

91 changes: 91 additions & 0 deletions mobile/src/main/java/com/example/android/apis/text/Link.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* 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 com.example.android.apis.text

import com.example.android.apis.R

import android.app.Activity
import android.graphics.Typeface
import android.os.Bundle
import android.text.Html
import android.text.SpannableString
import android.text.Spanned
import android.text.method.LinkMovementMethod
import android.text.style.StyleSpan
import android.text.style.URLSpan
import android.view.View
import android.widget.TextView

class Link : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.link)

// text1 shows the android:autoLink property, which
// automatically linkifies things like URLs and phone numbers
// found in the text. No java code is needed to make this
// work.

// text2 has links specified by putting <a> tags in the string
// resource. By default these links will appear but not
// respond to user input. To make them active, you need to
// call setMovementMethod() on the TextView object.

val t2 = findViewById<View>(R.id.text2) as TextView
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lazy 를 이용해서 findViewById 를 해보는 방법도 추천드려요

t2.movementMethod = LinkMovementMethod.getInstance()

// text3 shows creating text with links from HTML in the Java
// code, rather than from a string resource. Note that for a
// fixed string, using a (localizable) resource as shown above
// is usually a better way to go; this example is intended to
// illustrate how you might display text that came from a
// dynamic source (eg, the network).

val t3 = findViewById<View>(R.id.text3) as TextView
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
t3.text = Html.fromHtml(
"<b>text3: Constructed from HTML programmatically.</b> Text with a " +
"<a href=\"http://www.google.com\">link</a> " +
"created in the Java source code using HTML.", Html.FROM_HTML_MODE_LEGACY)
}
else{
t3.text = Html.fromHtml(
"<b>text3: Constructed from HTML programmatically.</b> Text with a " +
"<a href=\"http://www.google.com\">link</a> " +
"created in the Java source code using HTML.")
}
t3.movementMethod = LinkMovementMethod.getInstance()

// text4 illustrates constructing a styled string containing a
// link without using HTML at all. Again, for a fixed string
// you should probably be using a string resource, not a
// hardcoded value.

val ss = SpannableString(
"text4: Manually created spans. Click here to dial the phone.")

ss.setSpan(StyleSpan(Typeface.BOLD), 0, 30,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
ss.setSpan(URLSpan("tel:4155551212"), 31 + 6, 31 + 10,
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

val t4 = findViewById<View>(R.id.text4) as TextView
t4.text = ss
t4.movementMethod = LinkMovementMethod.getInstance()
}
}
64 changes: 0 additions & 64 deletions mobile/src/main/java/com/example/android/apis/text/LogTextBox.java

This file was deleted.

52 changes: 52 additions & 0 deletions mobile/src/main/java/com/example/android/apis/text/LogTextBox.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2007 The Android Open Source Project
*
* 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 com.example.android.apis.text

import android.widget.TextView
import android.content.Context
import android.text.method.ScrollingMovementMethod
import android.text.method.MovementMethod
import android.text.Editable
import android.util.AttributeSet

/**
* This is a TextView that is Editable and by default scrollable,
* like EditText without a cursor.

*
*
* **XML attributes**
*
*
* See
* [TextView Attributes][android.R.styleable.TextView],
* [View Attributes][android.R.styleable.View]
*/
class LogTextBox @JvmOverloads constructor(context: Context, attrs: AttributeSet ?= null, defStyle: Int = android.R.attr.textViewStyle) : TextView(context, attrs, defStyle) {

override fun getDefaultMovementMethod(): MovementMethod {
return ScrollingMovementMethod.getInstance()
}

override fun getText(): Editable {
return super.getText() as Editable
}

override fun setText(text: CharSequence, type: TextView.BufferType) {
super.setText(text, TextView.BufferType.EDITABLE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,18 @@
* to which text is appended.
*
*/
public class LogTextBox1 extends Activity {

private LogTextBox mText;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.log_text_box_1);

mText = (LogTextBox) findViewById(R.id.text);

Button addButton = (Button) findViewById(R.id.add);
addButton.setOnClickListener(new View.OnClickListener() {

public void onClick(View v) {
mText.append("This is a test\n");
} });
class LogTextBox1 : Activity() {

private var mText: LogTextBox? = null
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lazy이용시 nullable 표기 문제를 해소가능해서
아래 mText!!도 쉽게 해결되요


override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

setContentView(R.layout.log_text_box_1)

mText = findViewById<View>(R.id.text) as LogTextBox
val addButton = findViewById<View>(R.id.add) as Button
addButton.setOnClickListener { mText!!.append("This is a test\n") }
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@
import android.app.Activity;
import android.os.Bundle;

public class Marquee extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.marquee);
class Marquee : Activity() {
override fun onCreate(savedInstanceState:Bundle ?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.marquee)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<dl>
<dt><a href="Link.html">Linkify</a></dt>
<dd>Demonstrates the <a
<dd>Demonstrates the <a
href="../../../../../../../../../reference/android/text/util/Linkify.html"><code>Linkify</code>
class, which converts URLs in a block of text into hyperlinks. </dd>
class, which converts URLs in a block of text into hyperlinks.</a></dd>
</dl>