add dark theme to emojiDrawer

Fixes #3240
Closes #3353
This commit is contained in:
agrajaghh 2015-06-08 17:54:16 +02:00 committed by Jake McGinty
parent 40af2a81db
commit ae4f6b1dd4
80 changed files with 132 additions and 37 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 832 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 641 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 811 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 745 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 464 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 519 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 496 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 414 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 883 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 861 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 786 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 585 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 457 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 729 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_emoticons_activated_dark" />
<item android:drawable="@drawable/ic_emoji_emoticons_normal_dark" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_nature_activated_dark" />
<item android:drawable="@drawable/ic_emoji_nature_normal_dark" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_objects_activated_dark" />
<item android:drawable="@drawable/ic_emoji_objects_normal_dark" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_people_activated_dark" />
<item android:drawable="@drawable/ic_emoji_people_normal_dark" />
</selector>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_places_activated_dark" />
<item android:drawable="@drawable/ic_emoji_places_normal_dark" />
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_recents_activated_dark" />
<item android:drawable="@drawable/ic_emoji_recents_normal_dark" />
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:enterFadeDuration="200"
android:exitFadeDuration="300">
<item android:state_selected="true" android:drawable="@drawable/ic_emoji_symbols_activated_dark" />
<item android:drawable="@drawable/ic_emoji_symbols_normal_dark" />
</selector>

View File

@ -7,7 +7,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:background="@color/emoji_tab_strip_background"
<LinearLayout android:background="?emoji_tab_strip_background"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp">
@ -16,22 +16,22 @@
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="match_parent"
android:background="@color/emoji_tab_strip_background"
android:background="?emoji_tab_strip_background"
app:pstsShouldExpand="true"
app:pstsTabPaddingLeftRight="@dimen/emoji_drawer_left_right_padding"
app:pstsUnderlineColor="@color/emoji_tab_underline"
app:pstsIndicatorColor="@color/emoji_tab_indicator"
app:pstsUnderlineColor="?emoji_tab_underline"
app:pstsIndicatorColor="?emoji_tab_indicator"
app:pstsIndicatorHeight="@dimen/emoji_drawer_indicator_height" />
<View android:layout_width="1px"
android:layout_height="match_parent"
android:background="#ffcccccc"
android:background="?emoji_tab_seperator"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
<org.thoughtcrime.securesms.components.RepeatableImageKey
android:id="@+id/backspace"
android:background="@color/emoji_tab_strip_background"
android:background="?emoji_tab_strip_background"
android:src="@drawable/ic_backspace_grey600_24dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
@ -45,6 +45,6 @@
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffeeeeee" />
android:background="?emoji_background" />
</org.thoughtcrime.securesms.components.KeyboardAwareLinearLayout>

View File

@ -41,6 +41,21 @@
<attr name="conversation_attach_photo" format="reference"/>
<attr name="conversation_attach" format="reference"/>
<attr name="emoji_tab_strip_background" format="color" />
<attr name="emoji_tab_indicator" format="color" />
<attr name="emoji_tab_underline" format="color" />
<attr name="emoji_tab_seperator" format="color" />
<attr name="emoji_background" format="color" />
<attr name="emoji_text_color" format="color" />
<attr name="emoji_category_recent" format="reference"/>
<attr name="emoji_category_people" format="reference"/>
<attr name="emoji_category_objects" format="reference"/>
<attr name="emoji_category_nature" format="reference"/>
<attr name="emoji_category_places" format="reference"/>
<attr name="emoji_category_symbol" format="reference"/>
<attr name="emoji_category_emoticons" format="reference"/>
<attr name="conversation_item_background" format="reference"/>
<attr name="conversation_item_received_background" format="reference" />
<attr name="conversation_item_sent_background" format="color" />

View File

