• Stars
    star
    386
  • Rank 110,754 (Top 3 %)
  • Language
    Java
  • Created over 8 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Toggle button which shows a happy face for checked or unhappy for unchecked.

FaceOffToggleButton

WoWoViewPager BoomMenu CoCoin BlurLockView LeeCo GithubWidget JellyToggleButton FaceOffToggleButton

Toggle button which shows a happy face for checked or unhappy for unchecked.

FaceOffToggleButton

Recently, I spent some time to finish a cute toggle button and after that, I found a toggle button design with a happy or unhappy face to show the checked status. Check here for the IOS version and here for the design in Dribbble. Since I have made a similar one, so I just change some codes to create the new FaceOffToggleButton(FOTB). This document is a quite simple one and for more information, please check JellyToggleButton.

Guide

  1. 中文文档
  2. Gradle
  3. Demo
  4. Usage Guide
    1. Background Color
    2. Left & Right Background Color
    3. Left & Right Face Color
    4. Left & Right Eye Color
    5. Left & Right Mouth Color
    6. Set Checked and Toggle
    7. Listener
    8. Duration
    9. Draggable
    10. Color Change Type
    11. Dimension
    12. Other Method
  5. Todo
  6. Versions
  7. License

Gradle

dependencies {
    compile 'com.nightonke:faceofftogglebutton:1.0.0'
}

Demo

Try demo:

  1. On Github
  2. On Fir

QR Code

Usage Guide

Background Color

Notice that the background color here is totally different from the background color of a veiw. Try to set background color with the following method or check the source code and you will figure out why.

setBackgroundColor(int mBackgroundColor)
app:foBackgroundColor="@color/white"

Left & Right Background Color

The color of background when the face is on the end-of-left and end-of-right.

setLeftBackgroundColor(int mLeftBackgroundColor)
setRightBackgroundColor(int mRightBackgroundColor)
app:foLeftBackgroundColor="@color/gray"
app:foRightBackgroundColor="@color/blue"

Left & Right Face Color

The color of face when it is on the end-of-left and end-of-right.

setLeftFaceColor(int mLeftFaceColor)
setRightFaceColor(int mRightFaceColor)
app:foLeftFaceColor="@color/white"
app:foRightFaceColor="@color/white"

Left & Right Eye Color

FOTB has beautiful eyes.

setLeftEyeColor(int mLeftEyeColor)
setRightEyeColor(int mRightEyeColor)
app:foLeftEyeColor="@color/gray"
app:foRightEyeColor="@color/blue"

Left & Right Mouth Color

setLeftMouthColor(int mLeftMouthColor)
setRightMouthColor(int mRightMouthColor)
app:foLeftMouthColor="@color/gray"
app:foRightMouthColor="@color/blue"

Set Checked and Toggle

Method With Animation With Listener
setChecked(boolean checked) Y Y
setChecked(boolean checked, boolean callListener) Y Y/N
setCheckedImmediately(boolean checked) N Y
setCheckedImmediately(boolean checked, boolean callListener) N Y/N
toggle() Y Y
toggle(boolean callListener) Y Y/N
toggleImmediately() N Y
toggleImmediately(boolean callListener) N Y/N

Listener

fotb0.setOnStateChangeListener(new FaceOffToggleButton.OnStateChangeListener() {
    @Override
    public void onStateChange(float process, State state, FaceOffToggleButton fotb) {
        // process - current process of JTB, between [0, 1]
        // state   - current state of JTB, it is one of State.LEFT, State.LEFT_TO_RIGHT, State.RIGHT and State.RIGHT_TO_LEFT
        // fotb     - the FOTB
    }
});

Duration

setDuration(int duration)
app:foDuration="1000"

Draggable

setDraggable(boolean draggable)
app:foDraggable="false"

Color Change Type

For information, please check here.

setColorChangeType(ColorChangeType mColorChangeType)
app:foColorChangeType="hsv"

Dimension

// Radius of face, in pixel.
setFaceRadius(float mFaceRadius)

// The ratio for width to face radius, in float.
setWidthRadiusRatio(float mWidthRadiusRatio)

// The margin between face and background, in pixel.
setFaceMargin(float mFaceMargin)
app:foFaceRadius="15dp"
app:foWidthRadiusRatio="2.5"
app:foFaceMargin="1dp"

Other Method

The ratio for distance of finger movement to distance of face movement.

setTouchMoveRatioValue(float ratio)
app:foTouchMoveRatioValue="2"

Whether call listener when face moves to same state as last.

setMoveToSameStateCallListener(boolean callListener)
app:foMoveToSameStateCallListener="false"

Todo

  1. Ease out back effect of the eyes and mouth.
  2. More emoji.

Version

1.0.0

The first version.

License

Copyright 2016 Nightonke

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.

More Repositories

1

BoomMenu

A menu which can ... BOOM! - Android
Java
5,808
star
2

CoCoin

CoCoin, Multi-view Accounting Application
Java
2,837
star
3

WoWoViewPager

Combine ViewPager and Animations to provide a simple way to create applications' guide pages.
Java
2,748
star
4

Gitee

Gitee, OS X status bar application for Github
Swift
1,113
star
5

BlurLockView

Lock view with blur effect. Easy to customise.
Java
1,034
star
6

JellyToggleButton

Cute and colorful toggle button with 18 jelly types and 30 ease types.
Java
925
star
7

GithubWidget

Contributions, stars, followers, trending etc. on Github.
Java
698
star
8

VHBoomMenuButton

A menu which can ... BOOM! - iOS
Objective-C
582
star
9

LeeCo

LeeCo is an awesome app for (including unlock) problems, solutions, discuss(from leetcode) and comments.
Java
491
star
10

WeGo

Now we go!
Java
23
star
11

TimeFleeting

An app which record your past and remind you of future.
Java
9
star
12

Sicily

Sicily, where AC happens.
C++
8
star
13

coolweather

An example on an android-developing book.
Java
5
star
14

LeetCode

Problems and solutions in LeetCode.
C++
5
star
15

SecretPreferences

This is a powerful SharedPreferences which can encrypt the values in .xml files and decrypt them to original data.
Java
4
star
16

Notes

Someone has to win. Why not be me?
GCC Machine Description
4
star
17

SimpleWaveProgressMusicPlayer

A simple music player. Use the wave view to act like a progress to control the current position of the music.
Java
3
star
18

OldLeetCode

Solutions for LeetCode.
Java
3
star
19

What-I-ve-Done

Record what I've done.
2
star
20

ActivityAndFragmentInterface

An example code of my blog talking about the activity and fragment interface.
Java
1
star
21

Safe_SharedPreferences_AutoCompleteTextView_File_R_W

Android SharedPreferences安全存储/AutoCompleteTextView使用/文件读写
Java
1
star
22

dynamic_static_broadcast

This simple project shows how to use widget, dynamic and static broadcast in android.
Java
1
star
23

BoomMenuButton-Images

Provides images or other resource for BMB. Decrease size of code-repositories.
1
star