├── app
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── strings.xml
│ │ │ │ ├── colors.xml
│ │ │ │ └── styles.xml
│ │ │ ├── mipmap-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_launcher_round.png
│ │ │ ├── mipmap-anydpi-v26
│ │ │ │ ├── ic_launcher.xml
│ │ │ │ └── ic_launcher_round.xml
│ │ │ ├── drawable-v24
│ │ │ │ └── ic_launcher_foreground.xml
│ │ │ ├── layout
│ │ │ │ └── activity_main.xml
│ │ │ └── drawable
│ │ │ │ └── ic_launcher_background.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── birdeveloper
│ │ │ │ └── specialviewexample
│ │ │ │ └── MainActivity.kt
│ │ └── AndroidManifest.xml
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── birdeveloper
│ │ │ └── specialviewexample
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── birdeveloper
│ │ └── specialviewexample
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── specialview
├── .gitignore
├── consumer-rules.pro
├── src
│ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── res
│ │ │ └── values
│ │ │ │ └── attr.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── birdeveloper
│ │ │ └── specialview
│ │ │ ├── Shadow.kt
│ │ │ └── SpecialLayout.kt
│ ├── test
│ │ └── java
│ │ │ └── com
│ │ │ └── birdeveloper
│ │ │ └── specialview
│ │ │ └── ExampleUnitTest.kt
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── birdeveloper
│ │ └── specialview
│ │ └── ExampleInstrumentedTest.kt
├── proguard-rules.pro
└── build.gradle
├── Screenshot_1.png
├── sample_shape.png
├── sample_button.png
├── sample_message_bg.png
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── sample_circle_gradient_color.png
├── .gitignore
├── gradle.properties
├── gradlew.bat
├── gradlew
└── README.md
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/specialview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/specialview/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Screenshot_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/Screenshot_1.png
--------------------------------------------------------------------------------
/sample_shape.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/sample_shape.png
--------------------------------------------------------------------------------
/sample_button.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/sample_button.png
--------------------------------------------------------------------------------
/sample_message_bg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/sample_message_bg.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='SpecialViewExample'
2 | include ':app'
3 | include ':specialview'
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | SpecialViewExample
3 |
4 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/sample_circle_gradient_color.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/sample_circle_gradient_color.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/specialview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/birdeveloper/SpecialView/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #6200EE
4 | #3700B3
5 | #03DAC5
6 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sun Mar 29 20:17:21 EET 2020
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-5.6.4-all.zip
7 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/specialview/src/test/java/com/birdeveloper/specialview/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialview
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/test/java/com/birdeveloper/specialviewexample/ExampleUnitTest.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialviewexample
2 |
3 | import org.junit.Test
4 |
5 | import org.junit.Assert.*
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * See [testing documentation](http://d.android.com/tools/testing).
11 | */
12 | class ExampleUnitTest {
13 | @Test
14 | fun addition_isCorrect() {
15 | assertEquals(4, 2 + 2)
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/app/src/main/java/com/birdeveloper/specialviewexample/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialviewexample
2 |
3 | import android.graphics.Color
4 | import androidx.appcompat.app.AppCompatActivity
5 | import android.os.Bundle
6 | import android.util.Log
7 | import kotlinx.android.synthetic.main.activity_main.*
8 |
9 | class MainActivity : AppCompatActivity() {
10 |
11 | override fun onCreate(savedInstanceState: Bundle?) {
12 | super.onCreate(savedInstanceState)
13 | setContentView(R.layout.activity_main)
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
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
22 |
--------------------------------------------------------------------------------
/specialview/proguard-rules.pro:
--------------------------------------------------------------------------------
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
22 |
--------------------------------------------------------------------------------
/specialview/src/androidTest/java/com/birdeveloper/specialview/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialview
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.birdeveloper.specialview.test", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/birdeveloper/specialviewexample/ExampleInstrumentedTest.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialviewexample
2 |
3 | import androidx.test.platform.app.InstrumentationRegistry
4 | import androidx.test.ext.junit.runners.AndroidJUnit4
5 |
6 | import org.junit.Test
7 | import org.junit.runner.RunWith
8 |
9 | import org.junit.Assert.*
10 |
11 | /**
12 | * Instrumented test, which will execute on an Android device.
13 | *
14 | * See [testing documentation](http://d.android.com/tools/testing).
15 | */
16 | @RunWith(AndroidJUnit4::class)
17 | class ExampleInstrumentedTest {
18 | @Test
19 | fun useAppContext() {
20 | // Context of the app under test.
21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext
22 | assertEquals("com.birdeveloper.specialviewexample", appContext.packageName)
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx1536m
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. More details, visit
12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Automatically convert third-party libraries to use AndroidX
19 | android.enableJetifier=true
20 | # Kotlin code style for this project: "official" or "obsolete":
21 | kotlin.code.style=official
22 |
--------------------------------------------------------------------------------
/specialview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.2"
8 |
9 | defaultConfig {
10 | minSdkVersion 19
11 | targetSdkVersion 29
12 | versionCode 1
13 | versionName "1.0"
14 |
15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
16 | consumerProguardFiles 'consumer-rules.pro'
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | implementation 'androidx.appcompat:appcompat:1.1.0'
32 | implementation 'androidx.core:core-ktx:1.2.0'
33 | implementation 'com.android.support.constraint:constraint-layout:1.1.3'
34 | testImplementation 'junit:junit:4.12'
35 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
36 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
37 | }
38 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 29
7 | buildToolsVersion "29.0.2"
8 |
9 | defaultConfig {
10 | applicationId "com.birdeveloper.specialviewexample"
11 | minSdkVersion 19
12 | targetSdkVersion 29
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 |
26 | }
27 |
28 | dependencies {
29 | implementation fileTree(dir: 'libs', include: ['*.jar'])
30 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
31 | implementation 'androidx.appcompat:appcompat:1.1.0'
32 | implementation 'androidx.core:core-ktx:1.2.0'
33 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
34 | implementation project(':specialview')
35 | testImplementation 'junit:junit:4.12'
36 | androidTestImplementation 'androidx.test.ext:junit:1.1.1'
37 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
38 | }
39 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v24/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/specialview/src/main/res/values/attr.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS=
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/specialview/src/main/java/com/birdeveloper/specialview/Shadow.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialview
2 |
3 | import android.graphics.Color
4 | import android.graphics.drawable.Drawable
5 | import android.graphics.drawable.GradientDrawable
6 | import android.graphics.drawable.InsetDrawable
7 | import android.graphics.drawable.LayerDrawable
8 | import android.graphics.drawable.GradientDrawable.Orientation
9 |
10 | class Shadow(spread:Int, opacity:Int, color:String, shape:Int, radius:FloatArray, position:Position) {
11 | private var spread:Int = 0
12 | private var opacity:Int = 0
13 | private val color:String
14 | private var shape:Int = 0
15 | private val radius:FloatArray = radius
16 | lateinit var shadow:LayerDrawable
17 | val shadowPosition:Position
18 | init{
19 | this.spread = spread
20 | this.opacity = opacity
21 | this.color = color.replace("#", "")
22 | this.shape = shape
23 | this.shadowPosition = position
24 | init()
25 | }
26 | private fun init() {
27 | var hex = 0
28 | spread *= 14
29 | val gradientDrawables = arrayOfNulls(spread)
30 | val padding = 1
31 | val center = shadowPosition == Position.CENTER
32 | val orientation = getOrientation(shadowPosition)
33 | var i = 0
34 | var step = 0
35 | while (i < spread)
36 | {
37 | val drawable = GradientDrawable()
38 | drawable.shape = shape
39 | drawable.gradientType = shape
40 | var str = Integer.toHexString(hex)
41 | if (hex < 16)
42 | {
43 | str = "0" + str
44 | }
45 | str += color
46 | val col = Color.parseColor("#" + str)
47 | if (!center)
48 | {
49 | drawable.orientation = orientation
50 | val colors = intArrayOf(col, Color.parseColor("#00ffffff"))
51 | drawable.colors = colors
52 | }
53 | else
54 | {
55 | drawable.setColor(col)
56 | }
57 | drawable.cornerRadii = radius
58 | gradientDrawables[i] = InsetDrawable(drawable, padding, padding, padding, padding)
59 | if (step == spread / 14)
60 | {
61 | ++hex
62 | step = 0
63 | }
64 | ++step
65 | ++i
66 | }
67 | shadow = LayerDrawable(gradientDrawables)
68 | shadow.alpha = opacity
69 | }
70 | private fun getOrientation(position:Position):Orientation {
71 | var orientation = Orientation.TOP_BOTTOM
72 | when (position) {
73 | Position.BOTTOM -> orientation = Orientation.BOTTOM_TOP
74 | Position.LEFT -> orientation = Orientation.LEFT_RIGHT
75 | Position.RIGHT -> orientation = Orientation.RIGHT_LEFT
76 | Position.TOP -> orientation = Orientation.TOP_BOTTOM
77 | }
78 | return orientation
79 | }
80 | internal fun getShadow():Drawable {
81 | return shadow
82 | }
83 | enum class Position {
84 | CENTER,
85 | RIGHT,
86 | LEFT,
87 | TOP,
88 | BOTTOM
89 | }
90 | }
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
18 |
19 |
29 |
30 |
40 |
41 |
54 |
55 |
71 |
72 |
84 |
93 |
94 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Attempt to set APP_HOME
10 | # Resolve links: $0 may be a link
11 | PRG="$0"
12 | # Need this for relative symlinks.
13 | while [ -h "$PRG" ] ; do
14 | ls=`ls -ld "$PRG"`
15 | link=`expr "$ls" : '.*-> \(.*\)$'`
16 | if expr "$link" : '/.*' > /dev/null; then
17 | PRG="$link"
18 | else
19 | PRG=`dirname "$PRG"`"/$link"
20 | fi
21 | done
22 | SAVED="`pwd`"
23 | cd "`dirname \"$PRG\"`/" >/dev/null
24 | APP_HOME="`pwd -P`"
25 | cd "$SAVED" >/dev/null
26 |
27 | APP_NAME="Gradle"
28 | APP_BASE_NAME=`basename "$0"`
29 |
30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31 | DEFAULT_JVM_OPTS=""
32 |
33 | # Use the maximum available, or set MAX_FD != -1 to use that value.
34 | MAX_FD="maximum"
35 |
36 | warn () {
37 | echo "$*"
38 | }
39 |
40 | die () {
41 | echo
42 | echo "$*"
43 | echo
44 | exit 1
45 | }
46 |
47 | # OS specific support (must be 'true' or 'false').
48 | cygwin=false
49 | msys=false
50 | darwin=false
51 | nonstop=false
52 | case "`uname`" in
53 | CYGWIN* )
54 | cygwin=true
55 | ;;
56 | Darwin* )
57 | darwin=true
58 | ;;
59 | MINGW* )
60 | msys=true
61 | ;;
62 | NONSTOP* )
63 | nonstop=true
64 | ;;
65 | esac
66 |
67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68 |
69 | # Determine the Java command to use to start the JVM.
70 | if [ -n "$JAVA_HOME" ] ; then
71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72 | # IBM's JDK on AIX uses strange locations for the executables
73 | JAVACMD="$JAVA_HOME/jre/sh/java"
74 | else
75 | JAVACMD="$JAVA_HOME/bin/java"
76 | fi
77 | if [ ! -x "$JAVACMD" ] ; then
78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79 |
80 | Please set the JAVA_HOME variable in your environment to match the
81 | location of your Java installation."
82 | fi
83 | else
84 | JAVACMD="java"
85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86 |
87 | Please set the JAVA_HOME variable in your environment to match the
88 | location of your Java installation."
89 | fi
90 |
91 | # Increase the maximum file descriptors if we can.
92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93 | MAX_FD_LIMIT=`ulimit -H -n`
94 | if [ $? -eq 0 ] ; then
95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96 | MAX_FD="$MAX_FD_LIMIT"
97 | fi
98 | ulimit -n $MAX_FD
99 | if [ $? -ne 0 ] ; then
100 | warn "Could not set maximum file descriptor limit: $MAX_FD"
101 | fi
102 | else
103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104 | fi
105 | fi
106 |
107 | # For Darwin, add options to specify how the application appears in the dock
108 | if $darwin; then
109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110 | fi
111 |
112 | # For Cygwin, switch paths to Windows format before running java
113 | if $cygwin ; then
114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116 | JAVACMD=`cygpath --unix "$JAVACMD"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Escape application args
158 | save () {
159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160 | echo " "
161 | }
162 | APP_ARGS=$(save "$@")
163 |
164 | # Collect all arguments for the java command, following the shell quoting and substitution rules
165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166 |
167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169 | cd "$(dirname "$0")"
170 | fi
171 |
172 | exec "$JAVACMD" "$@"
173 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
10 |
15 |
20 |
25 |
30 |
35 |
40 |
45 |
50 |
55 |
60 |
65 |
70 |
75 |
80 |
85 |
90 |
95 |
100 |
105 |
110 |
115 |
120 |
125 |
130 |
135 |
140 |
145 |
150 |
155 |
160 |
165 |
170 |
171 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [![MIT License][license-shield]][license-url]
2 | [![LinkedIn][linkedin-shield]][linkedin-url]
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
Special Layout
14 |
15 |
16 | This layout will help you a lot while designing!
17 |
18 | Explore the docs »
19 |
20 |
21 | View Demo
22 | ·
23 | Report Bug
24 | ·
25 | Request Feature
26 |
27 |
28 |
29 |
30 |
31 |
32 | ## Table of Contents
33 |
34 | * [About the Project](#about-the-project)
35 | * [Getting Started](#getting-started)
36 | * [Installation](#installation)
37 | * [Usage](#usage)
38 | * [Problems](#problems)
39 | * [Contributing](#contributing)
40 | * [License](#license)
41 | * [Contact](#contact)
42 | * [Acknowledgements](#acknowledgements)
43 |
44 |
45 |
46 |
47 | ## About The Project
48 |
49 | With this library you will stop creating backgrounds that are constantly drawable. Because this layout will allow you to see many things simultaneously, such as background color, radius values, gradient colors, while you design. SpecialLayout is derived from a ConstraintLayout layout.
50 | **This library will save you from confusion while saving you time.**
51 |
52 |
53 |
54 | ## Getting Started
55 |
56 | To get a local copy up and running follow these simple steps.
57 |
58 | ### Installation
59 |
60 | To get a Git project into your build:
61 |
62 | **Step 1.** Add the JitPack repository to your build file
63 | Add it in your root build.gradle at the end of repositories:
64 | ```sh
65 | allprojects {
66 | repositories {
67 | ...
68 | maven { url 'https://jitpack.io' }
69 | }
70 | }
71 | ```
72 | **Step 2.** Add the dependency
73 | ```sh
74 | dependencies {
75 | implementation 'com.github.birdeveloper:SpecialView:1.1.1'
76 | }
77 | ```
78 |
79 |
80 |
81 |
82 | ## Usage
83 |
84 | Android Studio can also be applied in the design section.
85 |
86 | **1.** To create a **button**:
87 |
88 |
89 |
90 |
91 |
92 | ```sh
93 |
102 |
103 |
112 |
113 |
114 | ```
115 |
116 |
117 | **2.** To create **Round element with gradient**:
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | ```sh
126 |
136 | ```
137 | **gradientType values:** linear (default), sweep, radial
138 | **gradientAngle values:** LEFT_RIGHT, BOTTOM_TOP, RIGHT_LEFT, TOP_BOTTOM (default)
139 |
140 | **3.** To create a **shape**:
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 | ```sh
149 |
155 | ```
156 | **4.** To create a **message background**:
157 |
158 |
159 |
160 |
161 |
162 | ```sh
163 |
175 | ```
176 |
177 | ## Problems
178 |
179 | See the [open issues](https://github.com/birdeveloper/SpecialView/issues) for a list of proposed features (and known issues).
180 |
181 |
182 |
183 |
184 | ## Contributing
185 |
186 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
187 |
188 | 1. Fork the Project
189 | 2. Create your Feature Branch (`git checkout -b birdeveloper/SpecialView`)
190 | 3. Commit your Changes (`git commit -m 'Add some SpecialView'`)
191 | 4. Push to the Branch (`git push origin birdeveloper/SpecialView`)
192 | 5. Open a Pull Request
193 |
194 |
195 |
196 |
197 | ## License
198 |
199 | Distributed under the MIT License. See `LICENSE` for more information.
200 |
201 |
202 |
203 |
204 | ## Contact
205 |
206 | Görkem KARA - [@gorkemkara](https://tr.linkedin.com/in/gorkemkara) - [email](mailto:birdeveloper.com@gmail.com)
207 |
208 | Project Link: [https://github.com/birdeveloper/SpecialView](https://github.com/birdeveloper/SpecialView)
209 |
210 |
211 |
212 |
213 | ## Acknowledgements
214 |
215 | * []()
216 |
217 |
218 |
219 |
220 |
221 |
222 | [contributors-shield]: https://img.shields.io/github/contributors/othneildrew/Best-README-Template.svg?style=flat-square
223 | [contributors-url]: https://github.com/birdeveloper/SpecialView/graphs/contributors
224 | [forks-shield]: https://img.shields.io/github/forks/othneildrew/Best-README-Template.svg?style=flat-square
225 | [forks-url]: https://github.com/birdeveloper/SpecialView/network/members
226 | [stars-shield]: https://img.shields.io/github/stars/othneildrew/Best-README-Template.svg?style=flat-square
227 | [stars-url]: https://github.com/birdeveloper/SpecialView/stargazers
228 | [issues-shield]: https://img.shields.io/github/issues/othneildrew/Best-README-Template.svg?style=flat-square
229 | [issues-url]: https://github.com/birdeveloper/SpecialView/issues
230 | [license-shield]: https://img.shields.io/github/license/othneildrew/Best-README-Template.svg?style=flat-square
231 | [license-url]: https://github.com/birdeveloper/SpecialView/blob/master/LICENSE.txt
232 | [linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=flat-square&logo=linkedin&colorB=555
233 | [linkedin-url]: https://tr.linkedin.com/in/gorkemkara
234 | [product-screenshot]: images/screenshot.png
235 |
--------------------------------------------------------------------------------
/specialview/src/main/java/com/birdeveloper/specialview/SpecialLayout.kt:
--------------------------------------------------------------------------------
1 | package com.birdeveloper.specialview
2 | import android.content.Context
3 | import android.graphics.drawable.GradientDrawable
4 | import android.util.AttributeSet
5 | import android.view.View
6 | import android.view.animation.Animation
7 | import android.view.animation.Interpolator
8 | import android.view.animation.ScaleAnimation
9 | import android.widget.RelativeLayout
10 | import androidx.constraintlayout.widget.ConstraintLayout
11 | /**
12 | * This layout will help you a lot while designing!
13 | * Bu layout size tasarım yaparken çok yardımcı olacak!
14 | * for more: https://github.com/birdeveloper
15 | * @author birdeveloper - Görkem KARA
16 | */
17 | class SpecialLayout:ConstraintLayout, Animation.AnimationListener {
18 | var amplitude:Float = 0.toFloat()
19 | private var pClick:OnClickListener? = null
20 | var frequency:Float = 0.toFloat()
21 | private var init = true
22 | private var animation: ScaleAnimation? = null
23 | var animationDuration:Int = 0
24 | var toXScale:Float = 0.toFloat()
25 | private var fromXScale:Float = 0.toFloat()
26 | var toYScale:Float = 0.toFloat()
27 | private var fromYScale:Float = 0.toFloat()
28 | private var pivotX:Float? = 0.toFloat()
29 | private var pivotY:Float? = 0.toFloat()
30 | var onclickColor:Int = 0
31 | private var color:Int = 0
32 | private var gd = GradientDrawable()
33 | var radius:Float = 0.toFloat()
34 | set(radius) {
35 | field = radius
36 | gd.cornerRadius = radius
37 | }
38 | var topRightRadius:Float = 0.toFloat()
39 | var topLeftRadius:Float = 0.toFloat()
40 | var bottomRightRadius:Float = 0.toFloat()
41 | var bottomLeftRadius:Float = 0.toFloat()
42 | private var shape:Int = 0
43 | private var view:View? = null
44 | private var animate:Boolean = false
45 | private var colors = IntArray(3)
46 | var isClickTransferable:Boolean = false
47 | var isClickAfterAnimation:Boolean = false
48 | private val main:RelativeLayout? = null
49 | var gradientType = "linear"
50 | set(gradientType) {
51 | var gradient = GradientDrawable.LINEAR_GRADIENT
52 | when (gradientType) {
53 | "sweep" -> gradient = GradientDrawable.SWEEP_GRADIENT
54 | "radial" -> gradient = GradientDrawable.RADIAL_GRADIENT
55 | }
56 | field = gradientType
57 | gd.gradientType = gradient
58 | }
59 | var gradientAngle = "TOP_BOTTOM"
60 | private set(gradientAngle) {
61 | field = gradientAngle
62 | gd.orientation = GradientDrawable.Orientation.valueOf(gradientAngle.toUpperCase())
63 | }
64 | private var interpolate:Boolean = false
65 | var isSelfClickable:Boolean = false
66 | private var fromChild:Boolean = false
67 | var interpolator:Interpolator? = null
68 | private var first = true
69 | var shadow:Shadow? = null
70 | set(shadow) {
71 | background = shadow!!.shadow
72 | field = shadow
73 | }
74 | private var shadowPosition = Shadow.Position.CENTER
75 | constructor(context: Context, shadow: Shadow) : super(context) {
76 | background = gd
77 | this.shadow = shadow
78 | }
79 | constructor(context:Context, attrs:AttributeSet) : super(context, attrs) {
80 | init(attrs)
81 | }
82 | private fun init(set:AttributeSet) {
83 | val ta = context.obtainStyledAttributes(set, R.styleable.SpecialLayout)
84 | val shadow = ta.getBoolean(R.styleable.SpecialLayout_shadow, false)
85 | var shadowColor = ta.getString(R.styleable.SpecialLayout_shadowColor)
86 | if (shadowColor == null)
87 | {
88 | shadowColor = "000000"
89 | }
90 | isClickTransferable = ta.getBoolean(R.styleable.SpecialLayout_clickTransferable, false)
91 | isSelfClickable = ta.getBoolean(R.styleable.SpecialLayout_selfClickable, true)
92 | if (ta.getString(R.styleable.SpecialLayout_gradientAngle) != null){
93 | gradientAngle = ta.getString(R.styleable.SpecialLayout_gradientAngle)!!
94 | }
95 |
96 | isClickAfterAnimation = ta.getBoolean(R.styleable.SpecialLayout_clickAfterAnimation, true)
97 | if (this.gradientAngle == null) gradientAngle = "TOP_BOTTOM"
98 | val gradientCenterColor = ta.getColor(R.styleable.SpecialLayout_gradientCenterColor, 0)
99 | val gradientEndColor = ta.getInteger(R.styleable.SpecialLayout_gradientEndColor, 0)
100 | val gradientStartColor = ta.getInt(R.styleable.SpecialLayout_gradientStartColor, 0)
101 | colors[0] = gradientStartColor
102 | colors[1] = gradientCenterColor
103 | colors[2] = gradientEndColor
104 | if (ta.getString(R.styleable.SpecialLayout_gradientType) != null){
105 | gradientType = ta.getString(R.styleable.SpecialLayout_gradientType)!!
106 | }
107 | if (this.gradientType == null)
108 | {
109 | gradientType = "linear"
110 | }
111 | val spread = ta.getInt(R.styleable.SpecialLayout_shadowSpread, 1)
112 | val shadowAlpha = ta.getInt(R.styleable.SpecialLayout_shadowAlpha, 255)
113 | animationDuration = ta.getInteger(R.styleable.SpecialLayout_animationDuration, 2000)
114 | toXScale = ta.getFloat(R.styleable.SpecialLayout_toXScale, 1.0f)
115 | fromXScale = ta.getFloat(R.styleable.SpecialLayout_fromXScale, .3f)
116 | toYScale = ta.getFloat(R.styleable.SpecialLayout_toYScale, 1.0f)
117 | fromYScale = ta.getFloat(R.styleable.SpecialLayout_fromYScale, .3f)
118 | pivotX = ta.getFloat(R.styleable.SpecialLayout_pX, -1f)
119 | pivotY = ta.getFloat(R.styleable.SpecialLayout_pY, -1f)
120 | animate = ta.getBoolean(R.styleable.SpecialLayout_animate, false)
121 | radius = ta.getDimension(R.styleable.SpecialLayout_radius, 0f)
122 | topRightRadius = ta.getDimension(R.styleable.SpecialLayout_topRightRadius, 0f)
123 | topLeftRadius = ta.getDimension(R.styleable.SpecialLayout_topLeftRadius, 0f)
124 | bottomRightRadius = ta.getDimension(R.styleable.SpecialLayout_bottomRightRadius, 0f)
125 | bottomLeftRadius = ta.getDimension(R.styleable.SpecialLayout_bottomLeftRadius, 0f)
126 | color = ta.getColor(R.styleable.SpecialLayout_color, android.R.attr.colorBackground)
127 | onclickColor = ta.getColor(R.styleable.SpecialLayout_onclickColor, -1)
128 | interpolate = ta.getBoolean(R.styleable.SpecialLayout_interpolate, false)
129 | amplitude = ta.getFloat(R.styleable.SpecialLayout_amplitude, 1.0f)
130 | frequency = ta.getFloat(R.styleable.SpecialLayout_frequency, .3f)
131 | val sh = ta.getString(R.styleable.SpecialLayout_shape)
132 | viewTreeObserver.addOnGlobalLayoutListener {
133 | if (first && animate) {
134 | animation = ScaleAnimation(fromXScale, toXScale, fromYScale, toYScale,
135 | (if (pivotX == -1f) width as Float / 2 else pivotX)!!, (if (pivotY == -1f) height as Float / 2 else pivotY)!!
136 | )
137 | animation!!.duration = animationDuration.toLong()
138 | animation!!.setAnimationListener(this@SpecialLayout)
139 | if (interpolate) {
140 | val interpolator = DefaultInterpolator()
141 | animation!!.interpolator = interpolator
142 | }
143 | first = false
144 | }
145 | }
146 | if (sh != null)
147 | {
148 | when (sh) {
149 | "oval" -> shape = GradientDrawable.OVAL
150 | "ring" -> shape = GradientDrawable.RING
151 | "line" -> shape = GradientDrawable.LINE
152 | }
153 | }
154 | val sPosition = ta.getString(R.styleable.SpecialLayout_shadowPosition)
155 | if (sPosition != null)
156 | {
157 | when (sPosition) {
158 | "top" -> shadowPosition = Shadow.Position.TOP
159 | "left" -> shadowPosition = Shadow.Position.LEFT
160 | "right" -> shadowPosition = Shadow.Position.RIGHT
161 | "bottom" -> shadowPosition = Shadow.Position.BOTTOM
162 | }
163 | }
164 | setShape(shape)
165 | if (!isEmpty(colors))
166 | {
167 | gd.colors = colors
168 | }
169 | else
170 | {
171 | gd.setColor(color)
172 | }
173 | gradientType = this.gradientType
174 | gradientAngle = this.gradientAngle
175 | val initRad = floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius)
176 | val radius = floatArrayOf(topLeftRadius, topLeftRadius, topRightRadius, topRightRadius, bottomRightRadius, bottomRightRadius, bottomLeftRadius, bottomLeftRadius)
177 | val radToSet = if (this.radius == 0f) radius else initRad
178 | setCornerRadii(radToSet)
179 | if (shadow)
180 | {
181 | this.shadow = Shadow(spread, shadowAlpha, shadowColor, shape, radToSet, shadowPosition)
182 | background = this.shadow!!.shadow
183 |
184 | }
185 | else
186 | background = gd
187 | //setOnClickListener(this)
188 | ta.recycle()
189 | }
190 | fun setShape(shape:Int) {
191 | gd.shape = shape
192 | }
193 | fun setFromXScale(fromXScale:Float) {
194 | this.fromXScale = fromXScale
195 | }
196 | fun setFromYScale(fromYScale:Float) {
197 | this.fromYScale = fromYScale
198 | }
199 | fun setGradientColor(colors:IntArray) {
200 | gd.colors = colors
201 | }
202 | override fun setBackgroundResource(resid:Int) {
203 | throw RuntimeException("setBackgroundResource not supported in SpecialLayout")
204 | }
205 | private fun isEmpty(ints:IntArray):Boolean {
206 | for (i in ints)
207 | {
208 | if (i != 0) return false
209 | }
210 | return true
211 | }
212 | fun setColor(color:Int) {
213 | gd.setColor(color)
214 | }
215 | fun getColor(): Int {
216 | return gd.color!!.defaultColor
217 | }
218 | fun setCornerRadii(radii:FloatArray) {
219 | gd.cornerRadii = radii
220 | }
221 | fun setInterpolate(interpolate:Boolean) {
222 | this.interpolate = interpolate
223 | }
224 |
225 | /* override fun setOnClickListener(l: OnClickListener?) {
226 | if (init)
227 | {
228 | super.setOnClickListener(l)
229 | init = false
230 | return
231 | }
232 | pClick = l
233 | }
234 | override fun onClick(v:View) {
235 | if (!isSelfClickable && !fromChild)
236 | {
237 | return
238 | }
239 | val parent = parent
240 | if (parent is SpecialLayout && isClickTransferable)
241 | {
242 | val SpecialLayout = parent
243 | SpecialLayout.fromChild = true
244 | SpecialLayout.onClick(SpecialLayout)
245 | }
246 | if (onclickColor != -1)
247 | {
248 | gd.setColor(onclickColor)
249 | }
250 | if (animate)
251 | {
252 | if (!isClickAfterAnimation)
253 | {
254 | if (pClick != null) pClick!!.onClick(v)
255 | }
256 | startAnimation(animation)
257 | return
258 | }
259 | if (pClick != null) pClick!!.onClick(v)
260 | fromChild = false
261 | }
262 | fun startAnimation() {
263 | startAnimation(animation)
264 | }*/
265 | override fun setBackgroundColor(color:Int) {
266 | throw RuntimeException("setBackgroundColor not supported!")
267 | }
268 | override fun onAnimationStart(animation:Animation) {
269 | }
270 | override fun onAnimationEnd(animation:Animation) {
271 | gd.setColor(color)
272 | if (isClickAfterAnimation && pClick != null)
273 | {
274 | //pClick!!.onClick(view)
275 | }
276 | }
277 | override fun onAnimationRepeat(animation:Animation) {
278 | }
279 | private inner class DefaultInterpolator:Interpolator {
280 | override fun getInterpolation(time:Float):Float {
281 | return (-1.0 * Math.pow(Math.E, (-time / amplitude).toDouble()) * Math.cos((frequency * time).toDouble()) + 1).toFloat()
282 | }
283 | }
284 | }
--------------------------------------------------------------------------------