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

Commit

Permalink
Toggle selected
Browse files Browse the repository at this point in the history
Refs #1031
  • Loading branch information
M66B committed Jan 9, 2014
1 parent 95b7bce commit abd3587
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Test and beta releases will have experimental functions enabled by default.
**Next release**

* Sharper check marks, thanks @[jpeg729](https://github.com/jpeg729)
* Toggle (clear/set) selected
* Updated simplified Chinese translation
* Updated traditional Chinese translation
* Updated French translation
Expand Down
29 changes: 18 additions & 11 deletions src/biz/bokhorst/xprivacy/ActivityMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,7 @@ private void applyFilter() {
private void optionAll() {
// Check if some restricted
boolean some = false;
for (int pos = 0; pos < mAppAdapter.getCount(); pos++) {
ApplicationInfoEx xAppInfo = mAppAdapter.getItem(pos);
for (ApplicationInfoEx xAppInfo : mAppAdapter.getSelected(false)) {
for (boolean restricted : PrivacyManager.getRestricted(ActivityMain.this, xAppInfo.getUid(),
mAppAdapter.getRestrictionName()))
if (restricted) {
Expand Down Expand Up @@ -1011,10 +1010,11 @@ protected Boolean doInBackground(Boolean... params) {
boolean someRestricted = params[0];

// Apply action
int pos = 0;
boolean restart = false;
for (int pos = 0; pos < mAppAdapter.getCount(); pos++) {
publishProgress(pos, mAppAdapter.getCount());
ApplicationInfoEx xAppInfo = mAppAdapter.getItem(pos);
List<ApplicationInfoEx> listAppInfo = mAppAdapter.getSelected(false);
for (ApplicationInfoEx xAppInfo : listAppInfo) {
publishProgress(pos++, listAppInfo.size());
if (mAppAdapter.getRestrictionName() == null && someRestricted)
restart = PrivacyManager.deleteRestrictions(ActivityMain.this, xAppInfo.getUid()) || restart;
else if (mAppAdapter.getRestrictionName() == null) {
Expand Down Expand Up @@ -1065,7 +1065,7 @@ public SpinnerAdapter(Context context, int textViewResourceId) {
@SuppressLint("DefaultLocale")
private class AppListAdapter extends ArrayAdapter<ApplicationInfoEx> {
private Context mContext;
private List<ApplicationInfoEx> mListApp;
private List<ApplicationInfoEx> mListAppAll;
private List<ApplicationInfoEx> mListAppSelected = new ArrayList<ApplicationInfoEx>();
private String mRestrictionName;
private LayoutInflater mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Expand All @@ -1076,8 +1076,8 @@ public AppListAdapter(Context context, int resource, List<ApplicationInfoEx> obj
String initialRestrictionName) {
super(context, resource, objects);
mContext = context;
mListApp = new ArrayList<ApplicationInfoEx>();
mListApp.addAll(objects);
mListAppAll = new ArrayList<ApplicationInfoEx>();
mListAppAll.addAll(objects);
mRestrictionName = initialRestrictionName;

TypedArray ta1 = context.getTheme().obtainStyledAttributes(
Expand All @@ -1094,6 +1094,13 @@ public String getRestrictionName() {
return mRestrictionName;
}

public List<ApplicationInfoEx> getSelected(boolean selectedOnly) {
if (mListAppSelected.size() == 0)
return (selectedOnly ? new ArrayList<ApplicationInfoEx>() : mListAppAll);
else
return mListAppSelected;
}

@Override
public Filter getFilter() {
return new AppFilter();
Expand Down Expand Up @@ -1121,9 +1128,9 @@ protected FilterResults performFiltering(CharSequence constraint) {

// Match applications
int current = 0;
int max = AppListAdapter.this.mListApp.size();
int max = AppListAdapter.this.mListAppAll.size();
List<ApplicationInfoEx> lstApp = new ArrayList<ApplicationInfoEx>();
for (ApplicationInfoEx xAppInfo : AppListAdapter.this.mListApp) {
for (ApplicationInfoEx xAppInfo : AppListAdapter.this.mListAppAll) {
// Check if another filter has been started
if (filtersRunning != mFiltersRunning.get())
return null;
Expand Down Expand Up @@ -1207,7 +1214,7 @@ protected void publishResults(CharSequence constraint, FilterResults results) {
ProgressBar pbFilter = (ProgressBar) findViewById(R.id.pbFilter);
pbFilter.setVisibility(ProgressBar.GONE);
tvStats.setVisibility(TextView.VISIBLE);
tvStats.setText(results.count + "/" + AppListAdapter.this.mListApp.size());
tvStats.setText(results.count + "/" + AppListAdapter.this.mListAppAll.size());

Intent progressIntent = new Intent(ActivityShare.cProgressReport);
progressIntent.putExtra(ActivityShare.cProgressMessage, getString(R.string.title_restrict));
Expand Down

0 comments on commit abd3587

Please sign in to comment.