blob: d77fcdb1a9f9e841a9327e70f7abaa12eccf9f69 [file] [log] [blame]
Michael Kolb66706532010-12-12 19:50:22 -08001/*
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
17package com.android.browser;
18
Michael Kolbc3af0672011-08-09 10:24:41 -070019import android.animation.Animator;
20import android.animation.AnimatorListenerAdapter;
21import android.animation.AnimatorSet;
22import android.animation.ObjectAnimator;
Michael Kolb66706532010-12-12 19:50:22 -080023import android.app.Activity;
Michael Kolbc3af0672011-08-09 10:24:41 -070024import android.app.ActivityManager;
25import android.content.Context;
26import android.graphics.Bitmap;
27import android.graphics.Canvas;
28import android.graphics.Matrix;
Michael Kolb376b5412010-12-15 11:52:57 -080029import android.util.Log;
Michael Kolb66706532010-12-12 19:50:22 -080030import android.view.ActionMode;
31import android.view.Gravity;
Michael Kolba4183062011-01-16 10:43:21 -080032import android.view.KeyEvent;
Michael Kolbc3af0672011-08-09 10:24:41 -070033import android.view.LayoutInflater;
Michael Kolb66706532010-12-12 19:50:22 -080034import android.view.Menu;
Michael Kolb3ca12752011-07-20 13:52:25 -070035import android.view.MenuItem;
Michael Kolb66706532010-12-12 19:50:22 -080036import android.view.View;
Michael Kolb30adae62011-07-29 13:37:05 -070037import android.view.accessibility.AccessibilityEvent;
Michael Kolbc3af0672011-08-09 10:24:41 -070038import android.view.animation.DecelerateInterpolator;
Michael Kolb66706532010-12-12 19:50:22 -080039import android.webkit.WebView;
Michael Kolbfdb70242011-03-24 09:41:11 -070040import android.widget.FrameLayout;
Michael Kolbc3af0672011-08-09 10:24:41 -070041import android.widget.ImageView;
Michael Kolb66706532010-12-12 19:50:22 -080042
Michael Kolb629b22c2011-07-13 16:26:47 -070043import com.android.browser.UrlInputView.StateListener;
44
Michael Kolb66706532010-12-12 19:50:22 -080045/**
46 * Ui for regular phone screen sizes
47 */
48public class PhoneUi extends BaseUi {
49
50 private static final String LOGTAG = "PhoneUi";
51
Michael Kolb0241e752011-07-07 14:58:50 -070052 private PieControlPhone mPieControl;
Michael Kolbf2055602011-04-09 17:20:03 -070053 private NavScreen mNavScreen;
John Reck0f602f32011-07-07 15:38:43 -070054 private NavigationBarPhone mNavigationBar;
Michael Kolb66706532010-12-12 19:50:22 -080055
56 boolean mExtendedMenuOpen;
57 boolean mOptionsMenuOpen;
Michael Kolb08a687a2011-04-22 16:13:02 -070058 boolean mAnimating;
Michael Kolb66706532010-12-12 19:50:22 -080059
60 /**
61 * @param browser
62 * @param controller
63 */
64 public PhoneUi(Activity browser, UiController controller) {
65 super(browser, controller);
John Reck285ef042011-02-11 15:44:17 -080066 mActivity.getActionBar().hide();
Michael Kolbfdb70242011-03-24 09:41:11 -070067 setUseQuickControls(BrowserSettings.getInstance().useQuickControls());
John Reck0f602f32011-07-07 15:38:43 -070068 mNavigationBar = (NavigationBarPhone) mTitleBar.getNavigationBar();
John Reck285ef042011-02-11 15:44:17 -080069 }
Michael Kolb66706532010-12-12 19:50:22 -080070
John Reck285ef042011-02-11 15:44:17 -080071 @Override
Michael Kolb66706532010-12-12 19:50:22 -080072 public void onDestroy() {
Michael Kolb7cdc4902011-02-03 17:54:40 -080073 hideTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -080074 }
75
76 @Override
Michael Kolbdc2ee1b2011-02-14 14:34:40 -080077 public void editUrl(boolean clearInput) {
Michael Kolb46f987e2011-04-05 10:39:10 -070078 if (mUseQuickControls) {
John Reck0f602f32011-07-07 15:38:43 -070079 mTitleBar.setShowProgressOnly(false);
Michael Kolb46f987e2011-04-05 10:39:10 -070080 }
81 super.editUrl(clearInput);
Michael Kolbdc2ee1b2011-02-14 14:34:40 -080082 }
83
84 @Override
Michael Kolb66706532010-12-12 19:50:22 -080085 public boolean onBackKey() {
Michael Kolb9ef259a2011-07-12 15:33:08 -070086 if (mNavScreen != null) {
Michael Kolbf2055602011-04-09 17:20:03 -070087 mNavScreen.close();
88 return true;
Michael Kolb66706532010-12-12 19:50:22 -080089 }
90 return super.onBackKey();
91 }
92
93 @Override
Michael Kolbf2055602011-04-09 17:20:03 -070094 public boolean dispatchKey(int code, KeyEvent event) {
Michael Kolbf2055602011-04-09 17:20:03 -070095 return false;
96 }
97
98 @Override
John Reck30c714c2010-12-16 17:30:34 -080099 public void onProgressChanged(Tab tab) {
Michael Kolb66706532010-12-12 19:50:22 -0800100 if (tab.inForeground()) {
John Reck30c714c2010-12-16 17:30:34 -0800101 int progress = tab.getLoadProgress();
Michael Kolb7cdc4902011-02-03 17:54:40 -0800102 mTitleBar.setProgress(progress);
Michael Kolb66706532010-12-12 19:50:22 -0800103 if (progress == 100) {
104 if (!mOptionsMenuOpen || !mExtendedMenuOpen) {
John Reck5d43ce82011-06-21 17:16:51 -0700105 suggestHideTitleBar();
Michael Kolbc16c5952011-03-29 15:37:03 -0700106 if (mUseQuickControls) {
107 mTitleBar.setShowProgressOnly(false);
108 }
Michael Kolb66706532010-12-12 19:50:22 -0800109 }
110 } else {
111 if (!mOptionsMenuOpen || mExtendedMenuOpen) {
Michael Kolbc16c5952011-03-29 15:37:03 -0700112 if (mUseQuickControls && !mTitleBar.isEditingUrl()) {
113 mTitleBar.setShowProgressOnly(true);
114 setTitleGravity(Gravity.TOP);
115 }
Michael Kolb7cdc4902011-02-03 17:54:40 -0800116 showTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800117 }
118 }
119 }
120 }
121
122 @Override
Michael Kolbfdb70242011-03-24 09:41:11 -0700123 public void setActiveTab(final Tab tab) {
John Reck8ee633f2011-08-09 16:00:35 -0700124 mTitleBar.cancelTitleBarAnimation(true);
125 mTitleBar.setSkipTitleBarAnimations(true);
John Reck5d43ce82011-06-21 17:16:51 -0700126 super.setActiveTab(tab);
Michael Kolbfdb70242011-03-24 09:41:11 -0700127 BrowserWebView view = (BrowserWebView) tab.getWebView();
Michael Kolb376b5412010-12-15 11:52:57 -0800128 // TabControl.setCurrentTab has been called before this,
129 // so the tab is guaranteed to have a webview
130 if (view == null) {
131 Log.e(LOGTAG, "active tab with no webview detected");
132 return;
133 }
Michael Kolbfdb70242011-03-24 09:41:11 -0700134 // Request focus on the top window.
135 if (mUseQuickControls) {
136 mPieControl.forceToTop(mContentView);
Michael Kolbfdb70242011-03-24 09:41:11 -0700137 } else {
138 // check if title bar is already attached by animation
139 if (mTitleBar.getParent() == null) {
140 view.setEmbeddedTitleBar(mTitleBar);
141 }
142 }
Michael Kolb376b5412010-12-15 11:52:57 -0800143 if (tab.isInVoiceSearchMode()) {
Michael Kolbfdb70242011-03-24 09:41:11 -0700144 showVoiceTitleBar(tab.getVoiceDisplayTitle(), tab.getVoiceSearchResults());
Michael Kolb376b5412010-12-15 11:52:57 -0800145 } else {
146 revertVoiceTitleBar(tab);
147 }
Michael Kolb629b22c2011-07-13 16:26:47 -0700148 // update nav bar state
149 mNavigationBar.onStateChanged(StateListener.STATE_NORMAL);
Michael Kolbfdb70242011-03-24 09:41:11 -0700150 updateLockIconToLatest(tab);
Michael Kolb376b5412010-12-15 11:52:57 -0800151 tab.getTopWindow().requestFocus();
John Reck8ee633f2011-08-09 16:00:35 -0700152 mTitleBar.setSkipTitleBarAnimations(false);
Michael Kolb376b5412010-12-15 11:52:57 -0800153 }
154
Michael Kolb66706532010-12-12 19:50:22 -0800155 // menu handling callbacks
156
157 @Override
Michael Kolb3ca12752011-07-20 13:52:25 -0700158 public boolean onPrepareOptionsMenu(Menu menu) {
Michael Kolb7bdee0b2011-08-01 11:55:38 -0700159 updateMenuState(mActiveTab, menu);
Michael Kolb3ca12752011-07-20 13:52:25 -0700160 return true;
161 }
162
163 @Override
Michael Kolb7bdee0b2011-08-01 11:55:38 -0700164 public void updateMenuState(Tab tab, Menu menu) {
165 menu.setGroupVisible(R.id.NAV_MENU, (mNavScreen == null));
166 MenuItem bm = menu.findItem(R.id.bookmarks_menu_id);
167 if (bm != null) {
168 bm.setVisible(mNavScreen == null);
169 }
170 MenuItem nt = menu.findItem(R.id.new_tab_menu_id);
171 if (nt != null) {
172 nt.setVisible(mNavScreen == null);
173 }
Michael Kolb7bdee0b2011-08-01 11:55:38 -0700174 MenuItem abm = menu.findItem(R.id.add_bookmark_menu_id);
175 if (abm != null) {
176 abm.setVisible((tab != null) && !tab.isSnapshot());
177 }
178 }
179
180 @Override
Michael Kolb3ca12752011-07-20 13:52:25 -0700181 public boolean onOptionsItemSelected(MenuItem item) {
182 if (mNavScreen != null) {
183 hideNavScreen(false);
184 }
185 return false;
186 }
187
188 @Override
Michael Kolb66706532010-12-12 19:50:22 -0800189 public void onContextMenuCreated(Menu menu) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800190 hideTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800191 }
192
193 @Override
194 public void onContextMenuClosed(Menu menu, boolean inLoad) {
195 if (inLoad) {
Michael Kolb7cdc4902011-02-03 17:54:40 -0800196 showTitleBar();
Michael Kolb66706532010-12-12 19:50:22 -0800197 }
198 }
199
200 // action mode callbacks
201
202 @Override
203 public void onActionModeStarted(ActionMode mode) {
Michael Kolb42c0c062011-08-02 12:56:06 -0700204 if (!isEditingUrl()) {
205 hideTitleBar();
206 }
Michael Kolb66706532010-12-12 19:50:22 -0800207 }
208
Michael Kolba4183062011-01-16 10:43:21 -0800209 @Override
John Reck6cda7b12011-03-18 15:57:13 -0700210 public void onActionModeFinished(boolean inLoad) {
Michael Kolbc16c5952011-03-29 15:37:03 -0700211 if (inLoad) {
212 if (mUseQuickControls) {
213 mTitleBar.setShowProgressOnly(true);
John Reck6cda7b12011-03-18 15:57:13 -0700214 }
Michael Kolbc16c5952011-03-29 15:37:03 -0700215 showTitleBar();
216 }
217 mActivity.getActionBar().hide();
John Reck6cda7b12011-03-18 15:57:13 -0700218 }
219
220 @Override
Michael Kolbfdb70242011-03-24 09:41:11 -0700221 protected void setTitleGravity(int gravity) {
222 if (mUseQuickControls) {
223 FrameLayout.LayoutParams lp =
John Reck0f602f32011-07-07 15:38:43 -0700224 (FrameLayout.LayoutParams) mTitleBar.getLayoutParams();
Michael Kolbfdb70242011-03-24 09:41:11 -0700225 lp.gravity = gravity;
John Reck0f602f32011-07-07 15:38:43 -0700226 mTitleBar.setLayoutParams(lp);
Michael Kolbfdb70242011-03-24 09:41:11 -0700227 } else {
228 super.setTitleGravity(gravity);
229 }
230 }
231
Michael Kolb0241e752011-07-07 14:58:50 -0700232 @Override
233 public void setUseQuickControls(boolean useQuickControls) {
Michael Kolbfdb70242011-03-24 09:41:11 -0700234 mUseQuickControls = useQuickControls;
John Reck0f602f32011-07-07 15:38:43 -0700235 mTitleBar.setUseQuickControls(mUseQuickControls);
Michael Kolbfdb70242011-03-24 09:41:11 -0700236 if (useQuickControls) {
Michael Kolb0241e752011-07-07 14:58:50 -0700237 mPieControl = new PieControlPhone(mActivity, mUiController, this);
Michael Kolbfdb70242011-03-24 09:41:11 -0700238 mPieControl.attachToContainer(mContentView);
Michael Kolb46f987e2011-04-05 10:39:10 -0700239 WebView web = getWebView();
240 if (web != null) {
241 web.setEmbeddedTitleBar(null);
Michael Kolbfdb70242011-03-24 09:41:11 -0700242 }
243 } else {
Michael Kolbfdb70242011-03-24 09:41:11 -0700244 if (mPieControl != null) {
245 mPieControl.removeFromContainer(mContentView);
246 }
Michael Kolb46f987e2011-04-05 10:39:10 -0700247 WebView web = getWebView();
Michael Kolbfdb70242011-03-24 09:41:11 -0700248 if (web != null) {
249 web.setEmbeddedTitleBar(mTitleBar);
250 }
251 setTitleGravity(Gravity.NO_GRAVITY);
252 }
John Reck718a24d2011-08-12 11:08:30 -0700253 updateUrlBarAutoShowManagerTarget();
Michael Kolbfdb70242011-03-24 09:41:11 -0700254 }
255
Michael Kolbc3af0672011-08-09 10:24:41 -0700256 @Override
257 public boolean isWebShowing() {
258 return super.isWebShowing() && mNavScreen == null;
259 }
260
261 @Override
262 public void showWeb(boolean animate) {
263 super.showWeb(animate);
264 hideNavScreen(animate);
265 }
266
Michael Kolbf2055602011-04-09 17:20:03 -0700267 void showNavScreen() {
Michael Kolbc3af0672011-08-09 10:24:41 -0700268 mUiController.setBlockEvents(true);
Michael Kolbf2055602011-04-09 17:20:03 -0700269 mNavScreen = new NavScreen(mActivity, mUiController, this);
Michael Kolbc3af0672011-08-09 10:24:41 -0700270 mActiveTab.capture();
271 // Add the custom view to its container
Michael Kolb2814a362011-05-19 15:49:41 -0700272 mCustomViewContainer.addView(mNavScreen, COVER_SCREEN_PARAMS);
Michael Kolbc3af0672011-08-09 10:24:41 -0700273 AnimScreen ascreen = new AnimScreen(mActivity, getTitleBar(), getWebView());
274 final View animView = ascreen.mMain;
275 mCustomViewContainer.addView(animView, COVER_SCREEN_PARAMS);
Michael Kolbf2055602011-04-09 17:20:03 -0700276 mCustomViewContainer.setVisibility(View.VISIBLE);
277 mCustomViewContainer.bringToFront();
Michael Kolbc3af0672011-08-09 10:24:41 -0700278 View target = ((NavTabView) mNavScreen.mScroller.getSelectedView()).mImage;
279 int fromLeft = 0;
280 int fromTop = getTitleBar().getHeight();
281 int fromRight = mContentView.getWidth();
282 int fromBottom = mContentView.getHeight();
283 int width = target.getWidth();
284 int height = target.getHeight();
285 int toLeft = (mContentView.getWidth() - width) / 2;
286 int toTop = fromTop + (mContentView.getHeight() - fromTop - height) / 2;
287 int toRight = toLeft + width;
288 int toBottom = toTop + height;
289 float scaleFactor = width / (float) mContentView.getWidth();
290 detachTab(mActiveTab);
291 mContentView.setVisibility(View.GONE);
292 AnimatorSet inanim = new AnimatorSet();
293 ObjectAnimator tx = ObjectAnimator.ofInt(ascreen.mContent, "left",
294 fromLeft, toLeft);
295 ObjectAnimator ty = ObjectAnimator.ofInt(ascreen.mContent, "top",
296 fromTop, toTop);
297 ObjectAnimator tr = ObjectAnimator.ofInt(ascreen.mContent, "right",
298 fromRight, toRight);
299 ObjectAnimator tb = ObjectAnimator.ofInt(ascreen.mContent, "bottom",
300 fromBottom, toBottom);
301 ObjectAnimator title = ObjectAnimator.ofFloat(ascreen.mTitle, "alpha",
302 1f, 0f);
303 ObjectAnimator content = ObjectAnimator.ofFloat(ascreen.mContent, "alpha",
304 1f, 0f);
305 ObjectAnimator sx = ObjectAnimator.ofFloat(ascreen, "scaleFactor",
306 1f, scaleFactor);
307 inanim.playTogether(tx, ty, tr, tb, title, content, sx);
308 inanim.addListener(new AnimatorListenerAdapter() {
309 @Override
310 public void onAnimationEnd(Animator anim) {
311 mCustomViewContainer.removeView(animView);
312 finishAnimationIn();
313 mUiController.setBlockEvents(false);
314 }
315 });
316 inanim.setInterpolator(new DecelerateInterpolator(2f));
317 inanim.setDuration(300);
318 inanim.start();
319 }
320
321 private void finishAnimationIn() {
Michael Kolb30adae62011-07-29 13:37:05 -0700322 // notify accessibility manager about the screen change
323 mNavScreen.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
John Reck8ee633f2011-08-09 16:00:35 -0700324 mTabControl.setOnThumbnailUpdatedListener(mNavScreen);
Michael Kolbf2055602011-04-09 17:20:03 -0700325 }
326
Michael Kolb2814a362011-05-19 15:49:41 -0700327 void hideNavScreen(boolean animate) {
Michael Kolb09bf24f2011-06-09 14:34:30 -0700328 if (mNavScreen == null) return;
Michael Kolbc3af0672011-08-09 10:24:41 -0700329 final Tab tab = mNavScreen.getSelectedTab();
330 if ((tab != null) && !animate) {
331 finishAnimateOut(tab);
332 }
333 NavTabView tabview = (NavTabView) mNavScreen.getSelectedTabView();
334 if (tabview == null) {
335 finishAnimateOut(tab);
336 }
337 mUiController.setBlockEvents(true);
338 mUiController.setActiveTab(tab);
339 mContentView.setVisibility(View.VISIBLE);
340 final AnimScreen screen = new AnimScreen(mActivity, tab.getScreenshot());
341 View target = ((NavTabView) mNavScreen.mScroller.getSelectedView()).mImage;
342 int toLeft = 0;
343 int toTop = getTitleBar().getHeight();
344 int toRight = mContentView.getWidth();
345 int width = target.getWidth();
346 int height = target.getHeight();
347 int[] pos = new int[2];
348 tabview.mImage.getLocationInWindow(pos);
349 int fromLeft = pos[0];
350 int fromTop = pos[1];
351 int fromRight = fromLeft + width;
352 int fromBottom = fromTop + height;
353 float scaleFactor = mContentView.getWidth() / (float) width;
354 int toBottom = (int) (height * scaleFactor);
355 screen.mMain.setAlpha(0f);
356 mCustomViewContainer.addView(screen.mMain, COVER_SCREEN_PARAMS);
357 AnimatorSet animSet = new AnimatorSet();
358 ObjectAnimator l = ObjectAnimator.ofInt(screen.mContent, "left",
359 fromLeft, toLeft);
360 ObjectAnimator t = ObjectAnimator.ofInt(screen.mContent, "top",
361 fromTop, toTop);
362 ObjectAnimator r = ObjectAnimator.ofInt(screen.mContent, "right",
363 fromRight, toRight);
364 ObjectAnimator b = ObjectAnimator.ofInt(screen.mContent, "bottom",
365 fromBottom, toBottom);
366 ObjectAnimator scale = ObjectAnimator.ofFloat(screen, "scaleFactor",
367 1f, scaleFactor);
368 ObjectAnimator alpha = ObjectAnimator.ofFloat(screen.mMain, "alpha", 1f, 1f);
369 ObjectAnimator otheralpha = ObjectAnimator.ofFloat(mCustomViewContainer, "alpha", 1f, 0f);
370 alpha.setStartDelay(100);
371 animSet.playTogether(l, t, r, b, scale, alpha, otheralpha);
372 animSet.addListener(new AnimatorListenerAdapter() {
373 @Override
374 public void onAnimationEnd(Animator anim) {
375 mCustomViewContainer.removeView(screen.mMain);
376 finishAnimateOut(tab);
377 mUiController.setBlockEvents(false);
378 }
379 });
380 animSet.setDuration(250);
381 animSet.start();
382 }
383
384 private void finishAnimateOut(Tab tab) {
John Reck8ee633f2011-08-09 16:00:35 -0700385 mTabControl.setOnThumbnailUpdatedListener(null);
Michael Kolbf2055602011-04-09 17:20:03 -0700386 mCustomViewContainer.removeView(mNavScreen);
Michael Kolbc3af0672011-08-09 10:24:41 -0700387 mCustomViewContainer.setAlpha(1f);
Michael Kolbf2055602011-04-09 17:20:03 -0700388 mNavScreen = null;
389 mCustomViewContainer.setVisibility(View.GONE);
Michael Kolbf2055602011-04-09 17:20:03 -0700390 }
391
John Reck6b4bd5f2011-07-12 10:14:38 -0700392 @Override
393 public boolean needsRestoreAllTabs() {
394 return false;
395 }
396
Michael Kolb20be26d2011-07-18 16:38:02 -0700397 public void toggleNavScreen() {
398 if (mNavScreen == null) {
399 showNavScreen();
400 } else {
401 hideNavScreen(false);
402 }
403 }
404
John Reck1cf4b792011-07-26 10:22:22 -0700405 @Override
406 public boolean shouldCaptureThumbnails() {
407 return true;
408 }
409
Michael Kolbc3af0672011-08-09 10:24:41 -0700410 static class AnimScreen {
John Reck3ba45532011-08-11 16:26:53 -0700411
Michael Kolbc3af0672011-08-09 10:24:41 -0700412 private View mMain;
413 private ImageView mTitle;
414 private ImageView mContent;
415 private float mScale;
416
417 public AnimScreen(Context ctx, TitleBar tbar, WebView web) {
418 mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen,
419 null);
420 mContent = (ImageView) mMain.findViewById(R.id.content);
421 mContent.setTop(tbar.getHeight());
422
423 mTitle = (ImageView) mMain.findViewById(R.id.title);
424 Bitmap bm1 = Bitmap.createBitmap(tbar.getWidth(), tbar.getHeight(),
425 Bitmap.Config.RGB_565);
426 Canvas c1 = new Canvas(bm1);
427 tbar.draw(c1);
428 mTitle.setImageBitmap(bm1);
429 int h = web.getHeight() - tbar.getHeight();
430 Bitmap bm2 = Bitmap.createBitmap(web.getWidth(), h,
431 Bitmap.Config.RGB_565);
432 Canvas c2 = new Canvas(bm2);
433 int tx = web.getScrollX();
434 int ty = web.getScrollY();
435 c2.translate(-tx, -ty - tbar.getHeight());
436 web.draw(c2);
437 mContent.setImageBitmap(bm2);
438 mContent.setScaleType(ImageView.ScaleType.MATRIX);
439 mContent.setImageMatrix(new Matrix());
440 mScale = 1.0f;
441 setScaleFactor(getScaleFactor());
442 }
443
444 public AnimScreen(Context ctx, Bitmap image) {
445 mMain = LayoutInflater.from(ctx).inflate(R.layout.anim_screen,
446 null);
447 mContent = (ImageView) mMain.findViewById(R.id.content);
448 mContent.setImageBitmap(image);
449 mContent.setScaleType(ImageView.ScaleType.MATRIX);
450 mContent.setImageMatrix(new Matrix());
451 mScale = 1.0f;
452 setScaleFactor(getScaleFactor());
453 }
454
455 public void setScaleFactor(float sf) {
456 mScale = sf;
457 Matrix m = new Matrix();
458 m.postScale(sf,sf);
459 mContent.setImageMatrix(m);
460 }
461
462 public float getScaleFactor() {
463 return mScale;
464 }
465
John Reck3ba45532011-08-11 16:26:53 -0700466 }
467
Michael Kolb66706532010-12-12 19:50:22 -0800468}