From 34dc294d062f5b9ddce80b07bacff63c96791c00 Mon Sep 17 00:00:00 2001 From: SebasKoedam Date: Wed, 29 May 2024 16:12:23 +0200 Subject: [PATCH 01/12] fixed the main menu bars and theme --- code/src/Fitbot/app/src/main/res/drawable/box_background.xml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 code/src/Fitbot/app/src/main/res/drawable/box_background.xml diff --git a/code/src/Fitbot/app/src/main/res/drawable/box_background.xml b/code/src/Fitbot/app/src/main/res/drawable/box_background.xml new file mode 100644 index 0000000..a8b409b --- /dev/null +++ b/code/src/Fitbot/app/src/main/res/drawable/box_background.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From 4b46738bf04b65db35e87f7f3b79e10104a6c041 Mon Sep 17 00:00:00 2001 From: SebasKoedam Date: Wed, 29 May 2024 16:12:37 +0200 Subject: [PATCH 02/12] fixed the main menu bars and theme --- code/src/Fitbot/.idea/misc.xml | 6 +- .../fitbot/ui/activities/MainActivity.java | 69 ++++++++++++++----- .../src/main/res/drawable/box_background.xml | 8 ++- .../src/main/res/layout/activity_fitness.xml | 2 +- .../app/src/main/res/layout/activity_main.xml | 55 ++++++++------- .../Fitbot/app/src/main/res/layout/header.xml | 2 +- .../Fitbot/app/src/main/res/values/colors.xml | 8 ++- .../Fitbot/app/src/main/res/values/styles.xml | 9 ++- 8 files changed, 109 insertions(+), 50 deletions(-) diff --git a/code/src/Fitbot/.idea/misc.xml b/code/src/Fitbot/.idea/misc.xml index c120dfd..1807d5f 100644 --- a/code/src/Fitbot/.idea/misc.xml +++ b/code/src/Fitbot/.idea/misc.xml @@ -20,6 +20,7 @@ + @@ -27,13 +28,14 @@ - + - + + diff --git a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java index ca30bf2..2297d65 100644 --- a/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java +++ b/code/src/Fitbot/app/src/main/java/com/example/fitbot/ui/activities/MainActivity.java @@ -11,26 +11,34 @@ import android.support.v7.app.ActionBarDrawerToggle; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.util.Log; +import android.view.View; +import android.view.WindowManager; import android.widget.Button; import com.example.fitbot.R; public class MainActivity extends AppCompatActivity { - //Variables + // Variables DrawerLayout drawerLayout; NavigationView navigationView; Toolbar toolbar; Button startButton; @SuppressLint("WrongViewCast") - @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - Button startButton = findViewById(R.id.startButton); + // Set full screen mode + getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN); + + // Hide system UI + hideSystemUI(); + + startButton = findViewById(R.id.startButton); startButton.setOnClickListener(v -> { Uri videoUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.bicepvideo); Intent intent = new Intent(MainActivity.this, FitnessActivity.class); @@ -48,32 +56,61 @@ public class MainActivity extends AppCompatActivity { toolbar = findViewById(R.id.toolbar); startButton = findViewById(R.id.startButton); - startButton.setOnClickListener(v -> { // Switch to fitness activity - Log.i("MainActivity", "Switching to FitnessActivity"); - Intent intent = new Intent(MainActivity.this, FitnessActivity.class); - startActivity(intent); - }); + // Hide the action bar + if (getSupportActionBar() != null) { + getSupportActionBar().hide(); + } /*---Tool Bar---*/ setSupportActionBar(toolbar); // Make the toolbar act as the action bar - getSupportActionBar().setDisplayShowTitleEnabled(false); // Remove the title from the toolbar + if (getSupportActionBar() != null) { + getSupportActionBar().setDisplayShowTitleEnabled(false); // Remove the title from the toolbar + } /*---Navigation Drawer Menu---*/ navigationView.bringToFront(); // Make the navigation drawer menu clickable - ActionBarDrawerToggle toggle=new // Create a toggle for the navigation drawer - ActionBarDrawerToggle(this,drawerLayout,toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); + ActionBarDrawerToggle toggle = new // Create a toggle for the navigation drawer + ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { + @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 onBackPressed(){ // Close the navigation drawer when the back button is pressed - if(drawerLayout.isDrawerOpen(GravityCompat.START)){ - drawerLayout.closeDrawer(GravityCompat.START); + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + if (hasFocus) { + hideSystemUI(); } - else - {super.onBackPressed(); + } + + @Override + public void onBackPressed() { // Close the navigation drawer when the back button is pressed + if (drawerLayout.isDrawerOpen(GravityCompat.START)) { + drawerLayout.closeDrawer(GravityCompat.START); + } else { + super.onBackPressed(); } } } diff --git a/code/src/Fitbot/app/src/main/res/drawable/box_background.xml b/code/src/Fitbot/app/src/main/res/drawable/box_background.xml index a8b409b..53f8ad7 100644 --- a/code/src/Fitbot/app/src/main/res/drawable/box_background.xml +++ b/code/src/Fitbot/app/src/main/res/drawable/box_background.xml @@ -1,4 +1,6 @@ - - - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml b/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml index 1ddca4c..b204eb8 100644 --- a/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml +++ b/code/src/Fitbot/app/src/main/res/layout/activity_fitness.xml @@ -5,7 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" -android:background="@color/black" +android:background="@color/darkBlue" android:fitsSystemWindows="true" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" tools:context=".ui.activities.FitnessActivity" diff --git a/code/src/Fitbot/app/src/main/res/layout/activity_main.xml b/code/src/Fitbot/app/src/main/res/layout/activity_main.xml index 49bfb75..032d214 100644 --- a/code/src/Fitbot/app/src/main/res/layout/activity_main.xml +++ b/code/src/Fitbot/app/src/main/res/layout/activity_main.xml @@ -4,9 +4,7 @@ android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="#232323" android:fitsSystemWindows="true" - android:theme="@android:style/Theme.NoTitleBar.Fullscreen" tools:context=".ui.activities.MainActivity" tools:openDrawer="start"> @@ -26,36 +24,41 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> - + app:layout_constraintTop_toTopOf="parent"> - + + + +