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.annotation.TargetApi; | 10 import android.annotation.TargetApi; |
11 import android.app.Activity; | 11 import android.app.Activity; |
12 import android.app.PendingIntent; | 12 import android.app.PendingIntent; |
13 import android.content.Context; | 13 import android.content.Context; |
14 import android.content.ContextWrapper; | 14 import android.content.ContextWrapper; |
15 import android.content.Intent; | 15 import android.content.Intent; |
16 import android.content.pm.PackageManager; | 16 import android.content.pm.PackageManager; |
17 import android.os.Build; | 17 import android.os.Build; |
18 import android.os.Bundle; | 18 import android.os.Bundle; |
| 19 import android.os.IBinder; |
19 import android.os.Process; | 20 import android.os.Process; |
20 import android.util.Log; | 21 import android.util.Log; |
21 import android.util.SparseArray; | 22 import android.util.SparseArray; |
22 import android.view.View; | 23 import android.view.View; |
23 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
| 25 import android.view.Window; |
24 import android.view.accessibility.AccessibilityManager; | 26 import android.view.accessibility.AccessibilityManager; |
25 | 27 |
26 import org.chromium.base.ApiCompatibilityUtils; | 28 import org.chromium.base.ApiCompatibilityUtils; |
27 import org.chromium.base.Callback; | 29 import org.chromium.base.Callback; |
28 import org.chromium.base.ObserverList; | 30 import org.chromium.base.ObserverList; |
29 import org.chromium.base.VisibleForTesting; | 31 import org.chromium.base.VisibleForTesting; |
30 import org.chromium.base.annotations.CalledByNative; | 32 import org.chromium.base.annotations.CalledByNative; |
31 import org.chromium.base.annotations.JNINamespace; | 33 import org.chromium.base.annotations.JNINamespace; |
32 import org.chromium.ui.VSyncMonitor; | 34 import org.chromium.ui.VSyncMonitor; |
33 import org.chromium.ui.display.DisplayAndroid; | 35 import org.chromium.ui.display.DisplayAndroid; |
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 * Getter for the current context (not necessarily the application context). | 721 * Getter for the current context (not necessarily the application context). |
720 * Make no assumptions regarding what type of Context is returned here, it c
ould be for example | 722 * Make no assumptions regarding what type of Context is returned here, it c
ould be for example |
721 * an Activity or a Context created specifically to target an external displ
ay. | 723 * an Activity or a Context created specifically to target an external displ
ay. |
722 */ | 724 */ |
723 public WeakReference<Context> getContext() { | 725 public WeakReference<Context> getContext() { |
724 // Return a new WeakReference to prevent clients from releasing our inte
rnal WeakReference. | 726 // Return a new WeakReference to prevent clients from releasing our inte
rnal WeakReference. |
725 return new WeakReference<>(mContextRef.get()); | 727 return new WeakReference<>(mContextRef.get()); |
726 } | 728 } |
727 | 729 |
728 /** | 730 /** |
| 731 * Return the current window token, or null. |
| 732 */ |
| 733 @CalledByNative |
| 734 private IBinder getWindowToken() { |
| 735 Activity activity = activityFromContext(mContextRef.get()); |
| 736 if (activity == null) return null; |
| 737 Window window = activity.getWindow(); |
| 738 if (window == null) return null; |
| 739 View decorView = window.peekDecorView(); |
| 740 if (decorView == null) return null; |
| 741 return decorView.getWindowToken(); |
| 742 } |
| 743 |
| 744 /** |
729 * Update whether the placeholder is 'drawn' based on whether an animation i
s running | 745 * Update whether the placeholder is 'drawn' based on whether an animation i
s running |
730 * or touch exploration is enabled - if either of those are true, we call | 746 * or touch exploration is enabled - if either of those are true, we call |
731 * setWillNotDraw(false) to ensure that the animation is drawn over the Surf
aceView, | 747 * setWillNotDraw(false) to ensure that the animation is drawn over the Surf
aceView, |
732 * and otherwise we call setWillNotDraw(true). | 748 * and otherwise we call setWillNotDraw(true). |
733 */ | 749 */ |
734 private void refreshWillNotDraw() { | 750 private void refreshWillNotDraw() { |
735 boolean willNotDraw = !mIsTouchExplorationEnabled && mAnimationsOverCont
ent.isEmpty(); | 751 boolean willNotDraw = !mIsTouchExplorationEnabled && mAnimationsOverCont
ent.isEmpty(); |
736 if (mAnimationPlaceholderView.willNotDraw() != willNotDraw) { | 752 if (mAnimationPlaceholderView.willNotDraw() != willNotDraw) { |
737 mAnimationPlaceholderView.setWillNotDraw(willNotDraw); | 753 mAnimationPlaceholderView.setWillNotDraw(willNotDraw); |
738 } | 754 } |
(...skipping 14 matching lines...) Expand all Loading... |
753 private native void nativeOnVSync(long nativeWindowAndroid, | 769 private native void nativeOnVSync(long nativeWindowAndroid, |
754 long vsyncTimeMicros, | 770 long vsyncTimeMicros, |
755 long vsyncPeriodMicros); | 771 long vsyncPeriodMicros); |
756 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool
ean visible); | 772 private native void nativeOnVisibilityChanged(long nativeWindowAndroid, bool
ean visible); |
757 private native void nativeOnActivityStopped(long nativeWindowAndroid); | 773 private native void nativeOnActivityStopped(long nativeWindowAndroid); |
758 private native void nativeOnActivityStarted(long nativeWindowAndroid); | 774 private native void nativeOnActivityStarted(long nativeWindowAndroid); |
759 private native void nativeSetVSyncPaused(long nativeWindowAndroid, boolean p
aused); | 775 private native void nativeSetVSyncPaused(long nativeWindowAndroid, boolean p
aused); |
760 private native void nativeDestroy(long nativeWindowAndroid); | 776 private native void nativeDestroy(long nativeWindowAndroid); |
761 | 777 |
762 } | 778 } |
OLD | NEW |