mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-12-12 09:37:58 +01:00
Color preference: fix crash on Android < N
Change-Id: Id14a76c1933028a97c1da43dbcce61bd92547d65
This commit is contained in:
parent
6bca1bf18b
commit
69d90fc8dd
@ -21,6 +21,7 @@ import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
@ -121,12 +122,17 @@ public class ColorMatrixListPreferenceDialogFragment extends PreferenceDialogFra
|
||||
}
|
||||
|
||||
private boolean isDarkTheme() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
TypedValue tv = new TypedValue();
|
||||
getContext().getTheme().resolveAttribute(android.R.attr.colorBackground, tv, true);
|
||||
int bgColor = tv.data;
|
||||
getContext().getTheme().resolveAttribute(android.R.attr.colorForeground, tv, true);
|
||||
int fgColor = tv.data;
|
||||
return Color.luminance(fgColor) > Color.luminance(bgColor);
|
||||
} else {
|
||||
// We might want to implement a fallback here, but for now, let's just not care
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private int getAccentColor() {
|
||||
|
Loading…
Reference in New Issue
Block a user