Skip to content

Commit c138fdb

Browse files
committed
first push
version 1.0
1 parent 8e0cc1f commit c138fdb

File tree

7 files changed

+207
-0
lines changed

7 files changed

+207
-0
lines changed

build.gradle

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright 2019 Thatchakon Jom-ud
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
apply plugin: 'com.android.library'
18+
apply plugin: 'kotlin-android-extensions'
19+
apply plugin: 'kotlin-android'
20+
21+
android {
22+
compileSdkVersion 28
23+
24+
defaultConfig {
25+
minSdkVersion 21
26+
targetSdkVersion 28
27+
versionCode 1
28+
versionName "1.0"
29+
30+
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
31+
32+
}
33+
34+
buildTypes {
35+
release {
36+
minifyEnabled false
37+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
38+
}
39+
}
40+
41+
}
42+
43+
dependencies {
44+
implementation fileTree(dir: 'libs', include: ['*.jar'])
45+
46+
testImplementation 'junit:junit:4.12'
47+
androidTestImplementation 'com.android.support.test:runner:1.0.2'
48+
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
49+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
50+
}
51+
repositories {
52+
mavenCentral()
53+
}

proguard-rules.pro

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package tk.dsjin.roundlinearlayout;
2+
3+
import android.content.Context;
4+
import android.support.test.InstrumentationRegistry;
5+
import android.support.test.runner.AndroidJUnit4;
6+
7+
import org.junit.Test;
8+
import org.junit.runner.RunWith;
9+
10+
import static org.junit.Assert.*;
11+
12+
/**
13+
* Instrumented test, which will execute on an Android device.
14+
*
15+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
16+
*/
17+
@RunWith(AndroidJUnit4.class)
18+
public class ExampleInstrumentedTest {
19+
/**
20+
* Use app context.
21+
*/
22+
@Test
23+
public void useAppContext() {
24+
// Context of the app under test.
25+
Context appContext = InstrumentationRegistry.getTargetContext();
26+
27+
assertEquals("tk.dsjin.roundlinearlayout.test", appContext.getPackageName());
28+
}
29+
}

src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
<!--
3+
~ Copyright 2019 Thatchakon Jom-ud
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<manifest package="tk.dsjin.roundlinearlayout"/>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2019 Thatchakon Jom-ud
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package tk.dsjin.roundlinearlayout
18+
19+
import android.content.Context
20+
import android.graphics.Canvas
21+
import android.graphics.Path
22+
import android.graphics.RectF
23+
import android.util.AttributeSet
24+
import android.widget.LinearLayout
25+
26+
class RoundLinearLayout: LinearLayout {
27+
private var radian : Int
28+
private var path : Path
29+
constructor(context : Context): super(context)
30+
constructor(context: Context, attrs : AttributeSet):super(context, attrs){
31+
val a = context.obtainStyledAttributes(attrs, R.styleable.RoundLinearLayout)
32+
radian = a.getInt(R.styleable.RoundLinearLayout_radian, 20)
33+
a.recycle()
34+
}
35+
constructor(context : Context, attrs : AttributeSet, defStyleAttr : Int):super(context, attrs, defStyleAttr)
36+
init {
37+
path = Path()
38+
radian = 20
39+
}
40+
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
41+
super.onSizeChanged(w, h, oldw, oldh)
42+
path.reset()
43+
val rect = RectF()
44+
rect.set(0f, 0f, w.toFloat(), h.toFloat())
45+
path.addRoundRect(rect, radian.toFloat(), radian.toFloat(), Path.Direction.CW)
46+
path.close()
47+
}
48+
49+
override fun draw(canvas: Canvas) {
50+
val save = canvas.save()
51+
canvas.clipPath(path)
52+
super.draw(canvas)
53+
canvas.restoreToCount(save)
54+
}
55+
56+
fun setRadius(radian : Int){
57+
this.radian = radian
58+
invalidate()
59+
}
60+
}

src/main/res/values/attrs.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<declare-styleable name="RoundLinearLayout">
4+
<attr name="radian" format="integer" />
5+
</declare-styleable>
6+
</resources>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package tk.dsjin.roundlinearlayout;
2+
3+
import org.junit.Test;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Example local unit test, which will execute on the development machine (host).
9+
*
10+
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
11+
*/
12+
public class ExampleUnitTest {
13+
/**
14+
* Addition is correct.
15+
*/
16+
@Test
17+
public void addition_isCorrect() {
18+
assertEquals(4, 2 + 2);
19+
}
20+
}

0 commit comments

Comments
 (0)