Skip to content

Commit

Permalink
Finish 1.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
matecode committed Mar 7, 2017
2 parents 85d6a94 + 4af888f commit d39ee40
Show file tree
Hide file tree
Showing 20 changed files with 300 additions and 133 deletions.
24 changes: 17 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[![](https://jitpack.io/v/matecode/Snacky.svg)](https://jitpack.io/#matecode/Snacky)
[![API](https://img.shields.io/badge/API-9%2B-blue.svg?style=flat)](https://android-arsenal.com/api?level=9)
[![](https://img.shields.io/badge/LibHunt-Snacky-7DA800.svg?style=flat)](https://android.libhunt.com/project/snacky)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/siede)

[![Donate](https://d1iczxrky3cnb2.cloudfront.net/button-small-green.png)](https://donorbox.org/matecode)

# Snacky

Expand Down Expand Up @@ -34,25 +35,31 @@ It is necessary to set an activity or View for the snackbar.

most of them are self-explaining

`.setBackgroundColor()`
`.setBackgroundColor()` Color or ColorStateList

`.setText()` Charset or IntRes for text

`.setTextColor()` Color int of text

`.setTextSize()`
`.setTextSize()` size in SP or with ComplexUnit

`.setTextTypefaceStyle()` NORMAL, BOLD, ITALIC, BOLD_ITALIC from [Typeface](https://developer.android.com/reference/android/graphics/Typeface.html)

`.setMaxLines()`
`.setMaxLines()` max lines of Snackbar, off by default

`.centerText()` centers the text

`.setActionText()`

`.setActionTextColor()`

`.setActionTextSize()`

`.setActionTextTypefaceStyle()` like .setTextTypefaceStyle()

`.setActionClickListener(View.OnClickListener)`

`.setDuration(Snacky.DURATION)`
`.setDuration(Snacky.DURATION)` SHORT, LONG, INDEFINITE

`.setIcon()` Drawable to be shown, in my opinion ist best to use small drawables with 24dp size

Expand Down Expand Up @@ -80,7 +87,10 @@ After that you can handle the snackbar as you know it:

## Example

See [MainActivity.java](https://github.com/matecode/Snacky/blob/master/app/src/main/java/de/mateware/snackysample/MainActivity.java) for a list of examples as shown in [Screenshots](#screenshots).
See [ExampleActivity.java](https://github.com/matecode/Snacky/blob/master/app/src/main/java/de/mateware/snackysample/ExampleActivity.java) for a list of examples as shown in [Screenshots](#screenshots).

There you can also the see the right use of CoordinatorLayout and FloatingActionButton. For Snacky Builder just use the view from OnClickListener in FAB to animate it on click.

## Installation

Snacky is published via Jitpack. Add this in your root `build.gradle` file (**not** your module `build.gradle` file):
Expand All @@ -99,7 +109,7 @@ Add this to your module's `build.gradle` file (make sure the version matches the
```gradle
dependencies {
...
compile 'com.github.matecode:Snacky:1.0.1'
compile 'com.github.matecode:Snacky:1.0.2'
}
```

Expand Down
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "com.android.support:appcompat-v7:$rootProject.ext.supportLibVer"
testCompile 'junit:junit:4.12'
compile project(':library')
compile 'com.android.support.constraint:constraint-layout:1.0.1'
testCompile 'junit:junit:4.12'
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity
android:name=".ExampleActivity"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,43 @@
package de.mateware.snackysample;

import android.graphics.Color;
import android.graphics.Typeface;
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.Gravity;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.Toast;

import de.mateware.snacky.Snacky;


public class MainActivity extends AppCompatActivity {
public class ExampleActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final RelativeLayout layout = (RelativeLayout) findViewById(R.id.activity_main);
setContentView(R.layout.activity_example);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);

findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snacky.builder()
.setView(view)
.setText("You have to use CoordinatorLayout as usual to have a FAB floating with the Snackbar.")
.setDuration(Snacky.LENGTH_SHORT)
.build()
.show();
}
});

findViewById(R.id.button_default).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Snacky.builder()
.setActivty(MainActivity.this)
.setActivty(ExampleActivity.this)
.setActionText("ACTION")
.setActionClickListener(new View.OnClickListener() {
@Override
Expand All @@ -42,7 +56,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Snacky.builder()
.setActivty(MainActivity.this)
.setActivty(ExampleActivity.this)
.setText("Success")
.setDuration(Snacky.LENGTH_SHORT)
.success()
Expand All @@ -53,7 +67,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Snacky.builder()
.setActivty(MainActivity.this)
.setView(v)
.setText("Info (with centered text)")
.centerText()
.setDuration(Snacky.LENGTH_LONG)
Expand All @@ -65,7 +79,7 @@ public void onClick(View v) {
@Override
public void onClick(View v) {
Snackbar warningSnackBar = Snacky.builder()
.setActivty(MainActivity.this)
.setActivty(ExampleActivity.this)
.setText("Warning with Snackbar.Callback")
.setDuration(Snacky.LENGTH_LONG)
.warning();
Expand All @@ -92,7 +106,7 @@ public void onDismissed(Snackbar sb, int event) {
@Override
public void onClick(View v) {
Snacky.builder()
.setView(layout)
.setView(v)
.setText("Error")
.setDuration(Snacky.LENGTH_INDEFINITE)
.setActionText(android.R.string.ok)
Expand All @@ -108,20 +122,25 @@ public void onClick(View v) {
.setBackgroundColor(Color.parseColor("#0077CC"))
.setTextSize(18)
.setTextColor(Color.parseColor("#FFFFFF"))
.setTextTypefaceStyle(Typeface.ITALIC)
.setText(
"This is a custom Snackbar with all possibilities of customization and an icon. It will be cutted after 4 lines of text, so it depends on your test device if you can read all of this")
.setMaxLines(4)
.centerText()
.setActionText("YEAH!")
.setActionTextColor(Color.parseColor("#66FFFFFF"))
.setActionTextSize(20)
.setActionTextTypefaceStyle(Typeface.BOLD)
.setIcon(R.mipmap.ic_launcher)
.setActivty(MainActivity.this)
.setActivty(ExampleActivity.this)
.setDuration(Snacky.LENGTH_INDEFINITE)
.build()
.show();


}
});

}

}
34 changes: 34 additions & 0 deletions app/src/main/res/layout/activity_example.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="de.mateware.snackysample.ExampleActivity">

<android.support.design.widget.AppBarLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:theme="@style/AppTheme.AppBarOverlay">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>

</android.support.design.widget.AppBarLayout>

<include layout="@layout/content_example"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_alert"/>

</android.support.design.widget.CoordinatorLayout>
79 changes: 0 additions & 79 deletions app/src/main/res/layout/activity_main.xml

This file was deleted.

Loading

0 comments on commit d39ee40

Please sign in to comment.