| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.ui.base; | 5 package org.chromium.ui.base; |
| 6 | 6 |
| 7 import android.animation.Animator; | 7 import android.animation.Animator; |
| 8 import android.animation.AnimatorListenerAdapter; | 8 import android.animation.AnimatorListenerAdapter; |
| 9 import android.annotation.SuppressLint; | 9 import android.annotation.SuppressLint; |
| 10 import android.app.Activity; | 10 import android.app.Activity; |
| 11 import android.app.PendingIntent; | 11 import android.app.PendingIntent; |
| 12 import android.content.ContentResolver; | 12 import android.content.ContentResolver; |
| 13 import android.content.Context; | 13 import android.content.Context; |
| 14 import android.content.Intent; | 14 import android.content.Intent; |
| 15 import android.os.Bundle; | 15 import android.os.Bundle; |
| 16 import android.util.Log; | 16 import android.util.Log; |
| 17 import android.util.SparseArray; | 17 import android.util.SparseArray; |
| 18 import android.view.View; | 18 import android.view.View; |
| 19 import android.view.ViewGroup; |
| 19 import android.widget.Toast; | 20 import android.widget.Toast; |
| 20 | 21 |
| 21 import org.chromium.base.CalledByNative; | 22 import org.chromium.base.CalledByNative; |
| 22 import org.chromium.base.JNINamespace; | 23 import org.chromium.base.JNINamespace; |
| 23 import org.chromium.ui.VSyncMonitor; | 24 import org.chromium.ui.VSyncMonitor; |
| 24 | 25 |
| 25 import java.lang.ref.WeakReference; | 26 import java.lang.ref.WeakReference; |
| 26 import java.util.HashMap; | 27 import java.util.HashMap; |
| 27 import java.util.HashSet; | 28 import java.util.HashSet; |
| 28 | 29 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 // Ideally, this would be a SparseArray<String>, but there's no easy way to
store a | 50 // Ideally, this would be a SparseArray<String>, but there's no easy way to
store a |
| 50 // SparseArray<String> in a bundle during saveInstanceState(). So we use a H
ashMap and suppress | 51 // SparseArray<String> in a bundle during saveInstanceState(). So we use a H
ashMap and suppress |
| 51 // the Android lint warning "UseSparseArrays". | 52 // the Android lint warning "UseSparseArrays". |
| 52 protected HashMap<Integer, String> mIntentErrors; | 53 protected HashMap<Integer, String> mIntentErrors; |
| 53 | 54 |
| 54 // We track all animations over content and provide a drawing placeholder fo
r them. | 55 // We track all animations over content and provide a drawing placeholder fo
r them. |
| 55 private HashSet<Animator> mAnimationsOverContent = new HashSet<Animator>(); | 56 private HashSet<Animator> mAnimationsOverContent = new HashSet<Animator>(); |
| 56 private View mAnimationPlaceholderView; | 57 private View mAnimationPlaceholderView; |
| 57 | 58 |
| 59 private ViewGroup mKeyboardAccessoryView; |
| 60 |
| 58 private final VSyncMonitor.Listener mVSyncListener = new VSyncMonitor.Listen
er() { | 61 private final VSyncMonitor.Listener mVSyncListener = new VSyncMonitor.Listen
er() { |
| 59 @Override | 62 @Override |
| 60 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) { | 63 public void onVSync(VSyncMonitor monitor, long vsyncTimeMicros) { |
| 61 if (mNativeWindowAndroid != 0) { | 64 if (mNativeWindowAndroid != 0) { |
| 62 nativeOnVSync(mNativeWindowAndroid, | 65 nativeOnVSync(mNativeWindowAndroid, |
| 63 vsyncTimeMicros, | 66 vsyncTimeMicros, |
| 64 mVSyncMonitor.getVSyncPeriodInMicroseconds()); | 67 mVSyncMonitor.getVSyncPeriodInMicroseconds()); |
| 65 } | 68 } |
| 66 } | 69 } |
| 67 }; | 70 }; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 /** | 322 /** |
| 320 * Set the animation placeholder view, which we set to 'draw' during animati
ons, such that | 323 * Set the animation placeholder view, which we set to 'draw' during animati
ons, such that |
| 321 * animations aren't clipped by the SurfaceView 'hole'. This can be the Surf
aceView itself | 324 * animations aren't clipped by the SurfaceView 'hole'. This can be the Surf
aceView itself |
| 322 * or a view directly on top of it. This could be extended to many views if
we ever need it. | 325 * or a view directly on top of it. This could be extended to many views if
we ever need it. |
| 323 */ | 326 */ |
| 324 public void setAnimationPlaceholderView(View view) { | 327 public void setAnimationPlaceholderView(View view) { |
| 325 mAnimationPlaceholderView = view; | 328 mAnimationPlaceholderView = view; |
| 326 } | 329 } |
| 327 | 330 |
| 328 /** | 331 /** |
| 332 * Sets the keyboard accessory view. |
| 333 * @param view This view sits at the bottom of the content area and pushes t
he content up rather |
| 334 * than overlaying it. Currently used as a container for Autofil
l suggestions. |
| 335 */ |
| 336 public void setKeyboardAccessoryView(ViewGroup view) { |
| 337 mKeyboardAccessoryView = view; |
| 338 } |
| 339 |
| 340 /** |
| 341 * {@see setKeyboardAccessoryView(ViewGroup)}. |
| 342 */ |
| 343 public ViewGroup getKeyboardAccessoryView() { |
| 344 return mKeyboardAccessoryView; |
| 345 } |
| 346 |
| 347 /** |
| 329 * Start a post-layout animation on top of web content. | 348 * Start a post-layout animation on top of web content. |
| 330 * | 349 * |
| 331 * By default, Android optimizes what it shows on top of SurfaceViews (saves
power). | 350 * By default, Android optimizes what it shows on top of SurfaceViews (saves
power). |
| 332 * Effectively, layouts determine what gets drawn and post-layout animations
outside | 351 * Effectively, layouts determine what gets drawn and post-layout animations
outside |
| 333 * of this area may be 'clipped'. Using this method to start such animations
will | 352 * of this area may be 'clipped'. Using this method to start such animations
will |
| 334 * ensure that nothing is clipped during the animation, and restore the opti
mal | 353 * ensure that nothing is clipped during the animation, and restore the opti
mal |
| 335 * state when the animation ends. | 354 * state when the animation ends. |
| 336 */ | 355 */ |
| 337 public void startAnimationOverContent(Animator animation) { | 356 public void startAnimationOverContent(Animator animation) { |
| 338 // We may not need an animation placeholder (eg. Webview doesn't use Sur
faceView) | 357 // We may not need an animation placeholder (eg. Webview doesn't use Sur
faceView) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 367 | 386 |
| 368 private native long nativeInit(); | 387 private native long nativeInit(); |
| 369 private native void nativeOnVSync(long nativeWindowAndroid, | 388 private native void nativeOnVSync(long nativeWindowAndroid, |
| 370 long vsyncTimeMicros, | 389 long vsyncTimeMicros, |
| 371 long vsyncPeriodMicros); | 390 long vsyncPeriodMicros); |
| 372 private native void nativeOnActivityPaused(long nativeWindowAndroid); | 391 private native void nativeOnActivityPaused(long nativeWindowAndroid); |
| 373 private native void nativeOnActivityResumed(long nativeWindowAndroid); | 392 private native void nativeOnActivityResumed(long nativeWindowAndroid); |
| 374 private native void nativeDestroy(long nativeWindowAndroid); | 393 private native void nativeDestroy(long nativeWindowAndroid); |
| 375 | 394 |
| 376 } | 395 } |
| OLD | NEW |