From 8004993ab748362e4e1439b802296d3636f35885 Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 12 Sep 2014 08:13:57 +0200 Subject: [PATCH] Select all enabled applications Fixes #1977 --- CHANGELOG.md | 2 ++ src/biz/bokhorst/xprivacy/ActivityApp.java | 7 +++--- src/biz/bokhorst/xprivacy/ActivityMain.java | 27 +++++++++++++++------ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac475af1b..a31d00300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ See for more information about XPrivacy 3 [this FAQ](https://github.com/M66B/XPr **Next release** +* Select all enabled applications ([issue](/../../issues/1977)) + [Open issues](https://github.com/M66B/XPrivacy/issues?state=open) **Version 3.1.4 BETA** diff --git a/src/biz/bokhorst/xprivacy/ActivityApp.java b/src/biz/bokhorst/xprivacy/ActivityApp.java index 2db51b9d7..844058cde 100644 --- a/src/biz/bokhorst/xprivacy/ActivityApp.java +++ b/src/biz/bokhorst/xprivacy/ActivityApp.java @@ -360,9 +360,10 @@ protected void onResume() { super.onResume(); // Update switch - if (swEnabled != null) - swEnabled.setChecked(PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, - true)); + if (swEnabled != null) { + boolean enabled = PrivacyManager.getSettingBool(mAppInfo.getUid(), PrivacyManager.cSettingRestricted, true); + swEnabled.setChecked(enabled); + } // Update on demand check box int userId = Util.getUserId(Process.myUid()); diff --git a/src/biz/bokhorst/xprivacy/ActivityMain.java b/src/biz/bokhorst/xprivacy/ActivityMain.java index ad1ba2423..ad7ce9352 100644 --- a/src/biz/bokhorst/xprivacy/ActivityMain.java +++ b/src/biz/bokhorst/xprivacy/ActivityMain.java @@ -1579,20 +1579,31 @@ public int[] getSelectedOrVisibleUid(int flags) { } public void selectAllVisible() { - // Look through the visible apps to figure out what to do + // Look through the visible, enabled apps to figure out what to do mSelecting = false; for (int i = 0; i < this.getCount(); i++) { - if (!mListAppSelected.contains(this.getItem(i))) { - mSelecting = true; - break; + ApplicationInfoEx appInfo = this.getItem(i); + if (!mListAppSelected.contains(appInfo)) { + boolean enabled = PrivacyManager.getSettingBool(appInfo.getUid(), + PrivacyManager.cSettingRestricted, true); + if (enabled) { + mSelecting = true; + break; + } } } if (mSelecting) { - // Add the visible apps not already selected - for (int i = 0; i < this.getCount(); i++) - if (!mListAppSelected.contains(this.getItem(i))) - mListAppSelected.add(this.getItem(i)); + // Add the visible, enabled apps not already selected + for (int i = 0; i < this.getCount(); i++) { + ApplicationInfoEx appInfo = this.getItem(i); + if (!mListAppSelected.contains(appInfo)) { + boolean enabled = PrivacyManager.getSettingBool(appInfo.getUid(), + PrivacyManager.cSettingRestricted, true); + if (enabled) + mListAppSelected.add(this.getItem(i)); + } + } } else mListAppSelected.clear();