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

Commit

Permalink
Added half check boxes to template
Browse files Browse the repository at this point in the history
Closes #1706
  • Loading branch information
M66B committed Jun 5, 2014
1 parent 3bde89a commit 6e181a0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Changelog
* Made filter and sort dialog scrollable, thanks @[liudongmiao](https://github.com/liudongmiao)
* Made toggle restrictions scrollable
* Removed setting *Restrict dangerous functions* ([issue](/../../issues/1704))
* Added half check boxes to template ([issue](/../../issues/1706))
* Updated simplified Chinese translation

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
Expand Down
39 changes: 23 additions & 16 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,25 @@ public View getGroupView(int groupPosition, boolean isExpanded, View convertView
Boolean.toString(!ondemand) + "+ask", false);
holder.restricted = value.contains("true");
holder.asked = (!ondemand || value.contains("asked"));
Bitmap bmRestricted = (holder.restricted ? getFullCheckBox() : getOffCheckBox());
Bitmap bmAsked = (holder.asked ? getOffCheckBox() : getOnDemandCheckBox());

boolean partialRestricted = false;
boolean partialAsked = false;
if (holder.restricted)
for (Hook hook : PrivacyManager.getHooks(restrictionName)) {
String settingName = restrictionName + "." + hook.getName();
String childValue = PrivacyManager.getSetting(userId, Meta.cTypeTemplate, settingName,
Boolean.toString(holder.restricted && !hook.isDangerous())
+ (holder.asked ? "+asked" : "+ask"), false);
if (!childValue.contains("true"))
partialRestricted = true;
if (childValue.contains("asked"))
partialAsked = true;
}

Bitmap bmRestricted = (holder.restricted ? partialRestricted ? getHalfCheckBox() : getFullCheckBox()
: getOffCheckBox());
Bitmap bmAsked = (holder.asked ? getOffCheckBox() : partialAsked ? getHalfCheckBox()
: getOnDemandCheckBox());

// Set data
holder.tvRestriction.setTypeface(null, Typeface.BOLD);
Expand All @@ -1139,9 +1156,6 @@ public void onClick(View arg0) {
holder.restricted = !holder.restricted;
PrivacyManager.setSetting(userId, Meta.cTypeTemplate, restrictionName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
// Update view
Bitmap bmRestricted = (holder.restricted ? getFullCheckBox() : getOffCheckBox());
holder.imgCbRestrict.setImageBitmap(bmRestricted);
notifyDataSetChanged(); // update childs
}
});
Expand All @@ -1153,9 +1167,6 @@ public void onClick(View arg0) {
holder.asked = (!ondemand || !holder.asked);
PrivacyManager.setSetting(userId, Meta.cTypeTemplate, restrictionName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
// Update view
Bitmap bmAsked = (holder.asked ? getOffCheckBox() : getOnDemandCheckBox());
holder.imgCbAsk.setImageBitmap(bmAsked);
notifyDataSetChanged(); // update childs
}
});
Expand Down Expand Up @@ -1208,8 +1219,8 @@ public View getChildView(int groupPosition, int childPosition, boolean isLastChi

// Get child info
String value = PrivacyManager.getSetting(userId, Meta.cTypeTemplate, settingName,
Boolean.toString(parentRestricted && !hook.isDangerous())
+ (parentAsked ? "+asked" : "+ask"), false);
Boolean.toString(parentRestricted && !hook.isDangerous()) + (parentAsked ? "+asked" : "+ask"),
false);
holder.restricted = value.contains("true");
holder.asked = (!ondemand || value.contains("asked"));
Bitmap bmRestricted = (parentRestricted && holder.restricted ? getFullCheckBox() : getOffCheckBox());
Expand Down Expand Up @@ -1256,9 +1267,7 @@ public void onClick(View view) {
holder.restricted = !holder.restricted;
PrivacyManager.setSetting(userId, Meta.cTypeTemplate, settingName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
// Update view
Bitmap bmRestricted = (holder.restricted ? getFullCheckBox() : getOffCheckBox());
holder.imgCbRestrict.setImageBitmap(bmRestricted);
notifyDataSetChanged(); // update parent
}
});

Expand All @@ -1269,9 +1278,7 @@ public void onClick(View view) {
holder.asked = !holder.asked;
PrivacyManager.setSetting(userId, Meta.cTypeTemplate, settingName, (holder.restricted ? "true"
: "false") + "+" + (holder.asked ? "asked" : "ask"));
// Update view
Bitmap bmAsked = (holder.asked ? getOffCheckBox() : getOnDemandCheckBox());
holder.imgCbAsk.setImageBitmap(bmAsked);
notifyDataSetChanged(); // update parent
}
});

Expand Down

0 comments on commit 6e181a0

Please sign in to comment.