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 @@ + + + + + + + + diff --git a/src/pandroid/app/src/main/res/layout/activity_main.xml b/src/pandroid/app/src/main/res/layout/activity_main.xml index 27da16a9..c0d0efd7 100644 --- a/src/pandroid/app/src/main/res/layout/activity_main.xml +++ b/src/pandroid/app/src/main/res/layout/activity_main.xml @@ -8,6 +8,14 @@ tools:context=".app.MainActivity" android:background="?colorSurface"> + + - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/dialog_lua_scripts.xml b/src/pandroid/app/src/main/res/layout/dialog_lua_scripts.xml index 69a9d0a4..b0484879 100644 --- a/src/pandroid/app/src/main/res/layout/dialog_lua_scripts.xml +++ b/src/pandroid/app/src/main/res/layout/dialog_lua_scripts.xml @@ -1,9 +1,9 @@ - @@ -12,7 +12,6 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - - - - - + - \ No newline at end of file + 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 fa81a503..c4a698ea 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,105 +1,97 @@ - - - + + android:layout_height="match_parent" + android:orientation="vertical"> - - - - - - - + + android:paddingLeft="10dp" + android:paddingRight="10dp" + android:minHeight="190dp" + android:background="?colorSurfaceVariant"> - + + + + + + + android:layout_marginBottom="20dp"> - + - + - + - + + + + + + android:orientation="vertical" + android:gravity="start" + android:layout_marginTop="195dp"> - + app:menu="@menu/game_drawer_settings" + android:background="?colorSurface" + android:theme="@style/Widget.App.NavigationView" + app:subheaderTextAppearance="@style/TextAppearanceGameDrawerSubTitle"/> - + - - - - - - - - - - - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/fragment_games.xml b/src/pandroid/app/src/main/res/layout/fragment_games.xml index ee69fdc8..0538aeb6 100644 --- a/src/pandroid/app/src/main/res/layout/fragment_games.xml +++ b/src/pandroid/app/src/main/res/layout/fragment_games.xml @@ -1,6 +1,9 @@ - + android:gravity="center" + app:rippleColor="?colorOnSurfaceVariant" + app:backgroundTint="?colorPrimary" + tools:ignore="PrivateResource"/> - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/fragment_search.xml b/src/pandroid/app/src/main/res/layout/fragment_search.xml index 367b0f1d..3d987ff9 100644 --- a/src/pandroid/app/src/main/res/layout/fragment_search.xml +++ b/src/pandroid/app/src/main/res/layout/fragment_search.xml @@ -9,16 +9,17 @@ + android:paddingHorizontal="20dp" + android:background="?colorSurfaceVariant"> - @@ -46,4 +47,4 @@ - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/holder_game.xml b/src/pandroid/app/src/main/res/layout/holder_game.xml index b2d46d1b..fd14573f 100644 --- a/src/pandroid/app/src/main/res/layout/holder_game.xml +++ b/src/pandroid/app/src/main/res/layout/holder_game.xml @@ -4,13 +4,17 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" + android:foreground="@drawable/rounded_selectable_item_background" + android:focusable="true" android:orientation="vertical" android:padding="15dp"> - + android:layout_margin="10dp" + app:shapeAppearance="?attr/shapeAppearanceCornerLarge"> - + - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/holder_lua_script.xml b/src/pandroid/app/src/main/res/layout/holder_lua_script.xml index a1865c3f..071d3c8c 100644 --- a/src/pandroid/app/src/main/res/layout/holder_lua_script.xml +++ b/src/pandroid/app/src/main/res/layout/holder_lua_script.xml @@ -1,43 +1,50 @@ - + app:cardBackgroundColor="?attr/colorSurfaceVariant" + app:cardCornerRadius="8dp" + android:layout_gravity="center" + android:layout_margin="10dp"> - - - + android:orientation="vertical" + android:gravity="center" + android:padding="10dp"> - + + - + + + - - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/layout/preference_simple_about.xml b/src/pandroid/app/src/main/res/layout/preference_simple_about.xml index 9364de36..cf6370b9 100644 --- a/src/pandroid/app/src/main/res/layout/preference_simple_about.xml +++ b/src/pandroid/app/src/main/res/layout/preference_simple_about.xml @@ -2,6 +2,7 @@ @@ -26,4 +27,4 @@ android:alpha="0.5" android:textColor="?colorOnSurface"/> - \ No newline at end of file + diff --git a/src/pandroid/app/src/main/res/menu/game_drawer_actions.xml b/src/pandroid/app/src/main/res/menu/game_drawer_actions.xml deleted file mode 100644 index 9fd3264a..00000000 --- a/src/pandroid/app/src/main/res/menu/game_drawer_actions.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/menu/game_drawer_others.xml b/src/pandroid/app/src/main/res/menu/game_drawer_others.xml deleted file mode 100644 index b6dd4897..00000000 --- a/src/pandroid/app/src/main/res/menu/game_drawer_others.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/pandroid/app/src/main/res/menu/game_drawer_settings.xml b/src/pandroid/app/src/main/res/menu/game_drawer_settings.xml new file mode 100644 index 00000000..12fa6d47 --- /dev/null +++ b/src/pandroid/app/src/main/res/menu/game_drawer_settings.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + diff --git a/src/pandroid/app/src/main/res/values/themes.xml b/src/pandroid/app/src/main/res/values/themes.xml index 422299a4..79ecdd60 100644 --- a/src/pandroid/app/src/main/res/values/themes.xml +++ b/src/pandroid/app/src/main/res/values/themes.xml @@ -42,6 +42,10 @@ +