diff --git a/Source/Android/app/build.gradle b/Source/Android/app/build.gradle index 2cde9e0676..711ae5050e 100644 --- a/Source/Android/app/build.gradle +++ b/Source/Android/app/build.gradle @@ -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. diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java index 5cdb4d984d..3f463b372a 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameAdapter.java @@ -13,7 +13,7 @@ import android.view.ViewGroup; import org.dolphinemu.dolphinemu.R; import org.dolphinemu.dolphinemu.activities.EmulationActivity; -import org.dolphinemu.dolphinemu.dialogs.GameSettingsDialog; +import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog; import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.utils.PicassoUtils; import org.dolphinemu.dolphinemu.viewholders.GameViewHolder; @@ -69,7 +69,7 @@ public final class GameAdapter extends RecyclerView.Adapter impl public void onBindViewHolder(GameViewHolder holder, int position) { GameFile gameFile = mGameFiles.get(position); - PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile); + PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); holder.textGameTitle.setText(gameFile.getTitle()); holder.textCompany.setText(gameFile.getCompany()); @@ -145,10 +145,11 @@ public final class GameAdapter extends RecyclerView.Adapter impl return true; } - GameSettingsDialog fragment = - GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform()); + GamePropertiesDialog fragment = + GamePropertiesDialog + .newInstance(holder.gameFile.getPath(), gameId, holder.gameFile.getPlatform()); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction() - .add(fragment, GameSettingsDialog.TAG).commit(); + .add(fragment, GamePropertiesDialog.TAG).commit(); return true; } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java index 439c4a94d0..d2d720db53 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/adapters/GameRowPresenter.java @@ -13,7 +13,7 @@ import android.view.ViewGroup; import android.widget.ImageView; import org.dolphinemu.dolphinemu.R; -import org.dolphinemu.dolphinemu.dialogs.GameSettingsDialog; +import org.dolphinemu.dolphinemu.dialogs.GamePropertiesDialog; import org.dolphinemu.dolphinemu.model.GameFile; import org.dolphinemu.dolphinemu.ui.platform.Platform; import org.dolphinemu.dolphinemu.utils.PicassoUtils; @@ -49,7 +49,7 @@ public final class GameRowPresenter extends Presenter GameFile gameFile = (GameFile) item; holder.imageScreenshot.setImageDrawable(null); - PicassoUtils.loadGameBanner(holder.imageScreenshot, gameFile); + PicassoUtils.loadGameCover(holder.imageScreenshot, gameFile); holder.cardParent.setTitleText(gameFile.getTitle()); holder.cardParent.setContentText(gameFile.getCompany()); @@ -90,10 +90,11 @@ public final class GameRowPresenter extends Presenter return true; } - GameSettingsDialog fragment = - GameSettingsDialog.newInstance(gameId, holder.gameFile.getPlatform()); + GamePropertiesDialog fragment = + GamePropertiesDialog.newInstance(holder.gameFile.getPath(), gameId, + holder.gameFile.getPlatform()); ((FragmentActivity) view.getContext()).getSupportFragmentManager().beginTransaction() - .add(fragment, GameSettingsDialog.TAG).commit(); + .add(fragment, GamePropertiesDialog.TAG).commit(); return true; }); 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..a0332d2bd4 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameDetailsDialog.java @@ -0,0 +1,71 @@ +package org.dolphinemu.dolphinemu.dialogs; + +import android.app.Dialog; +import android.os.Bundle; +import android.view.View; +import android.view.ViewGroup; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.appcompat.app.AlertDialog; +import androidx.fragment.app.DialogFragment; + +import org.dolphinemu.dolphinemu.R; +import org.dolphinemu.dolphinemu.model.GameFile; +import org.dolphinemu.dolphinemu.services.GameFileCacheService; +import org.dolphinemu.dolphinemu.utils.PicassoUtils; + +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(requireActivity()); + ViewGroup contents = (ViewGroup) getActivity().getLayoutInflater() + .inflate(R.layout.dialog_game_details, null); + + ImageView banner = contents.findViewById(R.id.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); + TextView textGameId = contents.findViewById(R.id.text_game_id); + TextView textRevision = contents.findViewById(R.id.text_revision); + + String country = getResources().getStringArray(R.array.countryNames)[gameFile.getCountry()]; + String description = gameFile.getDescription(); + + textTitle.setText(gameFile.getTitle()); + textDescription.setText(gameFile.getDescription()); + if (description.isEmpty()) + { + textDescription.setVisibility(View.GONE); + } + textCountry.setText(country); + textCompany.setText(gameFile.getCompany()); + textGameId.setText(gameFile.getGameId()); + textRevision.setText(Integer.toString(gameFile.getRevision())); + + PicassoUtils.loadGameBanner(banner, gameFile); + + builder.setView(contents); + return builder.create(); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java similarity index 79% rename from Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java rename to Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java index 9d2bf1cf76..f5f6ea5eae 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GameSettingsDialog.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/dialogs/GamePropertiesDialog.java @@ -6,6 +6,7 @@ import android.os.Bundle; import androidx.annotation.NonNull; import androidx.appcompat.app.AlertDialog; import androidx.fragment.app.DialogFragment; +import androidx.fragment.app.FragmentActivity; import android.widget.Toast; @@ -17,17 +18,19 @@ import org.dolphinemu.dolphinemu.utils.DirectoryInitialization; import java.io.File; -public class GameSettingsDialog extends DialogFragment +public class GamePropertiesDialog extends DialogFragment { - public static final String TAG = "GameSettingsDialog"; + public static final String TAG = "GamePropertiesDialog"; + public static final String ARG_PATH = "path"; public static final String ARG_GAMEID = "game_id"; public static final String ARG_PLATFORM = "platform"; - public static GameSettingsDialog newInstance(String gameId, int platform) + public static GamePropertiesDialog newInstance(String path, String gameId, int platform) { - GameSettingsDialog fragment = new GameSettingsDialog(); + GamePropertiesDialog fragment = new GamePropertiesDialog(); Bundle arguments = new Bundle(); + arguments.putString(ARG_PATH, path); arguments.putString(ARG_GAMEID, gameId); arguments.putInt(ARG_PLATFORM, platform); fragment.setArguments(arguments); @@ -41,10 +44,12 @@ public class GameSettingsDialog extends DialogFragment { AlertDialog.Builder builder = new AlertDialog.Builder(requireContext()); + String path = requireArguments().getString(ARG_PATH); String gameId = requireArguments().getString(ARG_GAMEID); int platform = requireArguments().getInt(ARG_PLATFORM); - builder.setTitle(requireContext().getString(R.string.preferences_game_settings) + ": " + gameId) + builder.setTitle(requireContext() + .getString(R.string.preferences_game_properties) + ": " + gameId) .setItems(platform == Platform.GAMECUBE.toInt() ? R.array.gameSettingsMenusGC : R.array.gameSettingsMenusWii, (dialog, which) -> @@ -52,22 +57,26 @@ public class GameSettingsDialog extends DialogFragment switch (which) { case 0: - SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId); + GameDetailsDialog.newInstance(path).show((requireActivity()) + .getSupportFragmentManager(), "game_details"); break; case 1: - SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId); + SettingsActivity.launch(getContext(), MenuTag.CONFIG, gameId); break; case 2: - SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId); + SettingsActivity.launch(getContext(), MenuTag.GRAPHICS, gameId); break; case 3: + SettingsActivity.launch(getContext(), MenuTag.GCPAD_TYPE, gameId); + break; + case 4: // Clear option for GC, Wii controls for else if (platform == Platform.GAMECUBE.toInt()) clearGameSettings(gameId); else SettingsActivity.launch(getActivity(), MenuTag.WIIMOTE, gameId); break; - case 4: + case 5: clearGameSettings(gameId); break; } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java index 70be6cd080..dea006f24e 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/model/GameFile.java @@ -54,11 +54,4 @@ public class GameFile { return getPath().substring(0, getPath().lastIndexOf(".")) + ".cover.png"; } - - public String getScreenshotPath() - { - String gameId = getGameId(); - return "file://" + Environment.getExternalStorageDirectory().getPath() + - "/dolphin-emu/ScreenShots/" + gameId + "/" + gameId + "-1.png"; - } } diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java new file mode 100644 index 0000000000..b8c702f205 --- /dev/null +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/GameBannerRequestHandler.java @@ -0,0 +1,36 @@ +package org.dolphinemu.dolphinemu.utils; + +import android.graphics.Bitmap; + +import com.squareup.picasso.Picasso; +import com.squareup.picasso.Request; +import com.squareup.picasso.RequestHandler; + +import org.dolphinemu.dolphinemu.model.GameFile; + +public class GameBannerRequestHandler extends RequestHandler +{ + private final GameFile mGameFile; + + public GameBannerRequestHandler(GameFile gameFile) + { + mGameFile = gameFile; + } + + @Override + public boolean canHandleRequest(Request data) + { + return true; + } + + @Override + public Result load(Request request, int networkPolicy) + { + int[] vector = mGameFile.getBanner(); + int width = mGameFile.getBannerWidth(); + int height = mGameFile.getBannerHeight(); + Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888); + bitmap.setPixels(vector, 0, width, 0, 0, width, height); + return new Result(bitmap, Picasso.LoadedFrom.DISK); + } +} diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java index cc272e72f9..4dc0c200a6 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/utils/PicassoUtils.java @@ -2,6 +2,7 @@ package org.dolphinemu.dolphinemu.utils; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; +import android.net.Uri; import android.widget.ImageView; import com.squareup.picasso.Callback; @@ -15,6 +16,22 @@ import java.io.File; public class PicassoUtils { public static void loadGameBanner(ImageView imageView, GameFile gameFile) + { + Picasso picassoInstance = new Picasso.Builder(imageView.getContext()) + .addRequestHandler(new GameBannerRequestHandler(gameFile)) + .build(); + + picassoInstance + .load(Uri.parse("iso:/" + gameFile.getPath())) + .fit() + .noFade() + .noPlaceholder() + .config(Bitmap.Config.RGB_565) + .error(R.drawable.no_banner) + .into(imageView); + } + + public static void loadGameCover(ImageView imageView, GameFile gameFile) { File cover = new File(gameFile.getCustomCoverPath()); if (cover.exists()) @@ -41,10 +58,8 @@ public class PicassoUtils .error(R.drawable.no_banner) .into(imageView); } - /** - * GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting - * the cover will be by the disk's region, second will be the US cover, and third EN. - */ + // GameTDB has a pretty close to complete collection for US/EN covers. First pass at getting + // the cover will be by the disk's region, second will be the US cover, and third EN. else { Picasso.get() diff --git a/Source/Android/app/src/main/res/drawable-hdpi/ic_company.png b/Source/Android/app/src/main/res/drawable-hdpi/ic_company.png deleted file mode 100644 index 88e21de295..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-hdpi/ic_company.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-hdpi/ic_country.png b/Source/Android/app/src/main/res/drawable-hdpi/ic_country.png deleted file mode 100644 index 6e71c3a40f..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-hdpi/ic_country.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xhdpi/ic_company.png b/Source/Android/app/src/main/res/drawable-xhdpi/ic_company.png deleted file mode 100644 index 26b1ccfcf4..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xhdpi/ic_company.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xhdpi/ic_country.png b/Source/Android/app/src/main/res/drawable-xhdpi/ic_country.png deleted file mode 100644 index 5d500f5f04..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xhdpi/ic_country.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xxhdpi/ic_company.png b/Source/Android/app/src/main/res/drawable-xxhdpi/ic_company.png deleted file mode 100644 index ac4c2c70e8..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xxhdpi/ic_company.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xxhdpi/ic_country.png b/Source/Android/app/src/main/res/drawable-xxhdpi/ic_country.png deleted file mode 100644 index 077ae487a0..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xxhdpi/ic_country.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_company.png b/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_company.png deleted file mode 100644 index 6742ce771f..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_company.png and /dev/null differ diff --git a/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_country.png b/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_country.png deleted file mode 100644 index 27c03a5232..0000000000 Binary files a/Source/Android/app/src/main/res/drawable-xxxhdpi/ic_country.png and /dev/null differ 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..fc6b360320 --- /dev/null +++ b/Source/Android/app/src/main/res/layout/dialog_game_details.xml @@ -0,0 +1,146 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Android/app/src/main/res/values/arrays.xml b/Source/Android/app/src/main/res/values/arrays.xml index 9e2f268151..3cfffe433f 100644 --- a/Source/Android/app/src/main/res/values/arrays.xml +++ b/Source/Android/app/src/main/res/values/arrays.xml @@ -336,12 +336,14 @@ + Details Core Settings GFX Settings GameCube Controller Settings Clear Game Settings + Details Core Settings GFX Settings GameCube Controller Settings diff --git a/Source/Android/app/src/main/res/values/strings.xml b/Source/Android/app/src/main/res/values/strings.xml index 2ecbb07df7..9cf77f7eba 100644 --- a/Source/Android/app/src/main/res/values/strings.xml +++ b/Source/Android/app/src/main/res/values/strings.xml @@ -280,10 +280,14 @@ Save and Exit Settings - Game Settings + Game Properties Extension Bindings Junk Data Found The settings file for this game contains junk data created by an old version of Dolphin. Would you like to fix this by deleting the settings file for this game? All game-specific settings and cheats that you have added will be removed. This cannot be undone. + Country + Company + Game ID + Revision Take Screenshot