├── sample ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── dimens.xml │ │ │ │ ├── ic_launcher_background.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── styles.xml │ │ │ │ └── strings.xml │ │ │ ├── mipmap-hdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-mdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ ├── ic_launcher.png │ │ │ │ ├── ic_launcher_round.png │ │ │ │ └── ic_launcher_foreground.png │ │ │ ├── drawable │ │ │ │ ├── bg_oval_white.xml │ │ │ │ ├── bg_oval_border_black.xml │ │ │ │ ├── ic_expand_less_black_24dp.xml │ │ │ │ ├── ic_expand_more_black_24dp.xml │ │ │ │ ├── ic_qr_code.xml │ │ │ │ └── ic_launcher_background.xml │ │ │ ├── mipmap-anydpi-v26 │ │ │ │ ├── ic_launcher.xml │ │ │ │ └── ic_launcher_round.xml │ │ │ ├── menu │ │ │ │ └── menu_main.xml │ │ │ ├── layout │ │ │ │ ├── content_main.xml │ │ │ │ ├── activity_main.xml │ │ │ │ ├── item_scallop_options.xml │ │ │ │ ├── item_corner_options.xml │ │ │ │ ├── item_border_options.xml │ │ │ │ ├── bottomsheet_ticket_attributes.xml │ │ │ │ ├── item_background_options.xml │ │ │ │ ├── item_divider_options.xml │ │ │ │ └── activity_example.xml │ │ │ └── drawable-v24 │ │ │ │ └── ic_launcher_foreground.xml │ │ ├── ic_launcher-web.png │ │ ├── java │ │ │ └── com │ │ │ │ └── vipulasri │ │ │ │ └── ticketview │ │ │ │ └── sample │ │ │ │ ├── ViewExtentions.kt │ │ │ │ ├── ExampleActivity.kt │ │ │ │ ├── Utils.java │ │ │ │ ├── BaseActivity.kt │ │ │ │ └── MainActivity.kt │ │ └── AndroidManifest.xml │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── vipulasri │ │ │ └── ticketview │ │ │ └── sample │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── vipulasri │ │ └── ticketview │ │ └── sample │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── ticketview ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── attrs.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── vipulasri │ │ │ └── ticketview │ │ │ ├── Utils.java │ │ │ ├── BlurBuilder.java │ │ │ └── TicketView.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── vipulasri │ │ │ └── ticketview │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── vipulasri │ │ └── ticketview │ │ └── ExampleInstrumentedTest.java ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── art ├── showcase.png ├── google_play.png ├── screenshot_1.png └── screenshot_2.png ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .github └── FUNDING.yml ├── gradle.properties ├── .gitignore ├── gradlew.bat ├── gradlew ├── README.md └── LICENSE /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /ticketview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':sample', ':ticketview' 2 | -------------------------------------------------------------------------------- /art/showcase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/art/showcase.png -------------------------------------------------------------------------------- /art/google_play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/art/google_play.png -------------------------------------------------------------------------------- /art/screenshot_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/art/screenshot_1.png -------------------------------------------------------------------------------- /art/screenshot_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/art/screenshot_2.png -------------------------------------------------------------------------------- /sample/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 16dp 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /sample/src/main/ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/ic_launcher-web.png -------------------------------------------------------------------------------- /ticketview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TicketView 3 | 4 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /ticketview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-hdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-mdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vipulasri/TicketView/HEAD/sample/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png -------------------------------------------------------------------------------- /sample/src/main/res/values/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #E71844 4 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/bg_oval_white.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Oct 21 10:49:48 IST 2018 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-6.1.1-all.zip 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/bg_oval_border_black.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 7 | 8 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_expand_less_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_expand_more_black_24dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /sample/src/main/res/menu/menu_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /ticketview/src/test/java/com/vipulasri/ticketview/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview; 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 Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/src/test/java/com/vipulasri/ticketview/sample/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample; 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 Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /sample/src/main/java/com/vipulasri/ticketview/sample/ViewExtentions.kt: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample 2 | 3 | import androidx.annotation.LayoutRes 4 | import android.view.* 5 | 6 | fun inflateView(@LayoutRes layoutResId: Int, parent: ViewGroup, attachToRoot: Boolean): View { 7 | return LayoutInflater.from(parent.context).inflate(layoutResId, parent, attachToRoot) 8 | } 9 | 10 | inline fun whenNotNull(input: T?, callback: (T)->R): R? { 11 | return input?.let(callback) 12 | } 13 | 14 | infix fun Boolean.then(param: T): T? = if(this) param else null 15 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ['vipulasri'] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: ['https://www.paypal.me/vipulasri'] 13 | -------------------------------------------------------------------------------- /sample/src/main/java/com/vipulasri/ticketview/sample/ExampleActivity.kt: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.os.Bundle 6 | 7 | 8 | class ExampleActivity : BaseActivity() { 9 | 10 | fun launchActivity(startingActivity: Context) { 11 | val intent = Intent(startingActivity, ExampleActivity::class.java) 12 | startingActivity.startActivity(intent) 13 | } 14 | 15 | override fun onCreate(savedInstanceState: Bundle?) { 16 | super.onCreate(savedInstanceState) 17 | setContentView(R.layout.activity_example) 18 | isDisplayHomeAsUpEnabled = true 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /ticketview/src/main/java/com/vipulasri/ticketview/Utils.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.util.TypedValue; 6 | 7 | public class Utils { 8 | 9 | public static int dpToPx(float dp, Context context) { 10 | return dpToPx(dp, context.getResources()); 11 | } 12 | 13 | public static int dpToPx(float dp, Resources resources) { 14 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); 15 | return (int) px; 16 | } 17 | 18 | public static boolean isJellyBeanAndAbove() { 19 | return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1; 20 | } 21 | } -------------------------------------------------------------------------------- /sample/src/main/java/com/vipulasri/ticketview/sample/Utils.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample; 2 | 3 | import android.content.Context; 4 | import android.content.res.Resources; 5 | import android.util.TypedValue; 6 | 7 | public class Utils { 8 | 9 | public static int dpToPx(float dp, Context context) { 10 | return dpToPx(dp, context.getResources()); 11 | } 12 | 13 | public static int dpToPx(float dp, Resources resources) { 14 | float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, dp, resources.getDisplayMetrics()); 15 | return (int) px; 16 | } 17 | 18 | public static int pxToDp(float px, Context context) { 19 | float dp = px / context.getResources().getDisplayMetrics().density; 20 | return (int) dp; 21 | } 22 | } -------------------------------------------------------------------------------- /sample/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 | -------------------------------------------------------------------------------- /ticketview/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 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | android.enableJetifier=true 13 | android.useAndroidX=true 14 | org.gradle.jvmargs=-Xmx1536m 15 | 16 | # When configured, Gradle will run in incubating parallel mode. 17 | # This option should only be used with decoupled projects. More details, visit 18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 19 | # org.gradle.parallel=true 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | *.aab 5 | 6 | # Files for the ART/Dalvik VM 7 | *.dex 8 | 9 | # Java class files 10 | *.class 11 | 12 | # Generated files 13 | bin/ 14 | gen/ 15 | out/ 16 | sample/release/ 17 | 18 | # Gradle files 19 | .gradle/ 20 | build/ 21 | 22 | # Local configuration file (sdk path, etc) 23 | local.properties 24 | 25 | # Proguard folder generated by Eclipse 26 | proguard/ 27 | 28 | # Log Files 29 | *.log 30 | 31 | # Android Studio Navigation editor temp files 32 | .navigation/ 33 | 34 | # Android Studio captures folder 35 | captures/ 36 | 37 | # Intellij 38 | *.iml 39 | .idea/ 40 | 41 | # Keystore files 42 | *.jks 43 | 44 | # External native build folder generated in Android Studio 2.2 and later 45 | .externalNativeBuild 46 | 47 | #Android Studio 48 | projectFilesBackup/ 49 | 50 | #DS_STORE 51 | .DS_Store 52 | ._.DS_Store 53 | **/.DS_Store 54 | **/._.DS_Store -------------------------------------------------------------------------------- /ticketview/src/androidTest/java/com/vipulasri/ticketview/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.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 Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.vipulasri.ticketview.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/androidTest/java/com/vipulasri/ticketview/sample/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample; 2 | 3 | import android.content.Context; 4 | import androidx.test.platform.app.InstrumentationRegistry; 5 | import androidx.test.ext.junit.runners.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 Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.vipulasri.ticketview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/content_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /ticketview/src/main/java/com/vipulasri/ticketview/BlurBuilder.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | import android.renderscript.Allocation; 6 | import android.renderscript.Element; 7 | import android.renderscript.RenderScript; 8 | import android.renderscript.ScriptIntrinsicBlur; 9 | 10 | public class BlurBuilder { 11 | 12 | public static Bitmap blur(Context context, Bitmap image , float radius) { 13 | if(image == null || image.isRecycled()) return image; 14 | 15 | if (Utils.isJellyBeanAndAbove()) { 16 | RenderScript rs = RenderScript.create(context); 17 | ScriptIntrinsicBlur blur = ScriptIntrinsicBlur.create(rs, Element.U8_4(rs)); 18 | Allocation input = Allocation.createFromBitmap(rs, image); 19 | Allocation output = Allocation.createTyped(rs, input.getType()); 20 | blur.setRadius(radius); 21 | blur.setInput(input); 22 | blur.forEach(output); 23 | output.copyTo(image); 24 | input.destroy(); 25 | output.destroy(); 26 | } 27 | 28 | return image; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /sample/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #E71844 4 | #DE1B42 5 | #FFC857 6 | 7 | #1FE71844 8 | 9 | 10 | @color/material_red_500 11 | @color/material_pink_500 12 | @color/material_purple_500 13 | @color/material_deep_purple_500 14 | @color/material_indigo_500 15 | @color/material_blue_500 16 | @color/material_light_blue_500 17 | @color/material_cyan_500 18 | @color/material_teal_500 19 | @color/material_green_500 20 | @color/material_light_green_500 21 | @color/material_lime_500 22 | @color/material_yellow_500 23 | @color/material_amber_500 24 | @color/material_orange_500 25 | @color/material_deep_orange_500 26 | @color/material_brown_500 27 | @color/material_grey_500 28 | @color/material_blue_grey_500 29 | @color/material_light_white 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 13 | 14 | 20 | 21 | 22 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /ticketview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | ext { 4 | bintrayRepo = 'maven' 5 | bintrayRepoName = 'TicketView' 6 | 7 | groupId = 'com.vipulasri' 8 | libraryName = 'TicketView' 9 | artifact = 'ticketview' 10 | libraryVersion = '1.1.2' 11 | libraryDescription = 'A custom view to implement TicketView in android.' 12 | 13 | siteUrl = 'https://github.com/vipulasri/TicketView' 14 | gitUrl = 'https://github.com/vipulasri/TicketView.git' 15 | 16 | developerId = 'vipulasri' 17 | developerName = 'Vipul Asri' 18 | developerEmail = 'vipulasri.2007@gmail.com' 19 | 20 | licenseName = 'The Apache Software License, Version 2.0' 21 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 22 | licenses = ["Apache-2.0"] 23 | } 24 | 25 | android { 26 | compileSdkVersion versions.compileSdk 27 | defaultConfig { 28 | minSdkVersion versions.minSdk 29 | targetSdkVersion versions.targetSdk 30 | versionCode 12 31 | versionName "1.1.2" 32 | } 33 | 34 | buildTypes { 35 | release { 36 | minifyEnabled false 37 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 38 | } 39 | } 40 | 41 | } 42 | 43 | dependencies { 44 | implementation fileTree(include: ['*.jar'], dir: 'libs') 45 | implementation 'androidx.annotation:annotation:1.1.0' 46 | } 47 | 48 | apply from: 'https://raw.githubusercontent.com/vipulasri/BintrayHelper/master/install.gradle' 49 | apply from: 'https://raw.githubusercontent.com/vipulasri/BintrayHelper/master/bintray.gradle' 50 | -------------------------------------------------------------------------------- /sample/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 15 | 16 | 24 | 25 | 29 | 30 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_scallop_options.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 20 | 21 | 24 | 25 | 31 | 32 | 33 | 34 | 40 | 41 | 44 | 45 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /ticketview/src/main/res/values/attrs.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 | 38 | 39 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_corner_options.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 12 | 13 | 19 | 20 | 25 | 26 | 32 | 33 | 34 | 35 | 41 | 42 | 45 | 46 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | apply plugin: 'kotlin-android' 3 | apply plugin: 'kotlin-android-extensions' 4 | apply plugin: 'kotlin-kapt' 5 | 6 | android { 7 | compileSdkVersion versions.compileSdk 8 | defaultConfig { 9 | applicationId "com.vipulasri.ticketview.sample" 10 | minSdkVersion versions.minSdk 11 | targetSdkVersion versions.targetSdk 12 | versionCode 6 13 | versionName "1.0" 14 | testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner' 15 | vectorDrawables.useSupportLibrary = true 16 | } 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | } 24 | 25 | dependencies { 26 | implementation fileTree(dir: 'libs', include: ['*.jar']) 27 | testImplementation 'junit:junit:4.13' 28 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 29 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 30 | 31 | //kotlin 32 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${versions.kotlin.stdlib}" 33 | 34 | //support 35 | implementation 'androidx.appcompat:appcompat:1.2.0' 36 | implementation 'androidx.constraintlayout:constraintlayout:2.0.1' 37 | implementation 'com.google.android.material:material:1.2.1' 38 | 39 | //misc 40 | implementation 'com.dmitrymalkovich.android:material-design-dimens:1.4' 41 | implementation ('com.thebluealliance:spectrum:0.7.1') { 42 | exclude group: 'com.android.support' 43 | exclude module: 'appcompat-v7' 44 | exclude module: 'support-v4' 45 | } 46 | implementation ('org.adw.library:discrete-seekbar:1.0.1') { 47 | exclude group: 'com.android.support' 48 | exclude module: 'appcompat-v7' 49 | exclude module: 'support-v4' 50 | } 51 | implementation project(":ticketview") 52 | //implementation 'com.vipulasri:ticketview:1.0.3' 53 | } 54 | repositories { 55 | mavenCentral() 56 | } 57 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/ic_qr_code.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /sample/src/main/java/com/vipulasri/ticketview/sample/BaseActivity.kt: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample 2 | 3 | import android.graphics.drawable.Drawable 4 | import androidx.appcompat.app.AppCompatActivity 5 | import androidx.appcompat.widget.Toolbar 6 | import android.view.MenuItem 7 | 8 | open class BaseActivity : AppCompatActivity() { 9 | 10 | var toolbar: Toolbar? = null 11 | 12 | //If back button is displayed in action bar, return false 13 | protected var isDisplayHomeAsUpEnabled: Boolean 14 | get() = false 15 | set(value) { 16 | whenNotNull(supportActionBar) { 17 | it.setDisplayHomeAsUpEnabled(value) 18 | } 19 | 20 | } 21 | 22 | override fun setContentView(layoutResID: Int) { 23 | super.setContentView(layoutResID) 24 | 25 | injectViews() 26 | 27 | //Displaying the back button in the action bar 28 | if (isDisplayHomeAsUpEnabled) { 29 | whenNotNull(supportActionBar) { 30 | it.setDisplayHomeAsUpEnabled(true) 31 | } 32 | } 33 | } 34 | 35 | protected fun injectViews() { 36 | toolbar = findViewById(R.id.toolbar) 37 | setupToolbar() 38 | } 39 | 40 | fun setContentViewWithoutInject(layoutResId: Int) { 41 | super.setContentView(layoutResId) 42 | } 43 | 44 | protected fun setupToolbar() { 45 | whenNotNull(toolbar) { 46 | setSupportActionBar(it) 47 | } 48 | } 49 | 50 | fun setActivityTitle(title: Int) { 51 | whenNotNull(supportActionBar) { 52 | it.setTitle(title) 53 | } 54 | } 55 | 56 | fun setActivityTitle(title: String) { 57 | whenNotNull(supportActionBar) { 58 | it.setTitle(title) 59 | } 60 | } 61 | 62 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 63 | //Menu 64 | when (item.itemId) { 65 | //When home is clicked 66 | android.R.id.home -> { 67 | onActionBarHomeIconClicked() 68 | return true 69 | } 70 | } 71 | return super.onOptionsItemSelected(item) 72 | } 73 | 74 | fun setHomeAsUpIndicator(drawable: Drawable) { 75 | whenNotNull(supportActionBar) { 76 | it.setHomeAsUpIndicator(drawable) 77 | } 78 | } 79 | 80 | //Method for when home button is clicked 81 | private fun onActionBarHomeIconClicked() { 82 | if (isDisplayHomeAsUpEnabled) { 83 | onBackPressed() 84 | } else { 85 | finish() 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /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 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 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 Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /sample/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Ticket View 3 | Settings 4 | Options 5 | Orientation 6 | Horizontal 7 | Vertical 8 | Scallop 9 | Background Color 10 | Ticket Options 11 | Border 12 | Divider 13 | Radius 14 | Elevation 15 | Position(in %) 16 | Color 17 | Shadow Color 18 | Width 19 | Padding 20 | Enable 21 | Type 22 | Dash Length 23 | Dash Gap 24 | Ticket Attributes 25 | 26 | 2h 13min 27 | Adventure, Fantasy, Action 28 | 400–2000–2020 29 | Date 30 | 01–03–2017 31 | Time 32 | 23:30 33 | Seat 34 | C5-C8 35 | Corners 36 | Example 37 | Background 38 | Color before Divider 39 | Color after Divider 40 | 41 | 42 | Normal 43 | Dashed 44 | 45 | 46 | 47 | 10 48 | 20 49 | 30 50 | 40 51 | 50 52 | 60 53 | 70 54 | 80 55 | 90 56 | 100 57 | 58 | 59 | 60 | Normal 61 | Rounded 62 | Scallop 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_border_options.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 19 | 20 | 25 | 26 | 30 | 31 | 32 | 33 | 39 | 40 | 45 | 46 | 52 | 53 | 54 | 55 | 61 | 62 | 67 | 68 | 74 | 75 | 80 | 81 | 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/bottomsheet_ticket_attributes.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 22 | 23 | 29 | 30 | 36 | 37 | 38 | 39 | 42 | 43 | 50 | 51 | 54 | 55 | 62 | 63 | 69 | 70 | 77 | 78 | 79 | 80 | 83 | 84 | 85 | 86 | 89 | 90 | 91 | 92 | 95 | 96 | 97 | 98 | 101 | 102 | 103 | 104 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_background_options.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 12 | 13 | 19 | 20 | 23 | 24 | 30 | 31 | 32 | 33 | 39 | 40 | 45 | 46 | 52 | 53 | 58 | 59 | 60 | 61 | 62 | 63 | 69 | 70 | 75 | 76 | 82 | 83 | 88 | 89 | 90 | 91 | 92 | 93 | 99 | 100 | 105 | 106 | 112 | 113 | 118 | 119 | 120 | 121 | 122 | 123 | 129 | 130 | 135 | 136 | 142 | 143 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/item_divider_options.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 12 | 13 | 18 | 19 | 24 | 25 | 29 | 30 | 31 | 32 | 38 | 39 | 44 | 45 | 51 | 52 | 53 | 54 | 60 | 61 | 66 | 67 | 73 | 74 | 75 | 76 | 82 | 83 | 88 | 89 | 95 | 96 | 101 | 102 | 103 | 104 | 105 | 106 | 112 | 113 | 118 | 119 | 125 | 126 | 127 | 128 | 134 | 135 | 140 | 141 | 147 | 148 | 149 | 150 | 156 | 157 | 162 | 163 | 169 | 170 | 171 | 172 | -------------------------------------------------------------------------------- /sample/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 | # TicketView 2 | 3 | An Android Library used to implement TicketView in android with normal, rounded and scallop corners. 4 | 5 | ### Specs 6 | [![API](https://img.shields.io/badge/API-15%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=15) 7 | [![Maven Central](https://img.shields.io/maven-central/v/com.vipulasri/ticketview.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.vipulasri%22%20AND%20a:%22ticketview%22) 8 | [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/vipulasri/Timeline-View/blob/master/LICENSE) 9 | 10 | 11 | ### Badges/Featured In 12 | [![TicketView](https://www.appbrain.com/stats/libraries/shield/ticketview.svg)](https://www.appbrain.com/stats/libraries/details/ticketview/ticketview) 13 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Ticket%20View-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/6521) 14 | [![AndroidDev Digest](https://img.shields.io/badge/AndroidDev%20Digest-%23171-blue.svg)](https://www.androiddevdigest.com/digest-171/) 15 | 16 | ![showcase](https://github.com/vipulasri/TicketView/blob/master/art/showcase.png) 17 | 18 | ## Sample Project 19 | 20 | For information : checkout [Sample App Code](https://github.com/vipulasri/TicketView/tree/master/sample) in repository. 21 | 22 | ### Download 23 | 24 | [![TicketView on Google Play](https://github.com/vipulasri/TicketView/blob/master/art/google_play.png)](https://play.google.com/store/apps/details?id=com.vipulasri.ticketview.sample) 25 | 26 | ## Quick Setup 27 | 28 | ### 1. Include library 29 | 30 | **Using Gradle** 31 | 32 | ``` gradle 33 | dependencies { 34 | implementation 'com.vipulasri:ticketview:1.1.2' 35 | } 36 | ``` 37 | 38 | ### What's New 39 | 40 | See the project's Releases page for a list of versions with their change logs. 41 | 42 | ### [View Releases](https://github.com/vipulasri/TicketView/releases) 43 | 44 | If you Watch this repository, GitHub will send you an email every time I publish an update. 45 | 46 | ### 2. Usage 47 | * In XML Layout : 48 | 49 | ``` java 50 | 65 | ``` 66 | 67 | * Configure using xml attributes or setters in code: 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 |
Attribute NameDefault ValueDescription
app:ticketOrientation="vertical"horizontalsets orientation of divider and scallop
app:ticketBackgroundColor="@android:color/black"whitesets background color
app:ticketScallopRadius="10dp"20dpsets scallop radius
app:ticketScallopPositionPercent="50"50sets position of scallop and divider
app:ticketShowBorder="false"falseshows border if `true`
app:ticketBorderWidth="4dp"2dpsets border width
app:ticketBorderColor="@color/grey"blacksets border color
app:ticketShowDivider="true"falseshows divider if `true`
app:ticketDividerType="dash"normalsets type of divider ie `normal` or `dash`
app:ticketDividerColor="@color/colorAccent"dark graysets divider color
app:ticketDividerWidth="2dp"2dpsets divider width
app:ticketDividerPadding="0dp"10dpsets divider padding
app:ticketDividerDashGap="4dp"4dpsets divider dash gap
app:ticketDividerDashLength="8dp"8dpsets divider dash length
app:ticketCornerType="rounded"normalsets type of corner ie `normal` or `rounded` or `scallop`
app:ticketCornerRadius="15dp"4dpsets corner radius if corner rounder or scallop
app:ticketElevation="14dp"0dpsets elevation to ticket view on android jellybean and above
app:ticketBackgroundBeforeDividernonesets background to ticket view before divider
app:ticketBackgroundAfterDividernonesets background to ticket view after divider
app:ticketShadowColorblacksets shadow to ticket view
174 | 175 | ## Apps that use this library 176 | 177 | * [Open. Yoga](https://play.google.com/store/apps/details?id=com.labfoodandfriends.nikitagudkovs.jlogOpen_yoga) 178 | * [Open. Gym](https://play.google.com/store/apps/details?id=com.labfoodandfriends.nikitagudkovs.jlog_gym) 179 | 180 | [Apps using Ticket View, via AppBrain Stats](https://www.appbrain.com/stats/libraries/details/ticketview/ticketview) 181 | 182 | If you're using this library in your app and you'd like to list it here, 183 | Please let me know via [email](mailto:me@vipulasri.com), [pull requests](https://github.com/vipulasri/TicketView/pulls) or [issues](https://github.com/vipulasri/TicketView/issues). 184 | 185 | ## Special Thanks 186 | 187 | [**Nick Butcher**](https://github.com/nickbutcher) for helping me out with TicketView Shadow/Elevation. 188 | 189 | 190 | ## License 191 | 192 | 193 | Copyright 2017 Vipul Asri 194 | 195 | Licensed under the Apache License, Version 2.0 (the "License"); 196 | you may not use this file except in compliance with the License. 197 | You may obtain a copy of the License at 198 | 199 | http://www.apache.org/licenses/LICENSE-2.0 200 | 201 | Unless required by applicable law or agreed to in writing, software 202 | distributed under the License is distributed on an "AS IS" BASIS, 203 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 204 | See the License for the specific language governing permissions and 205 | limitations under the License. 206 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_example.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 14 | 15 | 21 | 22 | 23 | 24 | 32 | 33 | 48 | 49 | 55 | 56 | 65 | 66 | 75 | 76 | 83 | 84 | 85 | 86 | 96 | 97 | 103 | 104 | 110 | 111 | 117 | 118 | 123 | 124 | 130 | 131 | 137 | 138 | 144 | 145 | 146 | 147 | 153 | 154 | 160 | 161 | 167 | 168 | 174 | 175 | 176 | 177 | 183 | 184 | 190 | 191 | 197 | 198 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /sample/src/main/java/com/vipulasri/ticketview/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview.sample 2 | 3 | import android.content.Intent 4 | import android.os.Bundle 5 | import com.google.android.material.bottomsheet.BottomSheetBehavior 6 | import android.view.View 7 | import com.vipulasri.ticketview.TicketView 8 | 9 | import kotlinx.android.synthetic.main.content_main.* 10 | import com.thebluealliance.spectrum.SpectrumDialog 11 | import android.graphics.PorterDuff 12 | import android.graphics.drawable.ColorDrawable 13 | import androidx.annotation.NonNull 14 | import android.util.Log 15 | import android.view.Menu 16 | import android.view.MenuItem 17 | import android.widget.AdapterView 18 | import android.widget.ImageView 19 | import kotlinx.android.synthetic.main.item_background_options.* 20 | import kotlinx.android.synthetic.main.item_border_options.* 21 | import kotlinx.android.synthetic.main.item_divider_options.* 22 | import kotlinx.android.synthetic.main.item_scallop_options.* 23 | import org.adw.library.widgets.discreteseekbar.DiscreteSeekBar 24 | import android.widget.AdapterView.OnItemSelectedListener 25 | import kotlinx.android.synthetic.main.bottomsheet_ticket_attributes.* 26 | import kotlinx.android.synthetic.main.item_corner_options.* 27 | 28 | 29 | class MainActivity : BaseActivity() { 30 | 31 | private lateinit var mBottomSheetBehavior: BottomSheetBehavior 32 | 33 | override fun onCreate(savedInstanceState: Bundle?) { 34 | super.onCreate(savedInstanceState) 35 | setContentView(R.layout.activity_main) 36 | 37 | initOptionsBottomSheet() 38 | } 39 | 40 | override fun onCreateOptionsMenu(menu: Menu): Boolean { 41 | menuInflater.inflate(R.menu.menu_main, menu) 42 | return true 43 | } 44 | 45 | override fun onOptionsItemSelected(item: MenuItem): Boolean { 46 | when (item.itemId) { 47 | 48 | R.id.action_example -> { 49 | startActivity(Intent(this, ExampleActivity::class.java)) 50 | return true 51 | } 52 | } 53 | return super.onOptionsItemSelected(item) 54 | } 55 | 56 | 57 | private fun initOptionsBottomSheet() { 58 | mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet) 59 | 60 | view_options_header.setOnClickListener { 61 | if (mBottomSheetBehavior.state == BottomSheetBehavior.STATE_COLLAPSED) { 62 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_EXPANDED 63 | } else { 64 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED 65 | } 66 | } 67 | 68 | mBottomSheetBehavior.setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { 69 | override fun onStateChanged(@NonNull bottomSheet: View, newState: Int) { 70 | when(newState) { 71 | BottomSheetBehavior.STATE_COLLAPSED -> image_toggle.setImageResource(R.drawable.ic_expand_less_black_24dp) 72 | BottomSheetBehavior.STATE_EXPANDED -> image_toggle.setImageResource(R.drawable.ic_expand_more_black_24dp) 73 | else -> { 74 | image_toggle.setImageResource(R.drawable.ic_expand_less_black_24dp) 75 | } 76 | } 77 | } 78 | 79 | override fun onSlide(@NonNull bottomSheet: View, slideOffset: Float) { 80 | 81 | } 82 | }) 83 | 84 | image_background_color.background.setColorFilter(ticketView.backgroundColor, PorterDuff.Mode.SRC_ATOP) 85 | image_background_shadow_color.background.setColorFilter(ticketView.shadowColor, PorterDuff.Mode.SRC_ATOP) 86 | image_background_before_divider_color.setImageDrawable(ticketView.backgroundBeforeDivider) 87 | image_background_after_divider_color.setImageDrawable(ticketView.backgroundAfterDivider) 88 | 89 | image_border_color.background.setColorFilter(ticketView.borderColor, PorterDuff.Mode.SRC_ATOP) 90 | image_divider_color.background.setColorFilter(ticketView.dividerColor, PorterDuff.Mode.SRC_ATOP) 91 | 92 | when(ticketView.orientation) { 93 | TicketView.Orientation.HORIZONTAL -> radioButton_horizontal.isChecked = true 94 | TicketView.Orientation.VERTICAL -> radioButton_vertical.isChecked = true 95 | } 96 | 97 | radioGroup_orientation.setOnCheckedChangeListener { group, checkedId -> 98 | when(checkedId) { 99 | R.id.radioButton_horizontal -> ticketView.orientation = TicketView.Orientation.HORIZONTAL 100 | R.id.radioButton_vertical -> ticketView.orientation = TicketView.Orientation.VERTICAL 101 | else -> { 102 | ticketView.orientation = TicketView.Orientation.HORIZONTAL 103 | } 104 | } 105 | } 106 | 107 | //background properties 108 | 109 | image_background_color.setOnClickListener { 110 | showColorPicker(ticketView.backgroundColor, image_background_color) 111 | } 112 | 113 | image_background_shadow_color.setOnClickListener { 114 | showColorPicker(ticketView.shadowColor, image_background_shadow_color) 115 | } 116 | 117 | image_background_before_divider_color.setOnClickListener { 118 | showColorPicker(-1, image_background_before_divider_color) 119 | } 120 | 121 | image_background_after_divider_color.setOnClickListener { 122 | showColorPicker(-1, image_background_after_divider_color) 123 | } 124 | 125 | seekBar_elevation.setOnProgressChangeListener(progressChangeListener) 126 | 127 | //scallop properties 128 | 129 | seekBar_scallop_radius.progress = Utils.pxToDp(ticketView.scallopRadius.toFloat(), this) 130 | seekBar_scallop_radius.setOnProgressChangeListener(progressChangeListener) 131 | 132 | spinner_scallop_position.setSelection(4) 133 | spinner_scallop_position.onItemSelectedListener = object : OnItemSelectedListener { 134 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { 135 | val selectedItem = parent.getItemAtPosition(position).toString() 136 | ticketView.scallopPositionPercent = selectedItem.toFloat() 137 | } 138 | 139 | override fun onNothingSelected(parent: AdapterView<*>) { 140 | 141 | } 142 | } 143 | 144 | //border properties 145 | 146 | ticketView.isShowBorder = false 147 | checkbox_show_border.isChecked = false 148 | checkbox_show_border.setOnCheckedChangeListener { compoundButton, checked -> 149 | ticketView.isShowBorder = checked 150 | } 151 | 152 | seekBar_border_width.progress = Utils.pxToDp(ticketView.borderWidth.toFloat(), this) 153 | seekBar_border_width.setOnProgressChangeListener(progressChangeListener) 154 | 155 | image_border_color.setOnClickListener { 156 | showColorPicker(ticketView.borderColor, image_border_color) 157 | } 158 | 159 | //divider properties 160 | 161 | ticketView.isShowDivider = true 162 | checkbox_show_divider.isChecked = true 163 | checkbox_show_divider.setOnCheckedChangeListener { compoundButton, checked -> 164 | ticketView.isShowDivider = checked 165 | } 166 | 167 | image_divider_color.setOnClickListener { 168 | showColorPicker(ticketView.dividerColor, image_divider_color) 169 | } 170 | 171 | spinner_divider_type.setSelection(1) 172 | spinner_divider_type.onItemSelectedListener = object : OnItemSelectedListener { 173 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { 174 | val selectedItem = parent.getItemAtPosition(position).toString() 175 | when (selectedItem) { 176 | "Normal" -> ticketView.dividerType = TicketView.DividerType.NORMAL 177 | "Dashed" -> ticketView.dividerType = TicketView.DividerType.DASH 178 | else -> { 179 | ticketView.dividerType = TicketView.DividerType.NORMAL 180 | } 181 | } 182 | } 183 | 184 | override fun onNothingSelected(parent: AdapterView<*>) { 185 | 186 | } 187 | } 188 | 189 | seekBar_divider_width.progress = Utils.pxToDp(ticketView.dividerWidth.toFloat(), this) 190 | seekBar_divider_width.setOnProgressChangeListener(progressChangeListener) 191 | 192 | seekBar_divider_padding.progress = Utils.pxToDp(ticketView.dividerPadding.toFloat(), this) 193 | seekBar_divider_padding.setOnProgressChangeListener(progressChangeListener) 194 | 195 | seekBar_divider_dash_length.progress = Utils.pxToDp(ticketView.dividerDashLength.toFloat(), this) 196 | seekBar_divider_dash_length.setOnProgressChangeListener(progressChangeListener) 197 | 198 | seekBar_divider_dash_gap.progress = Utils.pxToDp(ticketView.dividerDashGap.toFloat(), this) 199 | seekBar_divider_dash_gap.setOnProgressChangeListener(progressChangeListener) 200 | 201 | //corner properties 202 | 203 | spinner_corner_type.setSelection(0) 204 | spinner_corner_type.onItemSelectedListener = object : OnItemSelectedListener { 205 | override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) { 206 | val selectedItem = parent.getItemAtPosition(position).toString() 207 | when (selectedItem) { 208 | "Normal" -> ticketView.cornerType = TicketView.CornerType.NORMAL 209 | "Rounded" -> ticketView.cornerType = TicketView.CornerType.ROUNDED 210 | "Scallop" -> ticketView.cornerType = TicketView.CornerType.SCALLOP 211 | else -> { 212 | ticketView.cornerType = TicketView.CornerType.NORMAL 213 | } 214 | } 215 | } 216 | 217 | override fun onNothingSelected(parent: AdapterView<*>) { 218 | 219 | } 220 | } 221 | 222 | seekBar_corner_radius.progress = Utils.pxToDp(ticketView.cornerRadius.toFloat(), this) 223 | seekBar_corner_radius.setOnProgressChangeListener(progressChangeListener) 224 | 225 | } 226 | 227 | private fun showColorPicker(selectedColor : Int, colorView: ImageView) { 228 | SpectrumDialog.Builder(this) 229 | .setColors(R.array.colors) 230 | .setSelectedColor(selectedColor) 231 | .setDismissOnColorSelected(true) 232 | .setOutlineWidth(1) 233 | .setOnColorSelectedListener { positiveResult, color -> 234 | if (positiveResult) { 235 | colorView.background.setColorFilter(color, PorterDuff.Mode.SRC_ATOP) 236 | 237 | when(colorView.id) { 238 | R.id.image_border_color -> ticketView.borderColor = color 239 | R.id.image_divider_color -> ticketView.dividerColor = color 240 | R.id.image_background_color -> ticketView.backgroundColor = color 241 | R.id.image_background_shadow_color -> ticketView.shadowColor = color 242 | R.id.image_background_before_divider_color -> ticketView.backgroundBeforeDivider = ColorDrawable(color) 243 | R.id.image_background_after_divider_color -> ticketView.backgroundAfterDivider = ColorDrawable(color) 244 | else -> { 245 | //do nothing 246 | } 247 | } 248 | 249 | } 250 | }.build().show(supportFragmentManager, "ColorPicker") 251 | } 252 | 253 | private var progressChangeListener: DiscreteSeekBar.OnProgressChangeListener = object : DiscreteSeekBar.OnProgressChangeListener { 254 | 255 | override fun onProgressChanged(discreteSeekBar: DiscreteSeekBar, value: Int, b: Boolean) { 256 | 257 | val valueInDp = Utils.dpToPx(value.toFloat(), this@MainActivity) 258 | Log.d("TAG", "->"+discreteSeekBar.id) 259 | when(discreteSeekBar.id) { 260 | R.id.seekBar_elevation -> ticketView.setTicketElevation(valueInDp.toFloat()) 261 | R.id.seekBar_border_width -> ticketView.borderWidth = valueInDp 262 | R.id.seekBar_scallop_radius -> ticketView.scallopRadius = valueInDp 263 | R.id.seekBar_divider_width -> ticketView.dividerWidth = valueInDp 264 | R.id.seekBar_divider_padding -> ticketView.dividerPadding = valueInDp 265 | R.id.seekBar_divider_dash_length -> ticketView.dividerDashLength = valueInDp 266 | R.id.seekBar_divider_dash_gap -> ticketView.dividerDashGap = valueInDp 267 | R.id.seekBar_corner_radius -> ticketView.cornerRadius = valueInDp 268 | } 269 | } 270 | 271 | override fun onStartTrackingTouch(discreteSeekBar: DiscreteSeekBar) { 272 | 273 | } 274 | 275 | override fun onStopTrackingTouch(discreteSeekBar: DiscreteSeekBar) { 276 | 277 | } 278 | } 279 | 280 | override fun onBackPressed() { 281 | if(mBottomSheetBehavior.state == BottomSheetBehavior.STATE_EXPANDED) { 282 | mBottomSheetBehavior.state = BottomSheetBehavior.STATE_COLLAPSED 283 | } else { 284 | super.onBackPressed() 285 | } 286 | } 287 | } 288 | -------------------------------------------------------------------------------- /ticketview/src/main/java/com/vipulasri/ticketview/TicketView.java: -------------------------------------------------------------------------------- 1 | package com.vipulasri.ticketview; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Bitmap; 6 | import android.graphics.Canvas; 7 | import android.graphics.DashPathEffect; 8 | import android.graphics.Paint; 9 | import android.graphics.Path; 10 | import android.graphics.PathEffect; 11 | import android.graphics.PorterDuffColorFilter; 12 | import android.graphics.RectF; 13 | import android.graphics.drawable.Drawable; 14 | 15 | import androidx.annotation.IntDef; 16 | import android.util.AttributeSet; 17 | import android.util.Log; 18 | import android.view.View; 19 | 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | 23 | import static android.graphics.Bitmap.Config.ARGB_8888; 24 | import static android.graphics.Color.TRANSPARENT; 25 | import static android.graphics.Paint.ANTI_ALIAS_FLAG; 26 | import static android.graphics.PorterDuff.Mode.SRC_IN; 27 | 28 | /** 29 | * Created by Vipul Asri on 31/10/17. 30 | */ 31 | 32 | public class TicketView extends View { 33 | 34 | public static final String TAG = TicketView.class.getSimpleName(); 35 | 36 | @Retention(RetentionPolicy.SOURCE) 37 | @IntDef({Orientation.HORIZONTAL, Orientation.VERTICAL}) 38 | public @interface Orientation { 39 | int HORIZONTAL = 0; 40 | int VERTICAL = 1; 41 | } 42 | 43 | @Retention(RetentionPolicy.SOURCE) 44 | @IntDef({DividerType.NORMAL, DividerType.DASH}) 45 | public @interface DividerType { 46 | int NORMAL = 0; 47 | int DASH = 1; 48 | } 49 | 50 | @Retention(RetentionPolicy.SOURCE) 51 | @IntDef({CornerType.NORMAL, CornerType.ROUNDED}) 52 | public @interface CornerType { 53 | int NORMAL = 0; 54 | int ROUNDED = 1; 55 | int SCALLOP = 2; 56 | } 57 | 58 | private Paint mBackgroundPaint = new Paint(); 59 | private Paint mBorderPaint = new Paint(); 60 | private Paint mDividerPaint = new Paint(); 61 | private int mOrientation; 62 | private Path mPath = new Path(); 63 | private boolean mDirty = true; 64 | private float mDividerStartX, mDividerStartY, mDividerStopX, mDividerStopY; 65 | private RectF mRect = new RectF(); 66 | private RectF mRoundedCornerArc = new RectF(); 67 | private RectF mScallopCornerArc = new RectF(); 68 | private int mScallopHeight; 69 | private float mScallopPosition; 70 | private float mScallopPositionPercent; 71 | private int mBackgroundColor; 72 | private boolean mShowBorder; 73 | private int mBorderWidth; 74 | private int mBorderColor; 75 | private boolean mShowDivider; 76 | private int mScallopRadius; 77 | private int mDividerDashLength; 78 | private int mDividerDashGap; 79 | private int mDividerType; 80 | private int mDividerWidth; 81 | private int mDividerColor; 82 | private int mCornerType; 83 | private int mCornerRadius; 84 | private int mDividerPadding; 85 | private Bitmap mShadow; 86 | private final Paint mShadowPaint = new Paint(ANTI_ALIAS_FLAG); 87 | private int mShadowColor; 88 | private float mShadowBlurRadius = 0f; 89 | private Drawable mBackgroundBeforeDivider; 90 | private Drawable mBackgroundAfterDivider; 91 | 92 | public TicketView(Context context) { 93 | super(context); 94 | init(null); 95 | } 96 | 97 | public TicketView(Context context, AttributeSet attrs) { 98 | super(context, attrs); 99 | init(attrs); 100 | } 101 | 102 | public TicketView(Context context, AttributeSet attrs, int defStyleAttr) { 103 | super(context, attrs, defStyleAttr); 104 | init(attrs); 105 | } 106 | 107 | @Override 108 | protected void onDraw(Canvas canvas) { 109 | super.onDraw(canvas); 110 | if (mDirty) { 111 | doLayout(); 112 | } 113 | if (mShadowBlurRadius > 0f && !isInEditMode()) { 114 | canvas.drawBitmap(mShadow, 0f, mShadowBlurRadius / 2f, null); 115 | } 116 | canvas.drawPath(mPath, mBackgroundPaint); 117 | canvas.clipPath(mPath); 118 | if (mShowBorder) { 119 | canvas.drawPath(mPath, mBorderPaint); 120 | } 121 | if (mShowDivider) { 122 | canvas.drawLine(mDividerStartX, mDividerStartY, mDividerStopX, mDividerStopY, mDividerPaint); 123 | } 124 | if (mBackgroundAfterDivider != null) { 125 | setTicketBackgroundAfterDivider(canvas); 126 | } 127 | if (mBackgroundBeforeDivider != null) { 128 | setTicketBackgroundBeforeDivider(canvas); 129 | } 130 | } 131 | 132 | private void doLayout() { 133 | float offset; 134 | float left = getPaddingLeft() + mShadowBlurRadius; 135 | float right = getWidth() - getPaddingRight() - mShadowBlurRadius; 136 | float top = getPaddingTop() + (mShadowBlurRadius / 2); 137 | float bottom = getHeight() - getPaddingBottom() - mShadowBlurRadius - (mShadowBlurRadius / 2); 138 | mPath.reset(); 139 | 140 | if (mOrientation == Orientation.HORIZONTAL) { 141 | offset = ((top + bottom) / mScallopPosition) - mScallopRadius; 142 | 143 | if (mCornerType == CornerType.ROUNDED) { 144 | mPath.arcTo(getTopLeftCornerRoundedArc(top, left), 180.0f, 90.0f, false); 145 | mPath.lineTo(left + mCornerRadius, top); 146 | 147 | mPath.lineTo(right - mCornerRadius, top); 148 | mPath.arcTo(getTopRightCornerRoundedArc(top, right), -90.0f, 90.0f, false); 149 | 150 | } else if (mCornerType == CornerType.SCALLOP) { 151 | mPath.arcTo(getTopLeftCornerScallopArc(top, left), 90.0f, -90.0f, false); 152 | mPath.lineTo(left + mCornerRadius, top); 153 | 154 | mPath.lineTo(right - mCornerRadius, top); 155 | mPath.arcTo(getTopRightCornerScallopArc(top, right), 180.0f, -90.0f, false); 156 | 157 | } else { 158 | mPath.moveTo(left, top); 159 | mPath.lineTo(right, top); 160 | } 161 | 162 | mRect.set(right - mScallopRadius, top + offset, right + mScallopRadius, mScallopHeight + offset + top); 163 | mPath.arcTo(mRect, 270, -180.0f, false); 164 | 165 | if (mCornerType == CornerType.ROUNDED) { 166 | 167 | mPath.arcTo(getBottomRightCornerRoundedArc(bottom, right), 0.0f, 90.0f, false); 168 | mPath.lineTo(right - mCornerRadius, bottom); 169 | 170 | mPath.lineTo(left + mCornerRadius, bottom); 171 | mPath.arcTo(getBottomLeftCornerRoundedArc(left, bottom), 90.0f, 90.0f, false); 172 | 173 | } else if (mCornerType == CornerType.SCALLOP) { 174 | 175 | mPath.arcTo(getBottomRightCornerScallopArc(bottom, right), 270.0f, -90.0f, false); 176 | mPath.lineTo(right - mCornerRadius, bottom); 177 | 178 | mPath.lineTo(left + mCornerRadius, bottom); 179 | mPath.arcTo(getBottomLeftCornerScallopArc(left, bottom), 0.0f, -90.0f, false); 180 | 181 | } else { 182 | mPath.lineTo(right, bottom); 183 | mPath.lineTo(left, bottom); 184 | } 185 | 186 | mRect.set(left - mScallopRadius, top + offset, left + mScallopRadius, mScallopHeight + offset + top); 187 | mPath.arcTo(mRect, 90.0f, -180.0f, false); 188 | mPath.close(); 189 | 190 | } else { 191 | offset = (((right + left) / mScallopPosition) - mScallopRadius); 192 | 193 | if (mCornerType == CornerType.ROUNDED) { 194 | mPath.arcTo(getTopLeftCornerRoundedArc(top, left), 180.0f, 90.0f, false); 195 | mPath.lineTo(left + mCornerRadius, top); 196 | 197 | } else if (mCornerType == CornerType.SCALLOP) { 198 | 199 | mPath.arcTo(getTopLeftCornerScallopArc(top, left), 90.0f, -90.0f, false); 200 | mPath.lineTo(left + mCornerRadius, top); 201 | 202 | } else { 203 | mPath.moveTo(left, top); 204 | } 205 | 206 | mRect.set(left + offset, top - mScallopRadius, mScallopHeight + offset + left, top + mScallopRadius); 207 | mPath.arcTo(mRect, 180.0f, -180.0f, false); 208 | 209 | if (mCornerType == CornerType.ROUNDED) { 210 | 211 | mPath.lineTo(right - mCornerRadius, top); 212 | mPath.arcTo(getTopRightCornerRoundedArc(top, right), -90.0f, 90.0f, false); 213 | 214 | mPath.arcTo(getBottomRightCornerRoundedArc(bottom, right), 0.0f, 90.0f, false); 215 | mPath.lineTo(right - mCornerRadius, bottom); 216 | 217 | } else if (mCornerType == CornerType.SCALLOP) { 218 | 219 | mPath.lineTo(right - mCornerRadius, top); 220 | mPath.arcTo(getTopRightCornerScallopArc(top, right), 180.0f, -90.0f, false); 221 | 222 | mPath.arcTo(getBottomRightCornerScallopArc(bottom, right), 270.0f, -90.0f, false); 223 | mPath.lineTo(right - mCornerRadius, bottom); 224 | 225 | } else { 226 | mPath.lineTo(right, top); 227 | mPath.lineTo(right, bottom); 228 | } 229 | 230 | mRect.set(left + offset, bottom - mScallopRadius, mScallopHeight + offset + left, bottom + mScallopRadius); 231 | mPath.arcTo(mRect, 0.0f, -180.0f, false); 232 | 233 | if (mCornerType == CornerType.ROUNDED) { 234 | 235 | mPath.arcTo(getBottomLeftCornerRoundedArc(left, bottom), 90.0f, 90.0f, false); 236 | mPath.lineTo(left, bottom - mCornerRadius); 237 | 238 | } else if (mCornerType == CornerType.SCALLOP) { 239 | 240 | mPath.arcTo(getBottomLeftCornerScallopArc(left, bottom), 0.0f, -90.0f, false); 241 | mPath.lineTo(left, bottom - mCornerRadius); 242 | 243 | } else { 244 | mPath.lineTo(left, bottom); 245 | } 246 | mPath.close(); 247 | } 248 | 249 | // divider 250 | if (mOrientation == Orientation.HORIZONTAL) { 251 | mDividerStartX = left + mScallopRadius + mDividerPadding; 252 | mDividerStartY = mScallopRadius + top + offset; 253 | mDividerStopX = right - mScallopRadius - mDividerPadding; 254 | mDividerStopY = mScallopRadius + top + offset; 255 | } else { 256 | mDividerStartX = mScallopRadius + left + offset; 257 | mDividerStartY = top + mScallopRadius + mDividerPadding; 258 | mDividerStopX = mScallopRadius + left + offset; 259 | mDividerStopY = bottom - mScallopRadius - mDividerPadding; 260 | } 261 | 262 | generateShadow(); 263 | mDirty = false; 264 | } 265 | 266 | private void generateShadow() { 267 | if (Utils.isJellyBeanAndAbove() && !isInEditMode()) { 268 | if (mShadowBlurRadius == 0f) return; 269 | 270 | if (mShadow == null) { 271 | mShadow = Bitmap.createBitmap(getWidth(), getHeight(), ARGB_8888); 272 | } else { 273 | mShadow.eraseColor(TRANSPARENT); 274 | } 275 | 276 | Canvas canvas = new Canvas(mShadow); 277 | canvas.drawPath(mPath, mShadowPaint); 278 | if (mShowBorder) { 279 | canvas.drawPath(mPath, mShadowPaint); 280 | } 281 | 282 | mShadow = BlurBuilder.blur(getContext(), mShadow, mShadowBlurRadius); 283 | } 284 | } 285 | 286 | private void init(AttributeSet attrs) { 287 | if (attrs != null) { 288 | TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.TicketView); 289 | mBackgroundBeforeDivider = typedArray.getDrawable(R.styleable.TicketView_ticketBackgroundBeforeDivider); 290 | mBackgroundAfterDivider = typedArray.getDrawable(R.styleable.TicketView_ticketBackgroundAfterDivider); 291 | mOrientation = typedArray.getInt(R.styleable.TicketView_ticketOrientation, Orientation.HORIZONTAL); 292 | mBackgroundColor = typedArray.getColor(R.styleable.TicketView_ticketBackgroundColor, getResources().getColor(android.R.color.white)); 293 | mScallopRadius = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketScallopRadius, Utils.dpToPx(20f, getContext())); 294 | mScallopPositionPercent = typedArray.getFloat(R.styleable.TicketView_ticketScallopPositionPercent, 50); 295 | mShowBorder = typedArray.getBoolean(R.styleable.TicketView_ticketShowBorder, false); 296 | mBorderWidth = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketBorderWidth, Utils.dpToPx(2f, getContext())); 297 | mBorderColor = typedArray.getColor(R.styleable.TicketView_ticketBorderColor, getResources().getColor(android.R.color.black)); 298 | mShowDivider = typedArray.getBoolean(R.styleable.TicketView_ticketShowDivider, false); 299 | mDividerType = typedArray.getInt(R.styleable.TicketView_ticketDividerType, DividerType.NORMAL); 300 | mDividerWidth = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerWidth, Utils.dpToPx(2f, getContext())); 301 | mDividerColor = typedArray.getColor(R.styleable.TicketView_ticketDividerColor, getResources().getColor(android.R.color.darker_gray)); 302 | mDividerDashLength = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerDashLength, Utils.dpToPx(8f, getContext())); 303 | mDividerDashGap = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerDashGap, Utils.dpToPx(4f, getContext())); 304 | mCornerType = typedArray.getInt(R.styleable.TicketView_ticketCornerType, CornerType.NORMAL); 305 | mCornerRadius = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketCornerRadius, Utils.dpToPx(4f, getContext())); 306 | mDividerPadding = typedArray.getDimensionPixelSize(R.styleable.TicketView_ticketDividerPadding, Utils.dpToPx(10f, getContext())); 307 | float elevation = 0f; 308 | if (typedArray.hasValue(R.styleable.TicketView_ticketElevation)) { 309 | elevation = typedArray.getDimension(R.styleable.TicketView_ticketElevation, elevation); 310 | } else if (typedArray.hasValue(R.styleable.TicketView_android_elevation)) { 311 | elevation = typedArray.getDimension(R.styleable.TicketView_android_elevation, elevation); 312 | } 313 | if (elevation > 0f) { 314 | setShadowBlurRadius(elevation); 315 | } 316 | mShadowColor = typedArray.getColor(R.styleable.TicketView_ticketShadowColor, getResources().getColor(android.R.color.black)); 317 | 318 | typedArray.recycle(); 319 | } 320 | 321 | initElements(); 322 | 323 | setLayerType(View.LAYER_TYPE_SOFTWARE, null); 324 | } 325 | 326 | private void initElements() { 327 | 328 | if (mDividerWidth > mScallopRadius) { 329 | mDividerWidth = mScallopRadius; 330 | Log.w(TAG, "You cannot apply divider width greater than scallop radius. Applying divider width to scallop radius."); 331 | } 332 | 333 | mScallopPosition = 100 / mScallopPositionPercent; 334 | mScallopHeight = mScallopRadius * 2; 335 | 336 | setShadowPaint(); 337 | setBackgroundPaint(); 338 | setBorderPaint(); 339 | setDividerPaint(); 340 | 341 | mDirty = true; 342 | invalidate(); 343 | } 344 | 345 | private void setTicketBackgroundBeforeDivider(Canvas canvas) { 346 | //getting the bound of view for setting background 347 | float left = getPaddingLeft() + mShadowBlurRadius; 348 | float right = getWidth() - getPaddingRight() - mShadowBlurRadius; 349 | float top = getPaddingTop() + (mShadowBlurRadius / 2); 350 | float bottom = getHeight() - getPaddingBottom() - mShadowBlurRadius - (mShadowBlurRadius / 2); 351 | if (mOrientation == Orientation.HORIZONTAL) { 352 | mBackgroundBeforeDivider.setBounds((int) left, (int) top, (int) right, (int) mDividerStartY); 353 | } else { 354 | mBackgroundBeforeDivider.setBounds((int) left, (int) top, (int) mDividerStartX, (int) bottom); 355 | } 356 | mBackgroundBeforeDivider.draw(canvas); 357 | } 358 | 359 | private void setTicketBackgroundAfterDivider(Canvas canvas) { 360 | //getting the bound of view for setting background 361 | float left = getPaddingLeft() + mShadowBlurRadius; 362 | float right = getWidth() - getPaddingRight() - mShadowBlurRadius; 363 | float top = getPaddingTop() + (mShadowBlurRadius / 2); 364 | float bottom = getHeight() - getPaddingBottom() - mShadowBlurRadius - (mShadowBlurRadius / 2); 365 | if (mOrientation == Orientation.HORIZONTAL) { 366 | mBackgroundAfterDivider.setBounds((int) left, (int) mDividerStopY, (int) right, (int) bottom); 367 | } else { 368 | mBackgroundAfterDivider.setBounds((int) mDividerStopX, (int) top, (int) right, (int) bottom); 369 | } 370 | mBackgroundAfterDivider.draw(canvas); 371 | } 372 | 373 | private void setShadowPaint() { 374 | mShadowPaint.setColorFilter(new PorterDuffColorFilter(mShadowColor, SRC_IN)); 375 | mShadowPaint.setAlpha(51); // 20% 376 | } 377 | 378 | private void setBackgroundPaint() { 379 | mBackgroundPaint.setAlpha(0); 380 | mBackgroundPaint.setAntiAlias(true); 381 | mBackgroundPaint.setColor(mBackgroundColor); 382 | mBackgroundPaint.setStyle(Paint.Style.FILL); 383 | } 384 | 385 | private void setBorderPaint() { 386 | mBorderPaint.setAlpha(0); 387 | mBorderPaint.setAntiAlias(true); 388 | mBorderPaint.setColor(mBorderColor); 389 | mBorderPaint.setStrokeWidth(mBorderWidth); 390 | mBorderPaint.setStyle(Paint.Style.STROKE); 391 | } 392 | 393 | private void setDividerPaint() { 394 | mDividerPaint.setAlpha(0); 395 | mDividerPaint.setAntiAlias(true); 396 | mDividerPaint.setColor(mDividerColor); 397 | mDividerPaint.setStrokeWidth(mDividerWidth); 398 | 399 | if (mDividerType == DividerType.DASH) 400 | mDividerPaint.setPathEffect(new DashPathEffect(new float[]{(float) mDividerDashLength, (float) mDividerDashGap}, 0.0f)); 401 | else 402 | mDividerPaint.setPathEffect(new PathEffect()); 403 | } 404 | 405 | private RectF getTopLeftCornerRoundedArc(float top, float left) { 406 | mRoundedCornerArc.set(left, top, left + mCornerRadius * 2, top + mCornerRadius * 2); 407 | return mRoundedCornerArc; 408 | } 409 | 410 | private RectF getTopRightCornerRoundedArc(float top, float right) { 411 | mRoundedCornerArc.set(right - mCornerRadius * 2, top, right, top + mCornerRadius * 2); 412 | return mRoundedCornerArc; 413 | } 414 | 415 | private RectF getBottomLeftCornerRoundedArc(float left, float bottom) { 416 | mRoundedCornerArc.set(left, bottom - mCornerRadius * 2, left + mCornerRadius * 2, bottom); 417 | return mRoundedCornerArc; 418 | } 419 | 420 | private RectF getBottomRightCornerRoundedArc(float bottom, float right) { 421 | mRoundedCornerArc.set(right - mCornerRadius * 2, bottom - mCornerRadius * 2, right, bottom); 422 | return mRoundedCornerArc; 423 | } 424 | 425 | private RectF getTopLeftCornerScallopArc(float top, float left) { 426 | mScallopCornerArc.set(left - mCornerRadius, top - mCornerRadius, left + mCornerRadius, top + mCornerRadius); 427 | return mScallopCornerArc; 428 | } 429 | 430 | private RectF getTopRightCornerScallopArc(float top, float right) { 431 | mScallopCornerArc.set(right - mCornerRadius, top - mCornerRadius, right + mCornerRadius, top + mCornerRadius); 432 | return mScallopCornerArc; 433 | } 434 | 435 | private RectF getBottomLeftCornerScallopArc(float left, float bottom) { 436 | mScallopCornerArc.set(left - mCornerRadius, bottom - mCornerRadius, left + mCornerRadius, bottom + mCornerRadius); 437 | return mScallopCornerArc; 438 | } 439 | 440 | private RectF getBottomRightCornerScallopArc(float bottom, float right) { 441 | mScallopCornerArc.set(right - mCornerRadius, bottom - mCornerRadius, right + mCornerRadius, bottom + mCornerRadius); 442 | return mScallopCornerArc; 443 | } 444 | 445 | public int getOrientation() { 446 | return mOrientation; 447 | } 448 | 449 | public void setOrientation(int orientation) { 450 | this.mOrientation = orientation; 451 | initElements(); 452 | } 453 | 454 | public float getScallopPositionPercent() { 455 | return mScallopPositionPercent; 456 | } 457 | 458 | public void setScallopPositionPercent(float scallopPositionPercent) { 459 | this.mScallopPositionPercent = scallopPositionPercent; 460 | initElements(); 461 | } 462 | 463 | public int getBackgroundColor() { 464 | return mBackgroundColor; 465 | } 466 | 467 | public void setBackgroundColor(int backgroundColor) { 468 | this.mBackgroundColor = backgroundColor; 469 | initElements(); 470 | } 471 | 472 | public boolean isShowBorder() { 473 | return mShowBorder; 474 | } 475 | 476 | public void setShowBorder(boolean showBorder) { 477 | this.mShowBorder = showBorder; 478 | initElements(); 479 | } 480 | 481 | public int getBorderWidth() { 482 | return mBorderWidth; 483 | } 484 | 485 | public void setBorderWidth(int borderWidth) { 486 | this.mBorderWidth = borderWidth; 487 | initElements(); 488 | } 489 | 490 | public int getBorderColor() { 491 | return mBorderColor; 492 | } 493 | 494 | public void setBorderColor(int borderColor) { 495 | this.mBorderColor = borderColor; 496 | initElements(); 497 | } 498 | 499 | public boolean isShowDivider() { 500 | return mShowDivider; 501 | } 502 | 503 | public void setShowDivider(boolean showDivider) { 504 | this.mShowDivider = showDivider; 505 | initElements(); 506 | } 507 | 508 | public int getScallopRadius() { 509 | return mScallopRadius; 510 | } 511 | 512 | public void setScallopRadius(int scallopRadius) { 513 | this.mScallopRadius = scallopRadius; 514 | initElements(); 515 | } 516 | 517 | public int getDividerDashLength() { 518 | return mDividerDashLength; 519 | } 520 | 521 | public void setDividerDashLength(int dividerDashLength) { 522 | this.mDividerDashLength = dividerDashLength; 523 | initElements(); 524 | } 525 | 526 | public int getDividerDashGap() { 527 | return mDividerDashGap; 528 | } 529 | 530 | public void setDividerDashGap(int dividerDashGap) { 531 | this.mDividerDashGap = dividerDashGap; 532 | initElements(); 533 | } 534 | 535 | public int getDividerType() { 536 | return mDividerType; 537 | } 538 | 539 | public void setDividerType(int dividerType) { 540 | this.mDividerType = dividerType; 541 | initElements(); 542 | } 543 | 544 | public int getDividerWidth() { 545 | return mDividerWidth; 546 | } 547 | 548 | public void setDividerWidth(int dividerWidth) { 549 | this.mDividerWidth = dividerWidth; 550 | initElements(); 551 | } 552 | 553 | public int getDividerPadding() { 554 | return mDividerPadding; 555 | } 556 | 557 | public void setDividerPadding(int mDividerPadding) { 558 | this.mDividerPadding = mDividerPadding; 559 | initElements(); 560 | } 561 | 562 | public int getDividerColor() { 563 | return mDividerColor; 564 | } 565 | 566 | public void setDividerColor(int dividerColor) { 567 | this.mDividerColor = dividerColor; 568 | initElements(); 569 | } 570 | 571 | public int getCornerType() { 572 | return mCornerType; 573 | } 574 | 575 | public void setCornerType(int cornerType) { 576 | this.mCornerType = cornerType; 577 | initElements(); 578 | } 579 | 580 | public int getCornerRadius() { 581 | return mCornerRadius; 582 | } 583 | 584 | public void setCornerRadius(int cornerRadius) { 585 | this.mCornerRadius = cornerRadius; 586 | initElements(); 587 | } 588 | 589 | public void setTicketElevation(float elevation) { 590 | if (!Utils.isJellyBeanAndAbove()) { 591 | Log.w(TAG, "Ticket elevation only works with Android Jelly Bean and above"); 592 | return; 593 | } 594 | setShadowBlurRadius(elevation); 595 | initElements(); 596 | } 597 | 598 | private void setShadowBlurRadius(float elevation) { 599 | if (!Utils.isJellyBeanAndAbove()) { 600 | Log.w(TAG, "Ticket elevation only works with Android Jelly Bean and above"); 601 | return; 602 | } 603 | float maxElevation = Utils.dpToPx(24f, getContext()); 604 | mShadowBlurRadius = Math.min(25f * (elevation / maxElevation), 25f); 605 | } 606 | 607 | public int getShadowColor() { 608 | return mShadowColor; 609 | } 610 | 611 | public void setShadowColor(int color) { 612 | this.mShadowColor = color; 613 | initElements(); 614 | } 615 | 616 | public Drawable getBackgroundBeforeDivider() { 617 | return mBackgroundBeforeDivider; 618 | } 619 | 620 | public void setBackgroundBeforeDivider(Drawable background) { 621 | this.mBackgroundBeforeDivider = background; 622 | initElements(); 623 | } 624 | 625 | public Drawable getBackgroundAfterDivider() { 626 | return mBackgroundAfterDivider; 627 | } 628 | 629 | public void setBackgroundAfterDivider(Drawable background) { 630 | this.mBackgroundAfterDivider = background; 631 | initElements(); 632 | } 633 | } 634 | --------------------------------------------------------------------------------