mirror of
https://github.com/M66B/NetGuard.git
synced 2024-12-24 16:56:18 +00:00
Allow searching for app name in log view
This commit is contained in:
parent
f1dbe2ea2c
commit
0bba1ac1f3
1 changed files with 15 additions and 2 deletions
|
@ -332,17 +332,30 @@ public class ActivityLog extends AppCompatActivity implements SharedPreferences.
|
||||||
menuSearch = menu.findItem(R.id.menu_search);
|
menuSearch = menu.findItem(R.id.menu_search);
|
||||||
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
|
||||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
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
|
@Override
|
||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
if (adapter != null)
|
if (adapter != null)
|
||||||
adapter.getFilter().filter(query);
|
adapter.getFilter().filter(getUidForName(query));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
if (adapter != null)
|
if (adapter != null)
|
||||||
adapter.getFilter().filter(newText);
|
adapter.getFilter().filter(getUidForName(newText));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue