├── .gitignore ├── .idea ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── README.md ├── Screenshot ├── barney_squint.png ├── list_squint.png └── screenshot.png ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── intrusoft │ │ └── diagonalApp │ │ └── ExampleInstrumentedTest.java │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── intrusoft │ │ │ └── diagonalApp │ │ │ └── MainActivity.java │ └── res │ │ ├── drawable │ │ ├── barney.jpg │ │ ├── barney_squint.png │ │ ├── c1.jpg │ │ ├── c2.jpg │ │ ├── c3.jpg │ │ └── ic_menu.xml │ │ ├── layout │ │ ├── activity_main.xml │ │ └── demo_2.xml │ │ ├── mipmap-hdpi │ │ └── ic_launcher.png │ │ ├── mipmap-mdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxhdpi │ │ └── ic_launcher.png │ │ ├── mipmap-xxxhdpi │ │ └── ic_launcher.png │ │ ├── values-w820dp │ │ └── dimens.xml │ │ └── values │ │ ├── colors.xml │ │ ├── dimens.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── intrusoft │ └── diagonalApp │ └── ExampleUnitTest.java ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle └── squint ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src ├── androidTest └── java │ └── com │ └── intrusoft │ └── squint │ └── ExampleInstrumentedTest.java ├── main ├── AndroidManifest.xml ├── java │ └── com │ │ └── intrusoft │ │ └── squint │ │ ├── DiagonalView.java │ │ ├── PathHelper.java │ │ └── Squint.java └── res │ └── values │ ├── attrs.xml │ └── strings.xml └── test └── java └── com └── intrusoft └── squint └── ExampleUnitTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Squint 2 | Provide Diagonal cut on view with awesome customization #DiagonalView 3 | 4 | [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Squint%20--%20A%20Diagonal%20Cut-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/4458) [![API](https://img.shields.io/badge/API-9%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=9) [![](https://jitpack.io/v/IntruderShanky/Squint.svg)](https://jitpack.io/#IntruderShanky/Squint) 5 | 6 | Buy Me a Coffee at ko-fi.com 7 | 8 | [Demo App - IS Library](https://play.google.com/store/apps/details?id=com.intrusoft.islibrarydemo) 9 | 10 | Get it on Google Play 11 | 12 | # Preview 13 | ![Screenshot](Screenshot/barney_squint.png) 14 | 15 | * Provide Diagonal anywhere we want 16 | * Provide Tint filter on image 17 | * Provide Solid color shape 18 | * Fully Customizable 19 | 20 | # Usage 21 | Step 1. Add the JitPack repository to your build file 22 | ```groovy 23 | allprojects { 24 | repositories { 25 | ... 26 | maven { url "https://jitpack.io" } 27 | } 28 | } 29 | ``` 30 | Step 2. Add the dependency 31 | ```groovy 32 | dependencies { 33 | compile 'com.github.IntruderShanky:Squint:3.0.1' 34 | } 35 | ``` 36 | 37 | ![Screenshot](Screenshot/list_squint.png) 38 | 39 | # Implementation 40 | ###XML Implementation: 41 | ```xml 42 | 51 | ``` 52 | ###Attributes 53 | ####Diagonal Angle 54 | ```xml 55 | squint:angle 56 | ``` 57 | ####Diagonal Gravity 58 | ```xml 59 | squint:gravity="left" 60 | squint:gravity="right" 61 | squint:gravity="top" 62 | squint:gravity="bottom" 63 | ``` 64 | ####Diagonal Direction 65 | ```xml 66 | squint:diagonalDirection="left_to_right" 67 | squint:diagonalDirection="top_to_bottom" 68 | squint:diagonalDirection="right_to_left" 69 | squint:diagonalDirection="bottom_to_top" 70 | ``` 71 | ####Background Tint Color (Color Shold have some alpha value, default value 55) 72 | ```xml 73 | squint:tint="@color/your_color" 74 | ``` 75 | ####To make solid color Diagonal 76 | ```xml 77 | squint:solidColor="@color/your_color" 78 | ``` 79 | 80 | ###Java Implementation: 81 | ```java 82 | DiagonalView diagonalView = (DiagonalView) findViewById(R.id.diagonal); 83 | 84 | // to set image from resources 85 | diagonalView.setImageSource(R.drawable.your_image); 86 | 87 | // to set bitmap 88 | diagonalView.setBitmap(bitmap); 89 | 90 | // to set the diagonal angle 91 | diagonalView.setAngle(15); 92 | 93 | // to set the diagonal gravity 94 | diagonalView.setGravity(DiagonalView.Gravity.LEFT); 95 | 96 | // to set the background color (color should have some alpha val) 97 | diagonalView.setColorTint(Color.GREEN); 98 | 99 | // to make the solid color diagonal 100 | diagonalView.setSolidColor(Color.BLUE); 101 | ``` 102 | #Licence 103 | ``` 104 | Licensed under the Apache License, Version 2.0 (the "License"); 105 | you may not use this file except in compliance with the License. 106 | You may obtain a copy of the License at 107 | 108 | http://www.apache.org/licenses/LICENSE-2.0 109 | 110 | Unless required by applicable law or agreed to in writing, software 111 | distributed under the License is distributed on an "AS IS" BASIS, 112 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 113 | See the License for the specific language governing permissions and 114 | limitations under the License. 115 | ``` 116 | -------------------------------------------------------------------------------- /Screenshot/barney_squint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/Screenshot/barney_squint.png -------------------------------------------------------------------------------- /Screenshot/list_squint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/Screenshot/list_squint.png -------------------------------------------------------------------------------- /Screenshot/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/Screenshot/screenshot.png -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 25 5 | buildToolsVersion "24.0.3" 6 | defaultConfig { 7 | applicationId "com.intrusoft.diagonalview" 8 | minSdkVersion 9 9 | targetSdkVersion 25 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 25 | exclude group: 'com.android.support', module: 'support-annotations' 26 | }) 27 | compile 'com.android.support:appcompat-v7:25.0.1' 28 | testCompile 'junit:junit:4.12' 29 | compile project(':squint') 30 | //0 31 | // compile 'com.github.IntruderShanky:Squint:3.0.0' 32 | compile 'com.android.support:cardview-v7:25.0.1' 33 | compile 'com.android.support:design:25.0.1' 34 | } 35 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/apple/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/intrusoft/diagonalApp/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.diagonalApp; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation 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.intrusoft.diagonalview", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /app/src/main/java/com/intrusoft/diagonalApp/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.diagonalApp; 2 | 3 | import android.support.v7.app.AppCompatActivity; 4 | import android.os.Bundle; 5 | import android.widget.ImageView; 6 | 7 | import com.intrusoft.squint.DiagonalView; 8 | import com.intrusoft.squint.Squint; 9 | 10 | public class MainActivity extends AppCompatActivity { 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_main); 16 | DiagonalView diagonalView = (DiagonalView) findViewById(R.id.diagonal); 17 | // diagonalView.setImageResource(R.drawable.barney_squint); 18 | // diagonalView.setDiagonalDirection(Squint.Direction.LEFT_TO_RIGHT); 19 | // diagonalView.setDiagonalGravity(Squint.Gravity.TOP); 20 | diagonalView.setScaleType(ImageView.ScaleType.FIT_XY); 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/barney.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/drawable/barney.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/barney_squint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/drawable/barney_squint.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/c1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/drawable/c1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/c2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/drawable/c2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/c3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/drawable/c3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_menu.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 21 | 22 | 34 | 35 | 47 | 48 | 58 | 59 | -------------------------------------------------------------------------------- /app/src/main/res/layout/demo_2.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 13 | 14 | 20 | 21 | 22 | 28 | 29 | 33 | 34 | 38 | 39 | 43 | 44 | 45 | 46 | 52 | 53 | 57 | 58 | 68 | 69 | 74 | 75 | 81 | 82 | 89 | 90 | 95 | 96 | 103 | 104 | 105 | 106 | 107 | 108 | 114 | 115 | 119 | 120 | 129 | 130 | 135 | 136 | 142 | 143 | 150 | 151 | 156 | 157 | 164 | 165 | 166 | 167 | 168 | 169 | 175 | 176 | 180 | 181 | 190 | 191 | 196 | 197 | 203 | 204 | 211 | 212 | 217 | 218 | 225 | 226 | 227 | 228 | 229 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #7CB32F 4 | #7CB32F 5 | #ffffff 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | DiagonalView 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/intrusoft/diagonalApp/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.diagonalApp; 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 | } -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.2' 9 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' 10 | 11 | // NOTE: Do not place your application dependencies here; they belong 12 | // in the individual module build.gradle files 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | jcenter() 19 | maven{url "https://jitpack.io"} 20 | } 21 | } 22 | 23 | task clean(type: Delete) { 24 | delete rootProject.buildDir 25 | } 26 | -------------------------------------------------------------------------------- /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 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IntruderShanky/Squint/2cd82f36fb62a152ade5369eda46e17d4e140ce0/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 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-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':squint' 2 | -------------------------------------------------------------------------------- /squint/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /squint/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | apply plugin: 'com.github.dcendents.android-maven' 3 | 4 | group='com.github.intrudershanky' 5 | 6 | android { 7 | compileSdkVersion 24 8 | buildToolsVersion "24.0.2" 9 | 10 | defaultConfig { 11 | minSdkVersion 9 12 | targetSdkVersion 24 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 17 | 18 | } 19 | buildTypes { 20 | release { 21 | minifyEnabled false 22 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 23 | } 24 | } 25 | } 26 | 27 | dependencies { 28 | compile fileTree(dir: 'libs', include: ['*.jar']) 29 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 30 | exclude group: 'com.android.support', module: 'support-annotations' 31 | }) 32 | compile 'com.android.support:appcompat-v7:24.2.1' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /squint/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/apple/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /squint/src/androidTest/java/com/intrusoft/squint/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.squint; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation 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.intrusoft.squint.test", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /squint/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /squint/src/main/java/com/intrusoft/squint/DiagonalView.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.squint; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.graphics.Bitmap; 6 | import android.graphics.BitmapShader; 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.ColorFilter; 10 | import android.graphics.Matrix; 11 | import android.graphics.Paint; 12 | import android.graphics.Path; 13 | import android.graphics.Shader; 14 | import android.graphics.drawable.BitmapDrawable; 15 | import android.graphics.drawable.ColorDrawable; 16 | import android.graphics.drawable.Drawable; 17 | import android.net.Uri; 18 | import android.util.AttributeSet; 19 | import android.widget.ImageView; 20 | 21 | import com.intrusoft.squint.Squint.Direction; 22 | import com.intrusoft.squint.Squint.Gravity; 23 | 24 | import static android.graphics.Paint.ANTI_ALIAS_FLAG; 25 | import static com.intrusoft.squint.Squint.DIRECTIONS; 26 | import static com.intrusoft.squint.Squint.GRAVITIES; 27 | 28 | public class DiagonalView extends ImageView { 29 | 30 | private final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888; 31 | private final Paint fillPaint = new Paint(ANTI_ALIAS_FLAG); 32 | private final Paint tintPaint = new Paint(ANTI_ALIAS_FLAG); 33 | private final Paint bitmapPaint = new Paint(ANTI_ALIAS_FLAG); 34 | private final Paint solidPaint = new Paint(ANTI_ALIAS_FLAG); 35 | private final Matrix shaderMatrix = new Matrix(); 36 | private final int DEFAULT_ALPHA = 50; 37 | private static int tintColor = Color.TRANSPARENT; 38 | private static int fillColor = Color.TRANSPARENT; 39 | private static int solidColor = Color.TRANSPARENT; 40 | private float width; 41 | private float height; 42 | private int angle = 10; 43 | private Gravity gravity = Gravity.BOTTOM; 44 | private Direction direction = Direction.LEFT_TO_RIGHT; 45 | private Bitmap bitmap; 46 | private BitmapShader bitmapShader; 47 | private ColorFilter colorFilter; 48 | 49 | 50 | public DiagonalView(Context context) { 51 | super(context); 52 | init(context, null, 0); 53 | } 54 | 55 | public DiagonalView(Context context, AttributeSet attrs) { 56 | super(context, attrs); 57 | init(context, attrs, 0); 58 | } 59 | 60 | public DiagonalView(Context context, AttributeSet attrs, int defStyleAttr) { 61 | super(context, attrs, defStyleAttr); 62 | init(context, attrs, defStyleAttr); 63 | } 64 | 65 | 66 | private void init(Context context, AttributeSet attributeSet, int defStyleAttr) { 67 | if (attributeSet != null) { 68 | TypedArray array = context.obtainStyledAttributes(attributeSet, R.styleable.DiagonalView, defStyleAttr, 0); 69 | angle = array.getInt(R.styleable.DiagonalView_angle, angle); 70 | gravity = GRAVITIES[array.getInt(R.styleable.DiagonalView_gravity, 3)]; 71 | tintColor = array.getColor(R.styleable.DiagonalView_tint, Color.TRANSPARENT); 72 | fillColor = array.getColor(R.styleable.DiagonalView_fillColor, Color.TRANSPARENT); 73 | solidColor = array.getColor(R.styleable.DiagonalView_solidColor, Color.TRANSPARENT); 74 | direction = DIRECTIONS[array.getInt(R.styleable.DiagonalView_diagonalDirection, 0)]; 75 | array.recycle(); 76 | } 77 | fillPaint.setStyle(Paint.Style.FILL); 78 | fillPaint.setColor(fillColor); 79 | tintPaint.setStyle(Paint.Style.FILL); 80 | tintPaint.setColor(tintColor); 81 | solidPaint.setStyle(Paint.Style.FILL); 82 | solidPaint.setColor(solidColor); 83 | solidPaint.setAlpha(255); 84 | if (tintPaint.getAlpha() == 255) 85 | tintPaint.setAlpha(DEFAULT_ALPHA); 86 | } 87 | 88 | @Override 89 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 90 | super.onMeasure(widthMeasureSpec, heightMeasureSpec); 91 | initializeBitmap(); 92 | } 93 | 94 | @Override 95 | public void draw(Canvas canvas) { 96 | Path path = PathHelper.getPathFor(getWidth(), getHeight(), angle, direction, gravity); 97 | if (bitmap != null) { 98 | if (fillColor != Color.TRANSPARENT) 99 | canvas.drawPath(path, fillPaint); 100 | canvas.drawPath(path, bitmapPaint); 101 | if (tintColor != Color.TRANSPARENT) 102 | canvas.drawPath(path, tintPaint); 103 | } 104 | if (solidColor != Color.TRANSPARENT) 105 | canvas.drawPath(path, solidPaint); 106 | } 107 | 108 | private void initializeBitmap() { 109 | width = getMeasuredWidth(); 110 | height = getMeasuredHeight(); 111 | Drawable drawable = getDrawable(); 112 | if (drawable != null) { 113 | if (drawable instanceof BitmapDrawable) 114 | bitmap = ((BitmapDrawable) drawable).getBitmap(); 115 | else { 116 | try { 117 | int COLOR_DRAWABLE_DIMENSIONS = 2; 118 | if (drawable instanceof ColorDrawable) 119 | bitmap = Bitmap.createBitmap(COLOR_DRAWABLE_DIMENSIONS, COLOR_DRAWABLE_DIMENSIONS, BITMAP_CONFIG); 120 | else 121 | bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG); 122 | 123 | Canvas canvas = new Canvas(bitmap); 124 | drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 125 | drawable.draw(canvas); 126 | } catch (Exception e) { 127 | e.printStackTrace(); 128 | } 129 | } 130 | if (bitmap == null) { 131 | invalidate(); 132 | return; 133 | } 134 | if (bitmapPaint != null) { 135 | bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP); 136 | bitmapPaint.setShader(bitmapShader); 137 | } 138 | if (this.getScaleType() != ScaleType.CENTER_CROP && this.getScaleType() != ScaleType.FIT_XY) 139 | this.setScaleType(ScaleType.CENTER_CROP); 140 | setUpScaleType(); 141 | applyColorFilter(); 142 | invalidate(); 143 | } 144 | } 145 | 146 | private void applyColorFilter() { 147 | if (bitmapPaint != null) { 148 | bitmapPaint.setColorFilter(colorFilter); 149 | } 150 | } 151 | 152 | private void setUpScaleType() { 153 | float scaleX = 1, scaleY = 1, dx = 0, dy = 0; 154 | if (bitmap == null || shaderMatrix == null) 155 | return; 156 | shaderMatrix.set(null); 157 | if (getScaleType() == ScaleType.CENTER_CROP) { 158 | if (width != bitmap.getWidth()) { 159 | scaleX = width / bitmap.getWidth(); 160 | } 161 | if (scaleX * bitmap.getHeight() < height) { 162 | scaleX = height / bitmap.getHeight(); 163 | } 164 | dy = (height - bitmap.getHeight() * scaleX) * 0.5f; 165 | dx = (width - bitmap.getWidth() * scaleX) * 0.5f; 166 | shaderMatrix.setScale(scaleX, scaleX); 167 | } else { 168 | scaleX = width / bitmap.getWidth(); 169 | scaleY = height / bitmap.getHeight(); 170 | dy = (height - bitmap.getHeight() * scaleY) * 0.5f; 171 | dx = (width - bitmap.getWidth() * scaleX) * 0.5f; 172 | shaderMatrix.setScale(scaleX, scaleY); 173 | } 174 | shaderMatrix.postTranslate(dx + 0.5f, dy + 0.5f); 175 | bitmapShader.setLocalMatrix(shaderMatrix); 176 | } 177 | 178 | @Override 179 | public void setColorFilter(ColorFilter colorFilter) { 180 | if (colorFilter == this.colorFilter) { 181 | return; 182 | } 183 | this.colorFilter = colorFilter; 184 | applyColorFilter(); 185 | invalidate(); 186 | } 187 | 188 | @Override 189 | public ColorFilter getColorFilter() { 190 | return colorFilter; 191 | } 192 | 193 | @Override 194 | public void setScaleType(ScaleType scaleType) { 195 | if (scaleType == ScaleType.CENTER_CROP || scaleType == ScaleType.FIT_XY) 196 | super.setScaleType(scaleType); 197 | else 198 | throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType)); 199 | } 200 | 201 | @Override 202 | public void setAdjustViewBounds(boolean adjustViewBounds) { 203 | if (adjustViewBounds) { 204 | throw new IllegalArgumentException("adjustViewBounds not supported."); 205 | } 206 | } 207 | 208 | @Override 209 | public void setImageResource(int resId) { 210 | super.setImageResource(resId); 211 | initializeBitmap(); 212 | } 213 | 214 | @Override 215 | public void setImageURI(Uri uri) { 216 | super.setImageURI(uri); 217 | initializeBitmap(); 218 | } 219 | 220 | @Override 221 | public void setImageDrawable(Drawable drawable) { 222 | super.setImageDrawable(drawable); 223 | initializeBitmap(); 224 | } 225 | 226 | @Override 227 | public void setImageBitmap(Bitmap bm) { 228 | super.setImageBitmap(bm); 229 | initializeBitmap(); 230 | } 231 | 232 | public int getTintColor() { 233 | return tintColor; 234 | } 235 | 236 | public void setTintColor(int tintColor) { 237 | DiagonalView.tintColor = tintColor; 238 | tintPaint.setColor(tintColor); 239 | if (tintPaint.getAlpha() == 255) 240 | tintPaint.setAlpha(DEFAULT_ALPHA); 241 | invalidate(); 242 | } 243 | 244 | public int getFillColor() { 245 | return fillColor; 246 | } 247 | 248 | public void setFillColor(int fillColor) { 249 | DiagonalView.fillColor = fillColor; 250 | fillPaint.setColor(fillColor); 251 | invalidate(); 252 | } 253 | 254 | public int getSolidColor() { 255 | return solidColor; 256 | } 257 | 258 | public void setSolidColor(int solidColor) { 259 | DiagonalView.solidColor = solidColor; 260 | solidPaint.setColor(solidColor); 261 | solidPaint.setAlpha(255); 262 | invalidate(); 263 | } 264 | 265 | public void setDiagonalGravity(Gravity gravity) { 266 | this.gravity = gravity; 267 | invalidate(); 268 | } 269 | 270 | public void setDiagonalDirection(Direction direction) { 271 | this.direction = direction; 272 | invalidate(); 273 | } 274 | 275 | public void setAngle(int angle) { 276 | this.angle = angle; 277 | invalidate(); 278 | } 279 | 280 | public void setBitmap(Bitmap bitmap) { 281 | this.bitmap = bitmap; 282 | invalidate(); 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /squint/src/main/java/com/intrusoft/squint/PathHelper.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.squint; 2 | 3 | import android.graphics.Path; 4 | 5 | import com.intrusoft.squint.Squint.Direction; 6 | import com.intrusoft.squint.Squint.Gravity; 7 | 8 | import static com.intrusoft.squint.Squint.Gravity.BOTTOM; 9 | import static com.intrusoft.squint.Squint.Gravity.LEFT; 10 | import static com.intrusoft.squint.Squint.Gravity.RIGHT; 11 | import static com.intrusoft.squint.Squint.Gravity.TOP; 12 | 13 | public class PathHelper { 14 | 15 | public static Path getPathFor(float width, float height, double angle, Direction direction, Gravity gravity) { 16 | switch (direction) { 17 | case LEFT_TO_RIGHT: 18 | return leftToRight(width, height, angle, gravity); 19 | case RIGHT_TO_LEFT: 20 | return rightToLeft(width, height, angle, gravity); 21 | case TOP_TO_BOTTOM: 22 | return topToBottom(width, height, angle, gravity); 23 | case BOTTOM_TO_TOP: 24 | return bottomToTop(width, height, angle, gravity); 25 | } 26 | return null; 27 | } 28 | 29 | 30 | private static Path leftToRight(float width, float height, double angle, Gravity gravity) { 31 | if (gravity == LEFT || gravity == RIGHT) 32 | gravity = BOTTOM; 33 | Path path = new Path(); 34 | float attitude = (float) Math.abs(Math.tan(Math.toRadians(angle)) * width); 35 | if (gravity == BOTTOM) { 36 | path.moveTo(0, 0); 37 | path.lineTo(width, 0); 38 | path.lineTo(width, height - attitude); 39 | path.lineTo(0, height); 40 | path.close(); 41 | } else { 42 | path.moveTo(0, 0); 43 | path.lineTo(width, attitude); 44 | path.lineTo(width, height); 45 | path.lineTo(0, height); 46 | path.close(); 47 | } 48 | return path; 49 | } 50 | 51 | private static Path rightToLeft(float width, float height, double angle, Gravity gravity) { 52 | if (gravity == LEFT || gravity == RIGHT) 53 | gravity = BOTTOM; 54 | Path path = new Path(); 55 | float attitude = (float) Math.abs(Math.tan(Math.toRadians(angle)) * width); 56 | if (gravity == BOTTOM) { 57 | path.moveTo(0, 0); 58 | path.lineTo(width, 0); 59 | path.lineTo(width, height); 60 | path.lineTo(0, height - attitude); 61 | path.close(); 62 | } else { 63 | path.moveTo(0, attitude); 64 | path.lineTo(width, 0); 65 | path.lineTo(width, height); 66 | path.lineTo(0, height); 67 | path.close(); 68 | } 69 | return path; 70 | } 71 | 72 | private static Path topToBottom(float width, float height, double angle, Gravity gravity) { 73 | if (gravity == TOP || gravity == BOTTOM) 74 | gravity = LEFT; 75 | float attitude = (float) Math.abs(Math.tan(Math.toRadians(angle)) * height); 76 | Path path = new Path(); 77 | if (gravity == LEFT) { 78 | path.moveTo(0, 0); 79 | path.lineTo(0, height); 80 | path.lineTo(width - attitude, height); 81 | path.lineTo(width, 0); 82 | path.close(); 83 | } else { 84 | path.moveTo(0, 0); 85 | path.lineTo(attitude, height); 86 | path.lineTo(width, height); 87 | path.lineTo(width, 0); 88 | path.close(); 89 | } 90 | return path; 91 | } 92 | 93 | private static Path bottomToTop(float width, float height, double angle, Gravity gravity) { 94 | if (gravity == TOP || gravity == BOTTOM) 95 | gravity = LEFT; 96 | 97 | float attitude = (float) Math.abs(Math.tan(Math.toRadians(angle)) * height); 98 | Path path = new Path(); 99 | if (gravity == LEFT) { 100 | path.moveTo(0, 0); 101 | path.lineTo(0, height); 102 | path.lineTo(width, height); 103 | path.lineTo(width - attitude, 0); 104 | path.close(); 105 | } else { 106 | path.moveTo(attitude, 0); 107 | path.lineTo(width, 0); 108 | path.lineTo(width, height); 109 | path.lineTo(0, height); 110 | path.close(); 111 | } 112 | return path; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /squint/src/main/java/com/intrusoft/squint/Squint.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.squint; 2 | 3 | public class Squint { 4 | 5 | public enum Gravity { 6 | LEFT(0), 7 | RIGHT(1), 8 | TOP(2), 9 | BOTTOM(3); 10 | final int value; 11 | 12 | Gravity(int value) { 13 | this.value = value; 14 | } 15 | } 16 | 17 | static final Gravity[] GRAVITIES = {Gravity.LEFT, Gravity.RIGHT, Gravity.TOP, Gravity.BOTTOM}; 18 | 19 | public enum Direction { 20 | LEFT_TO_RIGHT(0), 21 | RIGHT_TO_LEFT(1), 22 | TOP_TO_BOTTOM(2), 23 | BOTTOM_TO_TOP(3); 24 | final int value; 25 | 26 | Direction(int value) { 27 | this.value = value; 28 | } 29 | } 30 | 31 | static final Direction[] DIRECTIONS = {Direction.LEFT_TO_RIGHT, Direction.RIGHT_TO_LEFT, Direction.TOP_TO_BOTTOM, Direction.BOTTOM_TO_TOP}; 32 | } -------------------------------------------------------------------------------- /squint/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 | -------------------------------------------------------------------------------- /squint/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Squint 3 | 4 | -------------------------------------------------------------------------------- /squint/src/test/java/com/intrusoft/squint/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.intrusoft.squint; 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 | } --------------------------------------------------------------------------------