Skip to content

Commit 255d1e1

Browse files
Dianne HackbornAndroid (Google) Code Review
authored andcommitted
Merge "Fix issue #6475693: OnSystemUiVisibilityChangeListener reporting..." into jb-dev
2 parents 24938df + cf67578 commit 255d1e1

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

api/current.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23933,7 +23933,6 @@ package android.view {
2393323933
method public final android.view.View findViewWithTag(java.lang.Object);
2393423934
method public void findViewsWithText(java.util.ArrayList<android.view.View>, java.lang.CharSequence, int);
2393523935
method protected boolean fitSystemWindows(android.graphics.Rect);
23936-
method public boolean fitsSystemWindows();
2393723936
method public android.view.View focusSearch(int);
2393823937
method public void forceLayout();
2393923938
method public android.view.accessibility.AccessibilityNodeProvider getAccessibilityNodeProvider();
@@ -23958,6 +23957,7 @@ package android.view {
2395823957
method public void getDrawingRect(android.graphics.Rect);
2395923958
method public long getDrawingTime();
2396023959
method public boolean getFilterTouchesWhenObscured();
23960+
method public boolean getFitsSystemWindows();
2396123961
method public java.util.ArrayList<android.view.View> getFocusables(int);
2396223962
method public void getFocusedRect(android.graphics.Rect);
2396323963
method public boolean getGlobalVisibleRect(android.graphics.Rect, android.graphics.Point);

core/java/android/view/View.java

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,6 +5209,13 @@ public boolean isShown() {
52095209
* call to continue to your children, you must be sure to call the super
52105210
* implementation.
52115211
*
5212+
* <p>Here is a sample layout that makes use of fitting system windows
5213+
* to have controls for a video view placed inside of the window decorations
5214+
* that it hides and shows. This can be used with code like the second
5215+
* sample (video player) shown in {@link #setSystemUiVisibility(int)}.
5216+
*
5217+
* {@sample development/samples/ApiDemos/res/layout/video_player.xml complete}
5218+
*
52125219
* @param insets Current content insets of the window. Prior to
52135220
* {@link android.os.Build.VERSION_CODES#JELLY_BEAN} you must not modify
52145221
* the insets or else you and Android will be unhappy.
@@ -5251,7 +5258,8 @@ public void setFitsSystemWindows(boolean fitSystemWindows) {
52515258
}
52525259

52535260
/**
5254-
* Check for the FITS_SYSTEM_WINDOWS flag. If this method returns true, this view
5261+
* Check for state of {@link #setFitsSystemWindows(boolean). If this method
5262+
* returns true, this view
52555263
* will account for system screen decorations such as the status bar and inset its
52565264
* content. This allows the view to be positioned in absolute screen coordinates
52575265
* and remain visible to the user.
@@ -5260,7 +5268,7 @@ public void setFitsSystemWindows(boolean fitSystemWindows) {
52605268
*
52615269
* @attr ref android.R.styleable#View_fitsSystemWindows
52625270
*/
5263-
public boolean fitsSystemWindows() {
5271+
public boolean getFitsSystemWindows() {
52645272
return (mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS;
52655273
}
52665274

@@ -15376,7 +15384,8 @@ public boolean performHapticFeedback(int feedbackConstant, int flags) {
1537615384
* playing the application would like to go into a complete full-screen mode,
1537715385
* to use as much of the display as possible for the video. When in this state
1537815386
* the user can not interact with the application; the system intercepts
15379-
* touching on the screen to pop the UI out of full screen mode.
15387+
* touching on the screen to pop the UI out of full screen mode. See
15388+
* {@link #fitSystemWindows(Rect)} for a sample layout that goes with this code.
1538015389
*
1538115390
* {@sample development/samples/ApiDemos/src/com/example/android/apis/view/VideoPlayerActivity.java
1538215391
* content}
@@ -15458,11 +15467,13 @@ public void dispatchSystemUiVisibilityChanged(int visibility) {
1545815467
}
1545915468
}
1546015469

15461-
void updateLocalSystemUiVisibility(int localValue, int localChanges) {
15470+
boolean updateLocalSystemUiVisibility(int localValue, int localChanges) {
1546215471
int val = (mSystemUiVisibility&~localChanges) | (localValue&localChanges);
1546315472
if (val != mSystemUiVisibility) {
1546415473
setSystemUiVisibility(val);
15474+
return true;
1546515475
}
15476+
return false;
1546615477
}
1546715478

1546815479
/** @hide */
@@ -16861,7 +16872,7 @@ public interface OnCreateContextMenuListener {
1686116872
/**
1686216873
* Interface definition for a callback to be invoked when the status bar changes
1686316874
* visibility. This reports <strong>global</strong> changes to the system UI
16864-
* state, not just what the application is requesting.
16875+
* state, not what the application is requesting.
1686516876
*
1686616877
* @see View#setOnSystemUiVisibilityChangeListener(android.view.View.OnSystemUiVisibilityChangeListener)
1686716878
*/
@@ -16870,10 +16881,10 @@ public interface OnSystemUiVisibilityChangeListener {
1687016881
* Called when the status bar changes visibility because of a call to
1687116882
* {@link View#setSystemUiVisibility(int)}.
1687216883
*
16873-
* @param visibility Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE} or
16874-
* {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}. This tells you the
16875-
* <strong>global</strong> state of the UI visibility flags, not what your
16876-
* app is currently applying.
16884+
* @param visibility Bitwise-or of flags {@link #SYSTEM_UI_FLAG_LOW_PROFILE},
16885+
* {@link #SYSTEM_UI_FLAG_HIDE_NAVIGATION}, and {@link #SYSTEM_UI_FLAG_FULLSCREEN}.
16886+
* This tells you the <strong>global</strong> state of these UI visibility
16887+
* flags, not what your app is currently applying.
1687716888
*/
1687816889
public void onSystemUiVisibilityChange(int visibility);
1687916890
}
@@ -17158,6 +17169,11 @@ public void setPooled(boolean isPooled) {
1715817169
*/
1715917170
int mDisabledSystemUiVisibility;
1716017171

17172+
/**
17173+
* Last global system UI visibility reported by the window manager.
17174+
*/
17175+
int mGlobalSystemUiVisibility;
17176+
1716117177
/**
1716217178
* True if a view in this hierarchy has an OnSystemUiVisibilityChangeListener
1716317179
* attached.

core/java/android/view/ViewGroup.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,15 +1317,16 @@ public void dispatchSystemUiVisibilityChanged(int visible) {
13171317
}
13181318

13191319
@Override
1320-
void updateLocalSystemUiVisibility(int localValue, int localChanges) {
1321-
super.updateLocalSystemUiVisibility(localValue, localChanges);
1320+
boolean updateLocalSystemUiVisibility(int localValue, int localChanges) {
1321+
boolean changed = super.updateLocalSystemUiVisibility(localValue, localChanges);
13221322

13231323
final int count = mChildrenCount;
13241324
final View[] children = mChildren;
13251325
for (int i=0; i <count; i++) {
13261326
final View child = children[i];
1327-
child.updateLocalSystemUiVisibility(localValue, localChanges);
1327+
changed |= child.updateLocalSystemUiVisibility(localValue, localChanges);
13281328
}
1329+
return changed;
13291330
}
13301331

13311332
/**

core/java/android/view/ViewRootImpl.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3795,13 +3795,15 @@ public void handleDispatchSystemUiVisibilityChanged(SystemUiVisibilityInfo args)
37953795
}
37963796
if (mView == null) return;
37973797
if (args.localChanges != 0) {
3798-
if (mAttachInfo != null) {
3799-
mAttachInfo.mRecomputeGlobalAttributes = true;
3800-
}
38013798
mView.updateLocalSystemUiVisibility(args.localValue, args.localChanges);
3802-
scheduleTraversals();
38033799
}
3804-
mView.dispatchSystemUiVisibilityChanged(args.globalVisibility);
3800+
if (mAttachInfo != null) {
3801+
int visibility = args.globalVisibility&View.SYSTEM_UI_CLEARABLE_FLAGS;
3802+
if (visibility != mAttachInfo.mGlobalSystemUiVisibility) {
3803+
mAttachInfo.mGlobalSystemUiVisibility = visibility;
3804+
mView.dispatchSystemUiVisibilityChanged(visibility);
3805+
}
3806+
}
38053807
}
38063808

38073809
public void handleDispatchDoneAnimating() {

0 commit comments

Comments
 (0)