Merge branch 'filter_app' into stom79_baseline

# Conflicts:
#	app/src/main/java/org/eu/exodus_privacy/exodusprivacy/MainActivity.java
This commit is contained in:
stom79 2018-04-14 15:32:15 +02:00
commit 5723d9ea8d
2 changed files with 21 additions and 4 deletions

View File

@ -29,6 +29,7 @@ import android.os.Bundle;
import android.support.v7.widget.SearchView;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.inputmethod.InputMethodManager;
import org.eu.exodus_privacy.exodusprivacy.adapters.ApplicationListAdapter;
import org.eu.exodus_privacy.exodusprivacy.databinding.MainBinding;
@ -40,6 +41,8 @@ public class MainActivity extends AppCompatActivity {
AppListFragment appList;
ReportFragment report;
SearchView searchView;
private Menu mMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
@ -81,6 +84,13 @@ public class MainActivity extends AppCompatActivity {
.replace(R.id.fragment_container,report)
.addToBackStack(null)
.commit();
searchView.clearFocus();
if (mMenu != null)
(mMenu.findItem(R.id.action_filter)).collapseActionView();
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(mainBinding.fragmentContainer.getWindowToken(), 0);
};
appList = AppListFragment.newInstance(networkListener,onAppClickListener);
@ -103,12 +113,10 @@ public class MainActivity extends AppCompatActivity {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
mMenu = menu;
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main, menu);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
assert searchManager != null;
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView = (SearchView) menu.findItem(R.id.action_filter).getActionView();
searchView.setIconifiedByDefault(false);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override

View File

@ -28,6 +28,8 @@ import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
@ -61,6 +63,7 @@ public class ReportFragment extends Fragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
}
@ -178,4 +181,10 @@ public class ReportFragment extends Fragment {
public void setPackageInfo(PackageInfo packageInfo) {
this.packageInfo = packageInfo;
}
@Override
public void onPrepareOptionsMenu(Menu menu) {
MenuItem item = menu.findItem(R.id.action_filter);
item.setVisible(false);
}
}