diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..fe5af22 --- /dev/null +++ b/build.gradle @@ -0,0 +1,14 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath "com.android.tools.build:gradle:$GRADLE_PLUGIN_VERSION" + } +} + +allprojects { + repositories { + jcenter() + } +} diff --git a/demo.gif b/demo.gif new file mode 100644 index 0000000..9d70a2d Binary files /dev/null and b/demo.gif differ diff --git a/example/build.gradle b/example/build.gradle new file mode 100644 index 0000000..e4ee41a --- /dev/null +++ b/example/build.gradle @@ -0,0 +1,27 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion COMPILE_SDK_VERSION + buildToolsVersion BUILD_TOOLS_VERSION + + defaultConfig { + applicationId "com.github.ivbaranov.mfb.exmaple" + minSdkVersion MIN_SDK_VERSION + targetSdkVersion TARGET_SDK_VERSION + versionCode 1 + versionName VERSION_NAME + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + compile project(':materialfavoritebutton') + compile "com.android.support:appcompat-v7:$SUPPORT_LIBRARY_VERSION" + compile "com.android.support:design:$SUPPORT_LIBRARY_VERSION" + compile "com.android.support:cardview-v7:$SUPPORT_LIBRARY_VERSION" +} diff --git a/example/proguard-rules.pro b/example/proguard-rules.pro new file mode 100644 index 0000000..19345ba --- /dev/null +++ b/example/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/ivbaranov/Documents/Android/sdk/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/example/src/main/AndroidManifest.xml b/example/src/main/AndroidManifest.xml new file mode 100644 index 0000000..2674678 --- /dev/null +++ b/example/src/main/AndroidManifest.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + diff --git a/example/src/main/java/com/github/ivbaranov/mfb/example/MainActivity.java b/example/src/main/java/com/github/ivbaranov/mfb/example/MainActivity.java new file mode 100644 index 0000000..251b81e --- /dev/null +++ b/example/src/main/java/com/github/ivbaranov/mfb/example/MainActivity.java @@ -0,0 +1,84 @@ +package com.github.ivbaranov.mfb.example; + +import android.os.Bundle; +import android.support.design.widget.Snackbar; +import android.support.v7.app.AppCompatActivity; +import android.support.v7.widget.Toolbar; +import android.view.Menu; +import android.view.MenuItem; +import android.widget.TextView; +import com.github.ivbaranov.mfb.MaterialFavoriteButton; + +public class MainActivity extends AppCompatActivity { + private TextView niceCounter; + private int niceCounterValue = 37; + + @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); + setSupportActionBar(toolbar); + + //in the toolbar + MaterialFavoriteButton toolbarFavorite = new MaterialFavoriteButton.Builder(this) // + .favorite(true) + .color(MaterialFavoriteButton.STYLE_WHITE) + .type(MaterialFavoriteButton.STYLE_HEART) + .rotationDuration(400) + .create(); + toolbar.addView(toolbarFavorite); + toolbarFavorite.setOnFavoriteChangeListener( + new MaterialFavoriteButton.OnFavoriteChangeListener() { + @Override + public void onFavoriteChanged(MaterialFavoriteButton buttonView, boolean favorite) { + Snackbar.make(buttonView, getString(R.string.toolbar_favorite_snack) + favorite, + Snackbar.LENGTH_SHORT).show(); + } + }); + + //nice cardview + niceCounter = (TextView) findViewById(R.id.counter_value); + niceCounter.setText(String.valueOf(niceCounterValue)); + MaterialFavoriteButton materialFavoriteButtonNice = + (MaterialFavoriteButton) findViewById(R.id.favorite_nice); + materialFavoriteButtonNice.setFavorite(true, false); + materialFavoriteButtonNice.setOnFavoriteChangeListener( + new MaterialFavoriteButton.OnFavoriteChangeListener() { + @Override + public void onFavoriteChanged(MaterialFavoriteButton buttonView, boolean favorite) { + if (favorite) { + niceCounterValue++; + } else { + niceCounterValue--; + } + } + }); + materialFavoriteButtonNice.setOnFavoriteAnimationEndListener( + new MaterialFavoriteButton.OnFavoriteAnimationEndListener() { + @Override + public void onAnimationEnd(MaterialFavoriteButton buttonView, boolean favorite) { + niceCounter.setText(String.valueOf(niceCounterValue)); + } + }); + } + + @Override public boolean onCreateOptionsMenu(Menu menu) { + // Inflate the menu; this adds items to the action bar if it is present. + getMenuInflater().inflate(R.menu.menu_main, menu); + return true; + } + + @Override public boolean onOptionsItemSelected(MenuItem item) { + // Handle action bar item clicks here. The action bar will + // automatically handle clicks on the Home/Up button, so long + // as you specify a parent activity in AndroidManifest.xml. + int id = item.getItemId(); + + //noinspection SimplifiableIfStatement + if (id == R.id.action_settings) { + return true; + } + + return super.onOptionsItemSelected(item); + } +} diff --git a/example/src/main/res/drawable-hdpi/ic_event_available_black_24dp.png b/example/src/main/res/drawable-hdpi/ic_event_available_black_24dp.png new file mode 100644 index 0000000..aed4caf Binary files /dev/null and b/example/src/main/res/drawable-hdpi/ic_event_available_black_24dp.png differ diff --git a/example/src/main/res/drawable-hdpi/ic_event_busy_black_24dp.png b/example/src/main/res/drawable-hdpi/ic_event_busy_black_24dp.png new file mode 100644 index 0000000..bc75dcb Binary files /dev/null and b/example/src/main/res/drawable-hdpi/ic_event_busy_black_24dp.png differ diff --git a/example/src/main/res/drawable-hdpi/ic_settings_black_24dp.png b/example/src/main/res/drawable-hdpi/ic_settings_black_24dp.png new file mode 100644 index 0000000..acf1ddf Binary files /dev/null and b/example/src/main/res/drawable-hdpi/ic_settings_black_24dp.png differ diff --git a/example/src/main/res/layout/activity_main.xml b/example/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..d3cb3e2 --- /dev/null +++ b/example/src/main/res/layout/activity_main.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + diff --git a/example/src/main/res/layout/content_main.xml b/example/src/main/res/layout/content_main.xml new file mode 100644 index 0000000..d4ebf55 --- /dev/null +++ b/example/src/main/res/layout/content_main.xml @@ -0,0 +1,153 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example/src/main/res/menu/menu_main.xml b/example/src/main/res/menu/menu_main.xml new file mode 100644 index 0000000..0eaad1b --- /dev/null +++ b/example/src/main/res/menu/menu_main.xml @@ -0,0 +1,11 @@ + + + + + diff --git a/example/src/main/res/mipmap-hdpi/ic_launcher.png b/example/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/example/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-mdpi/ic_launcher.png b/example/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/example/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xhdpi/ic_launcher.png b/example/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/example/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/example/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..aee44e1 Binary files /dev/null and b/example/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/example/src/main/res/values-v21/styles.xml b/example/src/main/res/values-v21/styles.xml new file mode 100644 index 0000000..9431d7a --- /dev/null +++ b/example/src/main/res/values-v21/styles.xml @@ -0,0 +1,10 @@ + + + + +