summaryrefslogtreecommitdiffstats
path: root/src/com/cyanogenmod/trebuchet
diff options
context:
space:
mode:
authornebkat <nebkat@gmail.com>2011-12-25 13:16:01 +0000
committernebkat <nebkat@gmail.com>2011-12-27 11:08:13 +0000
commitc1d7bc76c7f214ce713d196b973f90925df62331 (patch)
tree2dcf6a828e5cfd6de240acbf2cb6a6a45f716138 /src/com/cyanogenmod/trebuchet
parente0b41c2232deb9ad121bc64a9851543c10c87c68 (diff)
downloadandroid_packages_apps_Trebuchet-c1d7bc76c7f214ce713d196b973f90925df62331.tar.gz
android_packages_apps_Trebuchet-c1d7bc76c7f214ce713d196b973f90925df62331.tar.bz2
android_packages_apps_Trebuchet-c1d7bc76c7f214ce713d196b973f90925df62331.zip
Launcher: Software Menu Button
Change-Id: Ief9a0bce26b557f10c341c79cd4c9a96d591f9cb
Diffstat (limited to 'src/com/cyanogenmod/trebuchet')
-rw-r--r--src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java4
-rw-r--r--src/com/cyanogenmod/trebuchet/FocusHelper.java13
-rw-r--r--src/com/cyanogenmod/trebuchet/Launcher.java28
3 files changed, 40 insertions, 5 deletions
diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
index ec4280908..ad02a305a 100644
--- a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
+++ b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java
@@ -140,6 +140,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 eb243054a..2f3d21f1d 100644
--- a/src/com/cyanogenmod/trebuchet/FocusHelper.java
+++ b/src/com/cyanogenmod/trebuchet/FocusHelper.java
@@ -81,13 +81,14 @@ 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 = (ViewGroup)
tabHost.findViewById(com.android.internal.R.id.tabcontent);
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);
@@ -96,8 +97,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;
@@ -105,7 +110,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 6224ff826..55afd1d85 100644
--- a/src/com/cyanogenmod/trebuchet/Launcher.java
+++ b/src/com/cyanogenmod/trebuchet/Launcher.java
@@ -79,6 +79,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.WindowManager;
@@ -90,6 +91,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.Advanceable;
import android.widget.EditText;
import android.widget.ImageView;
+import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;
@@ -1772,6 +1774,15 @@ public final class Launcher extends Activity
}
}
+ 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,
@@ -2783,7 +2794,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(
@@ -2801,6 +2813,17 @@ public final class Launcher extends Activity
updateTextButtonWithDrawable(R.id.market_button, d);
}
+ 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.
@@ -3076,6 +3099,9 @@ public final class Launcher extends Activity
// package changes in bindSearchablesChanged()
updateAppMarketIcon();
+ // Hide overflow menu on devices with a hardkey
+ updateOverflowMenuButton();
+
mWorkspace.post(mBuildLayersRunnable);
}