Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.idea
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
# Live-Emoji
# Live emojis

![](image.gif)

Animating Google emojis with Android animated vector drawables.

All credits to [noto-emoji](https://github.com/googlei18n/noto-emoji) for the original emoji.

## Can't see your favourite emoji?

- Find the svg [there](https://github.com/googlei18n/noto-emoji) and play with it. Then submit a PR, I'll be happy to review it!
- Or just post an issue with your idea. The more the merrier!

## Contributors

- [romainpiel](https://github.com/RomainPiel)
- [chiuki](https://github.com/chiuki)
- [sjthn](https://github.com/sjthn)

## License
```
Copyright 2016 Romain Piel

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 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
27 changes: 27 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

defaultConfig {
applicationId "com.romainpiel.liveemoji"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'androidx.appcompat:appcompat:1.1.0'
compile 'androidx.recyclerview:recyclerview:1.1.0'
}
17 changes: 17 additions & 0 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/romainpiel/Library/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 *;
#}
18 changes: 18 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.romainpiel.liveemoji">

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name="com.romainpiel.liveemoji.MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER"/>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>

</manifest>
41 changes: 41 additions & 0 deletions app/src/main/java/com/romainpiel/liveemoji/EmojiAdapter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.romainpiel.liveemoji;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

class EmojiAdapter extends RecyclerView.Adapter<EmojiViewHolder> {

private final List<EmojiViewModel> items;
private boolean animated;

EmojiAdapter(List<EmojiViewModel> items) {
this.items = items;
this.animated = false;
}

void setAnimated(boolean animated) {
this.animated = animated;
}

@Override
public EmojiViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_emoji, parent, false);
return new EmojiViewHolder(view);
}

@Override
public void onBindViewHolder(EmojiViewHolder holder, int position) {
holder.bind(items.get(position));
holder.setAnimated(animated);
}

@Override
public int getItemCount() {
return items.size();
}
}
32 changes: 32 additions & 0 deletions app/src/main/java/com/romainpiel/liveemoji/EmojiViewHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.romainpiel.liveemoji;

import android.graphics.drawable.AnimatedVectorDrawable;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

class EmojiViewHolder extends RecyclerView.ViewHolder {

private final ImageView imageView;

EmojiViewHolder(View itemView) {
super(itemView);
imageView = (ImageView) itemView.findViewById(R.id.emoji);
}

void bind(EmojiViewModel viewModel) {
imageView.setImageResource(viewModel.getDrawableRes());
}

void setAnimated(boolean animated) {
AnimatedVectorDrawable drawable = (AnimatedVectorDrawable) imageView.getDrawable();
if (drawable == null) {
return;
}
if (animated) {
drawable.start();
} else {
drawable.stop();
}
}
}
17 changes: 17 additions & 0 deletions app/src/main/java/com/romainpiel/liveemoji/EmojiViewModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.romainpiel.liveemoji;

import androidx.annotation.DrawableRes;

class EmojiViewModel {
@DrawableRes
private final int drawableRes;

EmojiViewModel(@DrawableRes int drawableRes) {
this.drawableRes = drawableRes;
}

@DrawableRes
int getDrawableRes() {
return drawableRes;
}
}
47 changes: 47 additions & 0 deletions app/src/main/java/com/romainpiel/liveemoji/MainActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.romainpiel.liveemoji;

import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;

public class MainActivity extends AppCompatActivity {

private EmojiAdapter adapter;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

ArrayList<EmojiViewModel> items = new ArrayList<>();
items.add(new EmojiViewModel(R.drawable.animated_emoji_u1f603));
//items.add(new EmojiViewModel(R.drawable.animated_emoji_u263a));
items.add(new EmojiViewModel(R.drawable.animated_emoji_u1f635));
items.add(new EmojiViewModel(R.drawable.animated_emoji_u1f613));
items.add(new EmojiViewModel(R.drawable.animated_emoji_u1f60e));

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recyclerview);
recyclerView.setLayoutManager(new GridLayoutManager(this, 4));

adapter = new EmojiAdapter(items);
recyclerView.setAdapter(adapter);
}

@Override
protected void onStart() {
super.onStart();
adapter.setAnimated(true);
adapter.notifyDataSetChanged();
}

@Override
protected void onStop() {
adapter.setAnimated(false);
adapter.notifyDataSetChanged();
super.onStop();
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/anim/blink.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<pathInterpolator
xmlns:android="http://schemas.android.com/apk/res/android"
android:pathData="M0,0 C0,0 0.95,0 0.95,0 C0.95,0 1,1 1,1" />
3 changes: 3 additions & 0 deletions app/src/main/res/anim/slow_blink.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<pathInterpolator
xmlns:android="http://schemas.android.com/apk/res/android"
android:pathData="M0,0 C0.025,0 0.1,0 0.1,0 C0.1,0 0.266,1.016 0.266,1 C0.266,1 1,1 1,1" />
10 changes: 10 additions & 0 deletions app/src/main/res/animator/u1f603_laugh.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:interpolator/overshoot"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="@string/u1f603_mouth_about_to_laugh"
android:valueTo="@string/u1f603_mouth_laughing"
android:valueType="pathType" />
10 changes: 10 additions & 0 deletions app/src/main/res/animator/u1f603_left_eye_laughing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@interpolator/slow_blink"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="@string/u1f603_left_eye_open"
android:valueTo="@string/u1f603_left_eye_half_closed"
android:valueType="pathType" />
10 changes: 10 additions & 0 deletions app/src/main/res/animator/u1f603_right_eye_laughing.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@interpolator/slow_blink"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="@string/u1f603_right_eye_open"
android:valueTo="@string/u1f603_right_eye_half_closed"
android:valueType="pathType" />
10 changes: 10 additions & 0 deletions app/src/main/res/animator/u1f60e_left_shade_animator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="@string/u1f60e_left_shade_start"
android:valueTo="@string/u1f60e_left_shade_end"
android:valueType="pathType" />
10 changes: 10 additions & 0 deletions app/src/main/res/animator/u1f60e_right_shade_animator.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<objectAnimator xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1000"
android:interpolator="@android:interpolator/fast_out_slow_in"
android:propertyName="pathData"
android:repeatCount="infinite"
android:repeatMode="reverse"
android:valueFrom="@string/u1f60e_right_shade_start"
android:valueTo="@string/u1f60e_right_shade_end"
android:valueType="pathType" />
40 changes: 40 additions & 0 deletions app/src/main/res/animator/u1f613_sweat_drip.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:repeatMode="restart">
<objectAnimator
android:duration="@integer/u1f613_duration"
android:repeatCount="infinite">
<propertyValuesHolder
android:propertyName="translateY">
<keyframe
android:fraction="0"
android:value="-20"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<keyframe
android:fraction="0.5"
android:value="0"/>
<keyframe
android:fraction="1"
android:value="0"/>
</propertyValuesHolder>
<propertyValuesHolder
android:propertyName="scaleY">
<keyframe
android:fraction="0"
android:value="0"
android:interpolator="@android:interpolator/fast_out_slow_in"/>
<keyframe
android:fraction="0.5"
android:value="1"/>
<keyframe
android:fraction="1"
android:value="1"/>
</propertyValuesHolder>
</objectAnimator>
<objectAnimator
android:propertyName="pivotY"
android:valueFrom="64"
android:valueTo="64"
android:duration="@integer/u1f613_duration"
android:repeatCount="infinite"/>
</set>
22 changes: 22 additions & 0 deletions app/src/main/res/animator/u1f613_sweat_drip_alpha.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
android:duration="@integer/u1f613_duration"
android:repeatCount="infinite">
<propertyValuesHolder
android:propertyName="fillAlpha">
<keyframe
android:fraction="0"
android:value="0"/>
<keyframe
android:fraction="0.25"
android:value="1"/>
<keyframe
android:fraction="0.75"
android:value="1"/>
<keyframe
android:fraction="1"
android:value="0"/>
</propertyValuesHolder>
</objectAnimator>
</set>
Loading