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

Commit

Permalink
Added application specific quirks
Browse files Browse the repository at this point in the history
Fixed #1844
  • Loading branch information
M66B committed Aug 16, 2014
1 parent f5d79df commit 95d7ae8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Version 2.99.x and version 3.x will be available with a [pro license](http://www

**Next release**

* Added application specific quirks ([issue](/../../issues/1844))
* Updated Simplified Chinese translation

[Open issues](https://github.com/M66B/XPrivacy/issues?state=open)
Expand Down
3 changes: 1 addition & 2 deletions res/layout/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
</LinearLayout>

<LinearLayout
android:id="@+id/llQuirks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="30dip"
Expand All @@ -156,7 +155,7 @@
android:id="@+id/etQuirks"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="freeze,noresolve,safemode,test"
android:hint="freeze,noresolve"
android:inputType="text"
tools:ignore="HardcodedText" />
</LinearLayout>
Expand Down
74 changes: 41 additions & 33 deletions src/biz/bokhorst/xprivacy/SettingsDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public static void edit(final ActivityBase context, ApplicationInfoEx appInfo) {
final CheckBox cbHttps = (CheckBox) dlgSettings.findViewById(R.id.cbHttps);
final LinearLayout llConfidence = (LinearLayout) dlgSettings.findViewById(R.id.llConfidence);
final EditText etConfidence = (EditText) dlgSettings.findViewById(R.id.etConfidence);
final LinearLayout llQuirks = (LinearLayout) dlgSettings.findViewById(R.id.llQuirks);
final EditText etQuirks = (EditText) dlgSettings.findViewById(R.id.etQuirks);

final CheckBox cbRandom = (CheckBox) dlgSettings.findViewById(R.id.cbRandom);
Expand Down Expand Up @@ -230,20 +229,23 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
tvAppName.setText(TextUtils.join(", ", appInfo.getApplicationName()));

// Get current values
boolean usage = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingUsage, true);
boolean parameters = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingParameters, false);
boolean log = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingLog, false);
boolean components = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingSystem, false);
boolean experimental = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingExperimental, false);
boolean https = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingHttps, true);
String confidence = PrivacyManager.getSetting(uid, PrivacyManager.cSettingConfidence, "");
boolean freeze = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingFreeze, false);
boolean noresolve = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingNoResolve, false);
boolean permman = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingPermMan, false);
boolean iwall = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingIntentWall, false);
boolean safemode = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingSafeMode, false);
boolean test = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingTestVersions, false);
boolean odsystem = PrivacyManager.getSettingBool(uid, PrivacyManager.cSettingOnDemandSystem, false);
boolean usage = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingUsage, true);
boolean parameters = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingParameters, false);
boolean log = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingLog, false);

boolean components = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSystem, false);
boolean experimental = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingExperimental, false);
boolean https = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingHttps, true);
String confidence = PrivacyManager.getSetting(-uid, PrivacyManager.cSettingConfidence, "");

// Get quirks
boolean freeze = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingFreeze, false);
boolean noresolve = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingNoResolve, false);
boolean permman = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingPermMan, false);
boolean iwall = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingIntentWall, false);
boolean safemode = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingSafeMode, false);
boolean test = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingTestVersions, false);
boolean odsystem = PrivacyManager.getSettingBool(-uid, PrivacyManager.cSettingOnDemandSystem, false);
List<String> listQuirks = new ArrayList<String>();
if (freeze)
listQuirks.add("freeze");
Expand All @@ -261,6 +263,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
listQuirks.add("odsystem");
Collections.sort(listQuirks);
String quirks = TextUtils.join(",", listQuirks.toArray());

final boolean expert = (components || experimental || !https || !"".equals(confidence) || listQuirks.size() > 0);

// Application specific
Expand Down Expand Up @@ -316,12 +319,16 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbUsage.setVisibility(View.GONE);
cbParameters.setVisibility(View.GONE);
cbLog.setVisibility(View.GONE);
cbExpert.setVisibility(View.GONE);
cbSystem.setVisibility(View.GONE);
cbExperimental.setVisibility(View.GONE);
cbHttps.setVisibility(View.GONE);
llConfidence.setVisibility(View.GONE);
llQuirks.setVisibility(View.GONE);

cbExpert.setChecked(expert);
if (expert)
etQuirks.setText(quirks);
else
etQuirks.setEnabled(false);
}

boolean gnotify = PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingNotify, true);
Expand Down Expand Up @@ -505,24 +512,25 @@ public void onClick(View view) {
PrivacyManager.setSetting(uid, PrivacyManager.cSettingHttps, Boolean.toString(cbHttps.isChecked()));
PrivacyManager
.setSetting(uid, PrivacyManager.cSettingConfidence, etConfidence.getText().toString());

List<String> listQuirks = Arrays.asList(etQuirks.getText().toString().split(","));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingFreeze,
Boolean.toString(listQuirks.contains("freeze")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoResolve,
Boolean.toString(listQuirks.contains("noresolve")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingPermMan,
Boolean.toString(listQuirks.contains("permman")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingIntentWall,
Boolean.toString(listQuirks.contains("iwall")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingSafeMode,
Boolean.toString(listQuirks.contains("safemode")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingTestVersions,
Boolean.toString(listQuirks.contains("test")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemandSystem,
Boolean.toString(listQuirks.contains("odsystem")));
}

// Quirks
List<String> listQuirks = Arrays.asList(etQuirks.getText().toString().split(","));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingFreeze,
Boolean.toString(listQuirks.contains("freeze")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingNoResolve,
Boolean.toString(listQuirks.contains("noresolve")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingPermMan,
Boolean.toString(listQuirks.contains("permman")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingIntentWall,
Boolean.toString(listQuirks.contains("iwall")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingSafeMode,
Boolean.toString(listQuirks.contains("safemode")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingTestVersions,
Boolean.toString(listQuirks.contains("test")));
PrivacyManager.setSetting(uid, PrivacyManager.cSettingOnDemandSystem,
Boolean.toString(listQuirks.contains("odsystem")));

// Notifications
PrivacyManager.setSetting(uid, PrivacyManager.cSettingNotify, Boolean.toString(cbNotify.isChecked()));

Expand Down

0 comments on commit 95d7ae8

Please sign in to comment.