Merge pull request #5 from wheremyfoodat/material_ui

Material UI (#394)
This commit is contained in:
Gabriel Machado 2024-02-09 22:00:09 -04:00 committed by GitHub
commit 8cb7a230cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 227 additions and 158 deletions

View file

@ -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;

View file

@ -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());
}
}
}
}

View file

@ -0,0 +1,9 @@
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?colorControlHighlight">
<item android:id="@android:id/mask">
<shape android:shape="rectangle">
<corners android:radius="9dp" />
<solid android:color="@android:color/black" />
</shape>
</item>
</ripple>

View file

@ -8,6 +8,14 @@
tools:context=".app.MainActivity"
android:background="?colorSurface">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/topAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?colorSurfaceVariant"
android:minHeight="?attr/actionBarSize"
app:title="@string/app_name" />
<androidx.fragment.app.FragmentContainerView
android:id="@+id/fragment_container"
android:layout_width="0dp"
@ -28,4 +36,4 @@
style="@style/ThemedNavigationBottom"
android:background="@drawable/color_surface"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
@ -12,7 +12,6 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@ -31,35 +30,35 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.LinearLayoutCompat
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="vertical"
android:layout_gravity="bottom|center">
<androidx.appcompat.widget.AppCompatButton
<com.google.android.material.button.MaterialButton
android:id="@+id/open_file"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="@string/open_file"
android:layout_margin="5dp"
android:textColor="?colorOnPrimary"
android:backgroundTint="?colorPrimary"
app:backgroundTint="?colorPrimary"
android:background="@drawable/simple_card_background"/>
<androidx.appcompat.widget.AppCompatButton
<com.google.android.material.button.MaterialButton
android:id="@+id/create"
android:layout_width="match_parent"
android:layout_height="40dp"
android:text="@string/create_new"
android:layout_margin="5dp"
android:textColor="?colorOnSurfaceVariant"
android:backgroundTint="?colorSurfaceVariant"
app:backgroundTint="?colorSurfaceVariant"
android:background="@drawable/simple_card_background"
android:layout_marginBottom="10dp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
</FrameLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>

View file

@ -1,105 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.drawerlayout.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="?colorSurface">
<androidx.appcompat.widget.LinearLayoutCompat
<!-- Main content layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:minHeight="190dp"
android:background="?colorSurfaceVariant">
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="90dp"
android:layout_height="90dp"
app:cardCornerRadius="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<com.panda3ds.pandroid.view.gamesgrid.GameIconView
android:id="@+id/game_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"/>
</androidx.cardview.widget.CardView>
<androidx.appcompat.widget.LinearLayoutCompat
<!-- Game related content -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_marginBottom="20dp">
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:minHeight="190dp"
android:background="?colorSurfaceVariant">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/game_title"
android:layout_width="wrap_content"
<com.google.android.material.card.MaterialCardView
android:layout_width="90dp"
android:layout_height="90dp"
app:cardCornerRadius="10dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp">
<com.panda3ds.pandroid.view.gamesgrid.GameIconView
android:id="@+id/game_icon"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?colorSurface"/>
</com.google.android.material.card.MaterialCardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="?colorOnSurfaceVariant"
android:paddingBottom="4dp"
android:orientation="vertical"
android:gravity="center"
android:textStyle="bold"
android:textSize="19sp"/>
android:layout_marginBottom="20dp">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/game_publisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="?colorOnSurfaceVariant"
android:textSize="14sp"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/game_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="?colorOnSurfaceVariant"
android:paddingBottom="4dp"
android:gravity="center"
android:textStyle="bold"
android:ellipsize="marquee"
style="?attr/textAppearanceTitleSmall"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:textSize="19sp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/game_publisher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textColor="?colorOnSurfaceVariant"
android:textSize="14sp"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
</LinearLayout>
</LinearLayout>
<!-- Drawer content layout -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginTop="10dp">
android:orientation="vertical"
android:gravity="start"
android:layout_marginTop="195dp">
<androidx.appcompat.widget.LinearLayoutCompat
<com.google.android.material.navigation.NavigationView
android:id="@+id/action_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
app:menu="@menu/game_drawer_settings"
android:background="?colorSurface"
android:theme="@style/Widget.App.NavigationView"
app:subheaderTextAppearance="@style/TextAppearanceGameDrawerSubTitle"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/actions"
style="@style/TextAppearanceGameDrawerSubTitle"/>
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/action_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/game_drawer_actions"
android:background="?colorSurface"/>
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/others"
style="@style/TextAppearanceGameDrawerSubTitle"/>
<com.google.android.material.navigation.NavigationView
android:id="@+id/others_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/game_drawer_others"
android:background="?colorSurface"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</ScrollView>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.drawerlayout.widget.DrawerLayout>

View file

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_marginTop="60dp"
android:layout_height="match_parent">
<com.panda3ds.pandroid.view.gamesgrid.GamesGridView
@ -10,16 +13,16 @@
android:paddingStart="15dp"
android:paddingEnd="15dp"/>
<androidx.appcompat.widget.AppCompatImageButton
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/add_rom"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:layout_gravity="end|bottom"
android:src="@drawable/ic_add"
android:tint="?colorOnPrimary"
android:background="@drawable/simple_card_background"
android:backgroundTint="?colorPrimary"/>
android:gravity="center"
app:rippleColor="?colorOnSurfaceVariant"
app:backgroundTint="?colorPrimary"
tools:ignore="PrivateResource"/>
</FrameLayout>
</FrameLayout>

