Skip to content
This repository has been archived by the owner on Sep 6, 2019. It is now read-only.

Commit

Permalink
Fixed check marks not visible with some themes
Browse files Browse the repository at this point in the history
Refs #1057
  • Loading branch information
M66B committed Jan 4, 2014
1 parent b395c16 commit ced4b4e
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 41 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Test and beta releases will have experimental functions enabled by default.

* Fixed disabling application settings when using global settings ([issue](https://github.com/M66B/XPrivacy/issues/1050))
* Fixed display issues and scroll lag ([issue](https://github.com/M66B/XPrivacy/issues/1049)) ([issue](https://github.com/M66B/XPrivacy/issues/1059))
* Fixed check marks not visible with some themes ([issue](https://github.com/M66B/XPrivacy/issues/1057))
* Updated Vietnamese translation

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
Expand Down
File renamed without changes
Binary file removed res/drawable/check_off_holo_dark.png
Binary file not shown.
Binary file removed res/drawable/check_off_holo_light.png
Binary file not shown.
Binary file removed res/drawable/checked_box_holo_dark.png
Binary file not shown.
Binary file removed res/drawable/checked_box_holo_light.png
Binary file not shown.
2 changes: 1 addition & 1 deletion res/layout/mainlist.xml
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
android:layout_width="24dip"
android:layout_height="24dip"
android:contentDescription="@string/title_restrict"
android:src="?attr/icon_checked" />
android:src="?attr/icon_restricted" />

<CheckBox
android:id="@+id/cbFRestriction"
Expand Down
8 changes: 2 additions & 6 deletions res/values-v14/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
<item name="icon_expander_minimized">@drawable/expander_ic_minimized_holo_dark</item>
<item name="icon_expander_maximized">@drawable/expander_ic_maximized_holo_dark</item>
<item name="icon_launcher">@drawable/ic_launcher_holo_dark</item>
<item name="icon_checked">@drawable/check_holo_dark</item>
<item name="icon_check_off">@drawable/check_off_holo_dark</item>
<item name="icon_checked_box">@drawable/checked_box_holo_dark</item>
<item name="icon_restricted">@drawable/check_holo_dark</item>
<item name="icon_clear">@drawable/cross_holo_dark</item>
<item name="icon_clear_grayed">@drawable/cross_grayed_out_holo_dark</item>
<item name="icon_frozen">@drawable/frozen_holo_dark</item>
Expand All @@ -37,9 +35,7 @@
<item name="icon_expander_minimized">@drawable/expander_ic_minimized_holo_light</item>
<item name="icon_expander_maximized">@drawable/expander_ic_maximized_holo_light</item>
<item name="icon_launcher">@drawable/ic_launcher_holo_light</item>
<item name="icon_checked">@drawable/check_holo_light</item>
<item name="icon_check_off">@drawable/check_off_holo_light</item>
<item name="icon_checked_box">@drawable/checked_box_holo_light</item>
<item name="icon_restricted">@drawable/check_holo_light</item>
<item name="icon_clear">@drawable/cross_holo_light</item>
<item name="icon_clear_grayed">@drawable/cross_grayed_out_holo_light</item>
<item name="icon_frozen">@drawable/frozen_holo_light</item>
Expand Down
4 changes: 1 addition & 3 deletions res/values/attrs.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<resources>

<attr name="icon_checked" format="reference" />
<attr name="icon_check_off" format="reference" />
<attr name="icon_checked_box" format="reference" />
<attr name="icon_restricted" format="reference" />
<attr name="icon_granted" format="reference" />
<attr name="icon_help" format="reference" />
<attr name="icon_info" format="reference" />
Expand Down
65 changes: 34 additions & 31 deletions src/biz/bokhorst/xprivacy/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Environment;
import android.os.Process;
Expand Down Expand Up @@ -403,42 +403,45 @@ public static Bitmap[] getTriStateCheckBox(Context context) {
Bitmap[] bitmap = new Bitmap[3];

// Get highlight color
TypedArray arrayColor = context.getTheme().obtainStyledAttributes(
TypedArray arrayColor1 = context.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.colorActivatedHighlight });
int highlightColor = arrayColor.getColor(0, 0xFF00FF);
arrayColor.recycle();
int highlightColor = arrayColor1.getColor(0, 0xFF00FF);
arrayColor1.recycle();

// Get off check box
TypedArray ta1 = context.getTheme().obtainStyledAttributes(
new int[] { android.R.attr.listChoiceIndicatorMultiple });
Drawable off = ta1.getDrawable(0);
ta1.recycle();
off.setBounds(0, 0, off.getIntrinsicWidth(), off.getIntrinsicHeight());

// Get check mark
Drawable checkmark = context.getResources().getDrawable(R.drawable.checkmark);
checkmark.setBounds(0, 0, off.getIntrinsicWidth(), off.getIntrinsicHeight());
checkmark.setColorFilter(highlightColor, Mode.SRC_ATOP);

// Create off check box
// TODO: do we need btn_check_off_holo_light&dark ?
bitmap[0] = BitmapFactory.decodeResource(context.getResources(), getThemed(context, R.attr.icon_check_off));
bitmap[0] = Bitmap.createBitmap(off.getIntrinsicWidth(), off.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas0 = new Canvas(bitmap[0]);
off.draw(canvas0);

// Create half check box
bitmap[1] = Bitmap.createBitmap(bitmap[0].getWidth(), bitmap[0].getHeight(), bitmap[0].getConfig());
Canvas canvas = new Canvas(bitmap[1]);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(highlightColor);
int border = bitmap[1].getWidth() / 3;
canvas.drawBitmap(bitmap[0], 0, 0, paint);
canvas.drawRect(border, border, bitmap[1].getWidth() - border, bitmap[1].getHeight() - border, paint);
bitmap[1] = Bitmap.createBitmap(off.getIntrinsicWidth(), off.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas1 = new Canvas(bitmap[1]);
off.draw(canvas1);
Paint paint1 = new Paint();
paint1.setStyle(Paint.Style.FILL);
paint1.setColor(highlightColor);
float wborder = off.getIntrinsicWidth() / 3f;
float hborder = off.getIntrinsicHeight() / 3f;
canvas1.drawRect(wborder, hborder, off.getIntrinsicWidth() - wborder, off.getIntrinsicHeight() - hborder,
paint1);

// Create full check box
// square of highlight color
bitmap[2] = Bitmap.createBitmap(bitmap[0].getWidth(), bitmap[0].getHeight(), bitmap[0].getConfig());
bitmap[2] = Bitmap.createBitmap(off.getIntrinsicWidth(), off.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas2 = new Canvas(bitmap[2]);
canvas2.drawRect(0, 0, bitmap[2].getWidth(), bitmap[2].getHeight(), paint);

// draw checkmark with porter-duff mode DstIn which keeps the highlight
// color where the checkmark goes
Bitmap checkmark = BitmapFactory.decodeResource(context.getResources(), R.drawable.checkmark);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
canvas2.drawBitmap(checkmark, 0, 0, paint);

// add border
Bitmap checked_box = BitmapFactory.decodeResource(context.getResources(),
getThemed(context, R.attr.icon_checked_box));
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_OVER));
canvas2.drawBitmap(checked_box, 0, 0, paint);
off.draw(canvas2);
checkmark.draw(canvas2);

return bitmap;
}
Expand Down

0 comments on commit ced4b4e

Please sign in to comment.