1/*
2 * Copyright (C) 2012 Google Inc.
3 * Licensed to The Android Open Source Project.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18package com.android.mail.ui;
19
20import android.app.Application;
21import android.app.FragmentManager;
22import android.app.LoaderManager;
23import android.content.ComponentName;
24import android.content.ContentResolver;
25import android.content.Context;
26import android.content.Intent;
27import android.os.Bundle;
28import android.support.v7.app.ActionBar;
29import android.support.v7.view.ActionMode;
30import android.view.MenuInflater;
31import android.view.MenuItem;
32import android.view.View;
33import android.view.Window;
34
35// Should not rely on any mail-specific packages.
36
37/**
38 * {@link RestrictedActivity} gives access to a subset of
39 * {@link android.support.v7.app.AppCompatActivity} methods.
40 * These methods match the signatures from
41 * {@link android.support.v7.app.AppCompatActivity}.
42 */
43public interface RestrictedActivity {
44    /*
45     * All methods are from android.app.Activity, and the doc strings need to point to the
46     * underlying methods.
47     */
48
49    /**
50     * @see android.app.Activity#findViewById(int)
51     */
52    <T extends View> T findViewById(int id);
53
54    /**
55     * @see android.app.Activity#finish()
56     */
57    void finish();
58
59    /**
60     * @see android.support.v7.app.AppCompatActivity#getSupportActionBar()
61     */
62    ActionBar getSupportActionBar();
63
64    /**
65     * @see android.app.Activity#getApplication()
66     */
67    Application getApplication();
68
69    /**
70     * @see android.app.Activity#getComponentName()
71     */
72    ComponentName getComponentName();
73
74    /**
75     * @see android.app.Activity#getContentResolver()
76     */
77    ContentResolver getContentResolver();
78
79    /**
80     * @see android.app.Activity#getFragmentManager()
81     */
82    FragmentManager getFragmentManager();
83
84    /**
85     * @see android.app.Activity#getIntent()
86     */
87    Intent getIntent();
88
89    /**
90     * @see android.app.Activity#getLoaderManager()
91     */
92    LoaderManager getLoaderManager();
93
94    /**
95     * @see android.app.Activity#getMenuInflater()
96     */
97    MenuInflater getMenuInflater();
98
99    /**
100     * @see android.app.Activity#getWindow()
101     */
102    Window getWindow();
103
104    /**
105     * @see android.support.v7.app.AppCompatActivity#supportInvalidateOptionsMenu()
106     */
107    void supportInvalidateOptionsMenu();
108
109    /**
110     * @see android.app.Activity#isChangingConfigurations()
111     */
112    boolean isChangingConfigurations();
113
114    /**
115     * @see android.app.Activity#isFinishing()
116     */
117    boolean isFinishing();
118
119    /**
120     * @see android.app.Activity#onBackPressed()
121     */
122    void onBackPressed();
123
124    /**
125     * @see android.app.Activity#setContentView(int)
126     */
127    void setContentView(int layoutResId);
128
129    /**
130     * @see android.app.Activity#setDefaultKeyMode(int)
131     */
132    void setDefaultKeyMode(int mode);
133
134    /**
135     * @see android.app.Activity#setResult(int, Intent)
136     */
137    void setResult(int resultCode, Intent data);
138
139    /**
140     * @see android.app.Activity#setTitle(CharSequence)
141     */
142    void setTitle(CharSequence title);
143
144    /**
145     * @see android.app.Activity#showDialog(int)
146     */
147    void showDialog(int id);
148
149    /**
150     * @see android.support.v7.app.AppCompatActivity#startSupportActionMode(ActionMode.Callback)
151     */
152    ActionMode startSupportActionMode(ActionMode.Callback callback);
153
154    /**
155     * @see android.app.Activity#startActivityForResult(Intent, int)
156     */
157    void startActivityForResult(Intent intent, int requestCode);
158
159    /**
160     * @see android.app.Activity#startActivityForResult(Intent, int)
161     */
162    void startActivity(Intent intent);
163
164    /**
165     * @see android.app.Activity#startSearch(String, boolean, Bundle, boolean)
166     */
167    void startSearch(String initialQuery, boolean selectInitialQuery,
168            Bundle appSearchData, boolean globalSearch);
169
170    /**
171     * @see android.app.Activity#getApplicationContext()
172     */
173    Context getApplicationContext();
174
175    /**
176     * Returns the context associated with the activity. This is different from the value returned
177     * by {@link #getApplicationContext()}, which is the single context of the root activity. Some
178     * components (dialogs) require the context of the activity. When implementing this, you can
179     * return this, since each activity is also a context.
180     * @return the context associated with this activity.
181     */
182    Context getActivityContext();
183
184    /**
185     * @see android.app.Activity#onOptionsItemSelected(MenuItem)
186     */
187    boolean onOptionsItemSelected(MenuItem item);
188
189    void setPendingToastOperation(ToastBarOperation op);
190
191    ToastBarOperation getPendingToastOperation();
192}
193