Fixed theming

This commit is contained in:
M66B 2016-01-31 09:41:09 +01:00
parent f090b48a84
commit 8e66f863d0
2 changed files with 13 additions and 11 deletions

View File

@ -43,8 +43,8 @@ public class AccessAdapter extends CursorAdapter {
private int colBlock;
private int colorText;
private int colorPrimary;
private int colorAccent;
private int colorOn;
private int colorOff;
public AccessAdapter(Context context, Cursor cursor) {
super(context, cursor, 0);
@ -62,10 +62,10 @@ public class AccessAdapter extends CursorAdapter {
}
TypedValue tv = new TypedValue();
context.getTheme().resolveAttribute(R.attr.colorPrimary, tv, true);
colorPrimary = tv.data;
context.getTheme().resolveAttribute(R.attr.colorAccent, tv, true);
colorAccent = tv.data;
context.getTheme().resolveAttribute(R.attr.colorOn, tv, true);
colorOn = tv.data;
context.getTheme().resolveAttribute(R.attr.colorOff, tv, true);
colorOff = tv.data;
}
@Override
@ -98,8 +98,8 @@ public class AccessAdapter extends CursorAdapter {
if (allowed < 0)
tvDest.setTextColor(colorText);
else if (allowed > 0)
tvDest.setTextColor(colorPrimary);
tvDest.setTextColor(colorOn);
else
tvDest.setTextColor(colorAccent);
tvDest.setTextColor(colorOff);
}
}

View File

@ -1505,9 +1505,11 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
TypedValue tv = new TypedValue();
getTheme().resolveAttribute(R.attr.colorPrimary, tv, true);
int colorPrimary = tv.data;
getTheme().resolveAttribute(R.attr.colorAccent, tv, true);
int colorAccent = tv.data;
getTheme().resolveAttribute(R.attr.colorOn, tv, true);
int colorOn = tv.data;
getTheme().resolveAttribute(R.attr.colorOff, tv, true);
int colorOff = tv.data;
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_cloud_upload_white_24dp)
@ -1548,7 +1550,7 @@ public class SinkholeService extends VpnService implements SharedPreferences.OnS
if (allowed >= 0) {
pos = sb.indexOf(daddr);
sp = new SpannableString(sb);
ForegroundColorSpan fgsp = new ForegroundColorSpan(allowed > 0 ? colorPrimary : colorAccent);
ForegroundColorSpan fgsp = new ForegroundColorSpan(allowed > 0 ? colorOn : colorOff);
sp.setSpan(fgsp, pos, pos + daddr.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
notification.addLine(sp);