diff --git a/src/pandroid/app/build.gradle.kts b/src/pandroid/app/build.gradle.kts index 201d5db1..f37b5dba 100644 --- a/src/pandroid/app/build.gradle.kts +++ b/src/pandroid/app/build.gradle.kts @@ -53,4 +53,5 @@ dependencies { implementation("androidx.preference:preference:1.2.1") implementation("androidx.constraintlayout:constraintlayout:2.1.4") implementation("com.google.code.gson:gson:2.10.1") + implementation("com.google.android.flexbox:flexbox:3.0.0") } diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/gamesgrid/ItemHolder.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/gamesgrid/ItemHolder.java index 54f86dae..8f5c1014 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/gamesgrid/ItemHolder.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/view/gamesgrid/ItemHolder.java @@ -5,7 +5,11 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.appcompat.widget.AppCompatTextView; import androidx.recyclerview.widget.RecyclerView; - +import android.widget.TextView; +import com.google.android.material.imageview.ShapeableImageView; +import com.google.android.material.button.MaterialButton; +import com.google.android.material.bottomsheet.BottomSheetDialog; + import com.panda3ds.pandroid.R; import com.panda3ds.pandroid.data.game.GameMetadata; import com.panda3ds.pandroid.utils.GameUtils; @@ -23,8 +27,37 @@ class ItemHolder extends RecyclerView.ViewHolder { ((AppCompatTextView) itemView.findViewById(R.id.description)) .setText(game.getPublisher()); + itemView.setOnLongClickListener((v) -> { + showBottomSheet(game); + return true; // Return true to consume the long click event + }); + itemView.setOnClickListener((v) -> { GameUtils.launch(v.getContext(), game); }); } -} \ No newline at end of file + private void showBottomSheet(GameMetadata game) { + BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(itemView.getContext()); + View bottomSheetView = View.inflate(itemView.getContext(), R.layout.game_dialog, null); + bottomSheetDialog.setContentView(bottomSheetView); + + TextView gameTitleTextView = bottomSheetView.findViewById(R.id.game_title); + gameTitleTextView.setText(game.getTitle()); + + ShapeableImageView gameIconImageView = bottomSheetView.findViewById(R.id.game_icon); + gameIconImageView.setImageBitmap(game.getIcon()); + + TextView gamePublisherTextView = bottomSheetView.findViewById(R.id.game_author); + gamePublisherTextView.setText(game.getPublisher()); + + MaterialButton gamePlayButton = bottomSheetView.findViewById(R.id.game_play); + gamePlayButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + GameUtils.launch(v.getContext(), game); + } + }); + + bottomSheetDialog.show(); + } +} diff --git a/src/pandroid/app/src/main/res/layout/game_dialog.xml b/src/pandroid/app/src/main/res/layout/game_dialog.xml new file mode 100644 index 00000000..3a3b8816 --- /dev/null +++ b/src/pandroid/app/src/main/res/layout/game_dialog.xml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +