diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index c7bbada3e..a342b7404 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -427,6 +427,7 @@ public class DB { public Vector getCategories() { Vector result = new Vector(); + result.add("All"); Cursor c = null; try { c = db.rawQuery("select distinct category from " + TABLE_APP + " order by category", null); diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java index 8202e8eff..14a72ea65 100644 --- a/src/org/fdroid/fdroid/FDroid.java +++ b/src/org/fdroid/fdroid/FDroid.java @@ -51,9 +51,10 @@ import android.widget.TabHost; import android.widget.TextView; import android.widget.Toast; import android.widget.AdapterView.OnItemClickListener; +import android.widget.AdapterView.OnItemSelectedListener; import android.widget.TabHost.TabSpec; -public class FDroid extends TabActivity implements OnItemClickListener { +public class FDroid extends TabActivity implements OnItemClickListener, OnItemSelectedListener { private String LOCAL_PATH = "/sdcard/.fdroid"; @@ -80,6 +81,7 @@ public class FDroid extends TabActivity implements OnItemClickListener { // Category list private ArrayAdapter categories; + private String currentCategory = "All"; private ProgressDialog pd; @@ -114,6 +116,7 @@ public class FDroid extends TabActivity implements OnItemClickListener { new Vector()); categories.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(categories); + spinner.setOnItemSelectedListener(FDroid.this); tabHost = getTabHost(); createTabs(); @@ -349,6 +352,9 @@ public class FDroid extends TabActivity implements OnItemClickListener { + " ms)"); for (DB.App app : apps) { + if (!"All".equals(currentCategory) && !currentCategory.equals(app.category)) { + continue; + } if (app.installedVersion == null) { apps_av.addItem(app); } else { @@ -405,6 +411,15 @@ public class FDroid extends TabActivity implements OnItemClickListener { } }; + public void onItemSelected(AdapterView parent, View view, int pos, long id) { + currentCategory = parent.getItemAtPosition(pos).toString(); + populateLists(false); + } + + public void onNothingSelected(AdapterView parent) { + // We always have at least "All" + } + // Handler for a click on one of the items in an application list. Pops // up a dialog that shows the details of the application and all its // available versions, with buttons to allow installation etc.