mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-23 15:29:15 +00:00
Enable and fix search feature again
For some reason we used the old SearchView. Changed it to androidx.appcompat.widget.SearchView and it works on Huawei devices again.
This commit is contained in:
parent
cc55a6dacb
commit
85bf4adc72
2 changed files with 28 additions and 34 deletions
|
@ -15,10 +15,10 @@ import android.view.MenuInflater;
|
|||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SubMenu;
|
||||
import android.widget.SearchView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.appcompat.view.ActionMode;
|
||||
import androidx.appcompat.widget.SearchView;
|
||||
|
||||
import com.beemdevelopment.aegis.AegisApplication;
|
||||
import com.beemdevelopment.aegis.R;
|
||||
|
@ -414,7 +414,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
if (_db.isLocked()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Intent intent = getIntent();
|
||||
if (Intent.ACTION_VIEW.equals(intent.getAction())) {
|
||||
Uri uri = intent.getData();
|
||||
|
@ -473,7 +473,7 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if ((_searchView != null && !_searchView.isIconified()) || _searchSubmitted ) {
|
||||
if (!_searchView.isIconified() || _searchSubmitted) {
|
||||
_searchSubmitted = false;
|
||||
_entryListView.setSearchFilter(null);
|
||||
|
||||
|
@ -516,38 +516,32 @@ public class MainActivity extends AegisActivity implements EntryListView.Listene
|
|||
MenuItem searchViewMenuItem = menu.findItem(R.id.mi_search);
|
||||
|
||||
_searchView = (SearchView) searchViewMenuItem.getActionView();
|
||||
if (_searchView != null)
|
||||
{
|
||||
_searchView.setFocusable(false);
|
||||
_searchView.setQueryHint(getString(R.string.search));
|
||||
_searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
setTitle(getString(R.string.search));
|
||||
getSupportActionBar().setSubtitle(s);
|
||||
_searchSubmitted = true;
|
||||
collapseSearchView();
|
||||
return false;
|
||||
}
|
||||
_searchView.setFocusable(false);
|
||||
_searchView.setQueryHint(getString(R.string.search));
|
||||
_searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String s) {
|
||||
setTitle(getString(R.string.search));
|
||||
getSupportActionBar().setSubtitle(s);
|
||||
_searchSubmitted = true;
|
||||
collapseSearchView();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String s) {
|
||||
if (!_searchSubmitted) {
|
||||
_entryListView.setSearchFilter(s);
|
||||
}
|
||||
return false;
|
||||
@Override
|
||||
public boolean onQueryTextChange(String s) {
|
||||
if (!_searchSubmitted) {
|
||||
_entryListView.setSearchFilter(s);
|
||||
}
|
||||
});
|
||||
_searchView.setOnSearchClickListener(v -> {
|
||||
if (_searchSubmitted) {
|
||||
_searchSubmitted = false;
|
||||
_entryListView.setSearchFilter(null);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
searchViewMenuItem.setVisible(false);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
_searchView.setOnSearchClickListener(v -> {
|
||||
if (_searchSubmitted) {
|
||||
_searchSubmitted = false;
|
||||
_entryListView.setSearchFilter(null);
|
||||
}
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
android:id="@+id/mi_search"
|
||||
android:title="@string/search"
|
||||
app:showAsAction="always"
|
||||
app:actionViewClass="android.widget.SearchView"
|
||||
app:actionViewClass="androidx.appcompat.widget.SearchView"
|
||||
/>
|
||||
<item
|
||||
android:id="@+id/action_lock"
|
||||
|
|
Loading…
Add table
Reference in a new issue