Refactoring

pull/156/head
M66B 6 years ago
parent 35c7993d92
commit 7f0de48d0e

@ -3005,10 +3005,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.colorWarning = Helper.resolveColor(context, R.attr.colorWarning);
this.textColorSecondary = Helper.resolveColor(context, android.R.attr.textColorSecondary);
this.colorUnread = Helper.resolveColor(context, R.attr.colorUnread);
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(R.attr.themeName, tv, true);
this.dark = !"light".equals(tv.string);
this.dark = Helper.isDarkTheme(context);
this.hasWebView = Helper.hasWebView(context);
this.contacts = Helper.hasPermission(context, Manifest.permission.READ_CONTACTS);

@ -37,7 +37,6 @@ import android.graphics.RectF;
import android.net.Uri;
import android.os.Handler;
import android.provider.ContactsContract;
import android.util.TypedValue;
import androidx.preference.PreferenceManager;
@ -159,11 +158,8 @@ public class ContactInfo {
}
if (info.bitmap == null) {
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(R.attr.themeName, tv, true);
int dp = Helper.dp2pixels(context, 48);
boolean dark = !"light".equals(tv.string);
boolean dark = Helper.isDarkTheme(context);
boolean identicons = prefs.getBoolean("identicons", false);
if (identicons)
info.bitmap = Identicon.icon(key, dp, 5, dark);

@ -36,6 +36,7 @@ import android.text.Spannable;
import android.text.Spanned;
import android.text.format.DateUtils;
import android.text.format.Time;
import android.util.TypedValue;
import android.view.Menu;
import android.view.View;
import android.view.ViewGroup;
@ -280,6 +281,12 @@ public class Helper {
}
}
static boolean isDarkTheme(Context context) {
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(R.attr.themeName, tv, true);
return (tv.string != null && !"light".contentEquals(tv.string));
}
// Formatting
static String humanReadableByteCount(long bytes, boolean si) {

Loading…
Cancel
Save