Skip to content

Commit

Permalink
GameDetailsDialog: Convert layout to ConstraintLayout
Browse files Browse the repository at this point in the history
This also removes the FAB from GameDetailsDialog. It was
previously outside of the visible area and thus unusable.
  • Loading branch information
JosJuice committed Nov 23, 2019
1 parent 4f15110 commit 2e13353
Show file tree
Hide file tree
Showing 3 changed files with 137 additions and 159 deletions.
1 change: 1 addition & 0 deletions Source/Android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ dependencies {
implementation 'androidx.exifinterface:exifinterface:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'

// Android TV UI libraries.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
import androidx.appcompat.app.AlertDialog;
import androidx.fragment.app.DialogFragment;

import com.google.android.material.floatingactionbutton.FloatingActionButton;

import org.dolphinemu.dolphinemu.R;
import org.dolphinemu.dolphinemu.activities.EmulationActivity;
import org.dolphinemu.dolphinemu.model.GameFile;
import org.dolphinemu.dolphinemu.services.GameFileCacheService;
import org.dolphinemu.dolphinemu.utils.PicassoUtils;
Expand Down Expand Up @@ -52,8 +49,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
TextView textGameId = contents.findViewById(R.id.text_game_id);
TextView textRevision = contents.findViewById(R.id.text_revision);

FloatingActionButton buttonLaunch = contents.findViewById(R.id.button_launch);

String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()];
String description = gameFile.getDescription();

Expand All @@ -68,12 +63,6 @@ public Dialog onCreateDialog(Bundle savedInstanceState)
textGameId.setText(gameFile.getGameId());
textRevision.setText(Integer.toString(gameFile.getRevision()));

buttonLaunch.setOnClickListener(view ->
{
// Start the emulation activity and send the path of the clicked ROM to it.
EmulationActivity.launch(getActivity(), gameFile);
});

PicassoUtils.loadGameBanner(banner, gameFile);

builder.setView(contents);
Expand Down
284 changes: 136 additions & 148 deletions Source/Android/app/src/main/res/layout/dialog_game_details.xml
Original file line number Diff line number Diff line change
@@ -1,149 +1,137 @@
<?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_height="wrap_content"
android:layout_width="match_parent"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="24dp"
android:transitionName="card_game">

<RelativeLayout
android:layout_width="480dp"
android:layout_height="wrap_content">

<ImageView
android:id="@+id/banner"
android:layout_width="144dp"
android:layout_height="48dp"
android:layout_below="@+id/text_description"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
tools:src="@drawable/no_banner"/>

<TextView
android:id="@+id/text_game_title"
style="@android:style/TextAppearance.Material.Headline"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:ellipsize="end"
tools:text="Rhythm Heaven Fever"/>

<TextView
android:id="@+id/text_description"
style="@android:style/TextAppearance.Material.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/text_game_title"
android:layout_alignStart="@+id/text_game_title"
android:layout_below="@+id/text_game_title"
android:layout_marginTop="8dp"
tools:text="Zany rhythm action!"/>

<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/banner"
android:layout_marginTop="16dp"
android:background="#1F000000"/>

<ImageView
android:id="@+id/icon_country"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignStart="@+id/banner"
android:layout_alignTop="@+id/divider"
android:layout_marginTop="24dp"
android:padding="6dp"
android:src="@drawable/ic_country"/>

<ImageView
android:id="@+id/icon_company"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignStart="@+id/icon_country"
android:layout_below="@+id/icon_country"
android:layout_marginTop="16dp"
android:padding="6dp"
android:src="@drawable/ic_company"/>

<ImageView
android:id="@+id/icon_game_id"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignStart="@+id/icon_company"
android:layout_below="@+id/icon_company"
android:layout_marginTop="16dp"
android:padding="6dp"/>

<ImageView
android:id="@+id/icon_revision"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignStart="@+id/icon_game_id"
android:layout_below="@+id/icon_game_id"
android:layout_marginTop="16dp"
android:padding="6dp"/>

<TextView
android:id="@+id/text_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/icon_country"
android:layout_alignBottom="@+id/icon_country"
android:layout_alignTop="@+id/icon_country"
android:gravity="center_vertical"
tools:text="United States"/>

<TextView
android:id="@+id/text_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/icon_company"
android:layout_alignStart="@+id/text_country"
android:layout_alignTop="@+id/icon_company"
android:gravity="center_vertical"
tools:text="Nintendo"/>

<TextView
android:id="@+id/text_game_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/icon_game_id"
android:layout_alignStart="@+id/text_company"
android:layout_alignTop="@+id/icon_game_id"
android:gravity="center_vertical"
tools:text="SOME01"/>

<TextView
android:id="@+id/text_revision"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/icon_revision"
android:layout_alignStart="@+id/text_game_id"
android:layout_alignTop="@+id/icon_revision"
android:gravity="center_vertical"
tools:text="0"/>

<android.support.design.widget.FloatingActionButton
android:id="@+id/button_launch"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_alignEnd="@+id/text_game_title"
android:layout_marginBottom="-28dp"
android:src="@drawable/ic_play"
android:stateListAnimator="@animator/button_elevation"
app:rippleColor="?android:colorPrimaryDark"
app:borderWidth="0dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp"/>

</RelativeLayout>

</FrameLayout>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingBottom="24dp"
android:transitionName="card_game">

<TextView
android:id="@+id/text_game_title"
style="@android:style/TextAppearance.Material.Headline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:ellipsize="end"
tools:text="Rhythm Heaven Fever"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/text_description"
style="@android:style/TextAppearance.Material.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
tools:text="Zany rhythm action!"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_game_title" />

<ImageView
android:id="@+id/banner"
android:layout_width="144dp"
android:layout_height="48dp"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
tools:src="@drawable/no_banner"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/text_description" />

<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="#1F000000"
android:layout_marginTop="32dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/banner" />

<ImageView
android:id="@+id/icon_country"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:padding="6dp"
android:src="@drawable/ic_country"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/divider" />

<ImageView
android:id="@+id/icon_company"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:padding="6dp"
android:src="@drawable/ic_company"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/icon_country" />

<ImageView
android:id="@+id/icon_game_id"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:padding="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/icon_company" />

<ImageView
android:id="@+id/icon_revision"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginTop="24dp"
android:padding="6dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/icon_game_id"
app:layout_constraintBottom_toBottomOf="parent" />

<TextView
android:id="@+id/text_country"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
tools:text="United States"
app:layout_constraintStart_toEndOf="@id/icon_country"
app:layout_constraintTop_toTopOf="@id/icon_country"
app:layout_constraintBottom_toBottomOf="@id/icon_country" />

<TextView
android:id="@+id/text_company"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
tools:text="Nintendo"
app:layout_constraintStart_toEndOf="@id/icon_company"
app:layout_constraintTop_toTopOf="@id/icon_company"
app:layout_constraintBottom_toBottomOf="@id/icon_company" />

<TextView
android:id="@+id/text_game_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
tools:text="SOME01"
app:layout_constraintStart_toEndOf="@id/icon_game_id"
app:layout_constraintTop_toTopOf="@id/icon_game_id"
app:layout_constraintBottom_toBottomOf="@id/icon_game_id" />

<TextView
android:id="@+id/text_revision"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:gravity="center_vertical"
tools:text="0"
app:layout_constraintStart_toEndOf="@id/icon_revision"
app:layout_constraintTop_toTopOf="@id/icon_revision"
app:layout_constraintBottom_toBottomOf="@id/icon_revision" />

</androidx.constraintlayout.widget.ConstraintLayout>

0 comments on commit 2e13353

Please sign in to comment.