1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-24 00:38:56 +00:00

Allow searching for app name in log view

This commit is contained in:
M66B 2017-03-06 08:05:46 +01:00
parent f1dbe2ea2c
commit 0bba1ac1f3

View file

@ -332,17 +332,30 @@ public class ActivityLog extends AppCompatActivity implements SharedPreferences.
menuSearch = menu.findItem(R.id.menu_search);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
private String getUidForName(String query) {
if (query != null && query.length() > 0) {
for (Rule rule : Rule.getRules(true, ActivityLog.this))
if (rule.name != null && rule.name.toLowerCase().contains(query.toLowerCase())) {
String newQuery = Integer.toString(rule.info.applicationInfo.uid);
Log.i(TAG, "Search " + query + " found " + rule.name + " new " + newQuery);
return newQuery;
}
Log.i(TAG, "Search " + query + " not found");
}
return query;
}
@Override
public boolean onQueryTextSubmit(String query) {
if (adapter != null)
adapter.getFilter().filter(query);
adapter.getFilter().filter(getUidForName(query));
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
if (adapter != null)
adapter.getFilter().filter(newText);
adapter.getFilter().filter(getUidForName(newText));
return true;
}
});