View file

@ -9,16 +9,17 @@
<FrameLayout
android:layout_width="match_parent"
android:layout_height="64dp"
android:paddingHorizontal="20dp">
android:paddingHorizontal="20dp"
android:background="?colorSurfaceVariant">
<androidx.appcompat.widget.AppCompatEditText
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/search_bar"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_gravity="center"
android:hint="@string/search"
android:paddingEnd="10dp"
android:paddingStart="50dp"
android:hint="@string/search"
android:textSize="16sp"
android:background="@drawable/search_bar_background"
android:backgroundTint="?colorSurfaceVariant" />
@ -46,4 +47,4 @@
</FrameLayout>
</LinearLayout>
</LinearLayout>

View file

@ -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">
<androidx.cardview.widget.CardView
<com.google.android.material.card.MaterialCardView
style="@style/Widget.Material3.CardView.Elevated"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="16dp">
android:layout_margin="10dp"
app:shapeAppearance="?attr/shapeAppearanceCornerLarge">
<com.panda3ds.pandroid.view.gamesgrid.GameIconView
android:id="@+id/icon"
@ -19,15 +23,20 @@
android:scaleType="centerCrop"
android:background="?colorSurfaceVariant"/>
</androidx.cardview.widget.CardView>
</com.google.android.material.card.MaterialCardView>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/textAppearanceTitleSmall"
android:text="@string/app_name"
android:layout_marginTop="8dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:textStyle="bold"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:gravity="center"/>
<androidx.appcompat.widget.AppCompatTextView
@ -36,6 +45,11 @@
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="10sp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true"
android:gravity="center"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>

View file

@ -1,43 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="start|center"
android:padding="5dp">
<androidx.appcompat.widget.LinearLayoutCompat
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/simple_card_background"
android:backgroundTint="?colorSurfaceVariant"
android:orientation="vertical"
android:gravity="center"
android:padding="10dp">
app:cardBackgroundColor="?attr/colorSurfaceVariant"
app:cardCornerRadius="8dp"
android:layout_gravity="center"
android:layout_margin="10dp">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginHorizontal="5dp"
android:scaleType="fitCenter"
android:tint="?colorOnSurfaceVariant"
android:alpha="0.5"
android:padding="14dp"
android:src="@drawable/ic_code"
android:layout_marginBottom="14dp"/>
<TextView
android:id="@+id/title"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="15sp"
android:gravity="center"/>
android:orientation="vertical"
android:gravity="center"
android:padding="10dp">
</androidx.appcompat.widget.LinearLayoutCompat>
<ImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_marginHorizontal="5dp"
android:scaleType="fitCenter"
android:tint="?attr/colorOnSurfaceVariant"
android:alpha="0.5"
android:padding="14dp"
android:src="@drawable/ic_code"
android:layout_marginBottom="14dp"/>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/app_name"
android:textSize="15sp"
android:gravity="center"/>
<androidx.appcompat.widget.AppCompatImageButton
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.button.MaterialButton
android:id="@+id/edit"
android:layout_width="40dp"
android:layout_height="40dp"
@ -46,7 +53,6 @@
android:padding="10dp"
android:tint="?colorOnSurfaceVariant"
android:layout_gravity="end|top"
android:background="#0000"
android:backgroundTint="#0000"
android:layout_margin="10dp"/>
</FrameLayout>
</FrameLayout>

View file

@ -2,6 +2,7 @@
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="320dp"
android:layout_marginTop="22dp"
android:orientation="vertical"
android:gravity="center">
@ -26,4 +27,4 @@
android:alpha="0.5"
android:textColor="?colorOnSurface"/>
</androidx.appcompat.widget.LinearLayoutCompat>
</androidx.appcompat.widget.LinearLayoutCompat>

View file

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/resume"
android:icon="@drawable/ic_shortcut"
android:title="@string/resume"/>
<item
android:id="@+id/exit"
android:icon="@drawable/ic_exit"
android:title="@string/exit"/>
</menu>

View file

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/lua_script"
android:icon="@drawable/ic_code"
android:title="@string/lua_script"/>
</menu>

View file

@ -0,0 +1,35 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:divider="@null"
android:dividerHeight="0dp">
<item
android:id="@+id/header_actions"
android:title="Actions">
<menu>
<item
android:id="@+id/resume"
android:icon="@drawable/ic_shortcut"
android:title="@string/resume" />
<item
android:id="@+id/exit"
android:icon="@drawable/ic_exit"
android:title="@string/exit"/>
</menu>
</item>
<item
android:id="@+id/header_others"
android:title="Others">
<menu>
<item
android:id="@+id/change_orientation"
android:icon="@drawable/ic_rotate_screen"
android:title="Rotate" />
<item
android:id="@+id/lua_script"
android:icon="@drawable/ic_code"
android:title="@string/lua_script" />
</menu>
</item>
</menu>

View file

@ -42,6 +42,10 @@
<style name="Theme.Pandroid" parent="Base.Theme.Pandroid"/>
<style name="Widget.App.NavigationView" parent="Widget.Material3.NavigationView">
<item name="android:listDivider">@android:color/transparent</item>
</style>
<style name="Theme.Pandroid.Custom" parent="Theme.Pandroid">
<item name="android:textColor">?colorOnSurface</item>
<item name="android:textSize">16sp</item>