Follow typical per-file detail formatting

Format the details in the expected format of individual files (instead of a complete game) and move the code to match the updated placement.
This commit is contained in:
Abandoned Cart 2022-08-21 07:40:32 -04:00 committed by Mark Collins
parent 5d6eaee301
commit 04cae942ea
11 changed files with 69 additions and 68 deletions

View File

@ -61,8 +61,8 @@ extern "C" JNIEXPORT jint JNICALL Java_emu_skyline_loader_RomFile_populate(JNIEn
language = loader->nacp->GetFirstSupportedTitleLanguage(); language = loader->nacp->GetFirstSupportedTitleLanguage();
env->SetObjectField(thiz, applicationNameField, env->NewStringUTF(loader->nacp->GetApplicationName(language).c_str())); env->SetObjectField(thiz, applicationNameField, env->NewStringUTF(loader->nacp->GetApplicationName(language).c_str()));
env->SetObjectField(thiz, applicationAuthorField, env->NewStringUTF(loader->nacp->GetApplicationPublisher(language).c_str()));
env->SetObjectField(thiz, applicationVersionField, env->NewStringUTF(loader->nacp->GetApplicationVersion().c_str())); env->SetObjectField(thiz, applicationVersionField, env->NewStringUTF(loader->nacp->GetApplicationVersion().c_str()));
env->SetObjectField(thiz, applicationAuthorField, env->NewStringUTF(loader->nacp->GetApplicationPublisher(language).c_str()));
auto icon{loader->GetIcon(language)}; auto icon{loader->GetIcon(language)};
jbyteArray iconByteArray{env->NewByteArray(static_cast<jsize>(icon.size()))}; jbyteArray iconByteArray{env->NewByteArray(static_cast<jsize>(icon.size()))};

View File

@ -29,13 +29,13 @@ namespace skyline::vfs {
return std::string(applicationName.as_string(true)); return std::string(applicationName.as_string(true));
} }
std::string NACP::GetApplicationPublisher(language::ApplicationLanguage language) {
auto applicationPublisher{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationPublisher)};
return std::string(applicationPublisher.as_string(true));
}
std::string NACP::GetApplicationVersion() { std::string NACP::GetApplicationVersion() {
auto applicationPublisher{span(nacpContents.displayVersion)}; auto applicationPublisher{span(nacpContents.displayVersion)};
return std::string(applicationPublisher.as_string(true)); return std::string(applicationPublisher.as_string(true));
} }
std::string NACP::GetApplicationPublisher(language::ApplicationLanguage language) {
auto applicationPublisher{span(nacpContents.titleEntries.at(static_cast<size_t>(language)).applicationPublisher)};
return std::string(applicationPublisher.as_string(true));
}
} }

View File

@ -47,8 +47,8 @@ namespace skyline::vfs {
std::string GetApplicationName(language::ApplicationLanguage language); std::string GetApplicationName(language::ApplicationLanguage language);
std::string GetApplicationPublisher(language::ApplicationLanguage language);
std::string GetApplicationVersion(); std::string GetApplicationVersion();
std::string GetApplicationPublisher(language::ApplicationLanguage language);
}; };
} }

View File

