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

Commit

Permalink
Show correct white/black list when navigating from icon
Browse files Browse the repository at this point in the history
Refs #1654
  • Loading branch information
M66B committed May 30, 2014
1 parent 7e1b614 commit b5bd6da
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/biz/bokhorst/xprivacy/ActivityApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
optionContacts();
return true;
case R.id.menu_whitelists:
optionWhitelists();
optionWhitelists(null);
return true;
case R.id.menu_settings:
optionSettings();
Expand Down Expand Up @@ -575,12 +575,12 @@ private void optionContacts() {
}
}

private void optionWhitelists() {
private void optionWhitelists(String type) {
if (Util.hasProLicense(this) == null) {
// Redirect to pro page
Util.viewUri(this, ActivityMain.cProUri);
} else {
WhitelistsTask whitelistsTask = new WhitelistsTask();
WhitelistsTask whitelistsTask = new WhitelistsTask(type);
whitelistsTask.executeOnExecutor(mExecutor, (Object) null);
}
}
Expand Down Expand Up @@ -834,9 +834,14 @@ public void onClick(DialogInterface dialog, int which) {
}

private class WhitelistsTask extends AsyncTask<Object, Object, Object> {
private String mType;
private WhitelistAdapter mWhitelistAdapter;
private Map<String, TreeMap<String, Boolean>> mListWhitelist;

public WhitelistsTask(String type) {
mType = type;
}

@Override
protected Object doInBackground(Object... params) {
// Get whitelisted elements
Expand All @@ -860,7 +865,8 @@ protected void onPostExecute(Object result) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View llWhitelists = inflater.inflate(R.layout.whitelists, null);

// TODO: sort localized whitelist types
int index = 0;
int selected = -1;
final List<String> localizedType = new ArrayList<String>();
for (String type : mListWhitelist.keySet()) {
String name = "whitelist_" + type.toLowerCase().replace("/", "");
Expand All @@ -869,6 +875,10 @@ protected void onPostExecute(Object result) {
localizedType.add(name);
else
localizedType.add(getResources().getString(id));

if (type.equals(mType))
selected = index;
index++;
}

Spinner spWhitelistType = (Spinner) llWhitelists.findViewById(R.id.spWhitelistType);
Expand All @@ -885,6 +895,8 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
public void onNothingSelected(AdapterView<?> view) {
}
});
if (selected >= 0)
spWhitelistType.setSelection(selected);

ListView lvWhitelist = (ListView) llWhitelists.findViewById(R.id.lvWhitelist);
lvWhitelist.setAdapter(mWhitelistAdapter);
Expand Down Expand Up @@ -1381,7 +1393,7 @@ protected void onPostExecute(Object result) {
holder.imgCbMethodWhitelist.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ActivityApp.this.optionWhitelists();
ActivityApp.this.optionWhitelists(md.whitelist());
}
});
else
Expand Down

0 comments on commit b5bd6da

Please sign in to comment.