Skip to content

Rework SettingsValuesVC#1360

Merged
kambala-decapitator merged 9 commits intoxbmc:masterfrom
wutschel:fix_settings
Nov 11, 2025
Merged

Rework SettingsValuesVC#1360
kambala-decapitator merged 9 commits intoxbmc:masterfrom
wutschel:fix_settings

Conversation

@wutschel
Copy link
Copy Markdown
Collaborator

@wutschel wutschel commented Nov 1, 2025

Description

Closes #981.

This applies several changes to SettingsValesVC to fix and improve the functionality.

Show labels instead of values

In case of multiselect lists the app showed values (e.g. "-600, -300, ..." or "0, 1, 2") instead of the option names (e.g. "-10 mins, -5 mins, ..."). This is now implemented by mapping the values to option names. As further improvement the navigation bar shows the setting name for such "multiselect" settings.

Bildschirmfoto 2025-11-02 um 15 20 21

Option names (each image pair: left=old, right=new)

Fix automatic height of labels

SettingsValuesVC's cells have different height, depending on their content and mode. To calculate this cell height correctly before heightForRowAtIndexPath is called, the whole layout needs to use the final size, which is fixed and represented by cellWidth. To keep this width, do not use autoresizing. For better centralization of the code, change dimensions only in configureCell and create all UI elements only using new.
The screenshots show two examples (before/after) where the old implementation assumed lesser width, which caused the app to assume more height would be needed. The two screenshots on the right (before/after) show, that now the same height is used as for 1-lined labels.

Bildschirmfoto 2025-11-02 um 00 28 38

Label heights (each image pair: left=old, right=new)

Support "slider" type

This PR fixes displaying and controlling settings of the type "slider", e.g. "Settings > Games > General > Maximum rewind time" or "Settings > Player > Subtitles > Opacity". Sliders which are reported without a maximum value but use "percentage" as format need to have the maximum slider value set explicitly. This also makes custom buttons work which are created from such setting.

Bildschirmfoto 2025-11-02 um 00 29 24

Slider type in number and percentage format (each image pair: left=old, right=new)

Support float and integer for "slider"

JSON API provides the "type" for each setting value. In the case of "slider" this is needed to differentiate between "number" (= float) and "integer" (= int) values as the formatting for the slider label is different. This will also be needed for future support of libfmt.
To implemented this, the new app-internal type SettingValueType, and the related code to read this from the JSON API response, was added. Formatting the label text is now taking this type into account. All slider related values are now handled as float and only cast to the targeted format when updating the slider's label.

Bildschirmfoto 2025-11-02 um 10 52 08

Slider with "number" (=float) type

Extract units from fmt-like string formats (experimental)

Even though in #1346 a full integration of libfmt is proposed, I feel this is overkill for just adding some units to slider labels. Therefore, a less complex solution is proposed to parse the unit from fmt-like formats inside getFormatString and append the unit to the default format. This improves the user experience without a full libfmt integration.

Bildschirmfoto 2025-11-02 um 13 13 30

Units on all sliders

Bildschirmfoto 2025-11-02 um 22 42 45

Units for custom buttons created from sliders (first one was created before this PR

Summary for release notes

Improvement: Show option labels instead of values
Improvement: Support float slider values
Improvement: Show units for slider values and Kodi >= 18.0
Bugfix: Fix automatic height of settings labels
Bugfix: Fix handling of "slider" settings

@wutschel wutschel added the bugfix label Nov 1, 2025
@wutschel wutschel marked this pull request as draft November 1, 2025 21:51
@wutschel wutschel marked this pull request as ready for review November 1, 2025 22:18
@wutschel wutschel changed the title Bugfix: Fix handling settings reporting as "slider" Rework SettingsValuesVC Nov 1, 2025
@wutschel wutschel marked this pull request as draft November 2, 2025 10:53
@wutschel wutschel force-pushed the fix_settings branch 2 times, most recently from 897d5c9 to 40554e2 Compare November 2, 2025 13:54
@wutschel
Copy link
Copy Markdown
Collaborator Author

wutschel commented Nov 2, 2025

Hmm, moving layoutCell to willDisplayCell works perfectly on iPhone. But, on iPad this causes problems snd calling it in cellForRowAtIndexPath (as in mainline code) works as expected.🤷🏼‍♂️
Need to look into this deeper ...

Edit: The exact opposite change was done in 52197ae to fix layout issues as well.

Edit 2: Rework this completely now. Before heightForRowAtIndexPath is called, the cell's height must be calculated correctly. This only works, if this is done right away in cellForRowAtIndexPath. To do this, the final width must be know and used for the layout in configureCell.

@wutschel wutschel marked this pull request as ready for review November 2, 2025 21:51
Copy link
Copy Markdown
Collaborator

@kambala-decapitator kambala-decapitator left a comment

Choose a reason for hiding this comment

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

I don't think I understand what's that fuss about cell height...

Comment thread XBMC Remote/SettingsValuesViewController.m Outdated
Comment thread XBMC Remote/SettingsValuesViewController.m Outdated
Comment thread XBMC Remote/SettingsValuesViewController.m
Comment thread XBMC Remote/SettingsValuesViewController.m
Comment thread XBMC Remote/SettingsValuesViewController.m Outdated
(CELL_HEIGHT_DEFAULT - LABEL_HEIGHT_DEFAULT) / 2,
cell.frame.size.width - 2 * PADDING_HORIZONTAL,
LABEL_HEIGHT_DEFAULT)];
UILabel *cellLabel = [UILabel new];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this huge cell setup should be extracted to a cell subclass

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

At the end I will have rewritten all of the app's code ... I guess this can be done in a separate PR?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

sure

At the end I will have rewritten all of the app's code

that's the goal ;) also "Ship of Theseus" :)

// Identify fmt-like format string
if (format.length && [format rangeOfString:@"{"].location != NSNotFound && [format rangeOfString:@"}"].location != NSNotFound) {
NSInteger openBraceLoc = [format rangeOfString:@"{"].location;
NSInteger closeBraceLoc = [format rangeOfString:@"}" options:NSBackwardsSearch].location;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

your code will break in a case like {...} smth}42 :) but I think we can assume that it won't happen

Map "slider" to SettingTypeSlider. Set "maximum" to 100% for format "percentage", if maximum is not defined or set to 0. Make sure also "step" < 1 is possible to be processed.
Only show ": " in case the second string is neither nil nor "".
- Introduce SettingValueType
- Introduce helper method to read settingValueType from item
- Introduce helper method to read settingOptions from item
- Move setting variable defaults to beginning of initWithFrame
Introduce getStringForSliderItem which can process both float and integer format. Still uses special handling Kodi < 18.0 and >= 18.0.
Identify the app's internal setting type by delivered "type", "format" and "options". Showing navbar title depends on setting type and is handled in layoutCell.
Extract the unit from fmt-like string formats. This improves the user experience, but avoids a full fmt integration.
Setting cells have different height, depending on their content and mode. To calculate this cell height correctly before heightForRowAtIndexPath is called, the whole layout needs to use the final size, which is fixed and represented by cellWidth. To keep this width, do not use autoresizing.
For better centralization of the code, change dimensions only in configureCell and create all UI elements only using new.
@wutschel
Copy link
Copy Markdown
Collaborator Author

Squashed and rebased to master.

@kambala-decapitator kambala-decapitator merged commit 08404e3 into xbmc:master Nov 11, 2025
1 check passed
@wutschel wutschel deleted the fix_settings branch November 11, 2025 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview of multiple selection options should list option names

2 participants