diff --git a/src/biz/bokhorst/xprivacy/ActivityApp.java b/src/biz/bokhorst/xprivacy/ActivityApp.java index ec70cdbcd..5becf1589 100644 --- a/src/biz/bokhorst/xprivacy/ActivityApp.java +++ b/src/biz/bokhorst/xprivacy/ActivityApp.java @@ -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(); @@ -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); } } @@ -834,9 +834,14 @@ public void onClick(DialogInterface dialog, int which) { } private class WhitelistsTask extends AsyncTask { + private String mType; private WhitelistAdapter mWhitelistAdapter; private Map> mListWhitelist; + public WhitelistsTask(String type) { + mType = type; + } + @Override protected Object doInBackground(Object... params) { // Get whitelisted elements @@ -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 localizedType = new ArrayList(); for (String type : mListWhitelist.keySet()) { String name = "whitelist_" + type.toLowerCase().replace("/", ""); @@ -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); @@ -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); @@ -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