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 18 package com.android.mail.ui; 19 20 import android.app.Application; 21 import android.app.FragmentManager; 22 import android.app.LoaderManager; 23 import android.content.ComponentName; 24 import android.content.ContentResolver; 25 import android.content.Context; 26 import android.content.Intent; 27 import android.os.Bundle; 28 import android.support.v7.app.ActionBar; 29 import android.support.v7.view.ActionMode; 30 import android.view.MenuInflater; 31 import android.view.MenuItem; 32 import android.view.View; 33 import 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 */ 43 public 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 */ findViewById(int id)52 <T extends View> T findViewById(int id); 53 54 /** 55 * @see android.app.Activity#finish() 56 */ finish()57 void finish(); 58 59 /** 60 * @see android.support.v7.app.AppCompatActivity#getSupportActionBar() 61 */ getSupportActionBar()62 ActionBar getSupportActionBar(); 63 64 /** 65 * @see android.app.Activity#getApplication() 66 */ getApplication()67 Application getApplication(); 68 69 /** 70 * @see android.app.Activity#getComponentName() 71 */ getComponentName()72 ComponentName getComponentName(); 73 74 /** 75 * @see android.app.Activity#getContentResolver() 76 */ getContentResolver()77 ContentResolver getContentResolver(); 78 79 /** 80 * @see android.app.Activity#getFragmentManager() 81 */ getFragmentManager()82 FragmentManager getFragmentManager(); 83 84 /** 85 * @see android.app.Activity#getIntent() 86 */ getIntent()87 Intent getIntent(); 88 89 /** 90 * @see android.app.Activity#getLoaderManager() 91 */ getLoaderManager()92 LoaderManager getLoaderManager(); 93 94 /** 95 * @see android.app.Activity#getMenuInflater() 96 */ getMenuInflater()97 MenuInflater getMenuInflater(); 98 99 /** 100 * @see android.app.Activity#getWindow() 101 */ getWindow()102 Window getWindow(); 103 104 /** 105 * @see android.support.v7.app.AppCompatActivity#supportInvalidateOptionsMenu() 106 */ supportInvalidateOptionsMenu()107 void supportInvalidateOptionsMenu(); 108 109 /** 110 * @see android.app.Activity#isChangingConfigurations() 111 */ isChangingConfigurations()112 boolean isChangingConfigurations(); 113 114 /** 115 * @see android.app.Activity#isFinishing() 116 */ isFinishing()117 boolean isFinishing(); 118 119 /** 120 * @see android.app.Activity#onBackPressed() 121 */ onBackPressed()122 void onBackPressed(); 123 124 /** 125 * @see android.app.Activity#setContentView(int) 126 */ setContentView(int layoutResId)127 void setContentView(int layoutResId); 128 129 /** 130 * @see android.app.Activity#setDefaultKeyMode(int) 131 */ setDefaultKeyMode(int mode)132 void setDefaultKeyMode(int mode); 133 134 /** 135 * @see android.app.Activity#setResult(int, Intent) 136 */ setResult(int resultCode, Intent data)137 void setResult(int resultCode, Intent data); 138 139 /** 140 * @see android.app.Activity#setTitle(CharSequence) 141 */ setTitle(CharSequence title)142 void setTitle(CharSequence title); 143 144 /** 145 * @see android.app.Activity#showDialog(int) 146 */ showDialog(int id)147 void showDialog(int id); 148 149 /** 150 * @see android.support.v7.app.AppCompatActivity#startSupportActionMode(ActionMode.Callback) 151 */ startSupportActionMode(ActionMode.Callback callback)152 ActionMode startSupportActionMode(ActionMode.Callback callback); 153 154 /** 155 * @see android.app.Activity#startActivityForResult(Intent, int) 156 */ startActivityForResult(Intent intent, int requestCode)157 void startActivityForResult(Intent intent, int requestCode); 158 159 /** 160 * @see android.app.Activity#startActivityForResult(Intent, int) 161 */ startActivity(Intent intent)162 void startActivity(Intent intent); 163 164 /** 165 * @see android.app.Activity#startSearch(String, boolean, Bundle, boolean) 166 */ startSearch(String initialQuery, boolean selectInitialQuery, Bundle appSearchData, boolean globalSearch)167 void startSearch(String initialQuery, boolean selectInitialQuery, 168 Bundle appSearchData, boolean globalSearch); 169 170 /** 171 * @see android.app.Activity#getApplicationContext() 172 */ getApplicationContext()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 */ getActivityContext()182 Context getActivityContext(); 183 184 /** 185 * @see android.app.Activity#onOptionsItemSelected(MenuItem) 186 */ onOptionsItemSelected(MenuItem item)187 boolean onOptionsItemSelected(MenuItem item); 188 setPendingToastOperation(ToastBarOperation op)189 void setPendingToastOperation(ToastBarOperation op); 190 getPendingToastOperation()191 ToastBarOperation getPendingToastOperation(); 192 } 193