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 | |
parent | 32fdce8214caa36a21c7f00664a0a10740139232 (diff) | |
download | packages_apps_trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.zip packages_apps_trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.tar.gz packages_apps_trebuchet-6fa3dd5f0f99c0c945180a64744115b9ca61285a.tar.bz2 |
Launcher: Software Menu Button
Change-Id: Ief9a0bce26b557f10c341c79cd4c9a96d591f9cb
-rw-r--r-- | proguard.flags | 3 | ||||
-rw-r--r-- | res/drawable-hdpi/ic_menu_overflow.png | bin | 0 -> 526 bytes | |||
-rw-r--r-- | res/drawable-mdpi/ic_menu_overflow.png | bin | 0 -> 445 bytes | |||
-rw-r--r-- | res/drawable-xhdpi/ic_menu_overflow.png | bin | 0 -> 554 bytes | |||
-rw-r--r-- | res/layout/apps_customize_pane.xml | 6 | ||||
-rw-r--r-- | res/layout/overflow_menu_button.xml | 32 | ||||
-rw-r--r-- | res/values/strings.xml | 2 | ||||
-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 |
10 files changed, 81 insertions, 6 deletions
diff --git a/proguard.flags b/proguard.flags index 5709023..8936a45 100644 --- a/proguard.flags +++ b/proguard.flags @@ -7,6 +7,7 @@ public void onClickConfigureButton(android.view.View); public void onClickAllAppsButton(android.view.View); public void onClickAppMarketButton(android.view.View); + public void onClickOverflowMenuButton(android.view.View); public void dismissWorkspaceCling(android.view.View); public void dismissAllAppsCling(android.view.View); public void dismissAllAppsSortCling(android.view.View); @@ -56,4 +57,4 @@ public float getHorizontalWallpaperOffset(); } --keep class com.cyanogenmod.trebuchet.preference.Preferences$*Fragment
\ No newline at end of file +-keep class com.cyanogenmod.trebuchet.preference.Preferences$*Fragment diff --git a/res/drawable-hdpi/ic_menu_overflow.png b/res/drawable-hdpi/ic_menu_overflow.png Binary files differnew file mode 100644 index 0000000..a12aedf --- /dev/null +++ b/res/drawable-hdpi/ic_menu_overflow.png diff --git a/res/drawable-mdpi/ic_menu_overflow.png b/res/drawable-mdpi/ic_menu_overflow.png Binary files differnew file mode 100644 index 0000000..4a3bde3 --- /dev/null +++ b/res/drawable-mdpi/ic_menu_overflow.png diff --git a/res/drawable-xhdpi/ic_menu_overflow.png b/res/drawable-xhdpi/ic_menu_overflow.png Binary files differnew file mode 100644 index 0000000..715cff8 --- /dev/null +++ b/res/drawable-xhdpi/ic_menu_overflow.png diff --git a/res/layout/apps_customize_pane.xml b/res/layout/apps_customize_pane.xml index 19d343e..bee51d7 100644 --- a/res/layout/apps_customize_pane.xml +++ b/res/layout/apps_customize_pane.xml @@ -41,6 +41,12 @@ android:tabStripEnabled="false" android:divider="@null" /> <include + android:id="@+id/overflow_menu_button" + layout="@layout/overflow_menu_button" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_gravity="right" /> + <include android:id="@+id/market_button" layout="@layout/market_button" android:layout_width="wrap_content" diff --git a/res/layout/overflow_menu_button.xml b/res/layout/overflow_menu_button.xml new file mode 100644 index 0000000..9438cc6 --- /dev/null +++ b/res/layout/overflow_menu_button.xml @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Copyright (C) 2011 The Android Open Source Project + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +--> +<TextView + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:launcher="http://schemas.android.com/apk/res/com.cyanogenmod.trebuchet" + style="@style/MarketButton" + android:onClick="onClickOverflowMenuButton" + android:drawableLeft="@drawable/ic_menu_overflow" + android:gravity="center" + android:paddingLeft="16dp" + android:paddingRight="16dp" + android:background="@drawable/tab_widget_indicator_selector" + android:contentDescription="@string/menu" + android:shadowColor="@color/workspace_all_apps_and_delete_zone_text_shadow_color" + android:shadowDx="0.0" + android:shadowDy="0.0" + android:shadowRadius="2.0" + android:focusable="true" + android:clickable="true" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 37a97a0..9d9172d 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -49,6 +49,8 @@ <!-- Market button text. The market button text is removed in Launcher.java in the Phone UI. [CHAR LIMIT=32] --> <string name="market">Shop</string> + <!-- Menu button text. --> + <string name="menu">Menu</string> <!-- The format string for the dimensions of a widget in the drawer --> <string name="widget_dims_format" translatable="false">%1$d x %2$d</string> diff --git a/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java b/src/com/cyanogenmod/trebuchet/AppsCustomizeTabHost.java index af762ea..08d9597 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 0ac6e24..9e0043a 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 f5951ea..21cc4ec 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 |