From 870912722ed515e4ead17aee3aa7635abfb4f192 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 15 Jun 2019 18:37:48 +0200 Subject: [PATCH] Revert "Android: Remove dead code and related lib " This reverts commit 593b69728d7e7813a3e3bbd1bfea2f2f56f3a38e. --- Source/Android/app/build.gradle | 3 + .../dolphinemu/dialogs/GameDetailsDialog.java | 83 +++++++++++ .../main/res/layout/dialog_game_details.xml | 130 ++++++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java create mode 100644 Source/Android/app/src/main/res/layout/dialog_game_details.xml diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 2cde9e0676..aa675a97b8 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -89,6 +89,9 @@ dependencies { // For REST calls implementation 'com.android.volley:volley:1.1.1' + // For showing the banner as a circle a-la Material Design Guidelines + implementation 'de.hdodenhof:circleimageview:2.1.0' + // For loading huge screenshots from the disk. implementation 'com.squareup.picasso:picasso:2.71828' diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java new file mode 100644 index 0000000000..be254a4b7c --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -0,0 +1,83 @@ +package org.dolphinemu.dolphinemu.dialogs; + +import android.app.AlertDialog; +import android.app.Dialog; +import android.os.Bundle; +import android.support.design.widget.FloatingActionButton; +import android.support.v4.app.DialogFragment; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import com.squareup.picasso.Picasso; + +import org.dolphinemu.dolphinemu.R; +import org.dolphinemu.dolphinemu.activities.EmulationActivity; +import org.dolphinemu.dolphinemu.model.GameFile; +import org.dolphinemu.dolphinemu.services.GameFileCacheService; + +import de.hdodenhof.circleimageview.CircleImageView; + +public final class GameDetailsDialog extends DialogFragment +{ + private static final String ARG_GAME_PATH = "game_path"; + + public static GameDetailsDialog newInstance(String gamePath) + { + GameDetailsDialog fragment = new GameDetailsDialog(); + + Bundle arguments = new Bundle(); + arguments.putString(ARG_GAME_PATH, gamePath); + fragment.setArguments(arguments); + + return fragment; + } + + @Override + public Dialog onCreateDialog(Bundle savedInstanceState) + { + GameFile gameFile = GameFileCacheService.addOrGet(getArguments().getString(ARG_GAME_PATH)); + + AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); + ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater() + .inflate(R.layout.dialog_game_details, null); + + final ImageView imageGameScreen = contents.findViewById(R.id.image_game_screen); + CircleImageView circleBanner = contents.findViewById(R.id.circle_banner); + + TextView textTitle = contents.findViewById(R.id.text_game_title); + TextView textDescription = contents.findViewById(R.id.text_description); + + TextView textCountry = contents.findViewById(R.id.text_country); + TextView textCompany = contents.findViewById(R.id.text_company); + + FloatingActionButton buttonLaunch = contents.findViewById(R.id.button_launch); + + String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()]; + + textTitle.setText(gameFile.getTitle()); + textDescription.setText(gameFile.getDescription()); + textCountry.setText(country); + textCompany.setText(gameFile.getCompany()); + + buttonLaunch.setOnClickListener(view -> + { + // Start the emulation activity and send the path of the clicked ROM to it. + EmulationActivity.launch(getActivity(), gameFile); + }); + + // Fill in the view contents. + Picasso.get() + .load(getArguments().getString(gameFile.getScreenshotPath())) + .fit() + .centerCrop() + .noFade() + .noPlaceholder() + .into(imageGameScreen); + + circleBanner.setImageResource(R.drawable.no_banner); + + builder.setView(contents); + return builder.create(); + } +} diff --git a/Source/Android/app/src/main/res/layout/dialog_game_details.xml b/Source/Android/app/src/main/res/layout/dialog_game_details.xml new file mode 100644 index 0000000000..61cc212f55 --- /dev/null +++ b/Source/Android/app/src/main/res/layout/dialog_game_details.xml @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +