Show search/run MenuItems in action bar.

This is only done if the device api version is >= 11, and if there is
room in the action bar. I added the funcitonality in a new class
CompatabilityUtils because there may be other things for which this is
desirable.
This commit is contained in:
Peter Serwylo 2013-04-09 11:22:46 +10:00
parent d02dd290ca
commit 7a83557772
4 changed files with 21 additions and 3 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ gen/*
proguard.cfg
proguard-project.txt
*~
.idea
*.iml

View File

@ -471,8 +471,9 @@ public class AppDetails extends ListActivity {
menu.add(Menu.NONE, INSTALL, 1, R.string.menu_install).setIcon(
android.R.drawable.ic_menu_add);
} else {
menu.add(Menu.NONE, LAUNCH, 1, R.string.menu_launch).setIcon(
android.R.drawable. ic_media_play);
MenuItem launch = menu.add( Menu.NONE, LAUNCH, 1, R.string.menu_launch ).setIcon(
android.R.drawable.ic_media_play );
CompatabilityUtils.showAsAction( launch );
menu.add(Menu.NONE, UNINSTALL, 1, R.string.menu_uninstall).setIcon(
android.R.drawable.ic_menu_delete);
}

View File

@ -0,0 +1,14 @@
package org.fdroid.fdroid;
import android.os.Build;
import android.view.MenuItem;
public class CompatabilityUtils {
protected static void showAsAction( MenuItem item ) {
if ( Build.VERSION.SDK_INT >= 11 ) {
item.setShowAsAction( MenuItem.SHOW_AS_ACTION_IF_ROOM );
}
}
}

View File

@ -150,12 +150,13 @@ public class FDroid extends TabActivity implements OnItemClickListener,
android.R.drawable.ic_menu_rotate);
menu.add(Menu.NONE, MANAGE_REPO, 2, R.string.menu_manage).setIcon(
android.R.drawable.ic_menu_agenda);
menu.add(Menu.NONE, SEARCH, 3, R.string.menu_search).setIcon(
MenuItem search = menu.add(Menu.NONE, SEARCH, 3, R.string.menu_search).setIcon(
android.R.drawable.ic_menu_search);
menu.add(Menu.NONE, PREFERENCES, 4, R.string.menu_preferences).setIcon(
android.R.drawable.ic_menu_preferences);
menu.add(Menu.NONE, ABOUT, 5, R.string.menu_about).setIcon(
android.R.drawable.ic_menu_help);
CompatabilityUtils.showAsAction( search );
return true;
}