lose embedded source jars from upstream branch
[debian/openrocket] / android / src / net / sf / openrocket / android / actionbarcompat / ActionBarFragmentActivity.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 android.app.Activity;
20 import android.os.Bundle;
21 import android.support.v4.app.FragmentActivity;
22 import android.view.Menu;
23 import android.view.MenuInflater;
24
25 /**
26  * A base activity that defers common functionality across app activities to an {@link
27  * ActionBarHelper}.
28  *
29  * NOTE: dynamically marking menu items as invisible/visible is not currently supported.
30  *
31  * NOTE: this may used with the Android Compatibility Package by extending
32  * android.support.v4.app.FragmentActivity instead of {@link Activity}.
33  */
34 public abstract class ActionBarFragmentActivity extends FragmentActivity {
35     final ActionBarHelper mActionBarHelper = ActionBarHelper.createInstance(this);
36
37     /**
38      * Returns the {@link ActionBarHelper} for this activity.
39      */
40     protected ActionBarHelper getActionBarHelper() {
41         return mActionBarHelper;
42     }
43
44     /**{@inheritDoc}*/
45     @Override
46     public MenuInflater getMenuInflater() {
47         return mActionBarHelper.getMenuInflater(super.getMenuInflater());
48     }
49
50     /**{@inheritDoc}*/
51     @Override
52     protected void onCreate(Bundle savedInstanceState) {
53         super.onCreate(savedInstanceState);
54         mActionBarHelper.onCreate(savedInstanceState);
55     }
56
57     /**{@inheritDoc}*/
58     @Override
59     protected void onPostCreate(Bundle savedInstanceState) {
60         super.onPostCreate(savedInstanceState);
61         mActionBarHelper.onPostCreate(savedInstanceState);
62     }
63
64     /**
65      * Base action bar-aware implementation for
66      * {@link Activity#onCreateOptionsMenu(android.view.Menu)}.
67      *
68      * Note: marking menu items as invisible/visible is not currently supported.
69      */
70     @Override
71     public boolean onCreateOptionsMenu(Menu menu) {
72         boolean retValue = false;
73         retValue |= mActionBarHelper.onCreateOptionsMenu(menu);
74         retValue |= super.onCreateOptionsMenu(menu);
75         return retValue;
76     }
77
78     /**{@inheritDoc}*/
79     @Override
80     protected void onTitleChanged(CharSequence title, int color) {
81         mActionBarHelper.onTitleChanged(title, color);
82         super.onTitleChanged(title, color);
83     }
84 }