switch to alsa.omap3 module
[android_pandora.git] / apps / AndroidSupportV2 / src / android / support / v2 / view / MenuCompat.java
CommitLineData
811a5a4a 1/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.support.v2.view;
18
19import android.view.MenuItem;
20
21/**
22 * Helper for accessing newer features in menus.
23 */
24public class MenuCompat {
25 /**
26 * Interface for the full API.
27 */
28 interface MenuVersionImpl {
29 public boolean setShowAsAction(MenuItem item, int actionEnum);
30 }
31
32 /**
33 * Interface implementation that doesn't use anything about v4 APIs.
34 */
35 static class BaseMenuVersionImpl implements MenuVersionImpl {
36 @Override
37 public boolean setShowAsAction(MenuItem item, int actionEnum) {
38 return false;
39 }
40 }
41
42 /**
43 * Interface implementation for devices with at least v11 APIs.
44 */
45 static class HoneycombMenuVersionImpl implements MenuVersionImpl {
46 @Override
47 public boolean setShowAsAction(MenuItem item, int actionEnum) {
a22e4567 48 //MenuCompatHoneycomb.setShowAsAction(item, actionEnum);
811a5a4a 49 return true;
50 }
51 }
52
53 /**
54 * Select the correct implementation to use for the current platform.
55 */
56 static final MenuVersionImpl IMPL;
57 static {
58 //v4 if (android.os.Build.VERSION.SDK_INT >= 11) {
59 if (android.support.v2.os.Build.VERSION.SDK_INT >= 11) {
a22e4567 60 IMPL = null;//new HoneycombMenuVersionImpl();
811a5a4a 61 } else {
62 IMPL = new BaseMenuVersionImpl();
63 }
64 }
65
66 // -------------------------------------------------------------------
67
68 /**
69 * Call {@link MenuItem#setShowAsAction(int) MenuItem.setShowAsAction()}.
70 * If running on a pre-{@android.os.Build.VERSION_CODES#HONEYCOMB} device,
71 * does nothing and returns false. Otherwise returns true.
72 */
73 public static boolean setShowAsAction(MenuItem item, int actionEnum) {
74 return IMPL.setShowAsAction(item, actionEnum);
75 }
76}