@ -76,8 +76,8 @@ class AppDialog : BottomSheetDialogFragment() {
binding.gameIcon.setImageBitmap(item.icon ?: missingIcon) binding.gameIcon.setImageBitmap(item.icon ?: missingIcon)
binding.gameTitle.text = item.title binding.gameTitle.text = item.title
binding.gameSubtitle.text = item.subTitle ?: item.loaderResultString(requireContext())
binding.gameVersion.text = item.version ?: item.loaderResultString(requireContext()) binding.gameVersion.text = item.version ?: item.loaderResultString(requireContext())
binding.gameSubtitle.text = item.subTitle ?: item.loaderResultString(requireContext())
binding.gamePlay.isEnabled = item.loaderResult == LoaderResult.Success binding.gamePlay.isEnabled = item.loaderResult == LoaderResult.Success
binding.gamePlay.setOnClickListener { binding.gamePlay.setOnClickListener {

View File

@ -44,10 +44,10 @@ interface LayoutBinding<V : ViewBinding> : ViewBinding {
val textTitle : TextView val textTitle : TextView
val textSubtitle : TextView
val textVersion : TextView val textVersion : TextView
val textSubtitle : TextView
val icon : ImageView val icon : ImageView
} }
@ -56,10 +56,10 @@ class ListBinding(parent : ViewGroup) : LayoutBinding<AppItemLinearBinding> {
override val textTitle = binding.textTitle override val textTitle = binding.textTitle
override val textSubtitle = binding.textSubtitle
override val textVersion = binding.textVersion override val textVersion = binding.textVersion
override val textSubtitle = binding.textSubtitle
override val icon = binding.icon override val icon = binding.icon
} }
@ -68,10 +68,10 @@ class GridBinding(parent : ViewGroup) : LayoutBinding<AppItemGridBinding> {
override val textTitle = binding.textTitle override val textTitle = binding.textTitle
override val textSubtitle = binding.textSubtitle
override val textVersion = binding.textVersion override val textVersion = binding.textVersion
override val textSubtitle = binding.textSubtitle
override val icon = binding.icon override val icon = binding.icon
} }
@ -80,10 +80,10 @@ class GridCompatBinding(parent : ViewGroup) : LayoutBinding<AppItemGridCompactBi
override val textTitle = binding.textTitle override val textTitle = binding.textTitle
override val textSubtitle = binding.textSubtitle
override val textVersion = binding.textVersion override val textVersion = binding.textVersion
override val textSubtitle = binding.textSubtitle
override val icon = binding.icon override val icon = binding.icon
} }
@ -95,8 +95,8 @@ class AppViewItem(var layoutType : LayoutType, private val item : AppItem, priva
override fun bind(holder : GenericViewHolder<LayoutBinding<*>>, position : Int) { override fun bind(holder : GenericViewHolder<LayoutBinding<*>>, position : Int) {
val binding = holder.binding val binding = holder.binding
binding.textTitle.text = item.title binding.textTitle.text = item.title
binding.textSubtitle.text = item.subTitle ?: item.loaderResultString(binding.root.context)
binding.textVersion.text = item.version ?: item.loaderResultString(binding.root.context) binding.textVersion.text = item.version ?: item.loaderResultString(binding.root.context)
binding.textSubtitle.text = item.subTitle ?: item.loaderResultString(binding.root.context)
binding.icon.setImageBitmap(item.icon ?: missingIcon) binding.icon.setImageBitmap(item.icon ?: missingIcon)

View File

@ -29,6 +29,11 @@ data class AppItem(private val meta : AppEntry) : DataItem() {
*/ */
val title get() = meta.name val title get() = meta.name
/**
* The application version
*/
val version get() = meta.version
/** /**
* The string used as the sub-title, we currently use the author * The string used as the sub-title, we currently use the author
*/ */
@ -39,11 +44,6 @@ data class AppItem(private val meta : AppEntry) : DataItem() {
*/ */
val uri get() = meta.uri val uri get() = meta.uri
/**
* The application version
*/
val version get() = meta.version
val loaderResult get() = meta.loaderResult val loaderResult get() = meta.loaderResult
fun loaderResultString(context : Context) = context.getString(when (meta.loaderResult) { fun loaderResultString(context : Context) = context.getString(when (meta.loaderResult) {

View File

@ -65,9 +65,9 @@ enum class LoaderResult(val value : Int) {
*/ */
data class AppEntry( data class AppEntry(
var name : String, var name : String,
var version : String?,
var author : String?, var author : String?,
var icon : Bitmap?, var icon : Bitmap?,
var version : String?,
var format : RomFormat, var format : RomFormat,
var uri : Uri, var uri : Uri,
var loaderResult : LoaderResult var loaderResult : LoaderResult
@ -82,12 +82,12 @@ data class AppEntry(
output.writeUTF(name) output.writeUTF(name)
output.writeObject(format) output.writeObject(format)
output.writeUTF(uri.toString()) output.writeUTF(uri.toString())
output.writeBoolean(author != null)
if (author != null)
output.writeUTF(author)
output.writeBoolean(version != null) output.writeBoolean(version != null)
if (version != null) if (version != null)
output.writeUTF(version) output.writeUTF(version)
output.writeBoolean(author != null)
if (author != null)
output.writeUTF(author)
output.writeInt(loaderResult.value) output.writeInt(loaderResult.value)
output.writeBoolean(icon != null) output.writeBoolean(icon != null)
icon?.let { icon?.let {
@ -103,10 +103,10 @@ data class AppEntry(
name = input.readUTF() name = input.readUTF()
format = input.readObject() as RomFormat format = input.readObject() as RomFormat
uri = Uri.parse(input.readUTF()) uri = Uri.parse(input.readUTF())
if (input.readBoolean())
author = input.readUTF()
if (input.readBoolean()) if (input.readBoolean())
version = input.readUTF() version = input.readUTF()
if (input.readBoolean())
author = input.readUTF()
loaderResult = LoaderResult.get(input.readInt()) loaderResult = LoaderResult.get(input.readInt())
if (input.readBoolean()) if (input.readBoolean())
icon = BitmapFactory.decodeStream(input) icon = BitmapFactory.decodeStream(input)
@ -129,6 +129,11 @@ internal class RomFile(context : Context, format : RomFormat, uri : Uri, systemL
*/ */
private var applicationName : String? = null private var applicationName : String? = null
/**
* @note This field is filled in by native code
*/
private var applicationVersion : String? = null
/** /**
* @note This field is filled in by native code * @note This field is filled in by native code
*/ */
@ -139,11 +144,6 @@ internal class RomFile(context : Context, format : RomFormat, uri : Uri, systemL
*/ */
private var rawIcon : ByteArray? = null private var rawIcon : ByteArray? = null
/**
* @note This field is filled in by native code
*/
private var applicationVersion : String? = null
val appEntry : AppEntry val appEntry : AppEntry
var result = LoaderResult.Success var result = LoaderResult.Success
@ -157,10 +157,10 @@ internal class RomFile(context : Context, format : RomFormat, uri : Uri, systemL
} }
appEntry = applicationName?.let { name -> appEntry = applicationName?.let { name ->
applicationAuthor?.let { author ->
applicationVersion?.let { version -> applicationVersion?.let { version ->
applicationAuthor?.let { author ->
rawIcon?.let { icon -> rawIcon?.let { icon ->
AppEntry(name, author, BitmapFactory.decodeByteArray(icon, 0, icon.size), version, format, uri, result) AppEntry(name, version, author, BitmapFactory.decodeByteArray(icon, 0, icon.size), format, uri, result)
} }
} }
} }

View File

@ -34,17 +34,6 @@
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
tools:text="The Legend of Zelda: Breath of the Wild" /> tools:text="The Legend of Zelda: Breath of the Wild" />
<TextView
android:id="@+id/game_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@android:color/tertiary_text_light"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@id/game_title"
app:layout_constraintTop_toBottomOf="@id/game_title"
tools:text="Nintendo" />
<TextView <TextView
android:id="@+id/game_version" android:id="@+id/game_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -52,11 +41,22 @@
android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@android:color/tertiary_text_light" android:textColor="@android:color/tertiary_text_light"
android:textSize="12sp" android:textSize="12sp"
app:layout_constraintStart_toStartOf="@id/game_subtitle" app:layout_constraintStart_toStartOf="@id/game_title"
app:layout_constraintTop_toBottomOf="@id/game_subtitle" app:layout_constraintTop_toBottomOf="@id/game_title"
tools:layout_editor_absoluteY="64dp"
tools:text="Version" /> tools:text="Version" />
<TextView
android:id="@+id/game_subtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@android:color/tertiary_text_light"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="@id/game_version"
app:layout_constraintTop_toBottomOf="@id/game_version"
tools:layout_editor_absoluteY="64dp"
tools:text="Nintendo" />
<com.google.android.flexbox.FlexboxLayout <com.google.android.flexbox.FlexboxLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View File

@ -40,7 +40,7 @@
tools:text="Title" /> tools:text="Title" />
<TextView <TextView
android:id="@+id/text_subtitle" android:id="@+id/text_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
@ -49,10 +49,10 @@
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true" android:singleLine="true"
android:textSize="12sp" android:textSize="12sp"
tools:text="Subtitle" /> tools:text="Version" />
<TextView <TextView
android:id="@+id/text_version" android:id="@+id/text_subtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
@ -62,5 +62,5 @@
android:marqueeRepeatLimit="marquee_forever" android:marqueeRepeatLimit="marquee_forever"
android:singleLine="true" android:singleLine="true"
android:textSize="12sp" android:textSize="12sp"
tools:text="Version" /> tools:text="Subtitle" />
</LinearLayout> </LinearLayout>

View File

@ -40,13 +40,13 @@
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:textStyle="bold" android:textStyle="bold"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/text_subtitle" app:layout_constraintBottom_toTopOf="@id/text_version"
app:layout_constraintEnd_toEndOf="@id/icon" app:layout_constraintEnd_toEndOf="@id/icon"
app:layout_constraintStart_toStartOf="@id/icon" app:layout_constraintStart_toStartOf="@id/icon"
tools:text="Title" /> tools:text="Title" />
<TextView <TextView
android:id="@+id/text_subtitle" android:id="@+id/text_version"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:alpha="242.25" android:alpha="242.25"
@ -59,13 +59,13 @@
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@android:color/white" android:textColor="@android:color/white"
app:layout_constraintBottom_toTopOf="@id/text_version" app:layout_constraintBottom_toTopOf="@id/text_subtitle"
app:layout_constraintEnd_toEndOf="@id/icon" app:layout_constraintEnd_toEndOf="@id/icon"
app:layout_constraintStart_toStartOf="@id/icon" app:layout_constraintStart_toStartOf="@id/icon"
tools:text="Subtitle" /> tools:text="Version" />
<TextView <TextView
android:id="@+id/text_version" android:id="@+id/text_subtitle"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="8dp" android:layout_marginBottom="8dp"
@ -82,6 +82,6 @@
app:layout_constraintBottom_toBottomOf="@id/icon" app:layout_constraintBottom_toBottomOf="@id/icon"
app:layout_constraintEnd_toEndOf="@id/icon" app:layout_constraintEnd_toEndOf="@id/icon"
app:layout_constraintStart_toStartOf="@id/icon" app:layout_constraintStart_toStartOf="@id/icon"
tools:text="Version" /> tools:text="Subtitle" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView> </com.google.android.material.card.MaterialCardView>

View File

@ -29,7 +29,7 @@
android:singleLine="true" android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceListItem" android:textAppearance="?android:attr/textAppearanceListItem"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@+id/text_subtitle" app:layout_constraintBottom_toTopOf="@id/text_version"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/icon" app:layout_constraintStart_toEndOf="@id/icon"
@ -37,21 +37,22 @@
tools:text="Title" /> tools:text="Title" />
<TextView <TextView
android:id="@+id/text_subtitle" android:id="@+id/text_version"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:textAppearance="?android:attr/textAppearanceListItemSecondary" android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="@android:color/tertiary_text_light" android:textColor="@android:color/tertiary_text_light"
app:layout_constrainedWidth="true" app:layout_constrainedWidth="true"
app:layout_constraintBottom_toTopOf="@id/text_subtitle"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/icon" app:layout_constraintStart_toEndOf="@id/icon"
app:layout_constraintTop_toBottomOf="@+id/text_title" app:layout_constraintTop_toBottomOf="@id/text_title"
tools:text="SubTitle" /> tools:text="Version" />
<TextView <TextView
android:id="@+id/text_version" android:id="@+id/text_subtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
@ -62,6 +63,6 @@
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_bias="0"
app:layout_constraintStart_toEndOf="@id/icon" app:layout_constraintStart_toEndOf="@id/icon"
app:layout_constraintTop_toBottomOf="@+id/text_subtitle" app:layout_constraintTop_toBottomOf="@id/text_version"
tools:text="Version" /> tools:text="SubTitle" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>