• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 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 android.app.stubs;
18 
19 import android.app.Activity;
20 import android.app.Dialog;
21 import android.content.res.Resources;
22 import android.os.Bundle;
23 import android.view.ContextMenu;
24 import android.view.Menu;
25 import android.view.MenuItem;
26 import android.view.View;
27 import android.view.ContextMenu.ContextMenuInfo;
28 
29 /**
30  * A minimal "Hello, World!" application.
31  */
32 public class AppStubActivity extends Activity {
33     private Dialog mDialog;
34     public boolean mOnPrepareDialog;
35     public boolean mOnOptionsMenuClosedCalled;
36     public boolean mOnPrepareOptionsMenuCalled;
37     public boolean mOnOptionsItemSelectedCalled;
38     public boolean mOnCreateOptionsMenu;
39     public boolean mIndterminate = false;
40     public boolean mIndterminatevisibility = false;
41     public boolean mSecPro = false;
42     public boolean mOnContextItemSelectedCalled;
43     public boolean mOnCreateContextMenu;
44     public boolean mApplyResourceCalled;
45     public boolean mCreateContextMenuCalled;
46     public boolean mRequestWinFeatureRet = false;
47 
AppStubActivity()48     public AppStubActivity() {
49 
50     }
51 
finalize()52     public void finalize() {
53         try {
54             super.finalize();
55         } catch (Throwable exception) {
56             System.err.print("exception!");
57         }
58     }
59 
60     @Override
onCreate(Bundle savedInstanceState)61     protected void onCreate(Bundle savedInstanceState){
62         super.onCreate(savedInstanceState);
63         mRequestWinFeatureRet = requestWindowFeature(1);
64         setContentView(R.layout.app_activity);
65     }
66 
getDialogById(int id)67     public Dialog getDialogById(int id) {
68         return mDialog;
69     }
70 
71     @Override
onCreateDialog(int id)72     public Dialog onCreateDialog(int id) {
73         super.onCreateDialog(id);
74         mDialog = new Dialog(this);
75         return mDialog;
76     }
77 
78     @Override
onPrepareDialog(int id, Dialog dialog)79     protected void onPrepareDialog(int id, Dialog dialog) {
80         super.onPrepareDialog(id, dialog);
81         mOnPrepareDialog = true;
82     }
83 
84     @Override
onOptionsMenuClosed(Menu menu)85     public void onOptionsMenuClosed(Menu menu) {
86         super.onOptionsMenuClosed(menu);
87         mOnOptionsMenuClosedCalled = true;
88     }
89 
90     @Override
onPrepareOptionsMenu(Menu menu)91     public boolean onPrepareOptionsMenu(Menu menu) {
92         mOnPrepareOptionsMenuCalled = true;
93         return super.onPrepareOptionsMenu(menu);
94     }
95 
96     @Override
onCreateOptionsMenu(Menu menu)97     public boolean onCreateOptionsMenu(Menu menu) {
98         mOnCreateOptionsMenu = true;
99         if(menu != null)
100             menu.add(0, 0, 0, "Fake Item");
101         return super.onCreateOptionsMenu(menu);
102     }
103 
104     @Override
onOptionsItemSelected(MenuItem item)105     public boolean onOptionsItemSelected(MenuItem item) {
106         mOnOptionsItemSelectedCalled = true;
107         return super.onOptionsItemSelected(item);
108     }
109 
setProBarIndeterminate(boolean indeterminate)110     public boolean setProBarIndeterminate(boolean indeterminate){
111         mIndterminate = indeterminate;
112         super.setProgressBarIndeterminate(indeterminate);
113         return mIndterminate;
114     }
115 
setProBarIndeterminateVisibility(boolean visible)116     public boolean setProBarIndeterminateVisibility(boolean visible){
117         mIndterminatevisibility = visible;
118         super.setProgressBarIndeterminateVisibility(visible);
119         return mIndterminatevisibility;
120     }
121 
setSecPro(int secPro)122     public boolean setSecPro(int secPro){
123         mSecPro = true;
124         super.setSecondaryProgress(secPro);
125         return mSecPro;
126     }
127 
128     @Override
onContextItemSelected(MenuItem item)129     public boolean onContextItemSelected(MenuItem item){
130         mOnContextItemSelectedCalled = true;
131         return super.onContextItemSelected(item);
132     }
133 
134     @Override
onApplyThemeResource( Resources.Theme theme, int resid, boolean first)135     public void onApplyThemeResource( Resources.Theme theme,
136                                       int resid,
137                                       boolean first){
138         super.onApplyThemeResource(theme,resid,first);
139         mApplyResourceCalled = true;
140     }
141 
142     @Override
onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)143     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
144         super.onCreateContextMenu(menu,v,menuInfo);
145         mCreateContextMenuCalled = true;
146     }
147 }
148 
149