diff --git a/app/src/main/java/eu/faircode/netguard/ActivityMain.java b/app/src/main/java/eu/faircode/netguard/ActivityMain.java index 39d143db..1d2c69b6 100644 --- a/app/src/main/java/eu/faircode/netguard/ActivityMain.java +++ b/app/src/main/java/eu/faircode/netguard/ActivityMain.java @@ -77,6 +77,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences private static final int MIN_SDK = Build.VERSION_CODES.LOLLIPOP; public static final String ACTION_RULES_CHANGED = "eu.faircode.netguard.ACTION_RULES_CHANGED"; + public static final String EXTRA_SEARCH = "Search"; @Override protected void onCreate(Bundle savedInstanceState) { @@ -192,7 +193,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences @Override public void onRefresh() { SinkholeService.reload(null, "pull", ActivityMain.this); - updateApplicationList(); + updateApplicationList(null); } }); @@ -246,7 +247,14 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences } // Fill application list - updateApplicationList(); + updateApplicationList(getIntent().getStringExtra(EXTRA_SEARCH)); + } + + @Override + protected void onNewIntent(Intent intent) { + Log.i(TAG, "New intent"); + super.onNewIntent(intent); + updateApplicationList(intent.getStringExtra(EXTRA_SEARCH)); } @Override @@ -345,7 +353,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences "whitelist_roaming".equals(name) || "manage_system".equals(name) || "imported".equals(name)) - updateApplicationList(); + updateApplicationList(null); else if ("dark_theme".equals(name)) recreate(); @@ -367,7 +375,7 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences else adapter.setDisconnected(); else - updateApplicationList(); + updateApplicationList(null); } }; @@ -376,11 +384,12 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences public void onReceive(Context context, Intent intent) { Log.i(TAG, "Received " + intent); Util.logExtras(intent); - updateApplicationList(); + updateApplicationList(null); } }; - private void updateApplicationList() { + private void updateApplicationList(final String search) { + Log.i(TAG, "Update search=" + search); new AsyncTask>() { private boolean refreshing = true; @@ -406,7 +415,13 @@ public class ActivityMain extends AppCompatActivity implements SharedPreferences if (adapter != null) adapter.set(result); if (menuSearch != null) - MenuItemCompat.collapseActionView(menuSearch); + if (search == null) + MenuItemCompat.collapseActionView(menuSearch); + else { + MenuItemCompat.expandActionView(menuSearch); + SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch); + searchView.setQuery(search, true); + } if (swipeRefresh != null) { refreshing = false; swipeRefresh.setRefreshing(false); diff --git a/app/src/main/java/eu/faircode/netguard/Receiver.java b/app/src/main/java/eu/faircode/netguard/Receiver.java index 8212ea97..39607a2f 100644 --- a/app/src/main/java/eu/faircode/netguard/Receiver.java +++ b/app/src/main/java/eu/faircode/netguard/Receiver.java @@ -110,7 +110,8 @@ public class Receiver extends BroadcastReceiver { // Build notification Intent main = new Intent(context, ActivityMain.class); - PendingIntent pi = PendingIntent.getActivity(context, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); + main.putExtra(ActivityMain.EXTRA_SEARCH, name); + PendingIntent pi = PendingIntent.getActivity(context, 999, main, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_security_white_24dp)