• Recent
    • Docs
    • Github
    • 百度网盘
    • Onedrive
    • Official
    • Shop
    • Register
    • Login

    A Method for Dynamically Hiding the Status Bar on Android 11

    Scheduled Pinned Locked Moved Pi 4B
    1 Posts 1 Posters 196 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      george
      last edited by

      diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
      index c1d54b7..6228ef0 100755
      --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
      +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBar.java
      @@ -202,6 +202,8 @@ import java.util.Map;
       public class PhoneStatusBar extends BaseStatusBar implements DemoMode,
               DragDownHelper.DragDownCallback, ActivityStarter, OnUnlockMethodChangedListener {
           static final String TAG = "PhoneStatusBar";
      +    static final String HIDE_NAVIGATION_BAR = "android.intent.action.HIDE_NAVIGATION_BAR";
      +    static final String SHOW_NAVIGATION_BAR = "android.intent.action.SHOW_NAVIGATION_BAR";
           public static final boolean DEBUG = BaseStatusBar.DEBUG;
           public static final boolean SPEW = false;
           public static final boolean DUMPTRUCK = true; // extra dumpsys info
      @@ -1090,6 +1092,8 @@ final Object mScreenshotLock = new Object();
                   filter.addAction("fake_artwork");
               }
               filter.addAction(ACTION_DEMO);
      +		    filter.addAction(HIDE_NAVIGATION_BAR);
      +        filter.addAction(SHOW_NAVIGATION_BAR);
               context.registerReceiverAsUser(mBroadcastReceiver, UserHandle.ALL, filter, null, null);
       
               // listen for USER_SETUP_COMPLETE setting (per-user)
      @@ -1381,6 +1385,12 @@ final Object mScreenshotLock = new Object();
                    return false;
                }
            };
      +	 
      +	    private void removeNavigationBar() {
      +        if (mNavigationBarView == null) return;
      +        		mWindowManager.removeView(mNavigationBarView);
      +        		mNavigationBarView = null;
      +      }	
             //$_rbox_$_modify_$_huangjc,add add/remove bar button	
             private View.OnTouchListener mHidebarPreloadOnTouchListener = new View.OnTouchListener() {
       
      @@ -1475,6 +1485,32 @@ final Object mScreenshotLock = new Object();
               mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
           }
       
      +	  private void addNavigationBarInnerLocked(){
      +	      if(mNavigationBarView == null){
      +		       mNavigationBarView = (NavigationBarView) View.inflate(mContext, R.layout.navigation_bar, null);	
      +			     mNavigationBarView.setDisabledFlags(mDisabled);
      +			     mNavigationBarView.setBar(this);
      +			     mNavigationBarView.setOnTouchListener(new View.OnTouchListener() {
      +				@Override
      +				public boolean onTouch(View v, MotionEvent event) {
      +					checkUserAutohide(v, event);
      +					return false;
      +				}});
      +		    if (mNavigationBarView == null) return;
      +		
      +		       prepareNavigationBarView();
      +		      try {
      +		           mWindowManager.addView(mNavigationBarView, getNavigationBarLayoutParams());
      +		            } catch (Exception e) {
      +                  }	
      +	      }
      +    }
      +    public void displayNavigation(){
      +    	addNavigationBarInnerLocked();
      +    }
      +    public void hideNavigation(){
      +    	removeNavigationBar();
      +    }
           private void repositionNavigationBar() {
               if (mNavigationBarView == null || !mNavigationBarView.isAttachedToWindow()) return;
       
      @@ -3436,7 +3472,11 @@ final Object mScreenshotLock = new Object();
                       if (DEBUG_MEDIA_FAKE_ARTWORK) {
                           updateMediaMetaData(true);
                       }
      -            }
      +            }else if(HIDE_NAVIGATION_BAR.equals(action)){
      +               hideNavigation();
      +            }else if(SHOW_NAVIGATION_BAR.equals(action)){
      +               displayNavigation();
      +		}
               }
           };
      
      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post