diff --git a/CHANGELOG.md b/CHANGELOG.md
index ccc4f0b..0b14093 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,12 +1,30 @@
Change Log
==========
+Version 2.0.0f (2016-09-15) *[fork update]*
+----------------------------
+
+Update fork to be in up to date to the main repo.
+
+Version 2.0.0 (2016-09-15)
+----------------------------
+
+- Stripping main library classes to bare minimum - `MaterialMenuDrawable` and `MaterialMenuView`.
+- Added `app:mm_iconState="enum"` attribute to `MaterialMenuView` that allows setting the
+initial state of the drawable.
+
Version 1.6.0 (2016-09-11)
----------------------------
+**Major update**
+
- Fork repo
- Move repository to jcenter
-- Drop deprecated compatibility by remove depencency to NineOldAndroids, ActionBarCompat and ActionBarSherlock (change min api to 11)
+- Removed `nineoldadroids` dependency!
+- Removed all `extras` packages since ActionBarCompat or ActionBarSherlock are not being maintained
+for quite a while now. Most usages will be with `Toolbar`. Integrating the drawable into it will be up
+to the user of the library (see README or demo).
+- Bumped min api version to 14
- Update demo support libs
Version 1.5.4 (2015-05-30)
diff --git a/README-1.0.md b/README-1.0.md
new file mode 100644
index 0000000..5ab0f95
--- /dev/null
+++ b/README-1.0.md
@@ -0,0 +1,293 @@
+Material Menu
+===============
+
+This document is a reference for versions up to 1.5.5 which are old and **unmaintained**. Please use version 2.0.0+ for latest features.
+
+Including in your project
+-------------------------
+
+
+```groovy
+// stock actionBar
+compile 'com.balysv.materialmenu:material-menu:1.5.5'
+
+// Toolbar and ActionBarCompat-v22 (includes support-v7:22.0.x)
+compile 'com.balysv.materialmenu:material-menu-toolbar:1.5.5'
+
+// actionBarCompat-v20 (up to support-v7:20.0.0 - does not support Toolbar)
+compile 'com.balysv.materialmenu:material-menu-abc:1.5.5'
+
+// actionBarSherlock
+compile 'com.balysv.materialmenu:material-menu-abs:1.5.5'
+```
+
+Usage
+-----
+
+The library provides two wrappers of `MaterialMenuDrawable` that eases implementation into the ActionBar, NavigationDrawer slide interaction or into any other custom layout.
+
+### MaterialMenuView
+
+A plain old `View` that draws the icon and provides an API to manipulate its state.
+
+Customisation is also available through attributes:
+
+```xml
+app:mm_color="color" // Color of drawable
+app:mm_visible="boolean" // Visible
+app:mm_transformDuration="integer" // Transformation animation duration
+app:mm_scale="integer" // Scale factor of drawable
+app:mm_strokeWidth="integer" // Stroke width of icons (can only be 1, 2 or 3)
+app:mm_rtlEnabled="boolean" // Enabled RTL layout support (flips all drawables)
+app:mm_iconState="enum" // Set the intial state of the drawable (burger, arrow, x or check)
+```
+
+### MaterialMenuIcon
+
+A POJO that initializes the drawable and replaces the ActionBar icon.
+
+Jump to instructions for :
+- [ActionBar (stock, Sherlock, Compat)]( https://github.com/balysv/material-menu#use-as-action-bar-icon-stock-compat-or-sherlock)
+- [Toolbar](https://github.com/balysv/material-menu#use-in-toolbar)
+- [NavigationDrawer interaction ](https://github.com/balysv/material-menu#navigationdrawer-slide-interaction)
+
+## API
+
+There are four icon states:
+
+```java
+BURGER, ARROW, X, CHECK
+```
+
+To morph the drawable state
+
+```java
+MaterialMenu.animateState(IconState state)
+```
+
+To change the drawable state without animation
+
+```java
+MaterialMenu.setState(IconState state)
+```
+
+To animate the drawable manually (i.e. on navigation drawer slide):
+
+```java
+MaterialMenu.setTransformationOffset(AnimationState state, float value)
+```
+To hide or show the drawable:
+
+```java
+MaterialMenu.setVisible(boolean visible)
+```
+
+where `AnimationState` is one of `BURGER_ARROW, BURGER_X, ARROW_X, ARROW_CHECK, BURGER_CHECK, X_CHECK`
+and `value` is between `0` and `2`
+
+**Note:** The current implementation resolves its state by current offset value. Make sure you use `offset` between `0` and `1` for forward animation and `1` and `2` for backwards to correctly save icon state on activity recreation.
+
+### Customisation
+
+```java
+// change color
+MaterialMenu.setColor(int color)
+
+// change icon visibility
+MaterialMenu.setVisible(boolean visible)
+
+// change transformation animation duration
+MaterialMenu.setTransformationDuration(int duration)
+
+// change transformation interpolator
+MaterialMenu.setInterpolator(Interpolator interpolator)
+
+// set RTL layout support
+MaterialMenu.setRTLEnabled(boolean enabled)
+```
+
+### Action Bar
+
+#### Use as Action Bar icon (stock, Compat or Sherlock)
+
+Depending on the `ActionBar` you use, use one of the following classes:
+`MaterialMenuIcon`, `MaterialMenuIconCompat` or `MaterialMenuIconSherlock`.
+
+In your `Activity` add the following:
+
+```java
+protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ materialMenu = new MaterialMenuIcon(this, Color.WHITE, Stroke.THIN);
+}
+
+protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ materialMenu.syncState(savedInstanceState);
+}
+
+protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ materialMenu.onSaveInstanceState(outState);
+}
+
+public boolean onOptionsItemSelected(MenuItem item) {
+ if (item.getId() == android.R.id.home) {
+ // Handle your drawable state here
+ materialMenu.animateState(newState);
+ }
+}
+```
+
+#### Use in Toolbar
+
+Use it as a standalone drawable. Note: you have to handle icon state yourself:
+
+```java
+private MaterialMenuDrawable materialMenu;
+
+protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ // Handle your drawable state here
+ materialMenu.animateState(newState);
+ }
+ });
+ materialMenu = new MaterialMenuDrawable(this, Color.WHITE, Stroke.THIN);
+ toolbar.setNavigationIcon(materialMenu);
+}
+```
+
+OR
+
+Use `MaterialMenuIconToolbar` which handles saved state:
+
+```java
+private MaterialMenuIconToolbar materialMenu;
+
+@Override
+protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ // Handle your drawable state here
+ materialMenu.animateState(newState);
+ }
+ });
+ materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, Stroke.THIN) {
+ @Override public int getToolbarViewId() {
+ return R.id.toolbar;
+ }
+ };
+}
+
+@Override
+protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ materialMenu.syncState(savedInstanceState);
+}
+
+@Override protected void onSaveInstanceState(Bundle outState) {
+ materialMenu.onSaveInstanceState(outState);
+ super.onSaveInstanceState(outState);
+}
+```
+
+#### Use in custom Action Bar view
+
+Simply add `MaterialMenuView` in your custom layout and register an `OnClickListener` to do the
+transformations.
+
+See [source of Demo][2] for details
+
+#### NavigationDrawer slide interaction
+
+Implement `MaterialMenu` into your ActionBar as described above and add a custom `DrawerListener`:
+
+```java
+private DrawerLayout drawerLayout;
+private boolean isDrawerOpened;
+private MaterialMenuIcon materialMenu;
+
+@Override
+protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ materialMenu = new MaterialMenuIcon(this, Color.WHITE, Stroke.THIN); // or retrieve from your custom view, etc
+ drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
+ drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
+ @Override
+ public void onDrawerSlide(View drawerView, float slideOffset) {
+ materialMenu.setTransformationOffset(
+ MaterialMenuDrawable.AnimationState.BURGER_ARROW,
+ isDrawerOpened ? 2 - slideOffset : slideOffset
+ );
+ }
+
+ @Override
+ public void onDrawerOpened(View drawerView) {
+ isDrawerOpened = true;
+ }
+
+ @Override
+ public void onDrawerClosed(View drawerView) {
+ isDrawerOpened = false;
+ }
+
+ @Override
+ public void onDrawerStateChanged(int newState) {
+ if(newState == DrawerLayout.STATE_IDLE) {
+ if(isDrawerOpened) menu.setState(MaterialMenuDrawable.IconState.ARROW)
+ else menu.setState(MaterialMenuDrawable.IconState.BURGER)
+ }
+ }
+ });
+}
+
+
+@Override
+protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ isDrawerOpened = drawerLayout.isDrawerOpen(Gravity.START); // or END, LEFT, RIGHT
+ materialMenu.syncState(savedInstanceState);
+}
+
+@Override
+protected void onSaveInstanceState(Bundle outState) {
+ super.onSaveInstanceState(outState);
+ materialMenu.onSaveInstanceState(outState);
+}
+```
+
+Developed By
+--------------------
+Balys Valentukevicius @ [Lemon Labs][1]
+
+License
+-----------
+
+```
+Copyright 2014 Balys Valentukevicius
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+```
+
+[1]: http://www.lemonlabs.co
+[2]: https://github.com/balysv/material-menu/blob/master/demo/src/stock/java/com/balysv/materialmenu/demo/stock/CustomViewActivity.java
+[3]: http://gradleplease.appspot.com/
diff --git a/README.md b/README.md
index a27b563..6717d9c 100644
--- a/README.md
+++ b/README.md
@@ -10,31 +10,43 @@ Have full control of the animation:
##Including in your project
-[![Bintray](https://img.shields.io/bintray/v/sosite/maven/material-menu.svg)](https://bintray.com/sosite/maven/material-menu/_latestVersion) [Releases](https://github.com/sosite/material-menu/releases)
-
```groovy
-// stock actionBar
-compile 'com.socros.android.lib:material-menu:1.6.0'
-
-// Toolbar and ActionBarCompat-v22 (includes support-v7:22.1.1)
-compile 'com.balysv.materialmenu:material-menu-toolbar:1.5.4'
+compile 'com.socros.android.lib:material-menu:2.0.0f'
```
-```groovy
-repositories {
- jcenter()
-}
-```
+[![Bintray](https://img.shields.io/bintray/v/sosite/maven/material-menu.svg)](https://bintray.com/sosite/maven/material-menu/_latestVersion) [Releases](https://github.com/sosite/material-menu/releases)
##Usage
-The library provides two wrappers of `MaterialMenuDrawable` that eases implementation into the ActionBar, NavigationDrawer slide interaction or into any other custom layout.
+###MaterialMenuDrawable
+
+Use it as a standalone drawable in your `Toolbar`:
+
+```java
+private MaterialMenuDrawable materialMenu;
+
+protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.toolbar);
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ // Handle your drawable state here
+ materialMenu.animateState(newState);
+ }
+ });
+ materialMenu = new MaterialMenuDrawable(this, Color.WHITE, Stroke.THIN);
+ toolbar.setNavigationIcon(materialMenu);
+}
+```
###MaterialMenuView
-A plain old `View` that draws the icon and provides an API to manipulate its state.
+A plain old `View` that draws the icon and provides an API to manipulate its state. You can embed it
+in any layout including a `Toolbar`.
-Customisation is also available through attributes:
+Customisation is also available through xml attributes:
```xml
app:mm_color="color" // Color of drawable
@@ -43,17 +55,9 @@ app:mm_transformDuration="integer" // Transformation animation duration
app:mm_scale="integer" // Scale factor of drawable
app:mm_strokeWidth="integer" // Stroke width of icons (can only be 1, 2 or 3)
app:mm_rtlEnabled="boolean" // Enabled RTL layout support (flips all drawables)
+app:mm_iconState="enum" // Set the intial state of the drawable (burger, arrow, x or check)
```
-###MaterialMenuIcon
-
-A POJO that initializes the drawable and replaces the ActionBar icon.
-
-Jump to instructions for :
-- [ActionBar](#use-as-action-bar-icon)
-- [Toolbar](#use-in-toolbar)
-- [NavigationDrawer interaction](#navigationdrawer-slide-interaction)
-
##API
There are four icon states:
@@ -65,13 +69,13 @@ BURGER, ARROW, X, CHECK
To morph the drawable state
```java
-MaterialMenu.animateState(IconState state)
+MaterialMenu.animateIconState(IconState state)
```
To change the drawable state without animation
```java
-MaterialMenu.setState(IconState state)
+MaterialMenu.setIconState(IconState state)
```
To animate the drawable manually (i.e. on navigation drawer slide):
@@ -88,136 +92,25 @@ MaterialMenu.setVisible(boolean visible)
where `AnimationState` is one of `BURGER_ARROW, BURGER_X, ARROW_X, ARROW_CHECK, BURGER_CHECK, X_CHECK`
and `value` is between `0` and `2`
-**Note:** The current implementation resolves its state by current offset value. Make sure you use `offset` between `0` and `1` for forward animation and `1` and `2` for backwards to correctly save icon state on activity recreation.
-
-###Customisation
-
-```java
-// change color
-MaterialMenu.setColor(int color)
-
-// change icon visibility
-MaterialMenu.setVisible(boolean visible)
-
-// change transformation animation duration
-MaterialMenu.setTransformationDuration(int duration)
-
-// change transformation interpolator
-MaterialMenu.setInterpolator(Interpolator interpolator)
-
-// set RTL layout support
-MaterialMenu.setRTLEnabled(boolean enabled)
-```
-
-###Use as Action Bar icon
-
-In your `Activity` add the following:
-
-```java
-protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- materialMenu = new MaterialMenuIcon(this, Color.WHITE, Stroke.THIN);
-}
-
-protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- materialMenu.syncState(savedInstanceState);
-}
-
-protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- materialMenu.onSaveInstanceState(outState);
-}
+**Note:** The icon state is resolved by current offset value. Make sure you use `offset` between `0` and `1` for forward animation and `1` and `2` for backwards to correctly save icon state on activity recreation.
-public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getId() == android.R.id.home) {
- // Handle your drawable state here
- materialMenu.animateState(newState);
- }
-}
-```
+## NavigationDrawer slide interaction
-###Use in Toolbar
-
-Use it as a standalone drawable. Note: you have to handle icon state yourself:
+Implement `MaterialMenu` into your ActionBar as described above and add a custom `DrawerListener`:
```java
+private DrawerLayout drawerLayout;
+private boolean isDrawerOpened;
private MaterialMenuDrawable materialMenu;
+@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.toolbar);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override public void onClick(View v) {
- // Handle your drawable state here
- materialMenu.animateState(newState);
- }
- });
materialMenu = new MaterialMenuDrawable(this, Color.WHITE, Stroke.THIN);
toolbar.setNavigationIcon(materialMenu);
-}
-```
-
-OR
-
-Use `MaterialMenuIconToolbar` which handles saved state:
-
-```java
-private MaterialMenuIconToolbar materialMenu;
-@Override
-protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.toolbar);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override public void onClick(View v) {
- // Handle your drawable state here
- materialMenu.animateState(newState);
- }
- });
- materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, Stroke.THIN) {
- @Override public int getToolbarViewId() {
- return R.id.toolbar;
- }
- };
-}
-
-@Override
-protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- materialMenu.syncState(savedInstanceState);
-}
-
-@Override protected void onSaveInstanceState(Bundle outState) {
- materialMenu.onSaveInstanceState(outState);
- super.onSaveInstanceState(outState);
-}
-```
-
-###Use in custom Action Bar view
-
-Simply add `MaterialMenuView` in your custom layout and register an `OnClickListener` to do the
-transformations.
-
-See [source of Demo][4] for details
-
-###NavigationDrawer slide interaction
-
-Implement `MaterialMenu` into your ActionBar as described above and add a custom `DrawerListener`:
-
-```java
-private DrawerLayout drawerLayout;
-private boolean isDrawerOpened;
-private MaterialMenuIcon materialMenu;
-
-@Override
-protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- materialMenu = new MaterialMenuIcon(this, Color.WHITE, Stroke.THIN); // or retrieve from your custom view, etc
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
@Override
@@ -241,38 +134,27 @@ protected void onCreate(Bundle savedInstanceState) {
@Override
public void onDrawerStateChanged(int newState) {
if(newState == DrawerLayout.STATE_IDLE) {
- if(isDrawerOpened) menu.setState(MaterialMenuDrawable.IconState.ARROW)
- else menu.setState(MaterialMenuDrawable.IconState.BURGER)
+ if(isDrawerOpened) {
+ menu.setIconState(MaterialMenuDrawable.IconState.ARROW);
+ } else {
+ menu.setIconState(MaterialMenuDrawable.IconState.BURGER);
+ }
}
}
});
}
-
-
-@Override
-protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- isDrawerOpened = drawerLayout.isDrawerOpen(Gravity.START); // or END, LEFT, RIGHT
- materialMenu.syncState(savedInstanceState);
-}
-
-@Override
-protected void onSaveInstanceState(Bundle outState) {
- super.onSaveInstanceState(outState);
- materialMenu.onSaveInstanceState(outState);
-}
```
##Developed By
-Balys Valentukevicius @ [Lemon Labs][1]
+Balys Valentukevicius
-Wojciech Rozwadowski @ [Socros][2]
+Wojciech Rozwadowski
##License
```
-Copyright 2014 Balys Valentukevicius
+Copyright 2016 Balys Valentukevicius
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -287,7 +169,4 @@ See the License for the specific language governing permissions and
limitations under the License.
```
-[1]: http://www.lemonlabs.co
-[2]: http://socros.com
-[3]: https://github.com/sosite/material-menu/blob/masterchef/demo/src/stock/java/com/balysv/materialmenu/demo/stock/CustomViewActivity.java
-[4]: http://gradleplease.appspot.com/
+[1]: https://github.com/balysv/material-menu/blob/master/README-1.0.md
diff --git a/demo/build.gradle b/demo/build.gradle
index a674750..42799df 100644
--- a/demo/build.gradle
+++ b/demo/build.gradle
@@ -2,37 +2,20 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 24
- buildToolsVersion "24.0.1"
+ buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.balysv.materialmenu.demo"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
- versionName "1.0"
- }
-
- productFlavors {
- stock {
- applicationId "com.balysv.materialmenu.demo.stock"
- resValue "string", "app_name", "Material menu - stock"
- }
- toolbar {
- applicationId "com.balysv.materialmenu.demo.toolbar"
- resValue "string", "app_name", "Material menu - toolbar"
- }
- abc_v21 {
- applicationId "com.balysv.materialmenu.demo.abc_v21"
- resValue "string", "app_name", "Material menu - abc_v21"
- }
+ versionName "2.0"
}
}
dependencies {
compile project(':library')
- toolbarCompile project(':extras-toolbar');
- abc_v21Compile project(':extras-toolbar')
- compile 'com.android.support:support-v4:24.2.0'
- compile 'com.android.support:cardview-v7:24.2.0'
+ compile 'com.android.support:support-v4:24.2.1'
+ compile "com.android.support:design:24.2.1"
}
diff --git a/demo/src/abc_v21/AndroidManifest.xml b/demo/src/abc_v21/AndroidManifest.xml
deleted file mode 100644
index 48e2c35..0000000
--- a/demo/src/abc_v21/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/BaseActivity.java b/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/BaseActivity.java
deleted file mode 100644
index a72461d..0000000
--- a/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/BaseActivity.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.balysv.materialmenu.demo.abc_v21;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-
-import com.balysv.materialmenu.demo.BaseActivityHelper;
-import com.balysv.materialmenu.demo.R;
-
-public abstract class BaseActivity extends AppCompatActivity {
-
- protected BaseActivityHelper helper;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.demo);
- helper = new BaseActivityHelper();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- helper.refreshDrawerState();
- }
-}
diff --git a/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/HomeIconActivity.java b/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/HomeIconActivity.java
deleted file mode 100644
index 942ebe1..0000000
--- a/demo/src/abc_v21/java/com/balysv/materialmenu/demo/abc_v21/HomeIconActivity.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.balysv.materialmenu.demo.abc_v21;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.MenuItem;
-
-import com.balysv.materialmenu.extras.toolbar.MaterialMenuIconCompat;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;
-
-
-public class HomeIconActivity extends BaseActivity {
-
- private MaterialMenuIconCompat materialMenu;
- private int actionBarMenuState;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- materialMenu = new MaterialMenuIconCompat(this, Color.BLACK, Stroke.THIN);
- helper.init(getWindow().getDecorView(), materialMenu);
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- materialMenu.syncState(savedInstanceState);
- }
-
- @Override protected void onSaveInstanceState(Bundle outState) {
- materialMenu.onSaveInstanceState(outState);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == android.R.id.home) {
- // random state
- actionBarMenuState = generateState(actionBarMenuState);
- materialMenu.animatePressedState(intToState(actionBarMenuState));
- }
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/demo/src/abc_v21/res/values-v21/styles.xml b/demo/src/abc_v21/res/values-v21/styles.xml
deleted file mode 100644
index ecfa918..0000000
--- a/demo/src/abc_v21/res/values-v21/styles.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/abc_v21/res/values/styles.xml b/demo/src/abc_v21/res/values/styles.xml
deleted file mode 100644
index c89f374..0000000
--- a/demo/src/abc_v21/res/values/styles.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/main/AndroidManifest.xml b/demo/src/main/AndroidManifest.xml
index 9611847..59dbad0 100644
--- a/demo/src/main/AndroidManifest.xml
+++ b/demo/src/main/AndroidManifest.xml
@@ -1,5 +1,18 @@
+ package="com.balysv.materialmenu.demo">
-
+
+
+
+
+
+
+
+
diff --git a/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java b/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java
deleted file mode 100644
index c65fb71..0000000
--- a/demo/src/main/java/com/balysv/materialmenu/demo/BaseActivityHelper.java
+++ /dev/null
@@ -1,153 +0,0 @@
-package com.balysv.materialmenu.demo;
-
-import android.graphics.Color;
-import android.support.v4.view.GravityCompat;
-import android.support.v4.widget.DrawerLayout;
-import android.view.Gravity;
-import android.view.View;
-import android.widget.SeekBar;
-
-import com.balysv.materialmenu.MaterialMenu;
-import com.balysv.materialmenu.MaterialMenuDrawable;
-import com.balysv.materialmenu.MaterialMenuView;
-
-import java.util.Random;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.IconState;
-
-public class BaseActivityHelper implements View.OnClickListener, SeekBar.OnSeekBarChangeListener {
-
- private MaterialMenuView materialMenuView;
- private int materialButtonState;
- private MaterialMenu materialIcon;
- private DrawerLayout drawerLayout;
- private boolean direction;
-
- public void init(View parent, MaterialMenu actionBarIcon) {
- SeekBar duration = (SeekBar) parent.findViewById(R.id.item_animation_duration);
- duration.setMax(4600);
- duration.setProgress(2600);
- duration.setOnSeekBarChangeListener(this);
-
- materialMenuView = (MaterialMenuView) parent.findViewById(R.id.material_menu_button);
- materialMenuView.setOnClickListener(this);
- materialIcon = actionBarIcon;
-
- parent.findViewById(R.id.switch_item_arrow).setOnClickListener(this);
- parent.findViewById(R.id.switch_item_menu).setOnClickListener(this);
- parent.findViewById(R.id.switch_item_x).setOnClickListener(this);
- parent.findViewById(R.id.switch_item_check).setOnClickListener(this);
- parent.findViewById(R.id.switch_item_show).setOnClickListener(this);
- parent.findViewById(R.id.switch_item_hide).setOnClickListener(this);
- parent.findViewById(R.id.animate_item_arrow).setOnClickListener(this);
- parent.findViewById(R.id.animate_item_menu).setOnClickListener(this);
- parent.findViewById(R.id.animate_item_x).setOnClickListener(this);
- parent.findViewById(R.id.animate_item_check).setOnClickListener(this);
-
- drawerLayout = ((DrawerLayout) parent.findViewById(R.id.drawer_layout));
- drawerLayout.setScrimColor(Color.parseColor("#66000000"));
- drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
-
- @Override
- public void onDrawerSlide(View drawerView, float slideOffset) {
- materialIcon.setTransformationOffset(
- MaterialMenuDrawable.AnimationState.BURGER_ARROW,
- direction ? 2 - slideOffset : slideOffset
- );
- }
-
- @Override
- public void onDrawerOpened(android.view.View drawerView) {
- direction = true;
- }
-
- @Override
- public void onDrawerClosed(android.view.View drawerView) {
- direction = false;
- }
- });
-
- drawerLayout.postDelayed(new Runnable() {
- @Override public void run() {
- drawerLayout.openDrawer(Gravity.LEFT);
- }
- }, 1500);
- }
-
- @Override public void onClick(View v) {
- final int id = v.getId();
- switch (id) {
- case R.id.animate_item_menu:
- materialMenuView.animateState(IconState.BURGER);
- break;
- case R.id.animate_item_arrow:
- materialMenuView.animateState(IconState.ARROW);
- break;
- case R.id.animate_item_x:
- materialMenuView.animateState(IconState.X);
- break;
- case R.id.animate_item_check:
- materialMenuView.animateState(IconState.CHECK);
- break;
- case R.id.switch_item_menu:
- materialMenuView.setState(IconState.BURGER);
- break;
- case R.id.switch_item_arrow:
- materialMenuView.setState(IconState.ARROW);
- break;
- case R.id.switch_item_x:
- materialMenuView.setState(IconState.X);
- break;
- case R.id.switch_item_check:
- materialMenuView.setState(IconState.CHECK);
- break;
- case R.id.switch_item_show:
- materialMenuView.setVisible(true);
- break;
- case R.id.switch_item_hide:
- materialMenuView.setVisible(false);
- break;
- case R.id.material_menu_button:
- setMainState();
- break;
- }
- }
-
- @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- materialMenuView.setTransformationDuration(400 + progress);
- }
-
- @Override public void onStartTrackingTouch(SeekBar seekBar) {
- }
-
- @Override public void onStopTrackingTouch(SeekBar seekBar) {
- }
-
- private void setMainState() {
- materialButtonState = generateState(materialButtonState);
- materialMenuView.animatePressedState(intToState(materialButtonState));
- }
-
- public void refreshDrawerState() {
- this.direction = drawerLayout.isDrawerOpen(GravityCompat.START);
- }
-
- public static int generateState(int previous) {
- int generated = new Random().nextInt(4);
- return generated != previous ? generated : generateState(previous);
- }
-
- public static IconState intToState(int state) {
- switch (state) {
- case 0:
- return IconState.BURGER;
- case 1:
- return IconState.ARROW;
- case 2:
- return IconState.X;
- case 3:
- return IconState.CHECK;
- }
- throw new IllegalArgumentException("Must be a number [0,3)");
- }
-}
diff --git a/demo/src/main/java/com/balysv/materialmenu/demo/DemoActivity.java b/demo/src/main/java/com/balysv/materialmenu/demo/DemoActivity.java
new file mode 100644
index 0000000..15dacd2
--- /dev/null
+++ b/demo/src/main/java/com/balysv/materialmenu/demo/DemoActivity.java
@@ -0,0 +1,186 @@
+package com.balysv.materialmenu.demo;
+
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v4.view.GravityCompat;
+import android.support.v4.widget.DrawerLayout;
+import android.support.v7.app.AppCompatActivity;
+import android.support.v7.widget.Toolbar;
+import android.view.View;
+import android.widget.SeekBar;
+
+import com.balysv.materialmenu.MaterialMenuDrawable;
+import com.balysv.materialmenu.MaterialMenuView;
+
+import java.util.Random;
+
+import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
+
+
+public class DemoActivity extends AppCompatActivity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener {
+
+ private Toolbar toolbar;
+ private MaterialMenuView materialMenuView;
+ private int materialButtonState;
+ private DrawerLayout drawerLayout;
+ private boolean direction;
+ private int actionBarMenuState;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ // Setup
+ setContentView(R.layout.demo);
+ toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ MaterialMenuDrawable materialMenu = new MaterialMenuDrawable(this, Color.WHITE, Stroke.THIN);
+ toolbar.setNavigationIcon(materialMenu);
+ toolbar.setNavigationOnClickListener(new View.OnClickListener() {
+ @Override public void onClick(View v) {
+ // random state
+ actionBarMenuState = generateState(actionBarMenuState);
+ getMaterialMenu(toolbar).animateIconState(intToState(actionBarMenuState));
+ }
+ });
+
+ // Demo view initialization
+ initViews();
+ drawerLayout.postDelayed(new Runnable() {
+ @Override public void run() {
+ drawerLayout.openDrawer(GravityCompat.START);
+ }
+ }, 1500);
+ }
+
+ private void initViews() {
+ materialMenuView = (MaterialMenuView) findViewById(R.id.material_menu_button);
+ materialMenuView.setOnClickListener(this);
+
+ drawerLayout = ((DrawerLayout) findViewById(R.id.drawer_layout));
+ drawerLayout.setScrimColor(Color.parseColor("#66000000"));
+ drawerLayout.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
+
+ @Override
+ public void onDrawerSlide(View drawerView, float slideOffset) {
+ getMaterialMenu(toolbar).setTransformationOffset(
+ MaterialMenuDrawable.AnimationState.BURGER_ARROW,
+ direction ? 2 - slideOffset : slideOffset
+ );
+ }
+
+ @Override
+ public void onDrawerOpened(android.view.View drawerView) {
+ direction = true;
+ }
+
+ @Override
+ public void onDrawerClosed(android.view.View drawerView) {
+ direction = false;
+ }
+ });
+
+ SeekBar duration = (SeekBar) findViewById(R.id.item_animation_duration);
+ duration.setMax(4600);
+ duration.setProgress(2600);
+ duration.setOnSeekBarChangeListener(this);
+
+ findViewById(R.id.switch_item_arrow).setOnClickListener(this);
+ findViewById(R.id.switch_item_menu).setOnClickListener(this);
+ findViewById(R.id.switch_item_x).setOnClickListener(this);
+ findViewById(R.id.switch_item_check).setOnClickListener(this);
+ findViewById(R.id.switch_item_show).setOnClickListener(this);
+ findViewById(R.id.switch_item_hide).setOnClickListener(this);
+ findViewById(R.id.animate_item_arrow).setOnClickListener(this);
+ findViewById(R.id.animate_item_menu).setOnClickListener(this);
+ findViewById(R.id.animate_item_x).setOnClickListener(this);
+ findViewById(R.id.animate_item_check).setOnClickListener(this);
+ }
+
+ @Override protected void onPostCreate(Bundle savedInstanceState) {
+ super.onPostCreate(savedInstanceState);
+ refreshDrawerState();
+ }
+
+ @Override public void onClick(View v) {
+ final int id = v.getId();
+ switch (id) {
+ case R.id.animate_item_menu:
+ materialMenuView.animateIconState(MaterialMenuDrawable.IconState.BURGER);
+ break;
+ case R.id.animate_item_arrow:
+ materialMenuView.animateIconState(MaterialMenuDrawable.IconState.ARROW);
+ break;
+ case R.id.animate_item_x:
+ materialMenuView.animateIconState(MaterialMenuDrawable.IconState.X);
+ break;
+ case R.id.animate_item_check:
+ materialMenuView.animateIconState(MaterialMenuDrawable.IconState.CHECK);
+ break;
+ case R.id.switch_item_menu:
+ materialMenuView.setIconState(MaterialMenuDrawable.IconState.BURGER);
+ break;
+ case R.id.switch_item_arrow:
+ materialMenuView.setIconState(MaterialMenuDrawable.IconState.ARROW);
+ break;
+ case R.id.switch_item_x:
+ materialMenuView.setIconState(MaterialMenuDrawable.IconState.X);
+ break;
+ case R.id.switch_item_check:
+ materialMenuView.setIconState(MaterialMenuDrawable.IconState.CHECK);
+ break;
+ case R.id.switch_item_show:
+ materialMenuView.setVisible(true);
+ break;
+ case R.id.switch_item_hide:
+ materialMenuView.setVisible(false);
+ break;
+ case R.id.material_menu_button:
+ setMainState();
+ break;
+ }
+ }
+
+ private void setMainState() {
+ materialButtonState = generateState(materialButtonState);
+ materialMenuView.animateIconState(intToState(materialButtonState));
+ }
+
+ private void refreshDrawerState() {
+ this.direction = drawerLayout.isDrawerOpen(GravityCompat.START);
+ }
+
+ @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
+ materialMenuView.setTransformationDuration(400 + progress);
+ }
+
+ @Override public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+
+ private static MaterialMenuDrawable getMaterialMenu(Toolbar toolbar) {
+ return (MaterialMenuDrawable) toolbar.getNavigationIcon();
+ }
+
+ private static int generateState(int previous) {
+ int generated = new Random().nextInt(4);
+ return generated != previous ? generated : generateState(previous);
+ }
+
+ private static MaterialMenuDrawable.IconState intToState(int state) {
+ switch (state) {
+ case 0:
+ return MaterialMenuDrawable.IconState.BURGER;
+ case 1:
+ return MaterialMenuDrawable.IconState.ARROW;
+ case 2:
+ return MaterialMenuDrawable.IconState.X;
+ case 3:
+ return MaterialMenuDrawable.IconState.CHECK;
+ }
+ throw new IllegalArgumentException("Must be a number [0,3)");
+ }
+}
diff --git a/demo/src/main/res/layout/action_bar.xml b/demo/src/main/res/layout/action_bar.xml
deleted file mode 100644
index 5e478d7..0000000
--- a/demo/src/main/res/layout/action_bar.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/demo/src/main/res/layout/demo.xml b/demo/src/main/res/layout/demo.xml
index 3facc07..900ce22 100644
--- a/demo/src/main/res/layout/demo.xml
+++ b/demo/src/main/res/layout/demo.xml
@@ -7,171 +7,184 @@
android:layout_height="match_parent"
tools:context=".DemoActivity">
-
+ android:orientation="vertical">
-
+ android:id="@+id/toolbar"
+ app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
+ android:background="?attr/colorPrimary"/>
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_height="40dp"
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:background="#686868"
+ android:paddingLeft="8dp"
+ android:paddingRight="8dp">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Material menuJust a random iconUse CustomViewUse Home icon
diff --git a/demo/src/toolbar/res/values/styles.xml b/demo/src/main/res/values/styles.xml
similarity index 100%
rename from demo/src/toolbar/res/values/styles.xml
rename to demo/src/main/res/values/styles.xml
diff --git a/demo/src/stock/AndroidManifest.xml b/demo/src/stock/AndroidManifest.xml
deleted file mode 100644
index ba9ed26..0000000
--- a/demo/src/stock/AndroidManifest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/BaseActivity.java b/demo/src/stock/java/com/balysv/materialmenu/demo/stock/BaseActivity.java
deleted file mode 100644
index 50acc0f..0000000
--- a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/BaseActivity.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.balysv.materialmenu.demo.stock;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-import com.balysv.materialmenu.demo.BaseActivityHelper;
-import com.balysv.materialmenu.demo.R;
-
-public abstract class BaseActivity extends Activity {
-
- protected BaseActivityHelper helper;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.demo);
- helper = new BaseActivityHelper();
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- helper.refreshDrawerState();
- }
-}
diff --git a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/CustomViewActivity.java b/demo/src/stock/java/com/balysv/materialmenu/demo/stock/CustomViewActivity.java
deleted file mode 100644
index 2880218..0000000
--- a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/CustomViewActivity.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.balysv.materialmenu.demo.stock;
-
-import android.app.ActionBar;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-
-import com.balysv.materialmenu.MaterialMenuView;
-import com.balysv.materialmenu.demo.R;
-
-import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;
-
-public class CustomViewActivity extends BaseActivity implements View.OnClickListener {
-
- private MaterialMenuView materialMenu;
- private int actionBarMenuState;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- initCustomActionBar();
- helper.init(getWindow().getDecorView(), materialMenu);
- }
-
- private void initCustomActionBar() {
- ActionBar actionBar = getActionBar();
- actionBar.setHomeButtonEnabled(false);
- actionBar.setDisplayShowHomeEnabled(false);
- actionBar.setDisplayShowTitleEnabled(false);
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setDisplayShowCustomEnabled(true);
- actionBar.setCustomView(R.layout.action_bar);
- materialMenu = (MaterialMenuView) actionBar.getCustomView().findViewById(R.id.action_bar_menu);
- materialMenu.setOnClickListener(this);
- }
-
- @Override public void onClick(View v) {
- if (v.getId() == R.id.action_bar_menu) {
- // random state on click
- actionBarMenuState = generateState(actionBarMenuState);
- materialMenu.animatePressedState(intToState(actionBarMenuState));
- return;
- }
- helper.onClick(v);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.custom_view, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- startActivity(new Intent(this, HomeIconActivity.class));
- finish();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/HomeIconActivity.java b/demo/src/stock/java/com/balysv/materialmenu/demo/stock/HomeIconActivity.java
deleted file mode 100644
index deec07c..0000000
--- a/demo/src/stock/java/com/balysv/materialmenu/demo/stock/HomeIconActivity.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package com.balysv.materialmenu.demo.stock;
-
-import android.content.Intent;
-import android.graphics.Color;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-
-import com.balysv.materialmenu.MaterialMenuIcon;
-import com.balysv.materialmenu.demo.R;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;
-
-public class HomeIconActivity extends BaseActivity {
-
- private MaterialMenuIcon materialMenu;
- private int actionBarMenuState;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- materialMenu = new MaterialMenuIcon(this, Color.WHITE, Stroke.THIN);
- helper.init(getWindow().getDecorView(), materialMenu);
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- materialMenu.syncState(savedInstanceState);
- }
-
- @Override protected void onSaveInstanceState(Bundle outState) {
- materialMenu.onSaveInstanceState(outState);
- super.onSaveInstanceState(outState);
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.home_icon, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- int id = item.getItemId();
- if (id == R.id.action_settings) {
- startActivity(new Intent(this, CustomViewActivity.class));
- finish();
- return true;
- }
- if (id == android.R.id.home) {
- // random state
- actionBarMenuState = generateState(actionBarMenuState);
- materialMenu.animatePressedState(intToState(actionBarMenuState));
- }
- return super.onOptionsItemSelected(item);
- }
-}
diff --git a/demo/src/stock/res/values/styles.xml b/demo/src/stock/res/values/styles.xml
deleted file mode 100644
index e494c3a..0000000
--- a/demo/src/stock/res/values/styles.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/toolbar/AndroidManifest.xml b/demo/src/toolbar/AndroidManifest.xml
deleted file mode 100644
index 7dd5886..0000000
--- a/demo/src/toolbar/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/demo/src/toolbar/java/com/balysv/materialmenu/demo/toolbar/ToolbarActivity.java b/demo/src/toolbar/java/com/balysv/materialmenu/demo/toolbar/ToolbarActivity.java
deleted file mode 100644
index da36b49..0000000
--- a/demo/src/toolbar/java/com/balysv/materialmenu/demo/toolbar/ToolbarActivity.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.balysv.materialmenu.demo.toolbar;
-
-import android.graphics.Color;
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
-import android.view.View;
-
-import com.balysv.materialmenu.demo.BaseActivityHelper;
-import com.balysv.materialmenu.demo.R;
-import com.balysv.materialmenu.extras.toolbar.MaterialMenuIconToolbar;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.generateState;
-import static com.balysv.materialmenu.demo.BaseActivityHelper.intToState;
-
-
-public class ToolbarActivity extends AppCompatActivity {
-
- private MaterialMenuIconToolbar materialMenu;
-
- private int actionBarMenuState;
-
- protected BaseActivityHelper helper;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.toolbar);
- Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
- setSupportActionBar(toolbar);
- toolbar.setNavigationOnClickListener(new View.OnClickListener() {
- @Override public void onClick(View v) {
- // random state
- actionBarMenuState = generateState(actionBarMenuState);
- materialMenu.animatePressedState(intToState(actionBarMenuState));
- }
- });
- materialMenu = new MaterialMenuIconToolbar(this, Color.WHITE, Stroke.THIN) {
- @Override public int getToolbarViewId() {
- return R.id.toolbar;
- }
- };
- helper = new BaseActivityHelper();
- helper.init(getWindow().getDecorView(), materialMenu);
- }
-
- @Override
- protected void onPostCreate(Bundle savedInstanceState) {
- super.onPostCreate(savedInstanceState);
- helper.refreshDrawerState();
- materialMenu.syncState(savedInstanceState);
- }
-
- @Override protected void onSaveInstanceState(Bundle outState) {
- materialMenu.onSaveInstanceState(outState);
- super.onSaveInstanceState(outState);
- }
-}
diff --git a/demo/src/toolbar/res/layout/toolbar.xml b/demo/src/toolbar/res/layout/toolbar.xml
deleted file mode 100644
index 900ce22..0000000
--- a/demo/src/toolbar/res/layout/toolbar.xml
+++ /dev/null
@@ -1,207 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/extras-toolbar/.gitignore b/extras-toolbar/.gitignore
deleted file mode 100644
index d0b97c6..0000000
--- a/extras-toolbar/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/build
-*.iml
\ No newline at end of file
diff --git a/extras-toolbar/build.gradle b/extras-toolbar/build.gradle
deleted file mode 100644
index a792b6f..0000000
--- a/extras-toolbar/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 24
- buildToolsVersion "24.0.1"
-
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 24
- versionCode 1
- versionName "1.4"
- }
-
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_7
- targetCompatibility JavaVersion.VERSION_1_7
- }
-}
-
-dependencies {
- compile project(':library')
- compile 'com.android.support:appcompat-v7:24.2.0'
-}
-
-apply from: '../bintray_push.gradle'
diff --git a/extras-toolbar/gradle.properties b/extras-toolbar/gradle.properties
deleted file mode 100644
index 5833e2c..0000000
--- a/extras-toolbar/gradle.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-POM_NAME=Material Menu Extras: Toolbar
-POM_ARTIFACT_ID=material-menu-toolbar
\ No newline at end of file
diff --git a/extras-toolbar/src/main/AndroidManifest.xml b/extras-toolbar/src/main/AndroidManifest.xml
deleted file mode 100644
index 341bdf2..0000000
--- a/extras-toolbar/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
diff --git a/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconCompat.java b/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconCompat.java
deleted file mode 100644
index 8098a3f..0000000
--- a/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconCompat.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.balysv.materialmenu.extras.toolbar;
-
-import android.app.Activity;
-import android.support.v7.app.ActionBar;
-import android.support.v7.app.AppCompatActivity;
-import android.view.View;
-
-import com.balysv.materialmenu.MaterialMenuBase;
-import com.balysv.materialmenu.MaterialMenuDrawable;
-
-public class MaterialMenuIconCompat extends MaterialMenuBase {
-
- public MaterialMenuIconCompat(AppCompatActivity activity, int color, MaterialMenuDrawable.Stroke stroke) {
- super(activity, color, stroke);
- }
-
- public MaterialMenuIconCompat(AppCompatActivity activity, int color, MaterialMenuDrawable.Stroke stroke, int transformDuration) {
- super(activity, color, stroke, transformDuration);
- }
-
- @Override
- protected View getActionBarHomeView(Activity activity) {
- return null;
- }
-
- @Override
- protected View getActionBarUpView(Activity activity) {
- return null;
- }
-
- @Override
- protected boolean providesActionBar() {
- return false;
- }
-
- @Override
- protected void setActionBarSettings(Activity activity) {
- ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setDisplayUseLogoEnabled(false);
- actionBar.setHomeButtonEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(true);
- actionBar.setDefaultDisplayHomeAsUpEnabled(true);
- actionBar.setHomeAsUpIndicator(getDrawable());
- }
-}
\ No newline at end of file
diff --git a/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconToolbar.java b/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconToolbar.java
deleted file mode 100644
index 3353dbd..0000000
--- a/extras-toolbar/src/main/java/com/balysv/materialmenu/extras/toolbar/MaterialMenuIconToolbar.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package com.balysv.materialmenu.extras.toolbar;
-
-import android.app.Activity;
-import android.support.v7.widget.Toolbar;
-import android.view.View;
-
-import com.balysv.materialmenu.MaterialMenuBase;
-import com.balysv.materialmenu.MaterialMenuDrawable;
-
-public abstract class MaterialMenuIconToolbar extends MaterialMenuBase {
-
- public MaterialMenuIconToolbar(Activity activity, int color, MaterialMenuDrawable.Stroke stroke) {
- super(activity, color, stroke);
- }
-
- public MaterialMenuIconToolbar(Activity activity, int color, MaterialMenuDrawable.Stroke stroke, int transformDuration) {
- super(activity, color, stroke, transformDuration);
- }
-
- @Override
- protected final void setActionBarSettings(Activity activity) {
- Toolbar toolbar = (Toolbar) activity.findViewById(getToolbarViewId());
- toolbar.setNavigationIcon(getDrawable());
- }
-
- @Override
- protected final View getActionBarHomeView(Activity activity) {
- return null;
- }
-
- @Override
- protected final View getActionBarUpView(Activity activity) {
- return null;
- }
-
- @Override
- protected final boolean providesActionBar() {
- return false;
- }
-
- public abstract int getToolbarViewId();
-}
diff --git a/extras-toolbar/src/main/res/values/strings.xml b/extras-toolbar/src/main/res/values/strings.xml
deleted file mode 100644
index 87cf966..0000000
--- a/extras-toolbar/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- extras-toolbar
-
diff --git a/gradle.properties b/gradle.properties
index 178540a..5dabcc4 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,5 +1,5 @@
-VERSION_NAME=1.6.0
-VERSION_CODE=17
+VERSION_NAME=2.0.0f
+VERSION_CODE=19
GROUP=com.socros.android.lib
POM_NAME=Material Menu
diff --git a/library/build.gradle b/library/build.gradle
index 2b33958..72cc253 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -2,13 +2,11 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 24
- buildToolsVersion "24.0.1"
+ buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 24
- versionCode 6
- versionName "1.6.0"
}
compileOptions {
@@ -17,7 +15,4 @@ android {
}
}
-dependencies {
-}
-
apply from: '../bintray_push.gradle'
\ No newline at end of file
diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenu.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenu.java
index 19b8241..30753d2 100644
--- a/library/src/main/java/com/balysv/materialmenu/MaterialMenu.java
+++ b/library/src/main/java/com/balysv/materialmenu/MaterialMenu.java
@@ -30,30 +30,21 @@ public interface MaterialMenu {
*
* @param state new icon state
*/
- void setState(IconState state);
+ void setIconState(IconState state);
/**
* Return current icon state
*
* @return icon state
*/
- IconState getState();
+ IconState getIconState();
/**
* Animate icon to given state.
*
* @param state new icon state
*/
- void animateState(IconState state);
-
- /**
- * Animate icon to given state and draw touch circle
- *
- * @param state new icon state
- * @deprecated Pressed state is not supported. Use {@link #animateState(IconState)}
- */
- @Deprecated
- void animatePressedState(IconState state);
+ void animateIconState(IconState state);
/**
* Set color of icon
@@ -104,10 +95,5 @@ public interface MaterialMenu {
* @param value between {@link com.balysv.materialmenu.MaterialMenuDrawable#TRANSFORMATION_START} and
* {@link com.balysv.materialmenu.MaterialMenuDrawable#TRANSFORMATION_END}.
*/
- void setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value);
-
- /**
- * @return {@link MaterialMenuDrawable} to be used for the menu
- */
- MaterialMenuDrawable getDrawable();
+ IconState setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value);
}
diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenuBase.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenuBase.java
deleted file mode 100644
index ce9fdd7..0000000
--- a/library/src/main/java/com/balysv/materialmenu/MaterialMenuBase.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2014 Balys Valentukevicius
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.balysv.materialmenu;
-
-import android.animation.Animator;
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.animation.Interpolator;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_SCALE;
-import static com.balysv.materialmenu.MaterialMenuDrawable.DEFAULT_TRANSFORM_DURATION;
-
-/**
- * Base class for ActionBar implementations of {@link MaterialMenuDrawable}
- *
- * @see MaterialMenuIcon
- */
-public abstract class MaterialMenuBase implements MaterialMenu {
-
- private static final String STATE_KEY = "material_menu_icon_state";
- private MaterialMenuDrawable.IconState currentState = MaterialMenuDrawable.IconState.BURGER;
-
- private MaterialMenuDrawable drawable;
-
- public MaterialMenuBase(Activity activity, int color, MaterialMenuDrawable.Stroke stroke) {
- this(activity, color, stroke, DEFAULT_TRANSFORM_DURATION);
- }
-
- public MaterialMenuBase(Activity activity, int color, MaterialMenuDrawable.Stroke stroke, int transformDuration) {
- drawable = new MaterialMenuDrawable(activity, color, stroke, DEFAULT_SCALE, transformDuration);
- setActionBarSettings(activity);
- if (providesActionBar()) {
- setupActionBar(activity);
- }
- }
-
- private void setupActionBar(Activity activity) {
- final View iconView = getActionBarHomeView(activity);
- final View upView = getActionBarUpView(activity);
-
- if (iconView == null || upView == null) {
- throw new IllegalStateException("Could not find ActionBar views");
- }
-
- // need no margins so that clicked state would work nicely
- ViewGroup.MarginLayoutParams iconParams = (ViewGroup.MarginLayoutParams) iconView.getLayoutParams();
- iconParams.bottomMargin = 0;
- iconParams.topMargin = 0;
- iconParams.leftMargin = 0;
- iconView.setLayoutParams(iconParams);
-
- // remove up arrow margins
- ViewGroup.MarginLayoutParams upParams = (ViewGroup.MarginLayoutParams) upView.getLayoutParams();
- upParams.leftMargin = activity.getResources().getDimensionPixelSize(R.dimen.mm_up_arrow_margin);
- upParams.rightMargin = 0;
- upView.setLayoutParams(upParams);
- }
-
- protected abstract void setActionBarSettings(Activity activity);
-
- protected abstract View getActionBarHomeView(Activity activity);
-
- protected abstract View getActionBarUpView(Activity activity);
-
- protected abstract boolean providesActionBar();
-
- @Override
- public final void setState(MaterialMenuDrawable.IconState state) {
- currentState = state;
- getDrawable().setIconState(state);
- }
-
- @Override
- public final MaterialMenuDrawable.IconState getState() {
- return getDrawable().getIconState();
- }
-
- @Override
- public final void animateState(MaterialMenuDrawable.IconState state) {
- currentState = state;
- getDrawable().animateIconState(state);
- }
-
- @Override
- public final void animatePressedState(MaterialMenuDrawable.IconState state) {
- animateState(state);
- }
-
- @Override
- public final void setColor(int color) {
- getDrawable().setColor(color);
- }
-
- @Override
- public final void setVisible(boolean visible) {
- getDrawable().setVisible(visible);
- }
-
- @Override
- public final void setTransformationDuration(int duration) {
- getDrawable().setTransformationDuration(duration);
- }
-
- @Override
- public final void setInterpolator(Interpolator interpolator) {
- getDrawable().setInterpolator(interpolator);
- }
-
- @Override
- public final void setAnimationListener(Animator.AnimatorListener listener) {
- getDrawable().setAnimationListener(listener);
- }
-
- @Override
- public final void setRTLEnabled(boolean rtlEnabled) {
- getDrawable().setRTLEnabled(rtlEnabled);
- }
-
- @Override
- public final void setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value) {
- currentState = getDrawable().setTransformationOffset(animationState, value);
- }
-
- @Override
- public final MaterialMenuDrawable getDrawable() {
- return drawable;
- }
-
- /**
- * Call from {@link android.app.Activity#onSaveInstanceState(android.os.Bundle)} to store current icon state
- *
- * @param outState outState
- */
- public void onSaveInstanceState(Bundle outState) {
- outState.putString(STATE_KEY, currentState.name());
- }
-
- /**
- * Call from {@link android.app.Activity#onPostCreate(android.os.Bundle)} to restore icon state
- *
- * @param state state
- */
- public void syncState(Bundle state) {
- if (state != null) {
- String iconStateName = state.getString(STATE_KEY);
- if (iconStateName == null) {
- iconStateName = MaterialMenuDrawable.IconState.BURGER.name();
- }
- setState(MaterialMenuDrawable.IconState.valueOf(iconStateName));
- }
- }
-}
diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java
index 5861d45..f02844d 100644
--- a/library/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java
+++ b/library/src/main/java/com/balysv/materialmenu/MaterialMenuDrawable.java
@@ -18,6 +18,7 @@
import android.animation.Animator;
+import android.animation.Animator.AnimatorListener;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
@@ -36,7 +37,7 @@
import static android.graphics.Paint.Style;
-public class MaterialMenuDrawable extends Drawable implements Animatable {
+public class MaterialMenuDrawable extends Drawable implements MaterialMenu, Animatable {
public enum IconState {
BURGER, ARROW, X, CHECK
@@ -175,8 +176,8 @@ protected static Stroke valueOf(int strokeWidth) {
private boolean visible;
private boolean rtlEnabled;
- private ObjectAnimator transformation;
- private Animator.AnimatorListener animatorListener;
+ private ObjectAnimator transformation;
+ private AnimatorListener animatorListener;
private MaterialMenuState materialMenuState;
@@ -215,7 +216,8 @@ public MaterialMenuDrawable(Context context, int color, Stroke stroke, int scale
materialMenuState = new MaterialMenuState();
}
- private MaterialMenuDrawable(int color, Stroke stroke, long transformDuration, int width, int height,
+ private MaterialMenuDrawable(
+ int color, Stroke stroke, long transformDuration, int width, int height,
float iconWidth, float circleRadius, float strokeWidth, float dip1
) {
this.dip1 = dip1;
@@ -606,7 +608,7 @@ public void setInterpolator(Interpolator interpolator) {
transformation.setInterpolator(interpolator);
}
- public void setAnimationListener(Animator.AnimatorListener listener) {
+ public void setAnimationListener(AnimatorListener listener) {
if (animatorListener != null) {
transformation.removeListener(animatorListener);
}
@@ -692,7 +694,7 @@ public IconState getIconState() {
return currentIconState;
}
- public boolean isDrawableVisible(){
+ public boolean isDrawableVisible() {
return visible;
}
@@ -808,25 +810,20 @@ private boolean resolveTransformation() {
return transformationRunning;
}
- @Override
- public int getIntrinsicWidth() {
+ @Override public int getIntrinsicWidth() {
return width;
}
- @Override
- public int getIntrinsicHeight() {
+ @Override public int getIntrinsicHeight() {
return height;
}
-
- @Override
- public ConstantState getConstantState() {
+ @Override public ConstantState getConstantState() {
materialMenuState.changingConfigurations = getChangingConfigurations();
return materialMenuState;
}
- @Override
- public Drawable mutate() {
+ @Override public Drawable mutate() {
materialMenuState = new MaterialMenuState();
return this;
}
@@ -837,8 +834,7 @@ private final class MaterialMenuState extends ConstantState {
private MaterialMenuState() {
}
- @Override
- public Drawable newDrawable() {
+ @Override public Drawable newDrawable() {
MaterialMenuDrawable drawable = new MaterialMenuDrawable(
circlePaint.getColor(), stroke, transformation.getDuration(),
width, height, iconWidth, circleRadius, strokeWidth, dip1
@@ -849,8 +845,7 @@ public Drawable newDrawable() {
return drawable;
}
- @Override
- public int getChangingConfigurations() {
+ @Override public int getChangingConfigurations() {
return changingConfigurations;
}
}
diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenuIcon.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenuIcon.java
deleted file mode 100644
index 3b5b342..0000000
--- a/library/src/main/java/com/balysv/materialmenu/MaterialMenuIcon.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2014 Balys Valentukevicius
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.balysv.materialmenu;
-
-import android.annotation.TargetApi;
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.res.Resources;
-import android.view.View;
-import android.view.ViewGroup;
-
-import static com.balysv.materialmenu.MaterialMenuDrawable.Stroke;
-
-/**
- * A helper class for implementing {@link MaterialMenuDrawable}
- * as an {@link android.app.ActionBar} icon.
- *
- * To disable pressed background color adjust your theme by setting android:actionBarItemBackground
- * to null and use android:actionButtonStyle, android:actionOverflowButtonStyle to enable other
- * menu icon backgrounds.
- *
- * Disables ActionBar Up arrow and replaces default drawable using {@link ActionBar#setIcon(android.graphics.drawable.Drawable)}
- */
-public class MaterialMenuIcon extends MaterialMenuBase {
-
- public MaterialMenuIcon(Activity activity, int color, Stroke stroke) {
- super(activity, color, stroke);
- }
-
- public MaterialMenuIcon(Activity activity, int color, Stroke stroke, int transformDuration) {
- super(activity, color, stroke, transformDuration);
- }
-
- @Override
- protected View getActionBarHomeView(Activity activity) {
- Resources resources = activity.getResources();
- return activity.getWindow().getDecorView().findViewById(
- resources.getIdentifier("android:id/home", null, null)
- );
- }
-
- @Override
- protected View getActionBarUpView(Activity activity) {
- Resources resources = activity.getResources();
- ViewGroup actionBarView = (ViewGroup) activity.getWindow().getDecorView().findViewById(
- resources.getIdentifier("android:id/action_bar", null, null)
- );
- View homeView = actionBarView.getChildAt(
- actionBarView.getChildCount() > 1 ? 1 : 0
- );
- return homeView.findViewById(
- resources.getIdentifier("android:id/up", null, null)
- );
- }
-
- @Override
- protected boolean providesActionBar() {
- return true;
- }
-
- @Override @TargetApi(14)
- protected void setActionBarSettings(Activity activity) {
- ActionBar actionBar = activity.getActionBar();
- actionBar.setDisplayShowHomeEnabled(true);
- actionBar.setHomeButtonEnabled(true);
- actionBar.setDisplayHomeAsUpEnabled(false);
- actionBar.setIcon(getDrawable());
- }
-}
diff --git a/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java b/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java
index 750f3b7..e0ee6d6 100644
--- a/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java
+++ b/library/src/main/java/com/balysv/materialmenu/MaterialMenuView.java
@@ -68,9 +68,26 @@ private void init(Context context, AttributeSet attributeSet) {
int transformDuration = attr.getInteger(R.styleable.MaterialMenuView_mm_transformDuration, DEFAULT_TRANSFORM_DURATION);
Stroke stroke = Stroke.valueOf(attr.getInteger(R.styleable.MaterialMenuView_mm_strokeWidth, 0));
boolean rtlEnabled = attr.getBoolean(R.styleable.MaterialMenuView_mm_rtlEnabled, false);
+ int state = attr.getInt(R.styleable.MaterialMenuView_mm_iconState, 0);
+
+ switch (state) {
+ case 0:
+ currentState = IconState.BURGER;
+ break;
+ case 1:
+ currentState = IconState.ARROW;
+ break;
+ case 2:
+ currentState = IconState.X;
+ break;
+ case 3:
+ currentState = IconState.CHECK;
+ break;
+ }
drawable = new MaterialMenuDrawable(context, color, stroke, scale, transformDuration);
+ drawable.setIconState(currentState);
drawable.setVisible(visible);
drawable.setRTLEnabled(rtlEnabled);
} finally {
@@ -80,8 +97,7 @@ private void init(Context context, AttributeSet attributeSet) {
drawable.setCallback(this);
}
- @Override
- public void draw(Canvas canvas) {
+ @Override public void draw(Canvas canvas) {
super.draw(canvas);
if (getPaddingLeft() != 0 || getPaddingTop() != 0) {
int saveCount = canvas.getSaveCount();
@@ -94,81 +110,63 @@ public void draw(Canvas canvas) {
}
}
- @Override
- public void setPadding(int left, int top, int right, int bottom) {
+ @Override public void setPadding(int left, int top, int right, int bottom) {
super.setPadding(left, top, right, bottom);
adjustDrawablePadding();
}
- @Override
- protected boolean verifyDrawable(Drawable who) {
+ @Override protected boolean verifyDrawable(Drawable who) {
return who == drawable || super.verifyDrawable(who);
}
- @Override
- public void setState(IconState state) {
+ @Override public void setIconState(IconState state) {
currentState = state;
drawable.setIconState(state);
}
- @Override
- public IconState getState() {
+ @Override public IconState getIconState() {
return drawable.getIconState();
}
- @Override
- public void animateState(IconState state) {
+ @Override public void animateIconState(IconState state) {
currentState = state;
drawable.animateIconState(state);
}
- @Override
- public void animatePressedState(IconState state) {
- animateState(state);
- }
-
- @Override
- public void setColor(int color) {
+ @Override public void setColor(int color) {
drawable.setColor(color);
}
- @Override
- public void setVisible(boolean visible) {
+ @Override public void setVisible(boolean visible) {
drawable.setVisible(visible);
}
- @Override
- public void setTransformationDuration(int duration) {
+ @Override public void setTransformationDuration(int duration) {
drawable.setTransformationDuration(duration);
}
- @Override
- public void setInterpolator(Interpolator interpolator) {
+ @Override public void setInterpolator(Interpolator interpolator) {
drawable.setInterpolator(interpolator);
}
- @Override
- public void setAnimationListener(Animator.AnimatorListener listener) {
+ @Override public void setAnimationListener(Animator.AnimatorListener listener) {
drawable.setAnimationListener(listener);
}
- @Override
- public void setRTLEnabled(boolean rtlEnabled) {
+ @Override public void setRTLEnabled(boolean rtlEnabled) {
drawable.setRTLEnabled(rtlEnabled);
}
- @Override
- public void setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value) {
+ @Override public IconState setTransformationOffset(MaterialMenuDrawable.AnimationState animationState, float value) {
currentState = drawable.setTransformationOffset(animationState, value);
+ return currentState;
}
- @Override
public MaterialMenuDrawable getDrawable() {
return drawable;
}
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int paddingX = getPaddingLeft() + getPaddingRight();
int paddingY = getPaddingTop() + getPaddingBottom();
@@ -181,14 +179,12 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}
}
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+ @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
adjustDrawablePadding();
}
- @Override
- public Parcelable onSaveInstanceState() {
+ @Override public Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
SavedState savedState = new SavedState(superState);
savedState.state = currentState;
@@ -196,11 +192,10 @@ public Parcelable onSaveInstanceState() {
return savedState;
}
- @Override
- public void onRestoreInstanceState(Parcelable state) {
+ @Override public void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
- setState(savedState.state);
+ setIconState(savedState.state);
setVisible(savedState.visible);
}
@@ -220,7 +215,7 @@ private TypedArray getTypedArray(Context context, AttributeSet attributeSet, int
private static class SavedState extends BaseSavedState {
protected IconState state;
- protected boolean visible;
+ protected boolean visible;
SavedState(Parcelable superState) {
super(superState);
@@ -228,25 +223,22 @@ private static class SavedState extends BaseSavedState {
private SavedState(Parcel in) {
super(in);
- state = IconState.valueOf(in.readString());
+ state = IconState.values()[in.readInt()];
visible = in.readByte() != 0;
}
- @Override
- public void writeToParcel(Parcel out, int flags) {
+ @Override public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
- out.writeString(state.name());
+ out.writeInt(state.ordinal());
out.writeByte((byte) (visible ? 1 : 0));
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
- @Override
- public SavedState createFromParcel(Parcel in) {
+ @Override public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
- @Override
- public SavedState[] newArray(int size) {
+ @Override public SavedState[] newArray(int size) {
return new SavedState[size];
}
};
diff --git a/library/src/main/res/values/dimens.xml b/library/src/main/res/values/dimens.xml
deleted file mode 100644
index 605a7bf..0000000
--- a/library/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
- -16dp
-
\ No newline at end of file
diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml
index e103d1d..0040309 100644
--- a/library/src/main/res/values/styles.xml
+++ b/library/src/main/res/values/styles.xml
@@ -7,5 +7,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/settings.gradle b/settings.gradle
index cff0cb4..462ba77 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':demo', ':library', ':extras-toolbar'
+include ':demo', ':library'