Merge pull request #301 from metaphore/media-send-emoji-panel-fix

Fix MediaSendActivity Crash
This commit is contained in:
Niels Andriesse 2020-08-27 09:32:30 +10:00 committed by GitHub
commit a31c58a25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 9 deletions

View File

@ -4,6 +4,6 @@
android:orientation="horizontal" android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/emoji_variation_selector_background"> android:elevation="4dp">
</LinearLayout> </LinearLayout>

View File

@ -27,6 +27,25 @@
<item name="colorAccent">@color/accent</item> <item name="colorAccent">@color/accent</item>
<item name="actionModeBackground">@color/compose_view_background</item> <item name="actionModeBackground">@color/compose_view_background</item>
<item name="windowActionModeOverlay">true</item> <item name="windowActionModeOverlay">true</item>
<item name="emoji_tab_strip_background">@color/compose_view_background</item>
<item name="emoji_tab_indicator">@color/accent</item>
<item name="emoji_tab_underline">@color/gray78</item>
<item name="emoji_tab_seperator">@color/gray70</item>
<item name="emoji_drawer_background">@color/compose_text_view_background</item>
<item name="emoji_text_color">@color/white</item>
<item name="emoji_category_recent">@drawable/ic_recent_dark_20</item>
<item name="emoji_category_people">@drawable/ic_emoji_people_dark_20</item>
<item name="emoji_category_nature">@drawable/ic_emoji_animal_dark_20</item>
<item name="emoji_category_foods">@drawable/ic_emoji_food_dark_20</item>
<item name="emoji_category_activity">@drawable/ic_emoji_activity_dark_20</item>
<item name="emoji_category_places">@drawable/ic_emoji_travel_dark_20</item>
<item name="emoji_category_objects">@drawable/ic_emoji_object_dark_20</item>
<item name="emoji_category_symbol">@drawable/ic_emoji_symbol_dark_20</item>
<item name="emoji_category_flags">@drawable/ic_emoji_flag_dark_20</item>
<item name="emoji_category_emoticons">@drawable/ic_emoji_emoticon_dark_20</item>
<item name="emoji_variation_selector_background">@drawable/emoji_variation_selector_background_dark</item>
</style> </style>
<style name="Session.DarkTheme.SubtitleActionBar" parent="@style/Theme.AppCompat"> <style name="Session.DarkTheme.SubtitleActionBar" parent="@style/Theme.AppCompat">

View File

@ -1,18 +1,19 @@
package org.thoughtcrime.securesms.components.emoji; package org.thoughtcrime.securesms.components.emoji;
import android.content.Context; import android.content.Context;
import android.os.Build;
import androidx.annotation.NonNull;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import network.loki.messenger.R; import androidx.annotation.NonNull;
import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider.EmojiEventListener; import org.thoughtcrime.securesms.components.emoji.EmojiKeyboardProvider.EmojiEventListener;
import java.util.List; import java.util.List;
import network.loki.messenger.R;
public class EmojiVariationSelectorPopup extends PopupWindow { public class EmojiVariationSelectorPopup extends PopupWindow {
private final Context context; private final Context context;
@ -29,10 +30,6 @@ public class EmojiVariationSelectorPopup extends PopupWindow {
setBackgroundDrawable(null); setBackgroundDrawable(null);
setOutsideTouchable(true); setOutsideTouchable(true);
if (Build.VERSION.SDK_INT >= 21) {
setElevation(20);
}
} }
public void setVariations(List<String> variations) { public void setVariations(List<String> variations) {

View File

@ -18,6 +18,7 @@
package org.thoughtcrime.securesms.util; package org.thoughtcrime.securesms.util;
import android.content.Context; import android.content.Context;
import android.content.res.Resources;
import android.content.res.Resources.Theme; import android.content.res.Resources.Theme;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
@ -25,10 +26,14 @@ import androidx.annotation.ArrayRes;
import androidx.annotation.AttrRes; import androidx.annotation.AttrRes;
import androidx.annotation.DimenRes; import androidx.annotation.DimenRes;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import android.util.TypedValue; import android.util.TypedValue;
import org.thoughtcrime.securesms.logging.Log;
public class ResUtil { public class ResUtil {
private static final String TAG = ResUtil.class.getSimpleName();
public static int getColor(Context context, @AttrRes int attr) { public static int getColor(Context context, @AttrRes int attr) {
final TypedArray styledAttributes = context.obtainStyledAttributes(new int[]{attr}); final TypedArray styledAttributes = context.obtainStyledAttributes(new int[]{attr});
@ -47,8 +52,15 @@ public class ResUtil {
return out.resourceId; return out.resourceId;
} }
@Nullable
public static Drawable getDrawable(Context c, @AttrRes int attr) { public static Drawable getDrawable(Context c, @AttrRes int attr) {
return ContextCompat.getDrawable(c, getDrawableRes(c, attr)); int drawableRes = getDrawableRes(c, attr);
if (drawableRes == 0) {
Log.e(TAG, "Cannot find a drawable resource associated with the attribute: " + attr,
new Resources.NotFoundException());
return null;
}
return ContextCompat.getDrawable(c, drawableRes);
} }
public static int[] getResourceIds(Context c, @ArrayRes int array) { public static int[] getResourceIds(Context c, @ArrayRes int array) {