├── .gitignore ├── .idea ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── LICENSE ├── README.md ├── build.gradle ├── depth ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── florent37 │ │ └── depth │ │ ├── CustomShadow.java │ │ ├── container │ │ ├── DepthContainerFrameLayout.java │ │ ├── DepthContainerLinearLayout.java │ │ ├── DepthContainerRelativeLayout.java │ │ ├── DepthLayoutContainer.java │ │ └── core │ │ │ ├── DepthContainerManager.java │ │ │ └── DepthMotionHandler.java │ │ └── view │ │ ├── DepthFrameLayout.java │ │ ├── DepthLinearLayout.java │ │ ├── DepthRelativeLayout.java │ │ └── core │ │ ├── DepthLayout.java │ │ └── DepthManager.java │ └── res │ ├── drawable │ ├── round_soft_shadow.png │ └── shadow.9.png │ └── values │ └── attrs.xml ├── gradle.properties ├── gradle ├── bintray-android-v1.gradle ├── bintray-java-v1.gradle ├── install-v1.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── medias ├── auto.gif ├── finger.gif ├── finger.mp4 └── test.mp4 ├── sample ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── github │ │ └── florent37 │ │ └── depth │ │ └── sample │ │ ├── AutoAnimateActivity.java │ │ ├── FollowUserInputActivity.java │ │ └── MainActivity.java │ └── res │ ├── drawable-xxhdpi │ ├── actionbar_shadow.png │ ├── aura_gradient.png │ ├── aura_gradient_inner.png │ ├── foam.png │ ├── grunge.png │ ├── ic_forward.png │ ├── marker_1px.png │ ├── noise.png │ ├── noise_scratch.png │ ├── smoke.png │ ├── splash1.png │ ├── splash2.png │ ├── splash3.png │ ├── splash4.png │ ├── stones.png │ ├── sun.png │ ├── sun_aura.png │ ├── water.png │ ├── water_scene_background.9.png │ └── x_y.png │ ├── drawable-xxxhdpi │ ├── ic_menu.png │ └── mountains.png │ ├── drawable │ ├── animation_list.xml │ ├── circle_blue.xml │ ├── color1.xml │ ├── color2.xml │ ├── color3.xml │ ├── color4.xml │ ├── depth_circle.xml │ ├── homer.jpg │ └── material.png │ ├── layout │ ├── activity_auto_animate.xml │ ├── activity_follow_user_input.xml │ ├── activity_main.xml │ └── fake_item.xml │ ├── mipmap-xhdpi │ ├── custom_shadow.png │ ├── gradien1.png │ ├── gradien1circle.png │ ├── ic_launcher.png │ └── round_shadow.png │ ├── mipmap-xxhdpi │ ├── bear_1.png │ ├── bear_2.png │ ├── bear_white.png │ ├── gfx_water_sunny.png │ ├── gfx_wind_bears.png │ ├── ic_launcher.png │ ├── ic_previous.png │ └── tree.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # Intellij 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/dictionaries 41 | .idea/libraries 42 | 43 | # Keystore files 44 | *.jks 45 | 46 | # External native build folder generated in Android Studio 2.2 and later 47 | .externalNativeBuild 48 | 49 | # Google Services (e.g. APIs or Firebase) 50 | google-services.json 51 | 52 | # Freeline 53 | freeline.py 54 | freeline/ 55 | freeline_project_description.json 56 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 26 | 27 | 28 | 29 | 30 | 31 | 33 | -------------------------------------------------------------------------------- /.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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) <2016> 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 5 | 6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 7 | 8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Android-3D-Layout 2 | 3 | WORK IN PROGRESS 4 | 5 | [![screen](https://raw.githubusercontent.com/florent37/Android-3D-Layout/master/medias/auto.gif)](https://www.github.com/florent37/Android-3D-Layout) 6 | 7 | [![screen](https://raw.githubusercontent.com/florent37/Android-3D-Layout/master/medias/finger.gif)](https://www.github.com/florent37/Android-3D-Layout) 8 | 9 | Fiches Plateau Moto : [https://www.fiches-plateau-moto.fr/](https://www.fiches-plateau-moto.fr/) 10 | -------------------------------------------------------------------------------- /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 | google() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.0.1' 10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' 11 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' 12 | 13 | // NOTE: Do not place your application dependencies here; they belong 14 | // in the individual module build.gradle files 15 | } 16 | } 17 | 18 | allprojects { 19 | repositories { 20 | jcenter() 21 | google() 22 | } 23 | } 24 | 25 | ext { 26 | sdk = 27 27 | minSdk = 14 28 | libraryVersion = "1.0.0" 29 | supportVersion = "27.0.2" 30 | } -------------------------------------------------------------------------------- /depth/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /depth/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion project.sdk 5 | 6 | defaultConfig { 7 | minSdkVersion project.minSdk 8 | targetSdkVersion project.sdk 9 | versionCode 1 10 | versionName "1.0" 11 | } 12 | } 13 | 14 | dependencies { 15 | compile 'com.android.support:appcompat-v7:'+ project.supportVersion 16 | compile 'com.android.support:support-annotations:' + project.supportVersion 17 | } 18 | 19 | 20 | 21 | ext { 22 | bintrayRepo = 'maven' 23 | bintrayName = 'depth' 24 | orgName = 'florent37' 25 | 26 | publishedGroupId = 'com.github.florent37' 27 | libraryName = 'Depth' 28 | artifact = 'depth' 29 | 30 | libraryDescription = '' 31 | 32 | siteUrl = 'https://github.com/florent37/Depth' 33 | gitUrl = 'https://github.com/florent37/Depth.git' 34 | 35 | libraryVersion = rootProject.ext.libraryVersion 36 | 37 | developerId = 'florent37' 38 | developerName = 'florent37' 39 | developerEmail = 'champigny.florent@gmail.com' 40 | 41 | licenseName = 'The Apache Software License, Version 2.0' 42 | licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' 43 | allLicenses = ["Apache-2.0"] 44 | } 45 | 46 | 47 | apply from: rootProject.file('gradle/install-v1.gradle') 48 | apply from: rootProject.file('gradle/bintray-android-v1.gradle') -------------------------------------------------------------------------------- /depth/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 C:\Users\Jawn\Develop\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 | -------------------------------------------------------------------------------- /depth/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/CustomShadow.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Matrix; 5 | import android.graphics.PointF; 6 | import android.graphics.drawable.Drawable; 7 | import android.view.View; 8 | 9 | public class CustomShadow { 10 | 11 | private static final float DEFAULT_SHADOW_PADDING = 10f; 12 | 13 | private final View view; 14 | 15 | private PointF topLeftBack = new PointF(0, 0); 16 | private PointF topRightBack = new PointF(0, 0); 17 | private PointF bottomLeftBack = new PointF(0, 0); 18 | private PointF bottomRightBack = new PointF(0, 0); 19 | private int padding; 20 | private Matrix matrix = new Matrix(); 21 | 22 | private float customShadowElevation; 23 | 24 | public CustomShadow(View view) { 25 | this.view = view; 26 | } 27 | 28 | public float getCustomShadowElevation() { 29 | return customShadowElevation; 30 | } 31 | 32 | public void setCustomShadowElevation(float customShadowElevation) { 33 | this.customShadowElevation = customShadowElevation * 3; 34 | } 35 | 36 | public boolean calculateBounds() { 37 | float[] src = new float[8]; 38 | float density = view.getResources().getDisplayMetrics().density; 39 | float offsetY = customShadowElevation; 40 | float offsetX = customShadowElevation / 5; 41 | padding = (int) (customShadowElevation / 4f + DEFAULT_SHADOW_PADDING * density); 42 | 43 | float[] dst = new float[]{-padding, -padding, view.getWidth() + padding, -padding, -padding, view.getHeight() + padding, view.getWidth() + padding, view.getHeight() + padding}; 44 | final Matrix matrix = view.getMatrix(); 45 | matrix.mapPoints(src, dst); 46 | 47 | topLeftBack.x = src[0] + view.getLeft() + offsetX; 48 | topLeftBack.y = src[1] + view.getTop() + offsetY; 49 | topRightBack.x = src[2] + view.getLeft() + offsetX; 50 | topRightBack.y = src[3] + view.getTop() + offsetY; 51 | 52 | bottomLeftBack.x = src[4] + view.getLeft() + offsetX; 53 | bottomLeftBack.y = src[5] + view.getTop() + offsetY; 54 | bottomRightBack.x = src[6] + view.getLeft() + offsetX; 55 | bottomRightBack.y = src[7] + view.getTop() + offsetY; 56 | 57 | return false; 58 | } 59 | 60 | public void drawShadow(Canvas canvas, Drawable shadow) { 61 | shadow.setBounds(-padding, -padding, view.getWidth() + padding, view.getHeight() + padding); 62 | float[] src = new float[]{0, 0, view.getWidth(), 0, view.getWidth(), view.getHeight(), 0, view.getHeight()}; 63 | float[] dst = new float[]{topLeftBack.x, topLeftBack.y, topRightBack.x, topRightBack.y, bottomRightBack.x, bottomRightBack.y, bottomLeftBack.x, bottomLeftBack.y}; 64 | final int count = canvas.save(); 65 | matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1); 66 | canvas.concat(matrix); 67 | shadow.draw(canvas); 68 | canvas.restoreToCount(count); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/DepthContainerFrameLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.widget.FrameLayout; 9 | 10 | import com.github.florent37.depth.container.core.DepthContainerManager; 11 | import com.github.florent37.depth.container.core.DepthMotionHandler; 12 | 13 | public class DepthContainerFrameLayout extends FrameLayout implements DepthLayoutContainer { 14 | 15 | private final DepthMotionHandler motionHandler; 16 | 17 | private final DepthContainerManager depthContainerManager; 18 | 19 | public DepthContainerFrameLayout(Context context) { 20 | super(context); 21 | motionHandler = new DepthMotionHandler(this); 22 | depthContainerManager = new DepthContainerManager(this); 23 | depthContainerManager.setup(); 24 | } 25 | 26 | public DepthContainerFrameLayout(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | motionHandler = new DepthMotionHandler(this); 29 | depthContainerManager = new DepthContainerManager(this); 30 | depthContainerManager.setup(); 31 | } 32 | 33 | public DepthContainerFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | motionHandler = new DepthMotionHandler(this); 36 | depthContainerManager = new DepthContainerManager(this); 37 | depthContainerManager.setup(); 38 | } 39 | 40 | @Override 41 | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 42 | if (!isInEditMode()) { 43 | depthContainerManager.drawChild(canvas, child, drawingTime); 44 | } 45 | return super.drawChild(canvas, child, drawingTime); 46 | } 47 | 48 | @Override 49 | public boolean dispatchTouchEvent(MotionEvent event) { 50 | return motionHandler.onTouchEvent(event); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/DepthContainerLinearLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.widget.LinearLayout; 9 | 10 | import com.github.florent37.depth.container.core.DepthContainerManager; 11 | import com.github.florent37.depth.container.core.DepthMotionHandler; 12 | 13 | public class DepthContainerLinearLayout extends LinearLayout implements DepthLayoutContainer { 14 | 15 | private final DepthMotionHandler motionHandler; 16 | 17 | private final DepthContainerManager depthContainerManager; 18 | 19 | public DepthContainerLinearLayout(Context context) { 20 | super(context); 21 | motionHandler = new DepthMotionHandler(this); 22 | depthContainerManager = new DepthContainerManager(this); 23 | depthContainerManager.setup(); 24 | } 25 | 26 | public DepthContainerLinearLayout(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | motionHandler = new DepthMotionHandler(this); 29 | depthContainerManager = new DepthContainerManager(this); 30 | depthContainerManager.setup(); 31 | } 32 | 33 | public DepthContainerLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | motionHandler = new DepthMotionHandler(this); 36 | depthContainerManager = new DepthContainerManager(this); 37 | depthContainerManager.setup(); 38 | } 39 | 40 | @Override 41 | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 42 | if (!isInEditMode()) { 43 | depthContainerManager.drawChild(canvas, child, drawingTime); 44 | } 45 | return super.drawChild(canvas, child, drawingTime); 46 | } 47 | 48 | @Override 49 | public boolean dispatchTouchEvent(MotionEvent event) { 50 | return motionHandler.onTouchEvent(event); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/DepthContainerRelativeLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.util.AttributeSet; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.widget.RelativeLayout; 9 | 10 | import com.github.florent37.depth.container.core.DepthContainerManager; 11 | import com.github.florent37.depth.container.core.DepthMotionHandler; 12 | 13 | public class DepthContainerRelativeLayout extends RelativeLayout implements DepthLayoutContainer { 14 | 15 | private final DepthMotionHandler motionHandler; 16 | 17 | private final DepthContainerManager depthContainerManager; 18 | 19 | public DepthContainerRelativeLayout(Context context) { 20 | super(context); 21 | motionHandler = new DepthMotionHandler(this); 22 | depthContainerManager = new DepthContainerManager(this); 23 | depthContainerManager.setup(); 24 | } 25 | 26 | public DepthContainerRelativeLayout(Context context, AttributeSet attrs) { 27 | super(context, attrs); 28 | motionHandler = new DepthMotionHandler(this); 29 | depthContainerManager = new DepthContainerManager(this); 30 | depthContainerManager.setup(); 31 | } 32 | 33 | public DepthContainerRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { 34 | super(context, attrs, defStyleAttr); 35 | motionHandler = new DepthMotionHandler(this); 36 | depthContainerManager = new DepthContainerManager(this); 37 | depthContainerManager.setup(); 38 | } 39 | 40 | @Override 41 | protected boolean drawChild(Canvas canvas, View child, long drawingTime) { 42 | if (!isInEditMode()) { 43 | depthContainerManager.drawChild(canvas, child, drawingTime); 44 | } 45 | return super.drawChild(canvas, child, drawingTime); 46 | } 47 | 48 | @Override 49 | public boolean dispatchTouchEvent(MotionEvent event) { 50 | return motionHandler.onTouchEvent(event); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/DepthLayoutContainer.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container; 2 | 3 | public interface DepthLayoutContainer { 4 | } 5 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/core/DepthContainerManager.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container.core; 2 | 3 | import android.graphics.Canvas; 4 | import android.graphics.Color; 5 | import android.graphics.Matrix; 6 | import android.graphics.Paint; 7 | import android.graphics.Path; 8 | import android.graphics.PointF; 9 | import android.graphics.drawable.Drawable; 10 | import android.graphics.drawable.NinePatchDrawable; 11 | import android.support.v4.content.ContextCompat; 12 | import android.view.View; 13 | import android.view.ViewGroup; 14 | import android.view.ViewTreeObserver; 15 | 16 | import com.gihub.florent37.depth.R; 17 | import com.github.florent37.depth.CustomShadow; 18 | import com.github.florent37.depth.view.core.DepthLayout; 19 | 20 | public class DepthContainerManager { 21 | private final ViewGroup view; 22 | 23 | private Matrix matrix = new Matrix(); 24 | private Paint shadowPaint = new Paint(); 25 | private NinePatchDrawable softShadow; 26 | private Drawable roundSoftShadow; 27 | private Path edgePath = new Path(); 28 | private float shadowAlpha = 0.3f; 29 | 30 | public DepthContainerManager(ViewGroup view) { 31 | this.view = view; 32 | } 33 | 34 | public float getTopEdgeLength(DepthLayout dl) { 35 | return getDistance(dl.getDepthManager().getTopLeftBack(), dl.getDepthManager().getTopRightBack()); 36 | } 37 | 38 | float getDistance(PointF p1, PointF p2) { 39 | return (float) Math.sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y)); 40 | } 41 | 42 | public float getShadowAlpha() { 43 | return shadowAlpha; 44 | } 45 | 46 | public void setShadowAlpha(float shadowAlpha) { 47 | this.shadowAlpha = Math.min(1f, Math.max(0, shadowAlpha)); 48 | } 49 | 50 | public void setup() { 51 | view.setLayerType(View.LAYER_TYPE_HARDWARE, null); 52 | 53 | view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { 54 | @Override 55 | public boolean onPreDraw() { 56 | for (int i = 0; i < view.getChildCount(); i++) { 57 | final View child = view.getChildAt(i); 58 | if (child instanceof DepthLayout) { 59 | boolean hasChangedBounds = ((DepthLayout) child).getDepthManager().calculateBounds(); 60 | if (hasChangedBounds) 61 | view.invalidate(); 62 | } 63 | } 64 | return true; 65 | } 66 | }); 67 | 68 | shadowPaint.setColor(Color.BLACK); 69 | shadowPaint.setAntiAlias(true); 70 | softShadow = (NinePatchDrawable) ContextCompat.getDrawable(view.getContext(), R.drawable.shadow); 71 | roundSoftShadow = ContextCompat.getDrawable(view.getContext(), R.drawable.round_soft_shadow); 72 | } 73 | 74 | private void drawCornerBaseShape(DepthLayout dl, Canvas canvas, float[] src) { 75 | final float[] dst = new float[]{dl.getDepthManager().getTopLeftBack().x, dl.getDepthManager().getTopLeftBack().y, dl.getDepthManager().getTopRightBack().x, dl.getDepthManager().getTopRightBack().y, dl.getDepthManager().getBottomRightBack().x, dl.getDepthManager().getBottomRightBack().y, dl.getDepthManager().getBottomLeftBack().x, dl.getDepthManager().getBottomLeftBack().y}; 76 | final int count = canvas.save(); 77 | matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1); 78 | canvas.concat(matrix); 79 | edgePath.reset(); 80 | edgePath.addRoundRect(0, 0, dl.getWidth(), dl.getHeight(), dl.getWidth() / 2f, dl.getHeight() / 2f, Path.Direction.CCW); 81 | 82 | canvas.drawPath(edgePath, dl.getDepthManager().getEdgePaint()); 83 | shadowPaint.setAlpha((int) (shadowAlpha * 0.5f * 255)); 84 | canvas.drawPath(edgePath, shadowPaint); 85 | 86 | canvas.restoreToCount(count); 87 | } 88 | 89 | private void drawHorizontalFist(DepthLayout dl, Canvas canvas, float[] src) { 90 | if (getLeftEdgeLength(dl) <= getRightEdgeLength(dl)) { 91 | drawLeftEdge(dl, canvas, src); 92 | } else { 93 | drawRightEdge(dl, canvas, src); 94 | } 95 | 96 | drawTopEdge(dl, canvas, src); 97 | drawBottomEdge(dl, canvas, src); 98 | 99 | if (getLeftEdgeLength(dl) >= getRightEdgeLength(dl)) { 100 | drawLeftEdge(dl, canvas, src); 101 | } else { 102 | drawRightEdge(dl, canvas, src); 103 | } 104 | } 105 | 106 | private void drawVerticalFirst(DepthLayout dl, Canvas canvas, float[] src) { 107 | if (getTopEdgeLength(dl) <= getBottomEdgeLength(dl)) { 108 | drawTopEdge(dl, canvas, src); 109 | } else { 110 | drawBottomEdge(dl, canvas, src); 111 | } 112 | 113 | drawLeftEdge(dl, canvas, src); 114 | drawRightEdge(dl, canvas, src); 115 | 116 | 117 | if (getTopEdgeLength(dl) >= getBottomEdgeLength(dl)) { 118 | drawTopEdge(dl, canvas, src); 119 | } else { 120 | drawBottomEdge(dl, canvas, src); 121 | } 122 | 123 | } 124 | 125 | float getLongestHorizontalEdge(DepthLayout dl) { 126 | final float topEdgeLength = getTopEdgeLength(dl); 127 | final float bottomEdgeLength = getBottomEdgeLength(dl); 128 | if (topEdgeLength > bottomEdgeLength) { 129 | return topEdgeLength; 130 | } else { 131 | return bottomEdgeLength; 132 | } 133 | } 134 | 135 | float getLongestVerticalEdge(DepthLayout dl) { 136 | final float leftEdgeLength = getLeftEdgeLength(dl); 137 | final float rightEdgeLength = getRightEdgeLength(dl); 138 | if (leftEdgeLength > rightEdgeLength) { 139 | return leftEdgeLength; 140 | } else { 141 | return rightEdgeLength; 142 | } 143 | } 144 | 145 | private float getRightEdgeLength(DepthLayout dl) { 146 | return getDistance(dl.getDepthManager().getTopRightBack(), dl.getDepthManager().getBottomRightBack()); 147 | } 148 | 149 | private float getLeftEdgeLength(DepthLayout dl) { 150 | return getDistance(dl.getDepthManager().getTopLeftBack(), dl.getDepthManager().getBottomLeftBack()); 151 | } 152 | 153 | private float getBottomEdgeLength(DepthLayout dl) { 154 | return getDistance(dl.getDepthManager().getBottomLeftBack(), dl.getDepthManager().getBottomRightBack()); 155 | } 156 | 157 | void drawShadow(PointF point1, PointF point2, float correctionValue, Canvas canvas, DepthLayout dl) { 158 | final float angle = Math.abs(Math.abs(getAngle(point1, point2)) + correctionValue); 159 | final float alpha = angle / 180f; 160 | shadowPaint.setAlpha((int) (alpha * 255f * shadowAlpha)); 161 | canvas.drawRect(0, 0, dl.getWidth(), dl.getHeight(), shadowPaint); 162 | } 163 | 164 | private void drawRectangle(DepthLayout dl, Canvas canvas) { 165 | canvas.drawRect(0, 0, dl.getWidth(), dl.getHeight(), dl.getDepthManager().getEdgePaint()); 166 | } 167 | 168 | public float getAngle(PointF point1, PointF point2) { 169 | return (float) Math.toDegrees(Math.atan2(point1.y - point2.y, point1.x - point2.x)); 170 | } 171 | 172 | private void drawLeftEdge(DepthLayout dl, Canvas canvas, float[] src) { 173 | final float[] dst = new float[]{dl.getDepthManager().getTopLeft().x, dl.getDepthManager().getTopLeft().y, dl.getDepthManager().getTopLeftBack().x, dl.getDepthManager().getTopLeftBack().y, dl.getDepthManager().getBottomLeftBack().x, dl.getDepthManager().getBottomLeftBack().y, dl.getDepthManager().getBottomLeft().x, dl.getDepthManager().getBottomLeft().y}; 174 | final int count = canvas.save(); 175 | matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1); 176 | canvas.concat(matrix); 177 | drawRectangle(dl, canvas); 178 | drawShadow(dl.getDepthManager().getTopLeft(), dl.getDepthManager().getBottomLeft(), 0, canvas, dl); 179 | canvas.restoreToCount(count); 180 | } 181 | 182 | private void drawRightEdge(DepthLayout dl, Canvas canvas, float[] src) { 183 | final float[] dst = new float[]{dl.getDepthManager().getTopRight().x, dl.getDepthManager().getTopRight().y, dl.getDepthManager().getTopRightBack().x, dl.getDepthManager().getTopRightBack().y, dl.getDepthManager().getBottomRightBack().x, dl.getDepthManager().getBottomRightBack().y, dl.getDepthManager().getBottomRight().x, dl.getDepthManager().getBottomRight().y}; 184 | final int count = canvas.save(); 185 | matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1); 186 | canvas.concat(matrix); 187 | drawRectangle(dl, canvas); 188 | drawShadow(dl.getDepthManager().getTopRight(), dl.getDepthManager().getBottomRight(), -180f, canvas, dl); 189 | canvas.restoreToCount(count); 190 | } 191 | 192 | private void drawTopEdge(DepthLayout dl, Canvas canvas, float[] src) { 193 | final float[] dst = new float[]{dl.getDepthManager().getTopLeft().x, dl.getDepthManager().getTopLeft().y, dl.getDepthManager().getTopRight().x, dl.getDepthManager().getTopRight().y, dl.getDepthManager().getTopRightBack().x, dl.getDepthManager().getTopRightBack().y, dl.getDepthManager().getTopLeftBack().x, dl.getDepthManager().getTopLeftBack().y}; 194 | final int count = canvas.save(); 195 | matrix.setPolyToPoly(src, 0, dst, 0, src.length >> 1); 196 | canvas.concat(matrix); 197 | drawRectangle(dl, canvas); 198 | drawShadow(dl.getDepthManager().getTopLeft(), dl.getDepthManager().getTopRight(), -180f, canvas, dl); 199 | canvas.restoreToCount(count); 200 | } 201 | 202 | private void drawBottomEdge(DepthLayout dl, Canvas canvas, float[] src) { 203 | final float[] dst = new float[]{dl.getDepthManager().getBottomLeft().x, dl.getDepthManager().getBottomLeft().y, dl.getDepthManager().getBottomRight().x, dl.getDepthManager().getBottomRight().y, dl.getDepthManager().getBottomRightBack().x, dl.getDepthManager().getBottomRightBack().y, dl.getDepthManager().getBottomLeftBack().x, dl.getDepthManager().getBottomLeftBack().y}; 204 | final int count = canvas.save(); 205 | matrix.setPolyToPoly(src, 0, dst, 0, dst.length >> 1); 206 | canvas.concat(matrix); 207 | drawRectangle(dl, canvas); 208 | drawShadow(dl.getDepthManager().getBottomLeft(), dl.getDepthManager().getBottomRight(), 0, canvas, dl); 209 | canvas.restoreToCount(count); 210 | } 211 | 212 | public void drawChild(Canvas canvas, View child, long drawingTime) { 213 | if (child instanceof DepthLayout) { 214 | final DepthLayout dl = (DepthLayout) child; 215 | final CustomShadow customShadow = dl.getDepthManager().getCustomShadow(); 216 | 217 | final float[] src = new float[]{0, 0, dl.getWidth(), 0, dl.getWidth(), dl.getHeight(), 0, dl.getHeight()}; 218 | if (dl.getDepthManager().isCircle()) { 219 | customShadow.drawShadow(canvas, roundSoftShadow); 220 | if (Math.abs(dl.getRotationX()) > 1 || Math.abs(dl.getRotationY()) > 1) { 221 | drawCornerBaseShape(dl, canvas, src); 222 | } 223 | } else { 224 | customShadow.drawShadow(canvas, softShadow); 225 | if (dl.getRotationX() != 0 || dl.getRotationY() != 0) { 226 | if (getLongestHorizontalEdge(dl) > getLongestVerticalEdge(dl)) 227 | drawVerticalFirst(dl, canvas, src); 228 | else 229 | drawHorizontalFist(dl, canvas, src); 230 | } 231 | } 232 | } 233 | } 234 | } 235 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/container/core/DepthMotionHandler.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.container.core; 2 | 3 | import android.animation.ObjectAnimator; 4 | import android.animation.ValueAnimator; 5 | import android.util.Log; 6 | import android.view.MotionEvent; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | 10 | import com.github.florent37.depth.view.core.DepthLayout; 11 | 12 | public class DepthMotionHandler { 13 | private final ViewGroup view; 14 | 15 | float speedRotationX = 1.8f; 16 | float speedRotationY = 1.8f; 17 | 18 | int minRotationX = -50; 19 | int maxRotationX = 50; 20 | int minRotationY = -50; 21 | int maxRotationY = 50; 22 | 23 | private Float clickedX; 24 | private Float clickedY; 25 | 26 | public DepthMotionHandler(ViewGroup view) { 27 | this.view = view; 28 | } 29 | 30 | public boolean onTouchEvent(MotionEvent event) { 31 | if (view.getWidth() == 0 || view.getHeight() == 0) { 32 | return false; 33 | } 34 | 35 | final float x = event.getX(); 36 | final float y = event.getY(); 37 | 38 | switch (event.getAction()) { 39 | case MotionEvent.ACTION_DOWN: { 40 | clickedX = x; 41 | clickedY = y; 42 | 43 | break; 44 | } 45 | case MotionEvent.ACTION_MOVE: { 46 | final float translationX = x - clickedX; 47 | final float translationY = y - clickedY; 48 | 49 | for (int i = 0; i < view.getChildCount(); i++) { 50 | final View childAt = view.getChildAt(i); 51 | if (childAt instanceof DepthLayout) { 52 | float percentX = translationX / view.getWidth(); 53 | float percentY = translationY / view.getHeight(); 54 | 55 | Log.d("Depth", "percentX :" + percentX); 56 | 57 | final int rotationY = (int) ((percentX * 90) * speedRotationY); 58 | final int rotationX = (int) ((-1 * percentY * 90) * speedRotationX); 59 | 60 | childAt.setRotationY(limit(rotationY, minRotationY, maxRotationY)); 61 | childAt.setRotationX(limit(rotationX, minRotationX, maxRotationX)); 62 | } 63 | } 64 | break; 65 | } 66 | case MotionEvent.ACTION_UP: 67 | case MotionEvent.ACTION_CANCEL: { 68 | clickedX = null; 69 | clickedY = null; 70 | break; 71 | } 72 | } 73 | 74 | return true; 75 | } 76 | 77 | private int limit(int value, int min, int max) { 78 | if (value > max) { 79 | value = max; 80 | } 81 | if (value < min) { 82 | value = min; 83 | } 84 | return value; 85 | } 86 | } -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/view/DepthFrameLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | import android.widget.FrameLayout; 7 | 8 | import com.gihub.florent37.depth.R; 9 | import com.github.florent37.depth.view.core.DepthManager; 10 | import com.github.florent37.depth.view.core.DepthLayout; 11 | 12 | public class DepthFrameLayout extends FrameLayout implements DepthLayout { 13 | 14 | private final DepthManager depthManager; 15 | 16 | public DepthFrameLayout(Context context) { 17 | super(context); 18 | depthManager = new DepthManager(this); 19 | initView(null); 20 | } 21 | 22 | public DepthFrameLayout(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | depthManager = new DepthManager(this); 25 | initView(attrs); 26 | 27 | } 28 | 29 | public DepthFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { 30 | super(context, attrs, defStyleAttr); 31 | depthManager = new DepthManager(this); 32 | initView(attrs); 33 | } 34 | 35 | @Override 36 | public boolean hasOverlappingRendering() { 37 | return false; 38 | } 39 | 40 | private void initView(AttributeSet attrs) { 41 | int edgeColor = -1; 42 | boolean isCircle = false; 43 | float depth = -1; 44 | int depthIndex = -1; 45 | float elevation = 0; 46 | boolean autoAnimate = false; 47 | 48 | if (attrs != null) { 49 | final TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthFrameLayout); 50 | edgeColor = arr.getInt(R.styleable.DepthFrameLayout_depth_edgeColor, edgeColor); 51 | isCircle = arr.getBoolean(R.styleable.DepthFrameLayout_depth_isCircle, isCircle); 52 | depth = arr.getDimension(R.styleable.DepthFrameLayout_depth_value, depth); 53 | depthIndex = arr.getInt(R.styleable.DepthFrameLayout_depth_zIndex, depthIndex); 54 | elevation = arr.getDimension(R.styleable.DepthFrameLayout_depth_elevation, elevation); 55 | autoAnimate = arr.getBoolean(R.styleable.DepthFrameLayout_depth_autoAnimate, autoAnimate); 56 | arr.recycle(); 57 | } 58 | depthManager.init(edgeColor, isCircle, depth, depthIndex, elevation, autoAnimate); 59 | 60 | } 61 | 62 | @Override 63 | public DepthManager getDepthManager() { 64 | return depthManager; 65 | } 66 | 67 | public void setCustomShadowElevation(float customShadowElevation) { 68 | this.depthManager.setCustomShadowElevation(customShadowElevation); 69 | } 70 | 71 | @Override 72 | public void setDepth(float depth) { 73 | this.depthManager.setDepth(depth); 74 | } 75 | 76 | @Override 77 | public void autoAnimate(boolean animate) { 78 | depthManager.autoAnimate(animate); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/view/DepthLinearLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | import android.widget.FrameLayout; 7 | 8 | import com.gihub.florent37.depth.R; 9 | import com.github.florent37.depth.view.core.DepthManager; 10 | import com.github.florent37.depth.view.core.DepthLayout; 11 | 12 | public class DepthLinearLayout extends FrameLayout implements DepthLayout { 13 | 14 | private final DepthManager depthManager; 15 | 16 | public DepthLinearLayout(Context context) { 17 | super(context); 18 | depthManager = new DepthManager(this); 19 | initView(null); 20 | } 21 | 22 | public DepthLinearLayout(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | depthManager = new DepthManager(this); 25 | initView(attrs); 26 | 27 | } 28 | 29 | public DepthLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { 30 | super(context, attrs, defStyleAttr); 31 | depthManager = new DepthManager(this); 32 | initView(attrs); 33 | } 34 | 35 | @Override 36 | public boolean hasOverlappingRendering() { 37 | return false; 38 | } 39 | 40 | private void initView(AttributeSet attrs) { 41 | int edgeColor = -1; 42 | boolean isCircle = false; 43 | float depth = -1; 44 | int depthIndex = -1; 45 | float elevation = 0; 46 | boolean autoAnimate = false; 47 | 48 | if (attrs != null) { 49 | final TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthLinearLayout); 50 | edgeColor = arr.getInt(R.styleable.DepthLinearLayout_depth_edgeColor, edgeColor); 51 | isCircle = arr.getBoolean(R.styleable.DepthLinearLayout_depth_isCircle, isCircle); 52 | depth = arr.getDimension(R.styleable.DepthLinearLayout_depth_value, depth); 53 | depthIndex = arr.getInt(R.styleable.DepthLinearLayout_depth_zIndex, depthIndex); 54 | elevation = arr.getDimension(R.styleable.DepthLinearLayout_depth_elevation, elevation); 55 | autoAnimate = arr.getBoolean(R.styleable.DepthLinearLayout_depth_autoAnimate, autoAnimate); 56 | arr.recycle(); 57 | } 58 | depthManager.init(edgeColor, isCircle, depth, depthIndex, elevation, autoAnimate); 59 | 60 | } 61 | 62 | @Override 63 | public DepthManager getDepthManager() { 64 | return depthManager; 65 | } 66 | 67 | public void setCustomShadowElevation(float customShadowElevation) { 68 | this.depthManager.setCustomShadowElevation(customShadowElevation); 69 | } 70 | 71 | @Override 72 | public void autoAnimate(boolean animate) { 73 | depthManager.autoAnimate(animate); 74 | } 75 | 76 | @Override 77 | public void setDepth(float depth) { 78 | this.depthManager.setDepth(depth); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/view/DepthRelativeLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.view; 2 | 3 | import android.content.Context; 4 | import android.content.res.TypedArray; 5 | import android.util.AttributeSet; 6 | import android.widget.RelativeLayout; 7 | 8 | import com.gihub.florent37.depth.R; 9 | import com.github.florent37.depth.view.core.DepthManager; 10 | import com.github.florent37.depth.view.core.DepthLayout; 11 | 12 | public class DepthRelativeLayout extends RelativeLayout implements DepthLayout { 13 | 14 | private final DepthManager depthManager; 15 | 16 | public DepthRelativeLayout(Context context) { 17 | super(context); 18 | depthManager = new DepthManager(this); 19 | initView(null); 20 | } 21 | 22 | public DepthRelativeLayout(Context context, AttributeSet attrs) { 23 | super(context, attrs); 24 | depthManager = new DepthManager(this); 25 | initView(attrs); 26 | 27 | } 28 | 29 | public DepthRelativeLayout(Context context, AttributeSet attrs, int defStyleAttr) { 30 | super(context, attrs, defStyleAttr); 31 | depthManager = new DepthManager(this); 32 | initView(attrs); 33 | } 34 | 35 | @Override 36 | public boolean hasOverlappingRendering() { 37 | return false; 38 | } 39 | 40 | private void initView(AttributeSet attrs) { 41 | int edgeColor = -1; 42 | boolean isCircle = false; 43 | float depth = -1; 44 | int depthIndex = -1; 45 | float elevation = 0; 46 | boolean autoAnimate = false; 47 | 48 | if (attrs != null) { 49 | final TypedArray arr = getContext().obtainStyledAttributes(attrs, R.styleable.DepthRelativeLayout); 50 | edgeColor = arr.getInt(R.styleable.DepthRelativeLayout_depth_edgeColor, edgeColor); 51 | isCircle = arr.getBoolean(R.styleable.DepthRelativeLayout_depth_isCircle, isCircle); 52 | depth = arr.getDimension(R.styleable.DepthRelativeLayout_depth_value, depth); 53 | depthIndex = arr.getInt(R.styleable.DepthRelativeLayout_depth_zIndex, depthIndex); 54 | elevation = arr.getDimension(R.styleable.DepthRelativeLayout_depth_elevation, elevation); 55 | autoAnimate = arr.getBoolean(R.styleable.DepthRelativeLayout_depth_autoAnimate, autoAnimate); 56 | arr.recycle(); 57 | } 58 | depthManager.init(edgeColor, isCircle, depth, depthIndex, elevation, autoAnimate); 59 | 60 | } 61 | 62 | @Override 63 | public DepthManager getDepthManager() { 64 | return depthManager; 65 | } 66 | 67 | public void setCustomShadowElevation(float customShadowElevation) { 68 | this.depthManager.setCustomShadowElevation(customShadowElevation); 69 | } 70 | 71 | @Override 72 | public void autoAnimate(boolean animate) { 73 | depthManager.autoAnimate(animate); 74 | } 75 | 76 | @Override 77 | public void setDepth(float depth) { 78 | this.depthManager.setDepth(depth); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/view/core/DepthLayout.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.view.core; 2 | 3 | public interface DepthLayout { 4 | 5 | int getWidth(); 6 | 7 | int getHeight(); 8 | 9 | DepthManager getDepthManager(); 10 | 11 | float getRotationY(); 12 | 13 | float getRotationX(); 14 | 15 | void setDepth(float depth); 16 | 17 | void autoAnimate(boolean animate); 18 | } 19 | -------------------------------------------------------------------------------- /depth/src/main/java/com/github/florent37/depth/view/core/DepthManager.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.view.core; 2 | 3 | import android.animation.Animator; 4 | import android.animation.ObjectAnimator; 5 | import android.animation.ValueAnimator; 6 | import android.graphics.Color; 7 | import android.graphics.Matrix; 8 | import android.graphics.Outline; 9 | import android.graphics.Paint; 10 | import android.graphics.PointF; 11 | import android.os.Build; 12 | import android.view.View; 13 | import android.view.ViewOutlineProvider; 14 | 15 | import com.github.florent37.depth.CustomShadow; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class DepthManager { 21 | public static final int DEFAULT_EDGE_COLOR = Color.WHITE; 22 | public static final int DEFAULT_THICKNESS = 2; 23 | 24 | public final PointF topLeft = new PointF(0, 0); 25 | public final PointF topRight = new PointF(0, 0); 26 | public final PointF bottomLeft = new PointF(0, 0); 27 | public final PointF bottomRight = new PointF(0, 0); 28 | public final PointF topLeftBack = new PointF(0, 0); 29 | public final PointF topRightBack = new PointF(0, 0); 30 | public final PointF bottomLeftBack = new PointF(0, 0); 31 | public final PointF bottomRightBack = new PointF(0, 0); 32 | 33 | public final CustomShadow customShadow; 34 | private final View view; 35 | public Paint edgePaint = new Paint(); 36 | public float[] prevSrc = new float[8]; 37 | public int depthIndex = 0; 38 | public float depth; 39 | public boolean isCircle = false; 40 | 41 | public DepthManager(View view) { 42 | this.view = view; 43 | customShadow = new CustomShadow(view); 44 | } 45 | 46 | public void init(int edgeColor, boolean isCircle, float depth, int depthIndex, float elevation, boolean autoAnimate) { 47 | view.setLayerType(View.LAYER_TYPE_HARDWARE, null); 48 | 49 | edgePaint.setColor(DEFAULT_EDGE_COLOR); 50 | edgePaint.setAntiAlias(true); 51 | 52 | if (edgeColor != -1) { 53 | this.edgePaint.setColor(edgeColor); 54 | } 55 | this.setIsCircle(isCircle); 56 | if (depth != -1) { 57 | this.setDepth(depth); 58 | } else { 59 | this.setDepth(DEFAULT_THICKNESS * view.getResources().getDisplayMetrics().density); 60 | } 61 | if (depthIndex != -1) { 62 | this.depthIndex = depthIndex; 63 | } 64 | setCustomShadowElevation(elevation); 65 | 66 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 67 | view.setOutlineProvider(new ViewOutlineProvider() { 68 | @Override 69 | public void getOutline(View view, Outline outline) { 70 | 71 | } 72 | }); 73 | } 74 | 75 | autoAnimate(autoAnimate); 76 | } 77 | 78 | public PointF getTopLeft() { 79 | return topLeft; 80 | } 81 | 82 | public PointF getTopRight() { 83 | return topRight; 84 | } 85 | 86 | public PointF getBottomLeft() { 87 | return bottomLeft; 88 | } 89 | 90 | public PointF getBottomRight() { 91 | return bottomRight; 92 | } 93 | 94 | public PointF getTopLeftBack() { 95 | return topLeftBack; 96 | } 97 | 98 | public PointF getTopRightBack() { 99 | return topRightBack; 100 | } 101 | 102 | public PointF getBottomLeftBack() { 103 | return bottomLeftBack; 104 | } 105 | 106 | public PointF getBottomRightBack() { 107 | return bottomRightBack; 108 | } 109 | 110 | boolean hasMatrixChanged(float[] newSrc) { 111 | for (int i = 0; i < 8; i++) { 112 | if (newSrc[i] != prevSrc[i]) 113 | return true; 114 | } 115 | return false; 116 | } 117 | 118 | public boolean isCircle() { 119 | return isCircle; 120 | } 121 | 122 | public void setIsCircle(boolean isCircle) { 123 | this.isCircle = isCircle; 124 | } 125 | 126 | public boolean calculateBounds() { 127 | 128 | float[] src = new float[8]; 129 | float[] dst = new float[]{0, 0, view.getWidth(), 0, 0, view.getHeight(), view.getWidth(), view.getHeight()}; 130 | final Matrix matrix = view.getMatrix(); 131 | 132 | matrix.mapPoints(src, dst); 133 | topLeft.x = src[0] + view.getLeft(); 134 | topLeft.y = src[1] + view.getTop(); 135 | topRight.x = src[2] + view.getLeft(); 136 | topRight.y = src[3] + view.getTop(); 137 | 138 | bottomLeft.x = src[4] + view.getLeft(); 139 | bottomLeft.y = src[5] + view.getTop(); 140 | bottomRight.x = src[6] + view.getLeft(); 141 | bottomRight.y = src[7] + view.getTop(); 142 | final boolean returnValue = hasMatrixChanged(src); 143 | prevSrc = src; 144 | float percentFrom90X = (view.getRotationX()) / 90f; 145 | float percentFrom90Y = (-view.getRotationY()) / 90f; 146 | 147 | 148 | matrix.postTranslate(percentFrom90Y * getDepth(), percentFrom90X * getDepth()); 149 | src = new float[8]; 150 | dst = new float[]{0, 0, view.getWidth(), 0, 0, view.getHeight(), view.getWidth(), view.getHeight()}; 151 | matrix.mapPoints(src, dst); 152 | 153 | topLeftBack.x = src[0] + view.getLeft(); 154 | topLeftBack.y = src[1] + view.getTop(); 155 | topRightBack.x = src[2] + view.getLeft(); 156 | topRightBack.y = src[3] + view.getTop(); 157 | 158 | bottomLeftBack.x = src[4] + view.getLeft(); 159 | bottomLeftBack.y = src[5] + view.getTop(); 160 | bottomRightBack.x = src[6] + view.getLeft(); 161 | bottomRightBack.y = src[7] + view.getTop(); 162 | this.customShadow.calculateBounds(); 163 | 164 | return returnValue; 165 | } 166 | 167 | public float getDepth() { 168 | return depth; 169 | } 170 | 171 | public void setDepth(float depth) { 172 | this.depth = depth; 173 | if (view.getParent() instanceof View) { 174 | ((View) view.getParent()).invalidate(); 175 | } 176 | } 177 | 178 | public Paint getEdgePaint() { 179 | return edgePaint; 180 | } 181 | 182 | public void setEdgePaint(Paint edgePaint) { 183 | this.edgePaint = edgePaint; 184 | } 185 | 186 | public int getDepthIndex() { 187 | return depthIndex; 188 | } 189 | 190 | public CustomShadow getCustomShadow() { 191 | return customShadow; 192 | } 193 | 194 | public void setCustomShadowElevation(float customShadowElevation) { 195 | this.customShadow.setCustomShadowElevation(customShadowElevation); 196 | if (view.getParent() instanceof View) { 197 | ((View) view.getParent()).invalidate(); 198 | } 199 | } 200 | 201 | private List animators = new ArrayList<>(); 202 | 203 | public void autoAnimate(boolean animate) { 204 | if(animate) { 205 | view.post(new Runnable() { 206 | @Override 207 | public void run() { 208 | final ObjectAnimator rotationY = ObjectAnimator.ofFloat(view, View.ROTATION_Y, 25, 0, -25); 209 | rotationY.setDuration(1000); 210 | rotationY.setRepeatCount(ValueAnimator.INFINITE); 211 | rotationY.setRepeatMode(ValueAnimator.REVERSE); 212 | rotationY.start(); 213 | 214 | animators.add(rotationY); 215 | 216 | final ObjectAnimator rotationX = ObjectAnimator.ofFloat(view, View.ROTATION_X, -25, 0, 25); 217 | rotationX.setDuration(2500); 218 | rotationX.setRepeatCount(ValueAnimator.INFINITE); 219 | rotationX.setRepeatMode(ValueAnimator.REVERSE); 220 | rotationX.start(); 221 | 222 | animators.add(rotationX); 223 | } 224 | }); 225 | } else { 226 | for (Animator animator : animators) { 227 | animator.cancel(); 228 | } 229 | } 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /depth/src/main/res/drawable/round_soft_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/depth/src/main/res/drawable/round_soft_shadow.png -------------------------------------------------------------------------------- /depth/src/main/res/drawable/shadow.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/depth/src/main/res/drawable/shadow.9.png -------------------------------------------------------------------------------- /depth/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 | -------------------------------------------------------------------------------- /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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/bintray-android-v1.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.jfrog.bintray' 2 | 3 | version = libraryVersion 4 | 5 | task sourcesJar(type: Jar) { 6 | from android.sourceSets.main.java.srcDirs 7 | classifier = 'sources' 8 | } 9 | 10 | task javadoc(type: Javadoc) { 11 | source = android.sourceSets.main.java.srcDirs 12 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) 13 | } 14 | 15 | task javadocJar(type: Jar, dependsOn: javadoc) { 16 | classifier = 'javadoc' 17 | from javadoc.destinationDir 18 | } 19 | artifacts { 20 | archives javadocJar 21 | archives sourcesJar 22 | } 23 | 24 | def _user = System.getenv("BINTRAY_USER") 25 | def _key = System.getenv("BINTRAY_API_KEY") 26 | def _passphrase = System.getenv("BINTRAY_PASSPHRASE") 27 | 28 | if(project.rootProject.file('local.properties').exists() && (_user == null || _user.isEmpty())){ 29 | Properties properties = new Properties() 30 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 31 | 32 | _user = properties.getProperty("bintray.user") 33 | _key = properties.getProperty("bintray.apikey"); 34 | _passphrase = properties.getProperty("bintray.gpg.password") 35 | } 36 | 37 | // Bintray 38 | 39 | bintray { 40 | user = _user 41 | key = _key 42 | 43 | configurations = ['archives'] 44 | pkg { 45 | repo = bintrayRepo 46 | name = bintrayName 47 | desc = libraryDescription 48 | userOrg = orgName 49 | websiteUrl = siteUrl 50 | vcsUrl = gitUrl 51 | licenses = allLicenses 52 | publish = true 53 | publicDownloadNumbers = true 54 | version { 55 | desc = libraryDescription 56 | gpg { 57 | sign = true //Determines whether to GPG sign the files. The default is false 58 | passphrase = _passphrase 59 | //Optional. The passphrase for GPG signing' 60 | } 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /gradle/bintray-java-v1.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.jfrog.bintray' 2 | 3 | version = libraryVersion 4 | 5 | task sourcesJar(type: Jar) { 6 | from sourceSets.main.allSource 7 | classifier = 'sources' 8 | } 9 | 10 | task javadocJar(type: Jar, dependsOn: javadoc) { 11 | classifier = 'javadoc' 12 | from javadoc.destinationDir 13 | } 14 | artifacts { 15 | archives javadocJar 16 | archives sourcesJar 17 | } 18 | 19 | // Bintray 20 | 21 | def _user = System.getenv("BINTRAY_USER") 22 | def _key = System.getenv("BINTRAY_API_KEY") 23 | def _passphrase = System.getenv("BINTRAY_PASSPHRASE") 24 | 25 | if(project.rootProject.file('local.properties').exists() && (_user == null || _user.isEmpty())){ 26 | Properties properties = new Properties() 27 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) 28 | 29 | _user = properties.getProperty("bintray.user") 30 | _key = properties.getProperty("bintray.apikey"); 31 | _passphrase = properties.getProperty("bintray.gpg.password") 32 | } 33 | 34 | bintray { 35 | user = _user 36 | key = _key 37 | 38 | configurations = ['archives'] 39 | pkg { 40 | repo = bintrayRepo 41 | name = bintrayName 42 | desc = libraryDescription 43 | userOrg = orgName 44 | websiteUrl = siteUrl 45 | vcsUrl = gitUrl 46 | licenses = ['Apache-2.0'] 47 | publish = true 48 | publicDownloadNumbers = true 49 | version { 50 | desc = libraryDescription 51 | gpg { 52 | sign = true //Determines whether to GPG sign the files. The default is false 53 | passphrase = _passphrase 54 | //Optional. The passphrase for GPG signing' 55 | } 56 | } 57 | } 58 | } 59 | 60 | //from https://github.com/workarounds/bundler/blob/master/gradle/bintray-java-v1.gradle -------------------------------------------------------------------------------- /gradle/install-v1.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.github.dcendents.android-maven' 2 | 3 | group = publishedGroupId // Maven Group ID for the artifact 4 | 5 | install { 6 | repositories.mavenInstaller { 7 | // This generates POM.xml with proper parameters 8 | pom { 9 | project { 10 | packaging 'aar' 11 | groupId publishedGroupId 12 | artifactId artifact 13 | 14 | // Add your description here 15 | name libraryName 16 | description libraryDescription 17 | url siteUrl 18 | 19 | // Set your license 20 | licenses { 21 | license { 22 | name licenseName 23 | url licenseUrl 24 | } 25 | } 26 | developers { 27 | developer { 28 | id developerId 29 | name developerName 30 | email developerEmail 31 | } 32 | } 33 | scm { 34 | connection gitUrl 35 | developerConnection gitUrl 36 | url siteUrl 37 | 38 | } 39 | } 40 | } 41 | } 42 | } 43 | 44 | //from https://github.com/workarounds/bundler/blob/master/gradle/install-v1.gradle -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu Mar 22 20:23:47 CET 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-4.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 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /medias/auto.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/medias/auto.gif -------------------------------------------------------------------------------- /medias/finger.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/medias/finger.gif -------------------------------------------------------------------------------- /medias/finger.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/medias/finger.mp4 -------------------------------------------------------------------------------- /medias/test.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/medias/test.mp4 -------------------------------------------------------------------------------- /sample/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | app.iml -------------------------------------------------------------------------------- /sample/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion project.sdk 5 | 6 | defaultConfig { 7 | minSdkVersion project.minSdk 8 | targetSdkVersion project.sdk 9 | applicationId "com.gihub.florent37.depth.sample" 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | 14 | lintOptions { 15 | abortOnError false 16 | } 17 | } 18 | 19 | dependencies { 20 | compile fileTree(include: ['*.jar'], dir: 'libs') 21 | compile 'com.android.support:cardview-v7:'+ project.supportVersion 22 | compile 'com.android.support:design:'+ project.supportVersion 23 | compile project(':depth') 24 | 25 | compile 'com.github.florent37:awesomebar:1.0.2' 26 | } -------------------------------------------------------------------------------- /sample/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/danielzeller/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 | -------------------------------------------------------------------------------- /sample/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 11 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /sample/src/main/java/com/github/florent37/depth/sample/AutoAnimateActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.sample; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.NavUtils; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.support.v7.widget.Toolbar; 7 | import android.view.MenuItem; 8 | 9 | public class AutoAnimateActivity extends AppCompatActivity { 10 | 11 | @Override 12 | protected void onCreate(Bundle savedInstanceState) { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_auto_animate); 15 | 16 | final Toolbar toolbar = findViewById(R.id.toolbar); 17 | setSupportActionBar(toolbar); 18 | 19 | getSupportActionBar().setDisplayHomeAsUpEnabled(true); 20 | } 21 | 22 | @Override 23 | public boolean onOptionsItemSelected(MenuItem item) { 24 | switch (item.getItemId()) { 25 | case android.R.id.home: 26 | finish(); 27 | return true; 28 | } 29 | return super.onOptionsItemSelected(item); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /sample/src/main/java/com/github/florent37/depth/sample/FollowUserInputActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.sample; 2 | 3 | import android.graphics.drawable.AnimationDrawable; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.widget.LinearLayout; 7 | 8 | public class FollowUserInputActivity extends AppCompatActivity { 9 | 10 | AnimationDrawable anim; 11 | 12 | @Override 13 | protected void onCreate(Bundle savedInstanceState) { 14 | super.onCreate(savedInstanceState); 15 | setContentView(R.layout.activity_follow_user_input); 16 | 17 | LinearLayout container = (LinearLayout) findViewById(R.id.container); 18 | anim = (AnimationDrawable) container.getBackground(); 19 | anim.setEnterFadeDuration(6000); 20 | anim.setExitFadeDuration(2000); 21 | } 22 | 23 | 24 | // Starting animation:- start the animation on onResume. 25 | @Override 26 | protected void onResume() { 27 | super.onResume(); 28 | if (anim != null && !anim.isRunning()) 29 | anim.start(); 30 | } 31 | 32 | // Stopping animation:- stop the animation on onPause. 33 | @Override 34 | protected void onPause() { 35 | super.onPause(); 36 | if (anim != null && anim.isRunning()) 37 | anim.stop(); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /sample/src/main/java/com/github/florent37/depth/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.github.florent37.depth.sample; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | 8 | public class MainActivity extends AppCompatActivity { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | 15 | findViewById(R.id.followUserInput).setOnClickListener(new View.OnClickListener() { 16 | @Override 17 | public void onClick(View view) { 18 | start(FollowUserInputActivity.class); 19 | } 20 | }); 21 | 22 | findViewById(R.id.autoAnimate).setOnClickListener(new View.OnClickListener() { 23 | @Override 24 | public void onClick(View view) { 25 | start(AutoAnimateActivity.class); 26 | } 27 | }); 28 | } 29 | 30 | private void start(Class theClass) { 31 | startActivity(new Intent(this, theClass)); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/actionbar_shadow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/actionbar_shadow.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/aura_gradient.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/aura_gradient.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/aura_gradient_inner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/aura_gradient_inner.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/foam.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/foam.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/grunge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/grunge.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/ic_forward.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/ic_forward.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/marker_1px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/marker_1px.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/noise.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/noise.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/noise_scratch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/noise_scratch.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/smoke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/smoke.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/splash1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/splash1.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/splash2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/splash2.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/splash3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/splash3.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/splash4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/splash4.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/stones.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/stones.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/sun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/sun.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/sun_aura.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/sun_aura.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/water.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/water.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/water_scene_background.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/water_scene_background.9.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxhdpi/x_y.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxhdpi/x_y.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/ic_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxxhdpi/ic_menu.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable-xxxhdpi/mountains.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable-xxxhdpi/mountains.png -------------------------------------------------------------------------------- /sample/src/main/res/drawable/animation_list.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 9 | 12 | 15 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/circle_blue.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/color1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/color2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/color3.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/color4.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/depth_circle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /sample/src/main/res/drawable/homer.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable/homer.jpg -------------------------------------------------------------------------------- /sample/src/main/res/drawable/material.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/florent37/Android-3D-Layout/981611c5af76ca0d6d23c6a1ebf2b4cd655099a9/sample/src/main/res/drawable/material.png -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_auto_animate.xml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 14 | 15 | 20 | 21 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 43 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_follow_user_input.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 13 | 14 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /sample/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 |