Add basic shell for game search functionaliy
Implement search using current file handling
This commit is contained in:
parent
f88561614e
commit
1d3964588c
|
@ -58,6 +58,7 @@ public class FileBrowser extends Fragment {
|
|||
private Drawable orig_bg;
|
||||
private boolean ImgBrowse;
|
||||
private boolean games;
|
||||
private String searchQuery = null;
|
||||
private OnItemSelectedListener mCallback;
|
||||
|
||||
private SharedPreferences mPrefs;
|
||||
|
@ -85,8 +86,10 @@ public class FileBrowser extends Fragment {
|
|||
game_directory = b.getString("path_entry");
|
||||
}
|
||||
}
|
||||
if (b.getString("search_params") != null) {
|
||||
searchQuery = b.getString("search_params");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static HashSet<String> getExternalMounts() {
|
||||
|
@ -253,9 +256,11 @@ public class FileBrowser extends Fragment {
|
|||
return false;
|
||||
} else if (array == R.array.flash && !name.startsWith("dc_")) {
|
||||
return false;
|
||||
} else {
|
||||
} else if (searchQuery == null || name.toLowerCase(Locale.getDefault())
|
||||
.contains(searchQuery.toLowerCase(Locale.getDefault())))
|
||||
return StringUtils.endsWithIgnoreCase(name, "." + type);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.content.SharedPreferences;
|
|||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.ResolveInfo;
|
||||
import android.content.res.Configuration;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
@ -22,6 +23,7 @@ import android.support.v4.app.Fragment;
|
|||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
|
@ -192,6 +194,33 @@ public class MainActivity extends AppCompatActivity implements
|
|||
navigationView.getMenu().findItem(R.id.rateme_menu).setVisible(false);
|
||||
}
|
||||
navigationView.setNavigationItemSelectedListener(this);
|
||||
|
||||
final SearchView searchView = (SearchView) findViewById(R.id.searchView);
|
||||
if (searchView != null) {
|
||||
searchView.setQueryHint(getString(R.string.search_hint));
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
FileBrowser fragment = new FileBrowser();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("ImgBrowse", true);
|
||||
args.putString("browse_entry", home_directory);
|
||||
args.putBoolean("games_entry", true);
|
||||
args.putString("search_params", query);
|
||||
fragment.setArguments(args);
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.fragment_container, fragment, "MAIN_BROWSER")
|
||||
.addToBackStack(null).commit();
|
||||
setTitle(R.string.browser);
|
||||
searchView.onActionViewCollapsed();
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean onQueryTextChange(String s) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void generateErrorLog() {
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
android:background="@android:color/black"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay">
|
||||
|
||||
<android.support.v7.widget.SearchView
|
||||
android:id="@+id/searchView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_gravity="right"
|
||||
android:iconifiedByDefault="true" />
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
</android.support.design.widget.AppBarLayout>
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
<string name="default_disk">Default Disk</string>
|
||||
|
||||
<string name="games_listing">Game List</string>
|
||||
<string name="search_hint">Game (ie. Crazy Taxi)</string>
|
||||
|
||||
<string name="game_details">Game Info - %1$s</string>
|
||||
<string name="info_unavailable">Game Info Unavailable</string>
|
||||
|
|
Loading…
Reference in New Issue