mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-03 21:21:12 +08:00
Handle VPN exceptions back button if search open
This commit is contained in:
parent
a620d914b7
commit
2f2d3c87f1
@ -1287,4 +1287,14 @@ public class Utils {
|
||||
// Delay otherwise the query won't be set when the activity is just started
|
||||
searchView.post(() -> searchView.setQuery(query, true));
|
||||
}
|
||||
|
||||
public static boolean backHandleSearchview(SearchView searchView) {
|
||||
if((searchView != null) && !searchView.isIconified()) {
|
||||
// Required to close the SearchView when the search submit button was not pressed
|
||||
searchView.setIconified(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,6 +23,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@ -61,6 +62,23 @@ public class VpnExceptionsActivity extends BaseActivity {
|
||||
getSupportFragmentManager().putFragment(outState, "fragment", mFragment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if(item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
return true;
|
||||
}
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if(mFragment.onBackPressed())
|
||||
return;
|
||||
|
||||
super.onBackPressed();
|
||||
}
|
||||
|
||||
public static class VpnExceptionsFragment extends AppsToggles {
|
||||
private static final String TAG = "VpnExceptions";
|
||||
private final Set<String> mExcludedApps = new HashSet<>();
|
||||
|
||||
@ -122,6 +122,12 @@ public abstract class AppsToggles extends Fragment implements AppsLoadListener,
|
||||
}
|
||||
}
|
||||
|
||||
// NOTE: must be called from the activity
|
||||
public boolean onBackPressed() {
|
||||
Log.d(TAG, "onBackPressed");
|
||||
return Utils.backHandleSearchview(mSearchView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) { return true; }
|
||||
|
||||
|
||||
@ -811,13 +811,8 @@ public class ConnectionsFragment extends Fragment implements ConnectionsListener
|
||||
return true;
|
||||
}
|
||||
|
||||
// NOTE: dispatched from activity, returns true if handled
|
||||
public boolean onBackPressed() {
|
||||
if((mSearchView != null) && !mSearchView.isIconified()) {
|
||||
// Required to close the SearchView when the search submit button was not pressed
|
||||
mSearchView.setIconified(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return Utils.backHandleSearchview(mSearchView);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user