lose embedded source jars from upstream branch
[debian/openrocket] / android / src / net / sf / openrocket / android / actionbarcompat / ActionBarHelper.java
1 /*
2  * Copyright 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
17 package net.sf.openrocket.android.actionbarcompat;
18
19 import net.sf.openrocket.R;
20 import android.app.Activity;
21 import android.os.Build;
22 import android.os.Bundle;
23 import android.view.Menu;
24 import android.view.MenuInflater;
25
26 /**
27  * An abstract class that handles some common action bar-related functionality in the app. This
28  * class provides functionality useful for both phones and tablets, and does not require any Android
29  * 3.0-specific features, although it uses them if available.
30  *
31  * Two implementations of this class are {@link ActionBarHelperBase} for a pre-Honeycomb version of
32  * the action bar, and {@link ActionBarHelperHoneycomb}, which uses the built-in ActionBar features
33  * in Android 3.0 and later.
34  */
35 public abstract class ActionBarHelper {
36     protected Activity mActivity;
37
38     /**
39      * Factory method for creating {@link ActionBarHelper} objects for a
40      * given activity. Depending on which device the app is running, either a basic helper or
41      * Honeycomb-specific helper will be returned.
42      */
43     public static ActionBarHelper createInstance(Activity activity) {
44         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
45             return new ActionBarHelperICS(activity);
46         } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
47             return new ActionBarHelperHoneycomb(activity);
48         } else {
49             return new ActionBarHelperBase(activity);
50         }
51     }
52
53     protected ActionBarHelper(Activity activity) {
54         mActivity = activity;
55     }
56
57     /**
58      * Action bar helper code to be run in {@link Activity#onCreate(android.os.Bundle)}.
59      */
60     public void onCreate(Bundle savedInstanceState) {
61     }
62
63     /**
64      * Action bar helper code to be run in {@link Activity#onPostCreate(android.os.Bundle)}.
65      */
66     public void onPostCreate(Bundle savedInstanceState) {
67     }
68
69     /**
70      * Action bar helper code to be run in {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
71      *
72      * NOTE: Setting the visibility of menu items in <em>menu</em> is not currently supported.
73      */
74     public boolean onCreateOptionsMenu(Menu menu) {
75         return true;
76     }
77
78     /**
79      * Action bar helper code to be run in {@link Activity#onTitleChanged(CharSequence, int)}.
80      */
81     protected void onTitleChanged(CharSequence title, int color) {
82     }
83
84     /**
85      * Sets the indeterminate loading state of the item with ID {@link R.id.menu_refresh}.
86      * (where the item ID was menu_refresh).
87      */
88     public abstract void setRefreshActionItemState(boolean refreshing);
89
90     /**
91      * Returns a {@link MenuInflater} for use when inflating menus. The implementation of this
92      * method in {@link ActionBarHelperBase} returns a wrapped menu inflater that can read
93      * action bar metadata from a menu resource pre-Honeycomb.
94      */
95     public MenuInflater getMenuInflater(MenuInflater superMenuInflater) {
96         return superMenuInflater;
97     }
98     
99     public abstract void setDisplayHomeAsUpEnabled( boolean enabled );
100     
101     public abstract void hide();
102 }