@ -9,9 +9,14 @@
<color name="black">#ff000000</color>
<color name="gray5">#ffeeeeee</color>
<color name="gray10">#ffdddddd</color>
<color name="gray12">#ffe0e0e0</color>
<color name="gray13">#ffababab</color>
<color name="gray20">#ffcccccc</color>
<color name="gray27">#ffbbbbbb</color>
<color name="gray50">#ff808080</color>
<color name="gray65">#ff595959</color>
<color name="gray70">#ff4d4d4d</color>
<color name="gray78">#ff383838</color>
<color name="gray95">#ff111111</color>
<color name="gray95_transparent50">#7F111111</color>
@ -50,8 +55,4 @@
<color name="import_export_item_background_shadow_dark">#ff222222</color>
<color name="import_export_touch_highlight_light">#400099cc</color>
<color name="import_export_touch_highlight_dark">#40ffffff</color>
<color name="emoji_tab_strip_background">#ffe0e0e0</color>
<color name="emoji_tab_indicator">#66555555</color>
<color name="emoji_tab_underline">#44555555</color>
</resources>

View File

@ -86,6 +86,21 @@
<item name="conversation_attach_photo">@drawable/ic_photo_camera_light</item>
<item name="conversation_attach">@drawable/ic_attach_grey600_24dp</item>
<item name="emoji_tab_strip_background">@color/gray12</item>
<item name="emoji_tab_indicator">#66555555</item>
<item name="emoji_tab_underline">#44555555</item>
<item name="emoji_tab_seperator">@color/gray20</item>
<item name="emoji_background">@color/gray5</item>
<item name="emoji_text_color">@color/black</item>
<item name="emoji_category_recent">@drawable/emoji_category_recent_light</item>
<item name="emoji_category_people">@drawable/emoji_category_people_light</item>
<item name="emoji_category_objects">@drawable/emoji_category_objects_light</item>
<item name="emoji_category_nature">@drawable/emoji_category_nature_light</item>
<item name="emoji_category_places">@drawable/emoji_category_places_light</item>
<item name="emoji_category_symbol">@drawable/emoji_category_symbol_light</item>
<item name="emoji_category_emoticons">@drawable/emoji_category_emoticons_light</item>
<item name="conversation_item_background">@drawable/conversation_item_background</item>
<item name="conversation_item_received_background">@color/conversation_item_received_background_light</item>
<item name="conversation_item_sent_background">@color/conversation_item_sent_background_light</item>
@ -220,6 +235,21 @@
<item name="conversation_attach_photo">@drawable/ic_photo_camera_dark</item>
<item name="conversation_attach">@drawable/ic_attach_white_24dp</item>
<item name="emoji_tab_strip_background">@color/gray95</item>
<item name="emoji_tab_indicator">@color/gray65</item>
<item name="emoji_tab_underline">@color/gray78</item>
<item name="emoji_tab_seperator">@color/gray70</item>
<item name="emoji_background">@color/black</item>
<item name="emoji_text_color">@color/white</item>
<item name="emoji_category_recent">@drawable/emoji_category_recent_dark</item>
<item name="emoji_category_people">@drawable/emoji_category_people_dark</item>
<item name="emoji_category_objects">@drawable/emoji_category_objects_dark</item>
<item name="emoji_category_nature">@drawable/emoji_category_nature_dark</item>
<item name="emoji_category_places">@drawable/emoji_category_places_dark</item>
<item name="emoji_category_symbol">@drawable/emoji_category_symbol_dark</item>
<item name="emoji_category_emoticons">@drawable/emoji_category_emoticons_dark</item>
<item name="menu_new_conversation_icon">@drawable/ic_add_white_24dp</item>
<item name="menu_group_icon">@drawable/ic_group_white_24dp</item>
<item name="menu_search_icon">@drawable/ic_search_white_24dp</item>

View File

@ -1,8 +1,6 @@
package org.thoughtcrime.securesms.components.emoji;
import android.content.Context;
import android.support.annotation.ArrayRes;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.view.PagerAdapter;
@ -13,7 +11,6 @@ import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
@ -169,7 +166,7 @@ public class EmojiDrawer extends KeyboardAwareLinearLayout {
@Override public View getCustomTabView(ViewGroup viewGroup, int i) {
ImageView image = new ImageView(context);
image.setScaleType(ScaleType.CENTER_INSIDE);
image.setImageResource(pages.get(i).getIconRes());
image.setImageResource(ResUtil.getDrawableRes(context, pages.get(i).getIconAttr()));
return image;
}
}

