Added hideUI in nav Manager

This commit is contained in:
SebasKoedam
2024-05-30 15:57:49 +02:00
parent a0988bf8cc
commit fa48f71407
5 changed files with 17 additions and 26 deletions

View File

@@ -55,8 +55,8 @@ public class FitnessActivity extends RobotActivity implements RobotLifecycleCall
VideoView videoView = findViewById(R.id.videoView);
FitnessCycle.playVideo(videoView, this);
NavigationManager.setupButtonNavigation(this, R.id.homeButtonFitness, MainActivity.class);
// Implement your logic when the robot focus is gained
NavigationManager.hideSystemUI(this);
}
@Override

View File

@@ -1,5 +1,6 @@
package com.example.fitbot.ui.activities;
import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
@@ -16,16 +17,6 @@ public class HelpActivity extends AppCompatActivity {
NavigationManager.setupButtonNavigation(this, R.id.homeButtonHelp, MainActivity.class);
// Hide system UI
hideSystemUI();
}
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
// Hide the status bar and navigation bar
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
NavigationManager.hideSystemUI(this);
}
}

View File

@@ -48,7 +48,7 @@ public class MainActivity extends AppCompatActivity {
setUpUi();
// Hide system UI
hideSystemUI();
NavigationManager.hideSystemUI(this);
}
private void setUpUi() {
@@ -79,33 +79,22 @@ public class MainActivity extends AppCompatActivity {
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
hideSystemUI();
}
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
hideSystemUI();
}
};
drawerLayout.addDrawerListener(toggle);
toggle.syncState(); // Synchronize the state of the navigation drawer
}
private void hideSystemUI() {
View decorView = getWindow().getDecorView();
// Hide the status bar and navigation bar
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
NavigationManager.hideSystemUI(this);
}
}

View File

@@ -8,6 +8,7 @@ import android.widget.Button;
import com.example.fitbot.ui.activities.FitnessActivity;
import com.example.fitbot.ui.activities.MainActivity;
import com.example.fitbot.ui.activities.HelpActivity;
public class NavigationManager {
@@ -37,4 +38,14 @@ public class NavigationManager {
Intent intent = new Intent(currentContext, targetActivity);
currentContext.startActivity(intent);
}
public static void hideSystemUI(Activity currentActivity) {
View decorView = currentActivity.getWindow().getDecorView();
// Hide the status bar and navigation bar
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
decorView.setSystemUiVisibility(uiOptions);
}
}

View File

@@ -45,7 +45,7 @@ tools:openDrawer="start">
android:layout_width="150dp"
android:layout_height="75dp"
android:layout_marginStart="404dp"
android:layout_marginBottom="0dp"
android:layout_marginBottom="30dp"
android:background="@drawable/red_button_gradient"
android:drawableTop="@drawable/ic_baseline_home_48"
android:drawableTint="@color/white"