Skip to content

Commit

Permalink
Add duplicate support for Emoji start with variant selector. (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanniktech authored Jul 21, 2020
1 parent 2180501 commit 29baaff
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 14 deletions.
4 changes: 2 additions & 2 deletions UPDATING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ Does not regenerate the Java code.
Parameters are passed to the script like this:

```
npm start -- --no-download --no-copy
npm start -- --no-optimize --no-copy
```

or

```
yarn start --no-download --no-copy
yarn start --no-optimize --no-copy
```
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ final class TravelAndPlacesCategoryChunk0 {
new FacebookEmoji(0x1F31D, new String[]{"full_moon_with_face"}, 5, 48, false),
new FacebookEmoji(0x1F31E, new String[]{"sun_with_face"}, 5, 49, false),
new FacebookEmoji(0x1FA90, new String[]{"ringed_planet"}, 52, 4, false),
new FacebookEmoji(0x2B50, new String[]{"star"}, 55, 42, false),
new FacebookEmoji(0x2B50, new String[]{"star"}, 55, 42, true,
new FacebookEmoji(new int[] { 0x2B50, 0xFE0F }, new String[0], 55, 42, true)
),
new FacebookEmoji(0x1F31F, new String[]{"star2"}, 5, 50, false),
new FacebookEmoji(0x1F320, new String[]{"stars"}, 5, 51, false),
new FacebookEmoji(0x1F30C, new String[]{"milky_way"}, 5, 31, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ final class TravelAndPlacesCategoryChunk0 {
new GoogleCompatEmoji(0x1F31D, new String[]{"full_moon_with_face"}, false),
new GoogleCompatEmoji(0x1F31E, new String[]{"sun_with_face"}, false),
new GoogleCompatEmoji(0x1FA90, new String[]{"ringed_planet"}, false),
new GoogleCompatEmoji(0x2B50, new String[]{"star"}, false),
new GoogleCompatEmoji(0x2B50, new String[]{"star"}, true,
new GoogleCompatEmoji(new int[] { 0x2B50, 0xFE0F }, new String[0], true)
),
new GoogleCompatEmoji(0x1F31F, new String[]{"star2"}, false),
new GoogleCompatEmoji(0x1F320, new String[]{"stars"}, false),
new GoogleCompatEmoji(0x1F30C, new String[]{"milky_way"}, false),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ final class TravelAndPlacesCategoryChunk0 {
new GoogleEmoji(0x1F31D, new String[]{"full_moon_with_face"}, 5, 48, false),
new GoogleEmoji(0x1F31E, new String[]{"sun_with_face"}, 5, 49, false),
new GoogleEmoji(0x1FA90, new String[]{"ringed_planet"}, 52, 4, false),
new GoogleEmoji(0x2B50, new String[]{"star"}, 55, 42, false),
new GoogleEmoji(0x2B50, new String[]{"star"}, 55, 42, true,
new GoogleEmoji(new int[] { 0x2B50, 0xFE0F }, new String[0], 55, 42, true)
),
new GoogleEmoji(0x1F31F, new String[]{"star2"}, 5, 50, false),
new GoogleEmoji(0x1F320, new String[]{"stars"}, 5, 51, false),
new GoogleEmoji(0x1F30C, new String[]{"milky_way"}, 5, 31, false),
Expand Down
5 changes: 5 additions & 0 deletions emoji-ios/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ dependencies {
api project(':emoji')
}

dependencies {
testImplementation rootProject.ext.testing.junit
testImplementation rootProject.ext.testing.assertJ
}

apply plugin: "com.vanniktech.maven.publish"
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ final class TravelAndPlacesCategoryChunk0 {
new IosEmoji(0x1F31D, new String[]{"full_moon_with_face"}, 5, 48, false),
new IosEmoji(0x1F31E, new String[]{"sun_with_face"}, 5, 49, false),
new IosEmoji(0x1FA90, new String[]{"ringed_planet"}, 52, 4, false),
new IosEmoji(0x2B50, new String[]{"star"}, 55, 42, false),
new IosEmoji(0x2B50, new String[]{"star"}, 55, 42, true,
new IosEmoji(new int[] { 0x2B50, 0xFE0F }, new String[0], 55, 42, true)
),
new IosEmoji(0x1F31F, new String[]{"star2"}, 5, 50, false),
new IosEmoji(0x1F320, new String[]{"stars"}, 5, 51, false),
new IosEmoji(0x1F30C, new String[]{"milky_way"}, 5, 31, false),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.vanniktech.emoji.ios;

import com.vanniktech.emoji.EmojiManager;
import com.vanniktech.emoji.EmojiUtils;
import org.junit.Before;
import org.junit.Test;

import static org.assertj.core.api.Java6Assertions.assertThat;

public class EmojiEdgeCaseTest {
@Before public void setUp() {
EmojiManager.install(new IosEmojiProvider());
}

@Test public void starWithVariantSelector() {
final String s = "⭐️⭐️⭐️";
assertThat(EmojiUtils.emojisCount(s)).isEqualTo(3);
assertThat(EmojiUtils.isOnlyEmojis(s)).isTrue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ final class TravelAndPlacesCategoryChunk0 {
new TwitterEmoji(0x1F31D, new String[]{"full_moon_with_face"}, 5, 48, false),
new TwitterEmoji(0x1F31E, new String[]{"sun_with_face"}, 5, 49, false),
new TwitterEmoji(0x1FA90, new String[]{"ringed_planet"}, 52, 4, false),
new TwitterEmoji(0x2B50, new String[]{"star"}, 55, 42, false),
new TwitterEmoji(0x2B50, new String[]{"star"}, 55, 42, true,
new TwitterEmoji(new int[] { 0x2B50, 0xFE0F }, new String[0], 55, 42, true)
),
new TwitterEmoji(0x1F31F, new String[]{"star2"}, 5, 50, false),
new TwitterEmoji(0x1F320, new String[]{"stars"}, 5, 51, false),
new TwitterEmoji(0x1F30C, new String[]{"milky_way"}, 5, 31, false),
Expand Down
5 changes: 5 additions & 0 deletions emoji/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ android {
dependencies {
api rootProject.ext.supportAppCompat
api rootProject.ext.supportCardView
}

dependencies {
testImplementation rootProject.ext.testing.junit
testImplementation rootProject.ext.testing.assertJ
testImplementation rootProject.ext.testing.robolectric
testImplementation rootProject.ext.testing.privateConstructor
}

dependencies {
androidTestAnnotationProcessor deps.support.test.autoService
}

Expand Down
5 changes: 2 additions & 3 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
package com.vanniktech.emoji;

import android.content.Context;
import android.text.Spannable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.Spannable;
import android.text.TextUtils;
import com.vanniktech.emoji.emoji.Emoji;
import com.vanniktech.emoji.emoji.EmojiCategory;
import java.util.ArrayList;
Expand Down Expand Up @@ -211,7 +210,7 @@ Pattern getEmojiRepetitivePattern() {

final List<EmojiRange> result = new ArrayList<>();

if (!TextUtils.isEmpty(text)) {
if (text != null && text.length() > 0) {
final Matcher matcher = emojiPattern.matcher(text);

while (matcher.find()) {
Expand Down
4 changes: 1 addition & 3 deletions emoji/src/main/java/com/vanniktech/emoji/EmojiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.text.TextUtils;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand All @@ -30,7 +28,7 @@ public final class EmojiUtils {

/** returns true when the string contains only emojis. Note that whitespace will be filtered out. */
public static boolean isOnlyEmojis(@Nullable final CharSequence text) {
if (!TextUtils.isEmpty(text)) {
if (text != null && text.length() > 0) {
final String inputWithoutSpaces = SPACE_REMOVAL.matcher(text).replaceAll(Matcher.quoteReplacement(""));

return EmojiManager.getInstance()
Expand Down
1 change: 1 addition & 0 deletions generator/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jspm_packages

# Optional npm cache directory
.npm
package-lock.json

# Optional eslint cache
.eslintcache
Expand Down
17 changes: 16 additions & 1 deletion generator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,22 @@ async function parse() {
variants: [],
};

if (dataEntry.skin_variations) {
// Star can have an extra variant selector - https://github.com/vanniktech/Emoji/issues/449
if (dataEntry.unified == "2B50") {
const variantEmoji = {
unicode: dataEntry.unified + "-FE0F",
x: dataEntry.sheet_x,
y: dataEntry.sheet_y,
isDuplicate: isDuplicate,
variants: [],
};

for (const target of targets) {
variantEmoji[target.package] = true
}

emoji.variants.push(variantEmoji)
} else if (dataEntry.skin_variations) {
for (const variantDataEntry of Object.values(dataEntry.skin_variations)) {
const isDuplicate = !!variantDataEntry.obsoleted_by || duplicates.includes(variantDataEntry.unified);

Expand Down

0 comments on commit 29baaff

Please sign in to comment.