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.v4.app; 18 19import android.app.Activity; 20import android.content.Intent; 21import android.view.ActionProvider; 22import android.view.MenuItem; 23import android.widget.ShareActionProvider; 24 25class ShareCompatICS { 26 private static final String HISTORY_FILENAME_PREFIX = ".sharecompat_"; 27 28 public static void configureMenuItem(MenuItem item, Activity callingActivity, Intent intent) { 29 ActionProvider itemProvider = item.getActionProvider(); 30 ShareActionProvider provider = null; 31 if (!(itemProvider instanceof ShareActionProvider)) { 32 provider = new ShareActionProvider(callingActivity); 33 } else { 34 provider = (ShareActionProvider) itemProvider; 35 } 36 provider.setShareHistoryFileName(HISTORY_FILENAME_PREFIX + 37 callingActivity.getClass().getName()); 38 provider.setShareIntent(intent); 39 item.setActionProvider(provider); 40 } 41} 42