Skip to content

Commit

Permalink
feat: hideNavigationBars in MainActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
ghusta committed Dec 14, 2024
1 parent c2ddcef commit 6267477
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/src/main/java/fr/husta/android/dockersearch/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowInsets;
import android.view.WindowInsetsController;
import android.widget.ExpandableListView;
import android.widget.TextView;
import android.widget.Toast;
Expand Down Expand Up @@ -101,6 +104,8 @@ protected void onCreate(Bundle savedInstanceState)
Log.d(TAG, "onCreate : " + this.getLocalClassName());
setContentView(R.layout.activity_main);

hideNavigationBars(getWindow());

APP_PACKAGE_NAME = getApplicationContext().getPackageName();

themeChooserDialog = initThemeChooserAlertDialog();
Expand Down Expand Up @@ -153,6 +158,26 @@ protected void onCreate(Bundle savedInstanceState)
swipeRefreshLayout.setOnRefreshListener(this);
}

private void hideNavigationBars(Window window)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R)
{
WindowInsetsController insetsController = window.getInsetsController();
if (insetsController != null)
{
// Hide system bars
// insetsController.hide(WindowInsets.Type.systemBars());
// Hide nav bars
insetsController.hide(WindowInsets.Type.navigationBars());

// Set the behavior to transient bars by swipe
insetsController.setSystemBarsBehavior(
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);
}
}
}

@Override
protected void onNewIntent(Intent intent)
{
Expand Down

0 comments on commit 6267477

Please sign in to comment.