2 * Copyright 2011 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package net.sf.openrocket.android.actionbarcompat;
19 import net.sf.openrocket.R;
20 import android.app.Activity;
21 import android.content.Context;
22 import android.view.LayoutInflater;
23 import android.view.Menu;
24 import android.view.MenuItem;
25 import android.view.View;
28 * An extension of {@link ActionBarHelper} that provides Android 3.0-specific functionality for
29 * Honeycomb tablets. It thus requires API level 11.
31 public class ActionBarHelperHoneycomb extends ActionBarHelper {
32 private Menu mOptionsMenu;
33 private View mRefreshIndeterminateProgressView = null;
35 protected ActionBarHelperHoneycomb(Activity activity) {
40 public boolean onCreateOptionsMenu(Menu menu) {
42 return super.onCreateOptionsMenu(menu);
46 public void setRefreshActionItemState(boolean refreshing) {
47 // On Honeycomb, we can set the state of the refresh button by giving it a custom
49 if (mOptionsMenu == null) {
53 final MenuItem refreshItem = mOptionsMenu.findItem(R.id.menu_refresh);
54 if (refreshItem != null) {
56 if (mRefreshIndeterminateProgressView == null) {
57 LayoutInflater inflater = (LayoutInflater)
58 getActionBarThemedContext().getSystemService(
59 Context.LAYOUT_INFLATER_SERVICE);
60 mRefreshIndeterminateProgressView = inflater.inflate(
61 R.layout.actionbar_indeterminate_progress, null);
64 refreshItem.setActionView(mRefreshIndeterminateProgressView);
66 refreshItem.setActionView(null);
72 * Returns a {@link Context} suitable for inflating layouts for the action bar. The
73 * implementation for this method in {@link ActionBarHelperICS} asks the action bar for a
76 protected Context getActionBarThemedContext() {
81 public void setDisplayHomeAsUpEnabled(boolean enabled) {
82 mActivity.getActionBar().setDisplayHomeAsUpEnabled(enabled);
87 mActivity.getActionBar().hide();