session-android/src/org/thoughtcrime/securesms/util/ThemeUtil.java
Greyson Parrelli 6fa7eca60b Implement new media send flow.
Update our media send flow to allow users to send multiple images/videos
at once. This change includes:

- New in-app media picker flow.
- Ability to caption images and videos.
- Image editing tools are made more prominent in the flow.
- Some fixes to the image editing tools.
2019-01-14 11:25:06 -08:00

47 lines
1.5 KiB
Java

package org.thoughtcrime.securesms.util;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.StyleRes;
import android.support.v7.view.ContextThemeWrapper;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import org.thoughtcrime.securesms.R;
public class ThemeUtil {
public static boolean isDarkTheme(@NonNull Context context) {
return getAttribute(context, R.attr.theme_type, "light").equals("dark");
}
public static int getThemedColor(@NonNull Context context, @AttrRes int attr) {
TypedValue typedValue = new TypedValue();
Resources.Theme theme = context.getTheme();
if (theme.resolveAttribute(attr, typedValue, true)) {
return typedValue.data;
}
return Color.RED;
}
public static LayoutInflater getThemedInflater(@NonNull Context context, @NonNull LayoutInflater inflater, @StyleRes int theme) {
Context contextThemeWrapper = new ContextThemeWrapper(context, theme);
return inflater.cloneInContext(contextThemeWrapper);
}
private static String getAttribute(Context context, int attribute, String defaultValue) {
TypedValue outValue = new TypedValue();
if (context.getTheme().resolveAttribute(attribute, outValue, true)) {
return outValue.coerceToString().toString();
} else {
return defaultValue;
}
}
}