View File

@ -1,7 +1,7 @@
package org.thoughtcrime.securesms.components.emoji;
public interface EmojiPageModel {
int getIconRes();
int getIconAttr();
String[] getEmoji();
boolean hasSpriteMap();
String getSprite();

View File

@ -7,7 +7,7 @@ import java.util.List;
public class EmojiPages {
public static final List<EmojiPageModel> PAGES = Arrays.<EmojiPageModel>asList(
new StaticEmojiPageModel(R.drawable.emoji_category_people, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_people, new String[] {
"\u263a", "\ud83d\ude0a", "\ud83d\ude00", "\ud83d\ude01", "\ud83d\ude02", "\ud83d\ude03",
"\ud83d\ude04", "\ud83d\ude05", "\ud83d\ude06", "\ud83d\ude07", "\ud83d\ude08", "\ud83d\ude09",
"\ud83d\ude2f", "\ud83d\ude10", "\ud83d\ude11", "\ud83d\ude15", "\ud83d\ude20", "\ud83d\ude2c",
@ -35,7 +35,7 @@ public class EmojiPages {
"\ud83d\udc4a", "\u261d", "\ud83d\udc46", "\ud83d\udc47", "\ud83d\udc48", "\ud83d\udc49",
"\ud83d\udc4b", "\ud83d\udc4f", "\ud83d\udc50",
}, "emoji-people.png"),
new StaticEmojiPageModel(R.drawable.emoji_category_objects, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_objects, new String[] {
"\ud83d\udd30", "\ud83d\udc84", "\ud83d\udc5e", "\ud83d\udc5f", "\ud83d\udc51", "\ud83d\udc52",
"\ud83c\udfa9", "\ud83c\udf93", "\ud83d\udc53", "\u231a", "\ud83d\udc54", "\ud83d\udc55",
"\ud83d\udc56", "\ud83d\udc57", "\ud83d\udc58", "\ud83d\udc59", "\ud83d\udc60", "\ud83d\udc61",
@ -64,7 +64,7 @@ public class EmojiPages {
"\ud83d\udcfc", "\ud83c\udfa7", "\ud83c\udfa4", "\ud83c\udfb5", "\ud83c\udfb6", "\ud83c\udfbc",
"\ud83c\udfbb", "\ud83c\udfb9", "\ud83c\udfb7", "\ud83c\udfba", "\ud83c\udfb8", "\u303d",
}, "emoji-objects.png"),
new StaticEmojiPageModel(R.drawable.emoji_category_nature, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_nature, new String[] {
"\ud83d\udc15", "\ud83d\udc36", "\ud83d\udc29", "\ud83d\udc08", "\ud83d\udc31", "\ud83d\udc00",
"\ud83d\udc01", "\ud83d\udc2d", "\ud83d\udc39", "\ud83d\udc22", "\ud83d\udc07", "\ud83d\udc30",
"\ud83d\udc13", "\ud83d\udc14", "\ud83d\udc23", "\ud83d\udc24", "\ud83d\udc25", "\ud83d\udc26",
@ -96,7 +96,7 @@ public class EmojiPages {
"\ud83c\udf06", "\ud83c\udf03", "\ud83c\udf0c", "\ud83c\udf09", "\ud83c\udf0a", "\ud83c\udf0b",
"\ud83c\udf0e", "\ud83c\udf0f", "\ud83c\udf0d", "\ud83c\udf10",
}, "emoji-nature.png"),
new StaticEmojiPageModel(R.drawable.emoji_category_places, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_places, new String[] {
"\ud83c\udfe0", "\ud83c\udfe1", "\ud83c\udfe2", "\ud83c\udfe3", "\ud83c\udfe4", "\ud83c\udfe5",
"\ud83c\udfe6", "\ud83c\udfe7", "\ud83c\udfe8", "\ud83c\udfe9", "\ud83c\udfea", "\ud83c\udfeb",
"\u26ea", "\u26f2", "\ud83c\udfec", "\ud83c\udfef", "\ud83c\udff0", "\ud83c\udfed",
@ -118,7 +118,7 @@ public class EmojiPages {
"\ud83d\udea6", "\ud83d\udea7", "\ud83d\udea8", "\u2668", "\ud83d\udc8c", "\ud83d\udc8d",
"\ud83d\udc8e", "\ud83d\udc90", "\ud83d\udc92",
}, "emoji-places.png"),
new StaticEmojiPageModel(R.drawable.emoji_category_symbol, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_symbol, new String[] {
"\ud83d\udd1d", "\ud83d\udd19", "\ud83d\udd1b", "\ud83d\udd1c", "\ud83d\udd1a", "\u23f3",
"\u231b", "\u23f0", "\u2648", "\u2649", "\u264a", "\u264b",
"\u264c", "\u264d", "\u264e", "\u264f", "\u2650", "\u2651",
@ -156,7 +156,7 @@ public class EmojiPages {
"\ud83d\udd04", "\ud83d\udce7", "\ud83d\udd05", "\ud83d\udd06", "\ud83d\udd07", "\ud83d\udd08",
"\ud83d\udd09", "\ud83d\udd0a",
}, "emoji-symbol.png"),
new StaticEmojiPageModel(R.drawable.emoji_category_emoticons, new String[] {
new StaticEmojiPageModel(R.attr.emoji_category_emoticons, new String[] {
"=-O", ":-P", ";-)", ":-(", ":-)", ":-!",
":-$", "B-)", ":O", ":-*", ":-D", ":'(",
":-\\", "O:-)", ":-[",

View File

@ -5,7 +5,6 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION_CODES;
@ -13,7 +12,8 @@ import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
import com.google.common.base.Optional;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.util.ResUtil;
public class EmojiView extends View implements Drawable.Callback {
private String emoji;
@ -58,7 +58,7 @@ public class EmojiView extends View implements Drawable.Callback {
} else {
float targetFontSize = 0.75f * getHeight() - getPaddingTop() - getPaddingBottom();
paint.setTextSize(targetFontSize);
paint.setColor(Color.BLACK);
paint.setColor(ResUtil.getColor(getContext(), R.attr.emoji_text_color));
paint.getTextBounds(emoji, 0, emoji.length(), textBounds);
float overflow = textBounds.width() / (getWidth() - getPaddingLeft() - getPaddingRight());
if (overflow > 1f) {

View File

@ -42,8 +42,8 @@ public class RecentEmojiPageModel implements EmojiPageModel {
}
}
@Override public int getIconRes() {
return R.drawable.emoji_category_recent;
@Override public int getIconAttr() {
return R.attr.emoji_category_recent;
}
@Override public String[] getEmoji() {

View File

@ -1,22 +1,22 @@
package org.thoughtcrime.securesms.components.emoji;
import android.support.annotation.DrawableRes;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
public class StaticEmojiPageModel implements EmojiPageModel {
@DrawableRes private final int icon;
@NonNull private final String[] emoji;
@Nullable private final String sprite;
@AttrRes private final int iconAttr;
@NonNull private final String[] emoji;
@Nullable private final String sprite;
public StaticEmojiPageModel(@DrawableRes int icon, @NonNull String[] emoji, @Nullable String sprite) {
this.icon = icon;
this.emoji = emoji;
this.sprite = sprite;
public StaticEmojiPageModel(@AttrRes int iconAttr, @NonNull String[] emoji, @Nullable String sprite) {
this.iconAttr = iconAttr;
this.emoji = emoji;
this.sprite = sprite;
}
public int getIconRes() {
return icon;
public int getIconAttr() {
return iconAttr;
}
@NonNull public String[] getEmoji() {