From 95d7ae8d6c6f9459398f8c5a7ed59583ba7040dc Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 16 Aug 2014 09:17:57 +0200 Subject: [PATCH] Added application specific quirks Fixed #1844 --- CHANGELOG.md | 1 + res/layout/settings.xml | 3 +- src/biz/bokhorst/xprivacy/SettingsDialog.java | 74 ++++++++++--------- 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 51bbe694c..fd5c2fa32 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/res/layout/settings.xml b/res/layout/settings.xml index 1c0be1798..21cab1540 100644 --- a/res/layout/settings.xml +++ b/res/layout/settings.xml @@ -138,7 +138,6 @@ diff --git a/src/biz/bokhorst/xprivacy/SettingsDialog.java b/src/biz/bokhorst/xprivacy/SettingsDialog.java index ad1fa58d0..47a4dfcd6 100644 --- a/src/biz/bokhorst/xprivacy/SettingsDialog.java +++ b/src/biz/bokhorst/xprivacy/SettingsDialog.java @@ -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); @@ -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 listQuirks = new ArrayList(); if (freeze) listQuirks.add("freeze"); @@ -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 @@ -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); @@ -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 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 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()));