Fix programmatic VectorDrawable references.
Have to be careful with pre-21 devices. You have to use specific compat loading methods with VectorDrawables or it'll crash.
This commit is contained in:
parent
bd63b9bec9
commit
1973fbf376
2 changed files with 7 additions and 12 deletions
|
@ -1,7 +1,6 @@
|
|||
package org.thoughtcrime.securesms.components.emoji;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.AppCompatImageButton;
|
||||
|
@ -9,6 +8,7 @@ import android.util.AttributeSet;
|
|||
|
||||
import org.thoughtcrime.securesms.R;
|
||||
import org.thoughtcrime.securesms.stickers.StickerKeyboardProvider;
|
||||
import org.thoughtcrime.securesms.util.ResUtil;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
|
||||
public class EmojiToggle extends AppCompatImageButton implements MediaKeyboard.MediaKeyboardListener {
|
||||
|
@ -44,17 +44,11 @@ public class EmojiToggle extends AppCompatImageButton implements MediaKeyboard.M
|
|||
}
|
||||
|
||||
private void initialize() {
|
||||
int attributes[] = new int[] {R.attr.conversation_emoji_toggle,
|
||||
R.attr.conversation_sticker_toggle,
|
||||
R.attr.conversation_keyboard_toggle};
|
||||
this.emojiToggle = ResUtil.getDrawable(getContext(), R.attr.conversation_emoji_toggle);
|
||||
this.stickerToggle = ResUtil.getDrawable(getContext(), R.attr.conversation_sticker_toggle);
|
||||
this.imeToggle = ResUtil.getDrawable(getContext(), R.attr.conversation_keyboard_toggle);
|
||||
this.mediaToggle = emojiToggle;
|
||||
|
||||
TypedArray drawables = getContext().obtainStyledAttributes(attributes);
|
||||
this.emojiToggle = drawables.getDrawable(0);
|
||||
this.stickerToggle = drawables.getDrawable(1);
|
||||
this.imeToggle = drawables.getDrawable(2);
|
||||
this.mediaToggle = emojiToggle;
|
||||
|
||||
drawables.recycle();
|
||||
setToMedia();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ import android.support.annotation.AttrRes;
|
|||
import android.support.annotation.DimenRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.content.res.AppCompatResources;
|
||||
import android.util.TypedValue;
|
||||
|
||||
public class ResUtil {
|
||||
|
@ -48,7 +49,7 @@ public class ResUtil {
|
|||
}
|
||||
|
||||
public static Drawable getDrawable(Context c, @AttrRes int attr) {
|
||||
return ContextCompat.getDrawable(c, getDrawableRes(c, attr));
|
||||
return AppCompatResources.getDrawable(c, getDrawableRes(c, attr));
|
||||
}
|
||||
|
||||
public static int[] getResourceIds(Context c, @ArrayRes int array) {
|
||||
|
|
Loading…
Add table
Reference in a new issue