fix the emoji selection dialog

This commit is contained in:
Conny Duck 2018-06-25 16:23:43 +02:00
parent 9bda0c6c5d
commit 970551adee
11 changed files with 100 additions and 93 deletions

View File

@ -117,7 +117,7 @@ public class EmojiPreference extends DialogPreference {
// Switch to downloading style // Switch to downloading style
download.setVisibility(View.GONE); download.setVisibility(View.GONE);
caption.setVisibility(View.GONE); caption.setVisibility(View.INVISIBLE);
progressBar.setVisibility(View.VISIBLE); progressBar.setVisibility(View.VISIBLE);
cancel.setVisibility(View.VISIBLE); cancel.setVisibility(View.VISIBLE);
@ -248,7 +248,6 @@ public class EmojiPreference extends DialogPreference {
.setNegativeButton(R.string.later, null) .setNegativeButton(R.string.later, null)
.setPositiveButton(R.string.restart, ((dialog, which) -> { .setPositiveButton(R.string.restart, ((dialog, which) -> {
// Restart the app // Restart the app
// TODO: I'm not sure if this is a good solution but it seems to work
// From https://stackoverflow.com/a/17166729/5070653 // From https://stackoverflow.com/a/17166729/5070653
Intent launchIntent = new Intent(context, MainActivity.class); Intent launchIntent = new Intent(context, MainActivity.class);
PendingIntent mPendingIntent = PendingIntent.getActivity( PendingIntent mPendingIntent = PendingIntent.getActivity(

View File

@ -32,33 +32,30 @@ public class EmojiCompatFont {
private static final String DIRECTORY = "emoji"; private static final String DIRECTORY = "emoji";
// These are the items which are also present in the JSON files // These are the items which are also present in the JSON files
private final String name, display, url, src; private final String name, display, url;
// The thumbnail image and the caption are provided as resource ids // The thumbnail image and the caption are provided as resource ids
private final int img, caption; private final int img, caption;
private AsyncTask fontDownloader; private AsyncTask fontDownloader;
// The system font gets some special behavior... // The system font gets some special behavior...
public static final EmojiCompatFont SYSTEM_DEFAULT = private static final EmojiCompatFont SYSTEM_DEFAULT =
new EmojiCompatFont("system-default", new EmojiCompatFont("system-default",
"System Default", "System Default",
R.string.caption_systememoji, R.string.caption_systememoji,
R.drawable.ic_emoji_24dp, R.drawable.ic_emoji_34dp,
"",
""); "");
private static final EmojiCompatFont BLOBMOJI = private static final EmojiCompatFont BLOBMOJI =
new EmojiCompatFont("Blobmoji", new EmojiCompatFont("Blobmoji",
"Blobmoji", "Blobmoji",
R.string.caption_blobmoji, R.string.caption_blobmoji,
R.drawable.ic_blobmoji, R.drawable.ic_blobmoji,
"https://tuskyapp.github.io/hosted/emoji/BlobmojiCompat.ttf", "https://tuskyapp.github.io/hosted/emoji/BlobmojiCompat.ttf"
"https://github.com/c1710/blobmoji"
); );
private static final EmojiCompatFont TWEMOJI = private static final EmojiCompatFont TWEMOJI =
new EmojiCompatFont("Twemoji", new EmojiCompatFont("Twemoji",
"Twemoji", "Twemoji",
R.string.caption_twemoji, R.string.caption_twemoji,
R.drawable.ic_twemoji, R.drawable.ic_twemoji,
"https://tuskyapp.github.io/hosted/emoji/TwemojiCompat.ttf", "https://tuskyapp.github.io/hosted/emoji/TwemojiCompat.ttf"
"https://github.com/twitter/twemoji"
); );
/** /**
@ -67,19 +64,16 @@ public class EmojiCompatFont {
*/ */
public static final EmojiCompatFont[] FONTS = {SYSTEM_DEFAULT, BLOBMOJI, TWEMOJI}; public static final EmojiCompatFont[] FONTS = {SYSTEM_DEFAULT, BLOBMOJI, TWEMOJI};
private EmojiCompatFont(String name, private EmojiCompatFont(String name,
String display, String display,
int caption, int caption,
int img, int img,
String url, String url) {
String src) {
this.name = name; this.name = name;
this.display = display; this.display = display;
this.caption = caption; this.caption = caption;
this.img = img; this.img = img;
this.url = url; this.url = url;
this.src = src;
} }
/** /**
@ -117,10 +111,6 @@ public class EmojiCompatFont {
return url; return url;
} }
public String getSrc() {
return src;
}
public Drawable getThumb(Context context) { public Drawable getThumb(Context context) {
return context.getResources().getDrawable(img); return context.getResources().getDrawable(img);
} }

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="34dp"
android:height="34dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="@color/text_color_secondary_dark"
android:pathData="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector>

View File

@ -1,5 +1,5 @@
<vector android:height="40dp" android:viewportHeight="128" <vector android:height="34dp" android:viewportHeight="128"
android:viewportWidth="128" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:viewportWidth="128" android:width="34dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FCC21B" android:pathData="M63.79,8.64C1.48,8.64 0,78.5 0,92.33c0,13.83 28.56,25.03 63.79,25.03c35.24,0 63.79,-11.21 63.79,-25.03C127.58,78.5 126.11,8.64 63.79,8.64z"/> <path android:fillColor="#FCC21B" android:pathData="M63.79,8.64C1.48,8.64 0,78.5 0,92.33c0,13.83 28.56,25.03 63.79,25.03c35.24,0 63.79,-11.21 63.79,-25.03C127.58,78.5 126.11,8.64 63.79,8.64z"/>
<path android:fillColor="#ED6C30" android:pathData="M96.46,70.26c-3.09,-2.09 -6.98,-0.71 -10.42,0c-9.58,1.98 -18,2.06 -22.04,2.06s-12.46,-0.08 -22.04,-2.06c-3.44,-0.71 -7.33,-2.09 -10.42,0c-3.92,2.65 -1.03,12.15 5.14,18.57c3.73,3.88 12.61,11.41 27.32,11.41c14.71,0 23.59,-7.53 27.32,-11.41C97.49,82.41 100.37,72.91 96.46,70.26z"/> <path android:fillColor="#ED6C30" android:pathData="M96.46,70.26c-3.09,-2.09 -6.98,-0.71 -10.42,0c-9.58,1.98 -18,2.06 -22.04,2.06s-12.46,-0.08 -22.04,-2.06c-3.44,-0.71 -7.33,-2.09 -10.42,0c-3.92,2.65 -1.03,12.15 5.14,18.57c3.73,3.88 12.61,11.41 27.32,11.41c14.71,0 23.59,-7.53 27.32,-11.41C97.49,82.41 100.37,72.91 96.46,70.26z"/>
<path android:fillAlpha="0.82304526" android:fillColor="#34d400" <path android:fillAlpha="0.82304526" android:fillColor="#34d400"

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="34dp"
android:height="34dp"
android:viewportHeight="24"
android:viewportWidth="24">
<path
android:fillColor="@color/text_color_secondary_light"
android:pathData="M12,17.5C14.33,17.5 16.3,16.04 17.11,14H6.89C7.69,16.04 9.67,17.5 12,17.5M8.5,11A1.5,1.5 0 0,0 10,9.5A1.5,1.5 0 0,0 8.5,8A1.5,1.5 0 0,0 7,9.5A1.5,1.5 0 0,0 8.5,11M15.5,11A1.5,1.5 0 0,0 17,9.5A1.5,1.5 0 0,0 15.5,8A1.5,1.5 0 0,0 14,9.5A1.5,1.5 0 0,0 15.5,11M12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4A8,8 0 0,1 20,12A8,8 0 0,1 12,20M12,2C6.47,2 2,6.5 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z" />
</vector>

View File

@ -1,5 +1,5 @@
<vector android:height="40dp" android:viewportHeight="36" <vector android:height="34dp" android:viewportHeight="36"
android:viewportWidth="36" android:width="40dp" xmlns:android="http://schemas.android.com/apk/res/android"> android:viewportWidth="36" android:width="34dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FFCB4C" android:pathData="M18,17.018m-17,0a17,17 0,1 1,34 0a17,17 0,1 1,-34 0"/> <path android:fillColor="#FFCB4C" android:pathData="M18,17.018m-17,0a17,17 0,1 1,34 0a17,17 0,1 1,-34 0"/>
<path android:fillColor="#65471B" android:pathData="M14.524,21.036c-0.145,-0.116 -0.258,-0.274 -0.312,-0.464 -0.134,-0.46 0.13,-0.918 0.59,-1.021 4.528,-1.021 7.577,1.363 7.706,1.465 0.384,0.306 0.459,0.845 0.173,1.205 -0.286,0.358 -0.828,0.401 -1.211,0.097 -0.11,-0.084 -2.523,-1.923 -6.182,-1.098 -0.274,0.061 -0.554,-0.016 -0.764,-0.184z"/> <path android:fillColor="#65471B" android:pathData="M14.524,21.036c-0.145,-0.116 -0.258,-0.274 -0.312,-0.464 -0.134,-0.46 0.13,-0.918 0.59,-1.021 4.528,-1.021 7.577,1.363 7.706,1.465 0.384,0.306 0.459,0.845 0.173,1.205 -0.286,0.358 -0.828,0.401 -1.211,0.097 -0.11,-0.084 -2.523,-1.923 -6.182,-1.098 -0.274,0.061 -0.554,-0.016 -0.764,-0.184z"/>
<path android:fillColor="#65471B" android:pathData="M10.994,11.174a2.125,2.656 0,1 0,4.25 0a2.125,2.656 0,1 0,-4.25 0z"/> <path android:fillColor="#65471B" android:pathData="M10.994,11.174a2.125,2.656 0,1 0,4.25 0a2.125,2.656 0,1 0,-4.25 0z"/>

View File

@ -158,6 +158,7 @@
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
license:license="@string/license_cc_by_4" license:license="@string/license_cc_by_4"
license:link="https://github.com/c1710/blobmoji"
license:name="Blobmoji" /> license:name="Blobmoji" />
<TextView <TextView

View File

@ -1,38 +1,42 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto" android:paddingTop="16dp">
android:layout_marginTop="20dp">
<LinearLayout <LinearLayout
android:id="@+id/emoji_font_list" android:id="@+id/emoji_font_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
<include <include
android:id="@+id/item_blobmoji" android:id="@+id/item_blobmoji"
layout="@layout/item_emoji_pref" /> layout="@layout/item_emoji_pref" />
<include <include
android:id="@+id/item_twemoji" android:id="@+id/item_twemoji"
layout="@layout/item_emoji_pref"/> layout="@layout/item_emoji_pref" />
<include <include
android:id="@+id/item_nomoji" android:id="@+id/item_nomoji"
layout="@layout/item_emoji_pref" /> layout="@layout/item_emoji_pref" />
</LinearLayout> </LinearLayout>
<!--There's a short explanation that you'll need to download the emoji fonts first-->
<TextView <TextView
android:id="@+id/emoji_download_label" android:id="@+id/emoji_download_label"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@+id/emoji_font_list" android:lineSpacingMultiplier="1.1"
android:paddingBottom="24dp" app:layout_constraintStart_toStartOf="parent"
android:paddingTop="20dp" app:layout_constraintEnd_toEndOf="parent"
android:paddingBottom="8dp"
android:paddingEnd="24dp" android:paddingEnd="24dp"
android:paddingStart="24dp" android:paddingStart="24dp"
android:paddingTop="16dp"
android:text="@string/download_fonts" android:text="@string/download_fonts"
android:textColor="?android:attr/textColorSecondary"/> android:textColor="?android:attr/textColorSecondary"
app:layout_constraintTop_toBottomOf="@+id/emoji_font_list" />
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>

View File

@ -1,54 +1,56 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/emojicompat_container" android:id="@+id/emojicompat_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="72dp" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
xmlns:tools="http://schemas.android.com/tools"> android:paddingBottom="8dp"
android:paddingTop="8dp">
<!--This is a thumbnail picture--> <!--This is a thumbnail picture-->
<ImageView <ImageView
android:id="@+id/emojicompat_thumb" android:id="@+id/emojicompat_thumb"
android:layout_width="48dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="42dp"
android:padding="4dp"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:layout_marginTop="12dp" android:padding="4dp"
android:layout_marginBottom="12dp" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" app:srcCompat="@drawable/ic_emoji_24dp" />
app:srcCompat="@drawable/ic_emoji_24dp"/>
<!--This is the font's name--> <!--This is the font's name-->
<TextView <TextView
android:id="@+id/emojicompat_name" android:id="@+id/emojicompat_name"
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="72dp" android:layout_marginEnd="72dp"
android:layout_marginTop="8dp" android:layout_marginStart="12dp"
tools:text="@string/system_default"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
android:textSize="?attr/status_text_medium" android:textSize="?attr/status_text_medium"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintBottom_toTopOf="@+id/emojicompat_caption"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintStart_toEndOf="@+id/emojicompat_thumb"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/system_default" />
<!--A short caption...--> <!--A short caption...-->
<TextView <TextView
android:id="@+id/emojicompat_caption" android:id="@+id/emojicompat_caption"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="72dp" android:layout_marginEnd="72dp"
tools:text=""
app:layout_constraintTop_toBottomOf="@id/emojicompat_name"
app:layout_constraintStart_toStartOf="@id/emojicompat_name"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintEnd_toEndOf="parent"
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
android:textSize="12sp"/> android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toStartOf="@id/emojicompat_name"
app:layout_constraintTop_toBottomOf="@id/emojicompat_name"
app:layout_constraintVertical_chainStyle="packed"
tools:text="@string/caption_blobmoji" />
<!--This progress bar is shown while the font is downloading.--> <!--This progress bar is shown while the font is downloading.-->
<ProgressBar <ProgressBar
@ -58,61 +60,54 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="72dp" android:layout_marginEnd="72dp"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:indeterminate="false"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@id/emojicompat_name" app:layout_constraintStart_toStartOf="@id/emojicompat_name"
app:layout_constraintTop_toBottomOf="@id/emojicompat_name" app:layout_constraintTop_toBottomOf="@id/emojicompat_name" />
android:indeterminate="false"
android:visibility="gone"/>
<!--Click on it and the font will be downloaded!--> <!--Click on it and the font will be downloaded!-->
<ImageButton <ImageButton
android:id="@+id/emojicompat_download" android:id="@+id/emojicompat_download"
android:layout_width="48dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="42dp"
android:layout_margin="12dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/download_fonts"
android:focusable="true"
android:tint="@color/colorPrimary"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/emojicompat_caption"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_file_download_black_24dp" app:srcCompat="@drawable/ic_file_download_black_24dp" />
android:tint="@color/colorPrimary"
app:layout_constraintVertical_bias="0.5"
android:focusable="true"
android:contentDescription="@string/download_fonts"
android:visibility="gone"/>
<!--TODO: enable this button again-->
<!--You should be able to cancel the download--> <!--You should be able to cancel the download-->
<ImageButton <ImageButton
android:id="@+id/emojicompat_download_cancel" android:id="@+id/emojicompat_download_cancel"
android:layout_width="48dp" android:layout_width="42dp"
android:layout_height="48dp" android:layout_height="42dp"
android:layout_margin="12dp"
android:background="?attr/selectableItemBackgroundBorderless" android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_cancel_black_24dp"
android:tint="@color/colorPrimary"
app:layout_constraintVertical_bias="0.5"
android:focusable="true"
android:contentDescription="@android:string/cancel" android:contentDescription="@android:string/cancel"
android:visibility="gone"/> android:focusable="true"
android:tint="@color/colorPrimary"
<!--You'll probably want to select an emoji font, don't you?--> android:visibility="gone"
<!--RadioButtons have a very strange behavior when it comes to their size.
That's why the width is set to such an unusual value.-->
<RadioButton
android:id="@+id/emojicompat_radio"
android:layout_width="52dp"
android:layout_height="72dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/emojicompat_name" app:layout_constraintStart_toEndOf="@id/emojicompat_name"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="1" app:srcCompat="@drawable/ic_cancel_black_24dp" />
android:visibility="visible" />
<!--You'll probably want to select an emoji font, don't you?-->
<android.support.v7.widget.AppCompatRadioButton
android:id="@+id/emojicompat_radio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:buttonTint="?attr/compound_button_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/emojicompat_name"
app:layout_constraintTop_toTopOf="parent" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>

View File

@ -280,7 +280,7 @@
<string name="later">Später</string> <string name="later">Später</string>
<string name="restart">Neustarten</string> <string name="restart">Neustarten</string>
<string name="caption_systememoji">Die Standard-Emojis deines Geräts</string> <string name="caption_systememoji">Die Standard-Emojis deines Geräts</string>
<string name="caption_blobmoji">Ein EmojiSet, das auf den "Blob"Emojis aus Android 4.47.1 basiert</string> <string name="caption_blobmoji">Die BlobEmojis aus Android 4.47.1</string>
<string name="caption_twemoji">Die Standard-Emojis von Mastodon</string> <string name="caption_twemoji">Die Standard-Emojis von Mastodon</string>
<string name="download_failed">Download fehlgeschlagen.</string> <string name="download_failed">Download fehlgeschlagen.</string>

View File

@ -325,7 +325,7 @@
<string name="later">Later</string> <string name="later">Later</string>
<string name="restart">Restart</string> <string name="restart">Restart</string>
<string name="caption_systememoji">Your device\'s default emoji set</string> <string name="caption_systememoji">Your device\'s default emoji set</string>
<string name="caption_blobmoji">An emoji set based on the Blob emojis known from Android 4.47.1</string> <string name="caption_blobmoji">The Blob emojis known from Android 4.47.1</string>
<string name="caption_twemoji">Mastodon\'s standard emoji set</string> <string name="caption_twemoji">Mastodon\'s standard emoji set</string>
<string name="download_failed">Download failed</string> <string name="download_failed">Download failed</string>