1/* 2 * Copyright (C) 2012 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.v7.view.menu; 18 19import static android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP; 20 21import android.content.Context; 22import android.os.Build; 23import android.support.annotation.RestrictTo; 24import android.support.v4.internal.view.SupportMenu; 25import android.support.v4.internal.view.SupportMenuItem; 26import android.support.v4.internal.view.SupportSubMenu; 27import android.view.Menu; 28import android.view.MenuItem; 29import android.view.SubMenu; 30 31/** 32 * @hide 33 */ 34@RestrictTo(LIBRARY_GROUP) 35public final class MenuWrapperFactory { 36 private MenuWrapperFactory() { 37 } 38 39 public static Menu wrapSupportMenu(Context context, SupportMenu supportMenu) { 40 return new MenuWrapperICS(context, supportMenu); 41 } 42 43 public static MenuItem wrapSupportMenuItem(Context context, SupportMenuItem supportMenuItem) { 44 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 45 return new MenuItemWrapperJB(context, supportMenuItem); 46 } else { 47 return new MenuItemWrapperICS(context, supportMenuItem); 48 } 49 } 50 51 public static SubMenu wrapSupportSubMenu(Context context, SupportSubMenu supportSubMenu) { 52 return new SubMenuWrapperICS(context, supportSubMenu); 53 } 54} 55