11 |
12 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 Naseem Ali
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ShapedNavigationView
2 |
3 | [](https://jitpack.io/#naseemali925/ShapedNavigationView)
4 |
5 | This is an Android library to make Shaped NavigationViews inside your Android applications.
6 |
7 |
8 |
9 | # Usage
10 |
11 | ```xml
12 |
20 |
21 | ...
22 |
23 |
34 |
35 |
36 | ```
37 |
38 | ## With Java Code
39 |
40 | ```java
41 | navigationView = (ShapedNavigationView) findViewById(R.id.nav_view);
42 | navigationView.getSettings().setShapeType(ShapedViewSettings.WAVES);
43 | ```
44 |
45 | # Download
46 |
47 | Step 1. Add the JitPack repository to your Project build.gradle file
48 |
49 | ```grrovy
50 | allprojects {
51 | repositories {
52 | ...
53 | maven { url 'https://jitpack.io' }
54 | }
55 | }
56 | ```
57 | Step 2. Add the dependency to your App build.gradle file
58 |
59 | ```groovy
60 | dependencies {
61 | implementation 'com.github.naseemali925:ShapedNavigationView:1.0.0'
62 | }
63 | ```
64 |
65 | ## Values Table
66 |
67 |
68 |
Attribute
Value
Shape Type
69 |
drawerShape
arcConvex
70 |
drawerShape
arcConcave
71 |
drawerShape
roundedRect
72 |
drawerShape
waves
73 |
drawerShape
bottom_round
74 |
drawerShape
full_round
75 |
drawerShape
waves_indefinite
76 |
77 |
78 | ## Sample App
79 |
80 | You can check out the [sample app](https://github.com/naseemali925/ShapedNavigationView/tree/master/app)
81 |
82 | ## Acknowledgements
83 |
84 | Thanks to [Roman Zavarnitsyn](https://github.com/rom4ek) for his [ArcNavigationView](https://github.com/rom4ek/ArcNavigationView) Project Idea.
85 |
86 | Thanks to [Hama Omer](https://github.com/hama-Omer) for the Wavy Look Idea.
87 |
88 | # License
89 |
90 | MIT License
91 |
92 | Copyright (c) 2017 Naseem Ali
93 |
94 | Permission is hereby granted, free of charge, to any person obtaining a copy
95 | of this software and associated documentation files (the "Software"), to deal
96 | in the Software without restriction, including without limitation the rights
97 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
98 | copies of the Software, and to permit persons to whom the Software is
99 | furnished to do so, subject to the license conditions.
100 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 27
5 | defaultConfig {
6 | applicationId "softpro.softnavigation"
7 | minSdkVersion 19
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:27.1.1'
24 | implementation 'com.android.support:design:27.1.1'
25 | implementation 'com.android.support.constraint:constraint-layout:1.1.0'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 | implementation 'com.android.support:recyclerview-v7:27.1.1'
30 | implementation 'com.android.support:cardview-v7:27.1.1'
31 | implementation 'de.hdodenhof:circleimageview:2.2.0'
32 | implementation project(':shapednavigationview')
33 | }
34 |
--------------------------------------------------------------------------------
/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 C:\Users\hp\AppData\Local\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/softpro/softnavigation/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package softpro.softnavigation;
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("softpro.softnavigation", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/app/src/main/java/softpro/softnavigation/MainActivity.java:
--------------------------------------------------------------------------------
1 | package softpro.softnavigation;
2 |
3 | import android.os.Bundle;
4 | import android.support.design.widget.FloatingActionButton;
5 | import android.support.design.widget.Snackbar;
6 | import android.view.View;
7 | import android.support.design.widget.NavigationView;
8 | import android.support.v4.view.GravityCompat;
9 | import android.support.v4.widget.DrawerLayout;
10 | import android.support.v7.app.ActionBarDrawerToggle;
11 | import android.support.v7.app.AppCompatActivity;
12 | import android.support.v7.widget.Toolbar;
13 | import android.view.Menu;
14 | import android.view.MenuItem;
15 |
16 | import softpro.naseemali.ShapedNavigationView;
17 | import softpro.naseemali.ShapedViewSettings;
18 |
19 | public class MainActivity extends AppCompatActivity
20 | implements NavigationView.OnNavigationItemSelectedListener {
21 | private ShapedNavigationView navigationView;
22 |
23 | @Override
24 | protected void onCreate(Bundle savedInstanceState) {
25 | super.onCreate(savedInstanceState);
26 | setContentView(R.layout.activity_main);
27 | Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
28 | setSupportActionBar(toolbar);
29 |
30 | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
31 | fab.setOnClickListener(new View.OnClickListener() {
32 | @Override
33 | public void onClick(View view) {
34 | Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
35 | .setAction("Action", null).show();
36 | }
37 | });
38 |
39 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
40 | ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
41 | this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
42 | drawer.setDrawerListener(toggle);
43 | toggle.syncState();
44 |
45 | navigationView = (ShapedNavigationView) findViewById(R.id.nav_view);
46 | navigationView.setNavigationItemSelectedListener(this);
47 | }
48 |
49 | @Override
50 | public void onBackPressed() {
51 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
52 | if (drawer.isDrawerOpen(GravityCompat.START)) {
53 | drawer.closeDrawer(GravityCompat.START);
54 | } else {
55 | super.onBackPressed();
56 | }
57 | }
58 |
59 | @Override
60 | public boolean onCreateOptionsMenu(Menu menu) {
61 | // Inflate the menu; this adds items to the action bar if it is present.
62 | getMenuInflater().inflate(R.menu.main, menu);
63 | return true;
64 | }
65 |
66 | @Override
67 | public boolean onOptionsItemSelected(MenuItem item) {
68 | // Handle action bar item clicks here. The action bar will
69 | // automatically handle clicks on the Home/Up button, so long
70 | // as you specify a parent activity in AndroidManifest.xml.
71 | int id = item.getItemId();
72 | switch (id){
73 | case R.id.waves:
74 | navigationView.getSettings().setShapeType(ShapedViewSettings.WAVES);
75 | break;
76 | case R.id.waves_indefinite:
77 | navigationView.getSettings().setShapeType(ShapedViewSettings.WAVES_INDEFINITE);
78 | break;
79 | case R.id.rounded_bottom:
80 | navigationView.getSettings().setShapeType(ShapedViewSettings.BOTTOM_ROUND);
81 | break;
82 | case R.id.full_rounded:
83 | navigationView.getSettings().setShapeType(ShapedViewSettings.FULL_ROUND);
84 | break;
85 | case R.id.arcConvex:
86 | navigationView.getSettings().setShapeType(ShapedViewSettings.ARC_CONVEX);
87 | break;
88 | case R.id.arcConcave:
89 | navigationView.getSettings().setShapeType(ShapedViewSettings.ARC_CONCAVE);
90 | break;
91 | case R.id.rounded_corners:
92 | navigationView.getSettings().setShapeType(ShapedViewSettings.ROUNDED_RECT);
93 | break;
94 | case R.id.normal:
95 | navigationView.getSettings().setShapeType(ShapedViewSettings.NORMAL);
96 | break;
97 | }
98 |
99 | return super.onOptionsItemSelected(item);
100 | }
101 |
102 | @SuppressWarnings("StatementWithEmptyBody")
103 | @Override
104 | public boolean onNavigationItemSelected(MenuItem item) {
105 | // Handle navigation view item clicks here.
106 | int id = item.getItemId();
107 |
108 | if (id == R.id.nav_camera) {
109 | // Handle the camera action
110 | } else if (id == R.id.nav_gallery) {
111 |
112 | } else if (id == R.id.nav_slideshow) {
113 |
114 | } else if (id == R.id.nav_manage) {
115 |
116 | } else if (id == R.id.nav_share) {
117 |
118 | } else if (id == R.id.nav_send) {
119 |
120 | }
121 |
122 | DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
123 | drawer.closeDrawer(GravityCompat.START);
124 | return true;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_camera.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_gallery.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_manage.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_send.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_share.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/ic_menu_slideshow.xml:
--------------------------------------------------------------------------------
1 |
6 |
9 |
10 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable-v21/naseem.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/drawable-v21/naseem.jpg
--------------------------------------------------------------------------------
/app/src/main/res/drawable/side_nav_bar.xml:
--------------------------------------------------------------------------------
1 |
3 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
15 |
16 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/app_bar_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
20 |
21 |
22 |
23 |
24 |
25 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/nav_header_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 |
22 |
23 |
30 |
31 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/activity_main_drawer.xml:
--------------------------------------------------------------------------------
1 |
2 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
14 |
19 |
24 |
29 |
34 |
39 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 16dp
6 | 160dp
7 | 16dp
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/drawables.xml:
--------------------------------------------------------------------------------
1 |
2 | @android:drawable/ic_menu_camera
3 | @android:drawable/ic_menu_gallery
4 | @android:drawable/ic_menu_slideshow
5 | @android:drawable/ic_menu_manage
6 | @android:drawable/ic_menu_share
7 | @android:drawable/ic_menu_send
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Soft Navigation
3 |
4 | Open navigation drawer
5 | Close navigation drawer
6 |
7 | Settings
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/app/src/test/java/softpro/softnavigation/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package softpro.softnavigation;
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 |
5 | repositories {
6 | google()
7 | jcenter()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.1.2'
11 |
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 | google()
21 | jcenter()
22 | }
23 | }
24 |
25 | task clean(type: Delete) {
26 | delete rootProject.buildDir
27 | }
28 |
--------------------------------------------------------------------------------
/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/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 20 20:32:06 IST 2017
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.4-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 |
--------------------------------------------------------------------------------
/images/bottom_rounded.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/bottom_rounded.png
--------------------------------------------------------------------------------
/images/concave.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/concave.png
--------------------------------------------------------------------------------
/images/convex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/convex.png
--------------------------------------------------------------------------------
/images/full_rounded.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/full_rounded.png
--------------------------------------------------------------------------------
/images/normal.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/normal.png
--------------------------------------------------------------------------------
/images/rounded_corner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/rounded_corner.png
--------------------------------------------------------------------------------
/images/waves.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/waves.png
--------------------------------------------------------------------------------
/images/waves_indefinte.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/inaseem/ShapedNavigationView/d5cf12b73f4a21b30feca3ad27634387bd22a005/images/waves_indefinte.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':shapednavigationview'
2 |
--------------------------------------------------------------------------------
/shapednavigationview/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/shapednavigationview/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | buildToolsVersion "27.1.1"
5 | compileSdkVersion 27
6 | defaultConfig {
7 | minSdkVersion 19
8 | targetSdkVersion 27
9 | versionCode 1
10 | versionName "1.0"
11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | implementation fileTree(dir: 'libs', include: ['*.jar'])
23 | implementation 'com.android.support:appcompat-v7:27.1.1'
24 | implementation 'com.android.support:design:27.1.1'
25 | implementation 'com.android.support.constraint:constraint-layout:1.1.0'
26 | testImplementation 'junit:junit:4.12'
27 | androidTestImplementation 'com.android.support.test:runner:1.0.2'
28 | androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
29 | }
30 |
--------------------------------------------------------------------------------
/shapednavigationview/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\hp\AppData\Local\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 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/java/softpro/naseemali/ShapedNavigationView.java:
--------------------------------------------------------------------------------
1 | package softpro.naseemali;
2 |
3 | /**
4 | * Created by Naseem on 18-10-2017.
5 | */
6 |
7 |
8 | import android.annotation.SuppressLint;
9 | import android.content.Context;
10 | import android.graphics.Canvas;
11 | import android.graphics.Color;
12 | import android.graphics.Path;
13 | import android.graphics.drawable.ColorDrawable;
14 | import android.os.Build;
15 | import android.support.design.internal.NavigationMenuView;
16 | import android.support.design.internal.ScrimInsetsFrameLayout;
17 | import android.support.design.widget.NavigationView;
18 | import android.support.v4.widget.DrawerLayout;
19 | import android.util.AttributeSet;
20 | import android.view.View;
21 |
22 | import java.lang.reflect.Field;
23 |
24 | /**
25 | * Created by rom4ek on 10.01.2017.
26 | */
27 |
28 | public class ShapedNavigationView extends NavigationView {
29 |
30 | private ShapedViewSettings settings;
31 | private int height = 0;
32 | private int width = 0;
33 |
34 | public ShapedNavigationView(Context context) {
35 | super(context);
36 | init(context, null);
37 | }
38 |
39 | public ShapedNavigationView(Context context, AttributeSet attrs) {
40 | super(context, attrs);
41 | init(context, attrs);
42 | }
43 |
44 | public void init(Context context, AttributeSet attrs) {
45 | settings = new ShapedViewSettings(context, attrs);
46 |
47 | /**
48 | * If hardware acceleration is on (default from API 14), clipPath worked correctly
49 | * from API 18.
50 | *
51 | * So we will disable hardware Acceleration if API < 18
52 | *
53 | * https://developer.android.com/guide/topics/graphics/hardware-accel.html#unsupported
54 | * Section #Unsupported Drawing Operations
55 | */
56 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
57 | setLayerType(View.LAYER_TYPE_SOFTWARE, null);
58 | }
59 | setBackgroundColor(Color.TRANSPARENT);
60 | setInsetsColor(Color.TRANSPARENT);
61 | }
62 |
63 | private void setInsetsColor(int color) {
64 | try {
65 | Field insetForegroundField = ScrimInsetsFrameLayout.class.getDeclaredField("mInsetForeground");
66 | insetForegroundField.setAccessible(true);
67 | ColorDrawable colorDrawable = new ColorDrawable(color);
68 | insetForegroundField.set(this, colorDrawable);
69 | } catch (NoSuchFieldException e) {
70 | e.printStackTrace();
71 | } catch (IllegalAccessException e) {
72 | e.printStackTrace();
73 | }
74 | }
75 |
76 | @Override
77 | protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
78 | super.onLayout(changed, left, top, right, bottom);
79 | final int count = getChildCount();
80 | for (int i = 0; i < count; i++) {
81 | final View v = getChildAt(i);
82 |
83 | if (v instanceof NavigationMenuView) {
84 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
85 | v.setBackground(settings.getBackgroundDrawable());
86 | } else {
87 | v.setBackgroundDrawable(settings.getBackgroundDrawable());
88 | }
89 | }
90 | }
91 | }
92 |
93 |
94 | @Override
95 | protected void measureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) {
96 | if (child instanceof NavigationMenuView) {
97 | child.measure(View.MeasureSpec.makeMeasureSpec(getMeasuredWidth(),
98 | View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(
99 | getMeasuredHeight(), View.MeasureSpec.EXACTLY));
100 | } else {
101 | super.measureChild(child, parentWidthMeasureSpec, parentHeightMeasureSpec);
102 | }
103 | }
104 |
105 | @Override
106 | protected void dispatchDraw(Canvas canvas) {
107 | canvas.save();
108 | canvas.clipPath(createClipPath(settings.getShapeType()));
109 | super.dispatchDraw(canvas);
110 | canvas.restore();
111 | }
112 |
113 | @SuppressLint("RtlHardcoded")
114 | private Path createClipPath(int type) {
115 | Path path = new Path();
116 | width = getMeasuredWidth();
117 | height = getMeasuredHeight();
118 | DrawerLayout.LayoutParams layoutParams = (DrawerLayout.LayoutParams) getLayoutParams();
119 | boolean rtl = getResources().getBoolean(R.bool.is_right_to_left);
120 | if (layoutParams.getLayoutDirection() == LAYOUT_DIRECTION_RTL || getResources().getBoolean(R.bool.is_right_to_left) == true) {
121 | rtl = true;
122 | } else {
123 | rtl = false;
124 | }
125 | if (rtl) {
126 | switch (type) {
127 | case ShapedViewSettings.ARC_CONVEX:
128 | path.moveTo(width, 0);
129 | path.lineTo(width / 8, 0);
130 | path.quadTo(0, height / 2,
131 | width / 8, height);
132 | path.lineTo(width, height);
133 | path.close();
134 | break;
135 | case ShapedViewSettings.ARC_CONCAVE:
136 | path.moveTo(width, 0);
137 | path.lineTo(0, 0);
138 | path.quadTo(width / 8, height / 2,
139 | 0, height);
140 | path.lineTo(width, height);
141 | path.close();
142 | break;
143 | case ShapedViewSettings.WAVES:
144 | path.moveTo(width, 0);
145 | path.quadTo(width / 2, 0, width / 2, height / 8);
146 | path.quadTo(width / 2, height / 2 - width / 2, width / 2 - width / 4, height / 2 - width / 4);
147 | path.quadTo(0, height / 2, width / 2 - width / 4, height / 2 + width / 4);
148 | path.quadTo(width / 2, height / 2 + width / 2, width / 2, height - height / 8);
149 | path.quadTo(width / 2, height, width, height);
150 | path.close();
151 | break;
152 | case ShapedViewSettings.WAVES_INDEFINITE:
153 | int num = 51;
154 | float wavewidth = height / num;
155 | float mh = 0;
156 | float fr = wavewidth / 2;
157 | path.moveTo(width, 0);
158 | path.lineTo(wavewidth, 0);
159 | for (int i = 0; i < num + 1; ++i) {
160 | if (i % 2 == 0) {
161 | path.quadTo(0, mh += fr, wavewidth, mh += fr);
162 | } else {
163 | path.quadTo(2 * wavewidth, mh += fr, wavewidth, mh += fr);
164 | }
165 | }
166 | path.lineTo(width, height);
167 | path.close();
168 | break;
169 | case ShapedViewSettings.ROUNDED_RECT:
170 | path.moveTo(0, width / 8);
171 | path.quadTo(0, 0, width / 8, 0);
172 | path.lineTo(width - width / 8, 0);
173 | path.quadTo(width, 0, width, width / 8);
174 | path.lineTo(width, height - width / 8);
175 | path.quadTo(width, height, width - width / 8, height);
176 | path.lineTo(width / 8, height);
177 | path.quadTo(0, height, 0, height - width / 8);
178 | path.close();
179 | break;
180 | case ShapedViewSettings.BOTTOM_ROUND:
181 | path.moveTo(0, 0);
182 | path.lineTo(width, 0);
183 | path.lineTo(width, height - height / 4);
184 | path.quadTo(width / 2, height, 0, height - height / 4);
185 | path.close();
186 | break;
187 | case ShapedViewSettings.FULL_ROUND:
188 | path.moveTo(width, 0);
189 | path.quadTo(0, 0, 0, height / 2);
190 | path.quadTo(0, height, width, height);
191 | path.close();
192 | break;
193 | case ShapedViewSettings.NORMAL:
194 | path.moveTo(0, 0);
195 | path.lineTo(width, 0);
196 | path.lineTo(width, height);
197 | path.lineTo(0, height);
198 | path.close();
199 | }
200 | } else {
201 | switch (type) {
202 | case ShapedViewSettings.ARC_CONVEX:
203 | path.moveTo(0, 0);
204 | path.lineTo(width, 0);
205 | path.quadTo(width - width / 4, height / 2,
206 | width, height);
207 | path.lineTo(0, height);
208 | path.close();
209 | break;
210 | case ShapedViewSettings.ARC_CONCAVE:
211 | path.moveTo(0, 0);
212 | path.lineTo(width - width / 8, 0);
213 | path.quadTo(width + width / 8, height / 2,
214 | width - width / 8, height);
215 | path.lineTo(0, height);
216 | path.close();
217 | break;
218 | case ShapedViewSettings.WAVES:
219 | path.moveTo(0, 0);
220 | path.quadTo(width / 2, 0, width / 2, height / 8);
221 | path.quadTo(width / 2, height / 2 - width / 2, width / 2 + width / 4, height / 2 - width / 4);
222 | path.quadTo(width, height / 2, width / 2 + width / 4, height / 2 + width / 4);
223 | path.quadTo(width / 2, height / 2 + width / 2, width / 2, height - height / 8);
224 | path.quadTo(width / 2, height, 0, height);
225 | path.close();
226 | break;
227 | case ShapedViewSettings.WAVES_INDEFINITE:
228 | path.moveTo(0, 0);
229 | int num = 51;
230 | float wavewidth = height / num;
231 | path.lineTo(width - height / num, 0);
232 | float mh = 0;
233 | float fr = wavewidth / 2;
234 | for (int i = 0; i < num + 1; ++i) {
235 | if (i % 2 == 0) {
236 | path.quadTo(width, mh += fr, width - wavewidth, mh += fr);
237 | } else {
238 | path.quadTo(width - 2 * wavewidth, mh += fr, width - wavewidth, mh += fr);
239 | }
240 | }
241 | path.lineTo(0, height);
242 | path.close();
243 | break;
244 | case ShapedViewSettings.ROUNDED_RECT:
245 | path.moveTo(0, width / 8);
246 | path.quadTo(0, 0, width / 8, 0);
247 | path.lineTo(width - width / 8, 0);
248 | path.quadTo(width, 0, width, width / 8);
249 | path.lineTo(width, height - width / 8);
250 | path.quadTo(width, height, width - width / 8, height);
251 | path.lineTo(width / 8, height);
252 | path.quadTo(0, height, 0, height - width / 8);
253 | path.close();
254 | break;
255 | case ShapedViewSettings.BOTTOM_ROUND:
256 | path.moveTo(0, 0);
257 | path.lineTo(width, 0);
258 | path.lineTo(width, height - height / 4);
259 | path.quadTo(width / 2, height, 0, height - height / 4);
260 | path.close();
261 | break;
262 | case ShapedViewSettings.FULL_ROUND:
263 | path.moveTo(0, 0);
264 | path.quadTo(width, 0, width, height / 2);
265 | path.quadTo(width, height, 0, height);
266 | path.close();
267 | break;
268 | case ShapedViewSettings.NORMAL:
269 | path.moveTo(0, 0);
270 | path.lineTo(width, 0);
271 | path.lineTo(width, height);
272 | path.lineTo(0, height);
273 | path.close();
274 | }
275 | }
276 | return path;
277 | }
278 |
279 | public ShapedViewSettings getSettings() {
280 | return settings;
281 | }
282 |
283 | }
284 |
285 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/java/softpro/naseemali/ShapedViewSettings.java:
--------------------------------------------------------------------------------
1 | package softpro.naseemali;
2 |
3 | /**
4 | * Created by Naseem on 18-10-2017.
5 | */
6 |
7 |
8 | import android.content.Context;
9 | import android.content.res.TypedArray;
10 | import android.graphics.Color;
11 | import android.graphics.drawable.ColorDrawable;
12 | import android.graphics.drawable.Drawable;
13 | import android.util.AttributeSet;
14 |
15 | public class ShapedViewSettings {
16 | public final static int ARC_CONCAVE = 0;
17 | public final static int ARC_CONVEX = 1;
18 | public final static int ROUNDED_RECT = 2;
19 | public final static int WAVES = 3;
20 | public final static int BOTTOM_ROUND = 4;
21 | public final static int FULL_ROUND = 5;
22 | public final static int WAVES_INDEFINITE = 6;
23 | public final static int NORMAL = 7;
24 | private int shapeType;
25 | private Drawable backgroundDrawable = new ColorDrawable(Color.WHITE); //default background color of navigation view
26 |
27 | public ShapedViewSettings(Context context, AttributeSet attrs) {
28 | TypedArray styledAttributes = context.obtainStyledAttributes(attrs, R.styleable.ShapedDrawer, 0, 0);
29 | final int shape = styledAttributes.getInt(R.styleable.ShapedDrawer_drawerShape, NORMAL);
30 | switch (shape) {
31 | case 0:
32 | shapeType = ARC_CONCAVE;
33 | break;
34 | case 1:
35 | shapeType = ARC_CONVEX;
36 | break;
37 | case 2:
38 | shapeType = ROUNDED_RECT;
39 | break;
40 | case 3:
41 | shapeType = WAVES;
42 | break;
43 | case 4:
44 | shapeType = BOTTOM_ROUND;
45 | break;
46 | case 5:
47 | shapeType = FULL_ROUND;
48 | break;
49 | case 6:
50 | shapeType = WAVES_INDEFINITE;
51 | break;
52 | default:
53 | shapeType = NORMAL;
54 | }
55 |
56 | int[] attrsArray = new int[]{
57 | android.R.attr.background,
58 | android.R.attr.layout_gravity,
59 | };
60 |
61 | TypedArray androidAttrs = context.obtainStyledAttributes(attrs, attrsArray);
62 | backgroundDrawable = androidAttrs.getDrawable(0);
63 |
64 | androidAttrs.recycle();
65 | styledAttributes.recycle();
66 | }
67 |
68 | public int getShapeType() {
69 | return shapeType;
70 | }
71 |
72 | public void setShapeType(int shapeType) {
73 | this.shapeType = shapeType;
74 | }
75 |
76 | public Drawable getBackgroundDrawable() {
77 | return backgroundDrawable;
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/res/values-ldrtl/isrighttoleft.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | true
4 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/res/values/isrighttoleft.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | false
4 |
--------------------------------------------------------------------------------
/shapednavigationview/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | ShapedNavigationView
3 |
4 |
--------------------------------------------------------------------------------