Add autocompletion for custom emoji (#1089)

* Remove unnecessary //noinspection ConstantConditions

* Add autocompletion for custom emoji

* Update MentionTagTokenizer tests for emoji autocomplete support

* Move 1) emoji list retrieval notifying and 2) setting of emojiList field into setEmojiList() method of ComposeActivity

* Convert RelativeLayout in item_autocomplete_emoji.xml to LinearLayout

* Rename MentionTag* to Compose*

* Improve emoji autocomplete matching

* Make hashtag autocomplete results bold

* Use Context.getString()'s built-in formatting

* Add a divider between emoji autocomplete results that *start with* the token and those that *contain* it
This commit is contained in:
autumnontape 2019-03-04 10:28:08 -08:00 committed by Konrad Pozniak
commit 10fcee4798
14 changed files with 232 additions and 38 deletions

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="@color/autocomplete_divider_dark" />
</shape>

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:height="1dp" />
<solid android:color="@color/status_divider_light" />
</shape>

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<View xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/autocomplete_divider_drawable" />

View file

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="8dp">
<ImageView
android:id="@+id/preview"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="4dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="4dp"
android:layout_marginBottom="4dp"
android:contentDescription="@null"
android:padding="4dp" />
<TextView
android:id="@+id/shortcode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:ellipsize="end"
android:maxLines="1"
android:textColor="?android:textColorPrimary"
android:textSize="?attr/status_text_large"
android:textStyle="normal|bold"
tools:text=":mastodon:" />
</LinearLayout>

View file

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hashtag"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
android:textSize="?attr/status_text_medium"
android:textStyle="normal|bold" />

View file

@ -72,6 +72,8 @@
<item name="compound_button_color">@color/compound_button_color_dark</item>
<item name="autocomplete_divider_drawable">@drawable/autocomplete_divider_dark</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="minTouchTargetSize">32dp</item> <!-- this affects RadioButton size -->

View file

@ -38,6 +38,7 @@
<attr name="card_background" format="reference|color" />
<attr name="card_image_background" format="reference|color" />
<attr name="compound_button_color" format="reference" />
<attr name="autocomplete_divider_drawable" format="reference" />
<attr name="play_indicator_drawable" format="reference" />
<attr name="status_text_small" format="dimension" />

View file

@ -28,6 +28,7 @@
<color name="compose_media_button_disabled_dark">#586173</color>
<color name="custom_tab_toolbar_dark">#313543</color>
<color name="compose_reply_content_background_dark">#373c4b</color>
<color name="autocomplete_divider_dark">#424a5b</color>
<!--Black Theme Colors-->
<color name="color_primary_black">#000000</color>
<color name="color_primary_dark_black">#111111</color> <!--Dark Dark-->

View file

@ -355,6 +355,7 @@
<string name="caption_systememoji">Your device\'s default emoji set</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="emoji_shortcode_format" translatable="false">:%s:</string>
<string name="download_failed">Download failed</string>

View file

@ -120,6 +120,8 @@
<item name="compound_button_color">@color/compound_button_color_light</item>
<item name="autocomplete_divider_drawable">@drawable/autocomplete_divider_light</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlay</item>
<item name="minTouchTargetSize">32dp</item> <!-- this affects RadioButton size -->