From 3b4960194ffc4539ed2343728d722dc25a51a970 Mon Sep 17 00:00:00 2001
From: Ishan09811 <156402647+Ishan09811@users.noreply.github.com>
Date: Thu, 8 Feb 2024 21:08:47 +0530
Subject: [PATCH] Material UI (#394)
* used material ui in ``holder_game`` + added click effect
* add click effect to use in ``holder_game``
* use material ui in ``dialog_lua_scripts``
* add required imports to use material ui in ``dialog_lua_scripts``
* use material ui in ``holder_lua_script``
* use material ui in ``fragment_game_drawer``
* use material ui in ``fragment_games``
* add appbar with app name + Material EditText
* fix drawarlayout
* remove line divider from ``NavigationView``
---
.../pandroid/app/game/DrawerFragment.java | 16 +-
.../pandroid/app/game/LuaDialogFragment.java | 3 +-
.../rounded_selectable_item_background.xml | 9 +
.../app/src/main/res/layout/activity_main.xml | 10 +-
.../main/res/layout/dialog_lua_scripts.xml | 19 +--
.../main/res/layout/fragment_game_drawer.xml | 154 +++++++++---------
.../src/main/res/layout/fragment_games.xml | 21 ++-
.../src/main/res/layout/fragment_search.xml | 9 +-
.../app/src/main/res/layout/holder_game.xml | 24 ++-
.../src/main/res/layout/holder_lua_script.xml | 60 ++++---
.../res/layout/preference_simple_about.xml | 3 +-
.../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 ++++
.../app/src/main/res/values/themes.xml | 4 +
15 files changed, 227 insertions(+), 158 deletions(-)
create mode 100644 src/pandroid/app/src/main/res/drawable/rounded_selectable_item_background.xml
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 bd402b52..3506e054 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.annotation.Nullable;
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 class DrawerFragment extends Fragment implements DrawerLayout.DrawerListe
((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 class DrawerFragment extends Fragment implements DrawerLayout.DrawerListe
}
}
+ 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 class DrawerFragment extends Fragment implements DrawerLayout.DrawerListe
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/java/com/panda3ds/pandroid/app/game/LuaDialogFragment.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/LuaDialogFragment.java
index 1db9f9c7..e7da87bf 100644
--- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/LuaDialogFragment.java
+++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/game/LuaDialogFragment.java
@@ -12,6 +12,7 @@ import androidx.activity.result.contract.ActivityResultContracts;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
+import com.google.android.material.button.MaterialButton;
import com.panda3ds.pandroid.AlberDriver;
import com.panda3ds.pandroid.R;
@@ -182,4 +183,4 @@ public class LuaDialogFragment extends BottomDialogFragment {
return FileUtils.getLastModified(absolutePath());
}
}
-}
\ No newline at end of file
+}
diff --git a/src/pandroid/app/src/main/res/drawable/rounded_selectable_item_background.xml b/src/pandroid/app/src/main/res/drawable/rounded_selectable_item_background.xml
new file mode 100644
index 00000000..fad2fe96
--- /dev/null
+++ b/src/pandroid/app/src/main/res/drawable/rounded_selectable_item_background.xml
@@ -0,0 +1,9 @@
+