Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 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 com.android.browser; |
| 18 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.AnimatorSet; |
| 22 | import android.animation.ObjectAnimator; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 23 | import android.app.Activity; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 24 | import android.content.Context; |
| 25 | import android.graphics.Bitmap; |
| 26 | import android.graphics.Canvas; |
| 27 | import android.graphics.Matrix; |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 28 | import android.os.Message; |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 29 | import android.util.Log; |
John Reck | aae029c | 2011-09-16 14:36:39 -0700 | [diff] [blame] | 30 | import android.util.TypedValue; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 31 | import android.view.ActionMode; |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 32 | import android.view.KeyEvent; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 33 | import android.view.LayoutInflater; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 34 | import android.view.Menu; |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 35 | import android.view.MenuItem; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 36 | import android.view.View; |
Michael Kolb | 30adae6 | 2011-07-29 13:37:05 -0700 | [diff] [blame] | 37 | import android.view.accessibility.AccessibilityEvent; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 38 | import android.webkit.WebView; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 39 | import android.widget.ImageView; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 40 | |
Michael Kolb | 629b22c | 2011-07-13 16:26:47 -0700 | [diff] [blame] | 41 | import com.android.browser.UrlInputView.StateListener; |
| 42 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 43 | /** |
| 44 | * Ui for regular phone screen sizes |
| 45 | */ |
| 46 | public class PhoneUi extends BaseUi { |
| 47 | |
| 48 | private static final String LOGTAG = "PhoneUi"; |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 49 | private static final int MSG_INIT_NAVSCREEN = 100; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 50 | |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 51 | private NavScreen mNavScreen; |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 52 | private AnimScreen mAnimScreen; |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 53 | private NavigationBarPhone mNavigationBar; |
John Reck | aae029c | 2011-09-16 14:36:39 -0700 | [diff] [blame] | 54 | private int mActionBarHeight; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 55 | |
Michael Kolb | 08a687a | 2011-04-22 16:13:02 -0700 | [diff] [blame] | 56 | boolean mAnimating; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * @param browser |
| 60 | * @param controller |
| 61 | */ |
| 62 | public PhoneUi(Activity browser, UiController controller) { |
| 63 | super(browser, controller); |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 64 | setUseQuickControls(BrowserSettings.getInstance().useQuickControls()); |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 65 | mNavigationBar = (NavigationBarPhone) mTitleBar.getNavigationBar(); |
John Reck | aae029c | 2011-09-16 14:36:39 -0700 | [diff] [blame] | 66 | TypedValue heightValue = new TypedValue(); |
| 67 | browser.getTheme().resolveAttribute( |
| 68 | com.android.internal.R.attr.actionBarSize, heightValue, true); |
| 69 | mActionBarHeight = TypedValue.complexToDimensionPixelSize(heightValue.data, |
| 70 | browser.getResources().getDisplayMetrics()); |
John Reck | 285ef04 | 2011-02-11 15:44:17 -0800 | [diff] [blame] | 71 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 72 | |
John Reck | 285ef04 | 2011-02-11 15:44:17 -0800 | [diff] [blame] | 73 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 74 | public void onDestroy() { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 75 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | @Override |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 79 | public void editUrl(boolean clearInput, boolean forceIME) { |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 80 | if (mUseQuickControls) { |
John Reck | 0f602f3 | 2011-07-07 15:38:43 -0700 | [diff] [blame] | 81 | mTitleBar.setShowProgressOnly(false); |
Michael Kolb | 46f987e | 2011-04-05 10:39:10 -0700 | [diff] [blame] | 82 | } |
Michael Kolb | 1f9b356 | 2012-04-24 14:38:34 -0700 | [diff] [blame] | 83 | super.editUrl(clearInput, forceIME); |
Michael Kolb | dc2ee1b | 2011-02-14 14:34:40 -0800 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 87 | public boolean onBackKey() { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 88 | if (showingNavScreen()) { |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 89 | mNavScreen.close(mUiController.getTabControl().getCurrentPosition()); |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 90 | return true; |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 91 | } |
| 92 | return super.onBackKey(); |
| 93 | } |
| 94 | |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 95 | private boolean showingNavScreen() { |
| 96 | return mNavScreen != null && mNavScreen.getVisibility() == View.VISIBLE; |
| 97 | } |
| 98 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 99 | @Override |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 100 | public boolean dispatchKey(int code, KeyEvent event) { |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 101 | return false; |
| 102 | } |
| 103 | |
| 104 | @Override |
John Reck | 30c714c | 2010-12-16 17:30:34 -0800 | [diff] [blame] | 105 | public void onProgressChanged(Tab tab) { |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame^] | 106 | super.onProgressChanged(tab); |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 107 | if (mNavScreen == null && getTitleBar().getHeight() > 0) { |
| 108 | mHandler.sendEmptyMessage(MSG_INIT_NAVSCREEN); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | @Override |
| 113 | protected void handleMessage(Message msg) { |
| 114 | super.handleMessage(msg); |
| 115 | if (msg.what == MSG_INIT_NAVSCREEN) { |
| 116 | if (mNavScreen == null) { |
| 117 | mNavScreen = new NavScreen(mActivity, mUiController, this); |
| 118 | mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS); |
| 119 | mNavScreen.setVisibility(View.GONE); |
| 120 | } |
| 121 | if (mAnimScreen == null) { |
| 122 | mAnimScreen = new AnimScreen(mActivity); |
| 123 | // initialize bitmaps |
| 124 | mAnimScreen.set(getTitleBar(), getWebView()); |
| 125 | } |
| 126 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | @Override |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 130 | public void setActiveTab(final Tab tab) { |
John Reck | 8ee633f | 2011-08-09 16:00:35 -0700 | [diff] [blame] | 131 | mTitleBar.cancelTitleBarAnimation(true); |
| 132 | mTitleBar.setSkipTitleBarAnimations(true); |
John Reck | 5d43ce8 | 2011-06-21 17:16:51 -0700 | [diff] [blame] | 133 | super.setActiveTab(tab); |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 134 | BrowserWebView view = (BrowserWebView) tab.getWebView(); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 135 | // TabControl.setCurrentTab has been called before this, |
| 136 | // so the tab is guaranteed to have a webview |
| 137 | if (view == null) { |
| 138 | Log.e(LOGTAG, "active tab with no webview detected"); |
| 139 | return; |
| 140 | } |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 141 | // Request focus on the top window. |
| 142 | if (mUseQuickControls) { |
| 143 | mPieControl.forceToTop(mContentView); |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 144 | view.setTitleBar(null); |
Michael Kolb | e8a8233 | 2012-04-25 14:14:26 -0700 | [diff] [blame^] | 145 | mTitleBar.setShowProgressOnly(true); |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 146 | } else { |
Michael Kolb | 4923c22 | 2012-04-02 16:18:36 -0700 | [diff] [blame] | 147 | view.setTitleBar(mTitleBar); |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 148 | } |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 149 | if (tab.isInVoiceSearchMode()) { |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 150 | showVoiceTitleBar(tab.getVoiceDisplayTitle(), tab.getVoiceSearchResults()); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 151 | } else { |
| 152 | revertVoiceTitleBar(tab); |
| 153 | } |
Michael Kolb | 629b22c | 2011-07-13 16:26:47 -0700 | [diff] [blame] | 154 | // update nav bar state |
| 155 | mNavigationBar.onStateChanged(StateListener.STATE_NORMAL); |
Michael Kolb | fdb7024 | 2011-03-24 09:41:11 -0700 | [diff] [blame] | 156 | updateLockIconToLatest(tab); |
John Reck | 8ee633f | 2011-08-09 16:00:35 -0700 | [diff] [blame] | 157 | mTitleBar.setSkipTitleBarAnimations(false); |
Michael Kolb | 376b541 | 2010-12-15 11:52:57 -0800 | [diff] [blame] | 158 | } |
| 159 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 160 | // menu handling callbacks |
| 161 | |
| 162 | @Override |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 163 | public boolean onPrepareOptionsMenu(Menu menu) { |
Michael Kolb | 7bdee0b | 2011-08-01 11:55:38 -0700 | [diff] [blame] | 164 | updateMenuState(mActiveTab, menu); |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 165 | return true; |
| 166 | } |
| 167 | |
| 168 | @Override |
Michael Kolb | 7bdee0b | 2011-08-01 11:55:38 -0700 | [diff] [blame] | 169 | public void updateMenuState(Tab tab, Menu menu) { |
Michael Kolb | 0d0245f | 2011-12-05 16:36:05 -0800 | [diff] [blame] | 170 | MenuItem bm = menu.findItem(R.id.bookmarks_menu_id); |
| 171 | if (bm != null) { |
| 172 | bm.setVisible(!showingNavScreen()); |
| 173 | } |
Michael Kolb | 7bdee0b | 2011-08-01 11:55:38 -0700 | [diff] [blame] | 174 | MenuItem abm = menu.findItem(R.id.add_bookmark_menu_id); |
| 175 | if (abm != null) { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 176 | abm.setVisible((tab != null) && !tab.isSnapshot() && !showingNavScreen()); |
John Reck | e1a03a3 | 2011-09-14 17:04:16 -0700 | [diff] [blame] | 177 | } |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 178 | MenuItem info = menu.findItem(R.id.page_info_menu_id); |
| 179 | if (info != null) { |
| 180 | info.setVisible(false); |
| 181 | } |
| 182 | MenuItem newtab = menu.findItem(R.id.new_tab_menu_id); |
| 183 | if (newtab != null && !mUseQuickControls) { |
| 184 | newtab.setVisible(false); |
| 185 | } |
| 186 | MenuItem incognito = menu.findItem(R.id.incognito_menu_id); |
| 187 | if (incognito != null) { |
| 188 | incognito.setVisible(showingNavScreen() || mUseQuickControls); |
| 189 | } |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 190 | if (showingNavScreen()) { |
John Reck | e1a03a3 | 2011-09-14 17:04:16 -0700 | [diff] [blame] | 191 | menu.setGroupVisible(R.id.LIVE_MENU, false); |
| 192 | menu.setGroupVisible(R.id.SNAPSHOT_MENU, false); |
John Reck | e1a03a3 | 2011-09-14 17:04:16 -0700 | [diff] [blame] | 193 | menu.setGroupVisible(R.id.NAV_MENU, false); |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 194 | menu.setGroupVisible(R.id.COMBO_MENU, true); |
Michael Kolb | 7bdee0b | 2011-08-01 11:55:38 -0700 | [diff] [blame] | 195 | } |
| 196 | } |
| 197 | |
| 198 | @Override |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 199 | public boolean onOptionsItemSelected(MenuItem item) { |
Michael Kolb | 315d502 | 2011-10-13 12:47:11 -0700 | [diff] [blame] | 200 | if (showingNavScreen() |
| 201 | && (item.getItemId() != R.id.history_menu_id) |
| 202 | && (item.getItemId() != R.id.snapshots_menu_id)) { |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 203 | hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false); |
Michael Kolb | 3ca1275 | 2011-07-20 13:52:25 -0700 | [diff] [blame] | 204 | } |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | @Override |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 209 | public void onContextMenuCreated(Menu menu) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 210 | hideTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | @Override |
| 214 | public void onContextMenuClosed(Menu menu, boolean inLoad) { |
| 215 | if (inLoad) { |
Michael Kolb | 7cdc490 | 2011-02-03 17:54:40 -0800 | [diff] [blame] | 216 | showTitleBar(); |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 217 | } |
| 218 | } |
| 219 | |
| 220 | // action mode callbacks |
| 221 | |
| 222 | @Override |
| 223 | public void onActionModeStarted(ActionMode mode) { |
Michael Kolb | 42c0c06 | 2011-08-02 12:56:06 -0700 | [diff] [blame] | 224 | if (!isEditingUrl()) { |
| 225 | hideTitleBar(); |
John Reck | aae029c | 2011-09-16 14:36:39 -0700 | [diff] [blame] | 226 | } else { |
| 227 | mTitleBar.animate().translationY(mActionBarHeight); |
Michael Kolb | 42c0c06 | 2011-08-02 12:56:06 -0700 | [diff] [blame] | 228 | } |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Michael Kolb | a418306 | 2011-01-16 10:43:21 -0800 | [diff] [blame] | 231 | @Override |
John Reck | 6cda7b1 | 2011-03-18 15:57:13 -0700 | [diff] [blame] | 232 | public void onActionModeFinished(boolean inLoad) { |
John Reck | aae029c | 2011-09-16 14:36:39 -0700 | [diff] [blame] | 233 | mTitleBar.animate().translationY(0); |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame] | 234 | if (inLoad) { |
| 235 | if (mUseQuickControls) { |
| 236 | mTitleBar.setShowProgressOnly(true); |
John Reck | 6cda7b1 | 2011-03-18 15:57:13 -0700 | [diff] [blame] | 237 | } |
Michael Kolb | c16c595 | 2011-03-29 15:37:03 -0700 | [diff] [blame] | 238 | showTitleBar(); |
| 239 | } |
John Reck | 6cda7b1 | 2011-03-18 15:57:13 -0700 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | @Override |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 243 | public boolean isWebShowing() { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 244 | return super.isWebShowing() && !showingNavScreen(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public void showWeb(boolean animate) { |
| 249 | super.showWeb(animate); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 250 | hideNavScreen(mUiController.getTabControl().getCurrentPosition(), animate); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 251 | } |
| 252 | |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 253 | void showNavScreen() { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 254 | mUiController.setBlockEvents(true); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 255 | if (mNavScreen == null) { |
| 256 | mNavScreen = new NavScreen(mActivity, mUiController, this); |
| 257 | mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS); |
| 258 | } else { |
| 259 | mNavScreen.setVisibility(View.VISIBLE); |
| 260 | mNavScreen.setAlpha(1f); |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 261 | mNavScreen.refreshAdapter(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 262 | } |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 263 | mActiveTab.capture(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 264 | if (mAnimScreen == null) { |
| 265 | mAnimScreen = new AnimScreen(mActivity); |
John Reck | ce8bcb0 | 2011-10-11 13:45:29 -0700 | [diff] [blame] | 266 | } else { |
| 267 | mAnimScreen.mMain.setAlpha(1f); |
| 268 | mAnimScreen.mTitle.setAlpha(1f); |
| 269 | mAnimScreen.setScaleFactor(1f); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 270 | } |
| 271 | mAnimScreen.set(getTitleBar(), getWebView()); |
Michael Kolb | a30e4fb | 2011-11-07 17:32:01 -0800 | [diff] [blame] | 272 | if (mAnimScreen.mMain.getParent() == null) { |
| 273 | mCustomViewContainer.addView(mAnimScreen.mMain, COVER_SCREEN_PARAMS); |
| 274 | } |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 275 | mCustomViewContainer.setVisibility(View.VISIBLE); |
| 276 | mCustomViewContainer.bringToFront(); |
John Reck | ce8bcb0 | 2011-10-11 13:45:29 -0700 | [diff] [blame] | 277 | mAnimScreen.mMain.layout(0, 0, mContentView.getWidth(), |
| 278 | mContentView.getHeight()); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 279 | int fromLeft = 0; |
| 280 | int fromTop = getTitleBar().getHeight(); |
| 281 | int fromRight = mContentView.getWidth(); |
| 282 | int fromBottom = mContentView.getHeight(); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 283 | int width = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_width); |
| 284 | int height = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_height); |
Michael Kolb | 7a321d6 | 2011-09-23 15:54:22 -0700 | [diff] [blame] | 285 | int ntth = mActivity.getResources().getDimensionPixelSize(R.dimen.nav_tab_titleheight); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 286 | int toLeft = (mContentView.getWidth() - width) / 2; |
Michael Kolb | 7a321d6 | 2011-09-23 15:54:22 -0700 | [diff] [blame] | 287 | int toTop = ((fromBottom - (ntth + height)) / 2 + ntth); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 288 | int toRight = toLeft + width; |
| 289 | int toBottom = toTop + height; |
| 290 | float scaleFactor = width / (float) mContentView.getWidth(); |
| 291 | detachTab(mActiveTab); |
| 292 | mContentView.setVisibility(View.GONE); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 293 | AnimatorSet set1 = new AnimatorSet(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 294 | AnimatorSet inanim = new AnimatorSet(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 295 | ObjectAnimator tx = ObjectAnimator.ofInt(mAnimScreen.mContent, "left", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 296 | fromLeft, toLeft); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 297 | ObjectAnimator ty = ObjectAnimator.ofInt(mAnimScreen.mContent, "top", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 298 | fromTop, toTop); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 299 | ObjectAnimator tr = ObjectAnimator.ofInt(mAnimScreen.mContent, "right", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 300 | fromRight, toRight); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 301 | ObjectAnimator tb = ObjectAnimator.ofInt(mAnimScreen.mContent, "bottom", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 302 | fromBottom, toBottom); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 303 | ObjectAnimator title = ObjectAnimator.ofFloat(mAnimScreen.mTitle, "alpha", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 304 | 1f, 0f); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 305 | ObjectAnimator sx = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 306 | 1f, scaleFactor); |
John Reck | 1adf030 | 2011-10-11 10:58:12 -0700 | [diff] [blame] | 307 | ObjectAnimator blend1 = ObjectAnimator.ofFloat(mAnimScreen.mMain, |
| 308 | "alpha", 1f, 0f); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 309 | blend1.setDuration(100); |
| 310 | |
| 311 | inanim.playTogether(tx, ty, tr, tb, sx, title); |
| 312 | inanim.setDuration(200); |
| 313 | set1.addListener(new AnimatorListenerAdapter() { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 314 | @Override |
| 315 | public void onAnimationEnd(Animator anim) { |
John Reck | 1adf030 | 2011-10-11 10:58:12 -0700 | [diff] [blame] | 316 | mCustomViewContainer.removeView(mAnimScreen.mMain); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 317 | finishAnimationIn(); |
| 318 | mUiController.setBlockEvents(false); |
| 319 | } |
| 320 | }); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 321 | set1.playSequentially(inanim, blend1); |
| 322 | set1.start(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | private void finishAnimationIn() { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 326 | if (showingNavScreen()) { |
Michael Kolb | b43f2f6 | 2011-08-17 10:39:31 -0700 | [diff] [blame] | 327 | // notify accessibility manager about the screen change |
| 328 | mNavScreen.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
| 329 | mTabControl.setOnThumbnailUpdatedListener(mNavScreen); |
| 330 | } |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 331 | } |
| 332 | |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 333 | void hideNavScreen(int position, boolean animate) { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 334 | if (!showingNavScreen()) return; |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 335 | final Tab tab = mUiController.getTabControl().getTab(position); |
Michael Kolb | bf32cd0 | 2011-08-16 15:07:04 -0700 | [diff] [blame] | 336 | if ((tab == null) || !animate) { |
Michael Kolb | 365561d | 2011-08-18 09:56:25 -0700 | [diff] [blame] | 337 | if (tab != null) { |
| 338 | setActiveTab(tab); |
| 339 | } else if (mTabControl.getTabCount() > 0) { |
| 340 | // use a fallback tab |
| 341 | setActiveTab(mTabControl.getCurrentTab()); |
| 342 | } |
Michael Kolb | bf32cd0 | 2011-08-16 15:07:04 -0700 | [diff] [blame] | 343 | mContentView.setVisibility(View.VISIBLE); |
| 344 | finishAnimateOut(); |
Michael Kolb | 8a00949 | 2011-08-15 15:37:30 -0700 | [diff] [blame] | 345 | return; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 346 | } |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 347 | NavTabView tabview = (NavTabView) mNavScreen.getTabView(position); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 348 | if (tabview == null) { |
Michael Kolb | 365561d | 2011-08-18 09:56:25 -0700 | [diff] [blame] | 349 | if (mTabControl.getTabCount() > 0) { |
| 350 | // use a fallback tab |
| 351 | setActiveTab(mTabControl.getCurrentTab()); |
| 352 | } |
Michael Kolb | bf32cd0 | 2011-08-16 15:07:04 -0700 | [diff] [blame] | 353 | mContentView.setVisibility(View.VISIBLE); |
| 354 | finishAnimateOut(); |
Michael Kolb | 8a00949 | 2011-08-15 15:37:30 -0700 | [diff] [blame] | 355 | return; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 356 | } |
| 357 | mUiController.setBlockEvents(true); |
| 358 | mUiController.setActiveTab(tab); |
| 359 | mContentView.setVisibility(View.VISIBLE); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 360 | if (mAnimScreen == null) { |
| 361 | mAnimScreen = new AnimScreen(mActivity); |
| 362 | } |
| 363 | mAnimScreen.set(tab.getScreenshot()); |
Michael Kolb | 0755fcd | 2012-01-10 10:19:50 -0800 | [diff] [blame] | 364 | if (mAnimScreen.mMain.getParent() == null) { |
| 365 | mCustomViewContainer.addView(mAnimScreen.mMain, COVER_SCREEN_PARAMS); |
| 366 | } |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 367 | mAnimScreen.mMain.layout(0, 0, mContentView.getWidth(), |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 368 | mContentView.getHeight()); |
| 369 | mNavScreen.mScroller.finishScroller(); |
| 370 | ImageView target = tabview.mImage; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 371 | int toLeft = 0; |
Michael Kolb | b7e1670 | 2011-12-15 11:59:40 -0800 | [diff] [blame] | 372 | int toTop = (tab.getWebView() != null) ? tab.getWebView().getVisibleTitleHeight() : 0; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 373 | int toRight = mContentView.getWidth(); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 374 | int width = target.getDrawable().getIntrinsicWidth(); |
| 375 | int height = target.getDrawable().getIntrinsicHeight(); |
| 376 | int fromLeft = tabview.getLeft() + target.getLeft() - mNavScreen.mScroller.getScrollX(); |
| 377 | int fromTop = tabview.getTop() + target.getTop() - mNavScreen.mScroller.getScrollY(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 378 | int fromRight = fromLeft + width; |
| 379 | int fromBottom = fromTop + height; |
| 380 | float scaleFactor = mContentView.getWidth() / (float) width; |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 381 | int toBottom = toTop + (int) (height * scaleFactor); |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 382 | mAnimScreen.mContent.setLeft(fromLeft); |
| 383 | mAnimScreen.mContent.setTop(fromTop); |
| 384 | mAnimScreen.mContent.setRight(fromRight); |
| 385 | mAnimScreen.mContent.setBottom(fromBottom); |
| 386 | mAnimScreen.setScaleFactor(1f); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 387 | AnimatorSet set1 = new AnimatorSet(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 388 | ObjectAnimator fade2 = ObjectAnimator.ofFloat(mAnimScreen.mMain, "alpha", 0f, 1f); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 389 | ObjectAnimator fade1 = ObjectAnimator.ofFloat(mNavScreen, "alpha", 1f, 0f); |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 390 | set1.playTogether(fade1, fade2); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 391 | set1.setDuration(100); |
| 392 | AnimatorSet set2 = new AnimatorSet(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 393 | ObjectAnimator l = ObjectAnimator.ofInt(mAnimScreen.mContent, "left", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 394 | fromLeft, toLeft); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 395 | ObjectAnimator t = ObjectAnimator.ofInt(mAnimScreen.mContent, "top", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 396 | fromTop, toTop); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 397 | ObjectAnimator r = ObjectAnimator.ofInt(mAnimScreen.mContent, "right", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 398 | fromRight, toRight); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 399 | ObjectAnimator b = ObjectAnimator.ofInt(mAnimScreen.mContent, "bottom", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 400 | fromBottom, toBottom); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 401 | ObjectAnimator scale = ObjectAnimator.ofFloat(mAnimScreen, "scaleFactor", |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 402 | 1f, scaleFactor); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 403 | ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 404 | otheralpha.setDuration(100); |
| 405 | set2.playTogether(l, t, r, b, scale); |
| 406 | set2.setDuration(200); |
| 407 | AnimatorSet combo = new AnimatorSet(); |
| 408 | combo.playSequentially(set1, set2, otheralpha); |
| 409 | combo.addListener(new AnimatorListenerAdapter() { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 410 | @Override |
| 411 | public void onAnimationEnd(Animator anim) { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 412 | mCustomViewContainer.removeView(mAnimScreen.mMain); |
Michael Kolb | bf32cd0 | 2011-08-16 15:07:04 -0700 | [diff] [blame] | 413 | finishAnimateOut(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 414 | mUiController.setBlockEvents(false); |
| 415 | } |
| 416 | }); |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 417 | combo.start(); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 418 | } |
| 419 | |
Michael Kolb | bf32cd0 | 2011-08-16 15:07:04 -0700 | [diff] [blame] | 420 | private void finishAnimateOut() { |
John Reck | 8ee633f | 2011-08-09 16:00:35 -0700 | [diff] [blame] | 421 | mTabControl.setOnThumbnailUpdatedListener(null); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 422 | mNavScreen.setVisibility(View.GONE); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 423 | mCustomViewContainer.setAlpha(1f); |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 424 | mCustomViewContainer.setVisibility(View.GONE); |
Michael Kolb | f205560 | 2011-04-09 17:20:03 -0700 | [diff] [blame] | 425 | } |
| 426 | |
John Reck | 6b4bd5f | 2011-07-12 10:14:38 -0700 | [diff] [blame] | 427 | @Override |
| 428 | public boolean needsRestoreAllTabs() { |
| 429 | return false; |
| 430 | } |
| 431 | |
Michael Kolb | 20be26d | 2011-07-18 16:38:02 -0700 | [diff] [blame] | 432 | public void toggleNavScreen() { |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 433 | if (!showingNavScreen()) { |
Michael Kolb | 20be26d | 2011-07-18 16:38:02 -0700 | [diff] [blame] | 434 | showNavScreen(); |
| 435 | } else { |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 436 | hideNavScreen(mUiController.getTabControl().getCurrentPosition(), false); |
Michael Kolb | 20be26d | 2011-07-18 16:38:02 -0700 | [diff] [blame] | 437 | } |
| 438 | } |
| 439 | |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 440 | @Override |
| 441 | public boolean shouldCaptureThumbnails() { |
| 442 | return true; |
| 443 | } |
| 444 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 445 | static class AnimScreen { |
John Reck | 3ba4553 | 2011-08-11 16:26:53 -0700 | [diff] [blame] | 446 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 447 | private View mMain; |
| 448 | private ImageView mTitle; |
| 449 | private ImageView mContent; |
| 450 | private float mScale; |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 451 | private Bitmap mTitleBarBitmap; |
| 452 | private Bitmap mContentBitmap; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 453 | |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 454 | public AnimScreen(Context ctx) { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 455 | mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen, |
| 456 | null); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 457 | mTitle = (ImageView) mMain.findViewById(R.id.title); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 458 | mContent = (ImageView) mMain.findViewById(R.id.content); |
| 459 | mContent.setScaleType(ImageView.ScaleType.MATRIX); |
| 460 | mContent.setImageMatrix(new Matrix()); |
| 461 | mScale = 1.0f; |
| 462 | setScaleFactor(getScaleFactor()); |
| 463 | } |
| 464 | |
| 465 | public void set(TitleBar tbar, WebView web) { |
John Reck | 62077d8 | 2011-10-13 15:17:50 -0700 | [diff] [blame] | 466 | if (tbar == null || web == null) { |
| 467 | return; |
| 468 | } |
John Reck | 1adf030 | 2011-10-11 10:58:12 -0700 | [diff] [blame] | 469 | if (tbar.getWidth() > 0 && tbar.getEmbeddedHeight() > 0) { |
| 470 | if (mTitleBarBitmap == null |
| 471 | || mTitleBarBitmap.getWidth() != tbar.getWidth() |
| 472 | || mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) { |
John Reck | a98c83b | 2011-10-31 12:31:58 -0700 | [diff] [blame] | 473 | mTitleBarBitmap = safeCreateBitmap(tbar.getWidth(), |
| 474 | tbar.getEmbeddedHeight()); |
John Reck | 1adf030 | 2011-10-11 10:58:12 -0700 | [diff] [blame] | 475 | } |
John Reck | a98c83b | 2011-10-31 12:31:58 -0700 | [diff] [blame] | 476 | if (mTitleBarBitmap != null) { |
| 477 | Canvas c = new Canvas(mTitleBarBitmap); |
| 478 | tbar.draw(c); |
| 479 | c.setBitmap(null); |
| 480 | } |
John Reck | 1adf030 | 2011-10-11 10:58:12 -0700 | [diff] [blame] | 481 | } else { |
| 482 | mTitleBarBitmap = null; |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 483 | } |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 484 | mTitle.setImageBitmap(mTitleBarBitmap); |
| 485 | mTitle.setVisibility(View.VISIBLE); |
John Reck | 9c5004e | 2011-10-07 16:00:12 -0700 | [diff] [blame] | 486 | int h = web.getHeight() - tbar.getEmbeddedHeight(); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 487 | if (mContentBitmap == null |
| 488 | || mContentBitmap.getWidth() != web.getWidth() |
| 489 | || mContentBitmap.getHeight() != h) { |
John Reck | a98c83b | 2011-10-31 12:31:58 -0700 | [diff] [blame] | 490 | mContentBitmap = safeCreateBitmap(web.getWidth(), h); |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 491 | } |
John Reck | a98c83b | 2011-10-31 12:31:58 -0700 | [diff] [blame] | 492 | if (mContentBitmap != null) { |
| 493 | Canvas c = new Canvas(mContentBitmap); |
| 494 | int tx = web.getScrollX(); |
| 495 | int ty = web.getScrollY(); |
| 496 | c.translate(-tx, -ty - tbar.getEmbeddedHeight()); |
| 497 | web.draw(c); |
| 498 | c.setBitmap(null); |
| 499 | } |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 500 | mContent.setImageBitmap(mContentBitmap); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 501 | } |
| 502 | |
John Reck | a98c83b | 2011-10-31 12:31:58 -0700 | [diff] [blame] | 503 | private Bitmap safeCreateBitmap(int width, int height) { |
| 504 | if (width <= 0 || height <= 0) { |
| 505 | Log.w(LOGTAG, "safeCreateBitmap failed! width: " + width |
| 506 | + ", height: " + height); |
| 507 | return null; |
| 508 | } |
| 509 | return Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); |
| 510 | } |
| 511 | |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 512 | public void set(Bitmap image) { |
Michael Kolb | a3194d0 | 2011-09-07 11:23:51 -0700 | [diff] [blame] | 513 | mTitle.setVisibility(View.GONE); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 514 | mContent.setImageBitmap(image); |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 515 | } |
| 516 | |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 517 | private void setScaleFactor(float sf) { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 518 | mScale = sf; |
| 519 | Matrix m = new Matrix(); |
| 520 | m.postScale(sf,sf); |
| 521 | mContent.setImageMatrix(m); |
| 522 | } |
| 523 | |
John Reck | cc0059c | 2011-10-07 13:53:13 -0700 | [diff] [blame] | 524 | private float getScaleFactor() { |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 525 | return mScale; |
| 526 | } |
| 527 | |
John Reck | 3ba4553 | 2011-08-11 16:26:53 -0700 | [diff] [blame] | 528 | } |
| 529 | |
Michael Kolb | 6670653 | 2010-12-12 19:50:22 -0800 | [diff] [blame] | 530 | } |