From e4428c903c1fd9bb9a8b251e9604296176211cd3 Mon Sep 17 00:00:00 2001
From: Ishan09811 <156402647+Ishan09811@users.noreply.github.com>
Date: Wed, 7 Feb 2024 01:11:12 +0530
Subject: [PATCH] fix drawarlayout
---
.../pandroid/app/game/DrawerFragment.java | 16 +-
.../main/res/layout/fragment_game_drawer.xml | 147 ++++++++----------
.../src/main/res/menu/game_drawer_actions.xml | 11 --
.../src/main/res/menu/game_drawer_others.xml | 7 -
.../main/res/menu/game_drawer_settings.xml | 35 +++++
5 files changed, 119 insertions(+), 97 deletions(-)
delete mode 100644 src/pandroid/app/src/main/res/menu/game_drawer_actions.xml
delete mode 100644 src/pandroid/app/src/main/res/menu/game_drawer_others.xml
create mode 100644 src/pandroid/app/src/main/res/menu/game_drawer_settings.xml
diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java
index bd402b525..3506e0546 100644
--- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java
+++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/DrawerFragment.java
@@ -12,6 +12,8 @@
import androidx.appcompat.widget.AppCompatTextView;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
+import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
import com.google.android.material.navigation.NavigationView;
import com.panda3ds.pandroid.AlberDriver;
@@ -47,7 +49,6 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
((AppCompatTextView)view.findViewById(R.id.game_publisher)).setText(game.getPublisher());
((NavigationView)view.findViewById(R.id.action_navigation)).setNavigationItemSelectedListener(this);
- ((NavigationView)view.findViewById(R.id.others_navigation)).setNavigationItemSelectedListener(this);
}
@Override
@@ -80,6 +81,17 @@ public void close() {
}
}
+ private void changeScreenOrientation() {
+ int currentOrientation = getResources().getConfiguration().orientation;
+
+ // Change the orientation
+ if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
+ requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ } else {
+ requireActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
+ }
+}
+
@Override
public void onDrawerSlide(@NonNull View drawerView, float slideOffset) {}
@@ -106,6 +118,8 @@ public boolean onNavigationItemSelected(@NonNull MenuItem item) {
requireActivity().finish();
} else if (id == R.id.lua_script){
new LuaDialogFragment().show(getParentFragmentManager(), null);
+ } else if (id == R.id.change_orientation) {
+ changeScreenOrientation();
}
return false;
diff --git a/src/pandroid/app/src/main/res/layout/fragment_game_drawer.xml b/src/pandroid/app/src/main/res/layout/fragment_game_drawer.xml
index e2cd045d5..c4a698eac 100644
--- a/src/pandroid/app/src/main/res/layout/fragment_game_drawer.xml
+++ b/src/pandroid/app/src/main/res/layout/fragment_game_drawer.xml
@@ -1,106 +1,97 @@
-