diff options
author | nebkat <nebkat@gmail.com> | 2011-12-25 13:16:01 +0000 |
---|---|---|
committer | nebkat <nebkat@teamhacksung.org> | 2012-12-27 10:22:30 +0000 |
commit | 6fa3dd5f0f99c0c945180a64744115b9ca61285a (patch) | |
tree | 55e9afdaebe39332d4cee7ab688a652b557ff34c /src | |
parent | 32fdce8214caa36a21c7f00664a0a10740139232 (diff) | |
download | android_packages_apps_Trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.tar.gz android_packages_apps_Trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.tar.bz2 android_packages_apps_Trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.zip |
Launcher: Software Menu Button
Change-Id: Ief9a0bce26b557f10c341c79cd4c9a96d591f9cb
Diffstat (limited to 'src')
-rw-r--r-- | src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java | 4 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/FocusHelper.java | 13 | ||||
-rw-r--r-- | src/com/cyanogenmod/trebuchet/Launcher.java | 27 |
3 files changed, 39 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java index af762ead0..08d959753 100644 --- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java +++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java @@ -154,6 +154,10 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona View shopButton = findViewById(R.id.market_button); shopButton.setOnKeyListener(keyListener); + // Soft menu button + View overflowMenuButton = findViewById(R.id.overflow_menu_button); + overflowMenuButton.setOnKeyListener(keyListener); + // Hide the tab bar until we measure mTabsContainer.setAlpha(0f); } diff --git a/src/com/cyanogenmod/trebuchet/FocusHelper.java b/src/com/cyanogenmod/trebuchet/FocusHelper.java index 0ac6e2442..9e0043a44 100644 --- a/src/com/cyanogenmod/trebuchet/FocusHelper.java +++ b/src/com/cyanogenmod/trebuchet/FocusHelper.java @@ -81,12 +81,13 @@ public class FocusHelper { } /** - * Handles key events in a AppsCustomize tab between the last tab view and the shop button. + * Handles key events in a AppsCustomize tab between the last tab view and the shop/menu button. */ static boolean handleAppsCustomizeTabKeyEvent(View v, int keyCode, KeyEvent e) { final TabHost tabHost = findTabHostParent(v); final ViewGroup contents = tabHost.getTabContentView(); final View shop = tabHost.findViewById(R.id.market_button); + final View overflowMenu = tabHost.findViewById(R.id.overflow_menu_button); final int action = e.getAction(); final boolean handleKeyEvent = (action != KeyEvent.ACTION_UP); @@ -95,8 +96,12 @@ public class FocusHelper { case KeyEvent.KEYCODE_DPAD_RIGHT: if (handleKeyEvent) { // Select the shop button if we aren't on it - if (v != shop) { - shop.requestFocus(); + if (v != shop || v != overflowMenu) { + if (shop.getVisibility() == View.VISIBLE){ + shop.requestFocus(); + } else if (overflowMenu.getVisibility() == View.VISIBLE) { + overflowMenu.requestFocus(); + } } } wasHandled = true; @@ -104,7 +109,7 @@ public class FocusHelper { case KeyEvent.KEYCODE_DPAD_DOWN: if (handleKeyEvent) { // Select the content view (down is handled by the tab key handler otherwise) - if (v == shop) { + if (v == shop || v == overflowMenu) { contents.requestFocus(); wasHandled = true; } diff --git a/src/com/cyanogenmod/trebuchet/Launcher.java b/src/com/cyanogenmod/trebuchet/Launcher.java index f5951ea9a..21cc4ec57 100644 --- a/src/com/cyanogenmod/trebuchet/Launcher.java +++ b/src/com/cyanogenmod/trebuchet/Launcher.java @@ -83,6 +83,7 @@ import android.view.MotionEvent; import android.view.Surface; import android.view.View; import android.view.View.OnLongClickListener; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.view.ViewTreeObserver; import android.view.ViewTreeObserver.OnGlobalLayoutListener; @@ -2174,6 +2175,15 @@ public final class Launcher extends Activity popupMenu.show(); } + public void onClickOverflowMenuButton(View v) { + final PopupMenu popupMenu = new PopupMenu(this, v); + final Menu menu = popupMenu.getMenu(); + onCreateOptionsMenu(menu); + onPrepareOptionsMenu(menu); + popupMenu.show(); + } + + void startApplicationDetailsActivity(ComponentName componentName) { String packageName = componentName.getPackageName(); Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, @@ -3408,7 +3418,8 @@ public final class Launcher extends Activity // Find the app market activity by resolving an intent. // (If multiple app markets are installed, it will return the ResolverActivity.) ComponentName activityName = intent.resolveActivity(getPackageManager()); - if (activityName != null) { + if (activityName != null && (ViewConfiguration.get(this).hasPermanentMenuKey() || + getResources().getBoolean(R.bool.config_cyanogenmod))) { int coi = getCurrentOrientationIndexForGlobalIcons(); mAppMarketIntent = intent; sAppMarketIcon[coi] = updateTextButtonWithIconFromExternalActivity( @@ -3448,6 +3459,17 @@ public final class Launcher extends Activity return result; } + private void updateOverflowMenuButton() { + View overflowMenuButton = findViewById(R.id.overflow_menu_button); + if (ViewConfiguration.get(this).hasPermanentMenuKey() || + getResources().getBoolean(R.bool.config_cyanogenmod)) { + overflowMenuButton.setVisibility(View.GONE); + overflowMenuButton.setEnabled(false); + } else { + overflowMenuButton.setVisibility(View.VISIBLE); + } + } + /** * Displays the shortcut creation dialog and launches, if necessary, the * appropriate activity. @@ -3918,6 +3940,9 @@ public final class Launcher extends Activity .commit(); } }.start(); + + // Hide overflow menu on devices with a hardkey + updateOverflowMenuButton(); } @Override |