Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge pull request #8188 from JosJuice/android-game-details
Android: Bring back and update the game details dialog
- Loading branch information
Showing
19 changed files
with
310 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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(); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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); | ||
| } | ||
| } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.