Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite BaseItemInfoRow with Compose #3379

Merged

Conversation

nielsvanvelzen
Copy link
Member

This is an old branch of mine that I started about a year ago but never finished... I've finally completed it now lol.

The info row is what is shown below the title while browsing, almost all screens use it and thus it is a bit messy. This pull request aims to rewrite it in Kotlin with Compose, not necessarily to clean it up.

The info row items shown are mostly the same. There are some tweaks to the design, improvements to datetime formatting and in some cases some items are removed/reordered or added.

This also adds a lot of proper plurals to the strings, so stuff like "1 episodes" should not happen in this row anymore.

Changes

  • Replace most of InfoLayoutHelper with new BaseItemInfoRow

Before
91400002c3

After
90700002c2

Issues

@nielsvanvelzen nielsvanvelzen added the enhancement New feature or request label Feb 17, 2024
@nielsvanvelzen nielsvanvelzen added this to the v0.17.0 milestone Feb 17, 2024
<item quantity="one">%1$s item</item>
<item quantity="other">%1$s items</item>
</plurals>
<plurals name="movies">

Check warning

Code scanning / Android Lint

Unused resources Warning

The resource R.plurals.movies appears to be unused
<item quantity="one">%1$s movie</item>
<item quantity="other">%1$s movies</item>
</plurals>
<plurals name="tv_series">

Check warning

Code scanning / Android Lint

Unused resources Warning

The resource R.plurals.tv_series appears to be unused
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detekt found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@nielsvanvelzen nielsvanvelzen force-pushed the compose-base-item-info-row branch from d0ff7ca to 366b188 Compare February 17, 2024 18:53
@nielsvanvelzen nielsvanvelzen marked this pull request as ready for review February 17, 2024 18:56

public class InfoLayoutHelper {
public static void addInfoRow(Context context, BaseItemDto item, LinearLayout layout, boolean includeRuntime) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations

public class InfoLayoutHelper {
public static void addInfoRow(Context context, BaseItemDto item, LinearLayout layout, boolean includeRuntime) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations

public class InfoLayoutHelper {
public static void addInfoRow(Context context, BaseItemDto item, LinearLayout layout, boolean includeRuntime) {

Check notice

Code scanning / Android Lint

Unknown nullness Note

Unknown nullability; explicitly declare as @Nullable or @NonNull to improve Kotlin interoperability; see https://developer.android.com/kotlin/interop#nullability_annotations
}

@Composable
fun InfoRowMediaDetails(item: BaseItemDto) {

Check warning

Code scanning / detekt

One method should have one responsibility. Long methods tend to handle many things at once. Prefer smaller methods to make them easier to understand. Warning

The function InfoRowMediaDetails is too long (67). The maximum length is 60.
}

@Composable
fun BaseItemInfoRow(

Check warning

Code scanning / detekt

One method should have one responsibility. Long methods tend to handle many things at once. Prefer smaller methods to make them easier to understand. Warning

The function BaseItemInfoRow is too long (120). The maximum length is 60.
}

@Composable
fun InfoRowMediaDetails(item: BaseItemDto) {

Check warning

Code scanning / detekt

Prefer splitting up complex methods into smaller, easier to test methods. Warning

The function InfoRowMediaDetails appears to be too complex based on Cyclomatic Complexity (complexity: 22). Defined complexity threshold for methods is set to '15'
}

@Composable
fun BaseItemInfoRow(

Check warning

Code scanning / detekt

Prefer splitting up complex methods into smaller, easier to test methods. Warning

The function BaseItemInfoRow appears to be too complex based on Cyclomatic Complexity (complexity: 51). Defined complexity threshold for methods is set to '15'

@Composable
@Suppress("MagicNumber")
fun getResolutionName(width: Int, height: Int, interlaced: Boolean = false): String {

Check warning

Code scanning / detekt

Prefer splitting up complex methods into smaller, easier to test methods. Warning

The function getResolutionName appears to be too complex based on Cyclomatic Complexity (complexity: 15). Defined complexity threshold for methods is set to '15'
verticalAlignment = Alignment.CenterVertically,
) {
if (ratingType != RatingType.RATING_HIDDEN) {
item.communityRating?.let { InfoRowCommunityRating(it / 10f) }

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
) {
if (ratingType != RatingType.RATING_HIDDEN) {
item.communityRating?.let { InfoRowCommunityRating(it / 10f) }
item.criticRating?.let { InfoRowCriticRating(it / 100f) }

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
* Colors used inm the [BaseItemInfoRow].
*/
object InfoRowColors {
val Default = Color(0xFF333333)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
*/
object InfoRowColors {
val Default = Color(0xFF333333)
val Green = Color(0xFF30843D)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
object InfoRowColors {
val Default = Color(0xFF333333)
val Green = Color(0xFF30843D)
val Red = Color(0xFFB20000)

Check warning

Code scanning / detekt

Report magic numbers. Magic number is a numeric literal that is not defined as a constant and hence it's unclear what the purpose of this number is. It's better to declare such numbers as constants and give them a proper name. By default, -1, 0, 1, and 2 are not considered to be magic numbers. Warning

This expression contains a magic number. Consider defining it to a well named constant.
Co-authored-by: Cody Robibero <[email protected]>
@nielsvanvelzen nielsvanvelzen merged commit 004d4e0 into jellyfin:master Feb 20, 2024
6 checks passed
@nielsvanvelzen nielsvanvelzen deleted the compose-base-item-info-row branch February 20, 2024 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants