mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-19 20:19:13 +12:00
Merge branch 'ishan-reviews' of https://github.com/GabrielBRDeveloper/Panda3DS-Android into ishan-reviews
This commit is contained in:
commit
f2e49f3953
3 changed files with 135 additions and 2 deletions
|
@ -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")
|
||||
}
|
||||
|
|
|
@ -5,6 +5,10 @@ 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;
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
99
src/pandroid/app/src/main/res/layout/game_dialog.xml
Normal file
99
src/pandroid/app/src/main/res/layout/game_dialog.xml
Normal file
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
|
||||
android:id="@+id/drag_handle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:nextFocusRight="@id/game_play"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<com.google.android.material.imageview.ShapeableImageView
|
||||
android:id="@+id/game_icon"
|
||||
android:layout_width="140dp"
|
||||
android:layout_height="140dp"
|
||||
android:contentDescription="icon"
|
||||
android:focusable="false"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/constraintLayout"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/constraintLayout"
|
||||
app:shapeAppearance="?attr/shapeAppearanceCornerLarge" />
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/constraintLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="16dp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHeight_min="140dp"
|
||||
app:layout_constraintStart_toEndOf="@id/game_icon"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_title"
|
||||
style="?attr/textAppearanceTitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAlignment="viewStart"
|
||||
android:textSize="20sp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="Pokemon X" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/game_author"
|
||||
style="?attr/textAppearanceBodyMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="@id/game_title"
|
||||
app:layout_constraintTop_toBottomOf="@id/game_title"
|
||||
tools:text="Nintendo 3ds" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.flexbox.FlexboxLayout
|
||||
android:id="@+id/flexboxGeneral"
|
||||
style="@style/ThemeOverlay.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
app:flexWrap="nowrap"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/game_icon"
|
||||
app:layout_constraintVertical_bias="1">
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/game_play"
|
||||
style="@style/Widget.Material3.Button.Icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:contentDescription="play"
|
||||
android:focusedByDefault="true"
|
||||
android:text="Play"
|
||||
app:icon="@drawable/ic_play"
|
||||
app:layout_flexGrow="1"
|
||||
app:layout_maxWidth="140dp"/>
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/game_settings"
|
||||
style="@style/Widget.Material3.Button.IconButton.Filled.Tonal"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:contentDescription="settings"
|
||||
app:icon="@drawable/ic_settings"/>
|
||||
|
||||
</com.google.android.flexbox.FlexboxLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
</LinearLayout>
|
Loading…
Add table
Add a link
Reference in a new issue