Skip to content

Convert newpipe/util/FilenameUtils.java to kotlin#12944

Closed
ghost wants to merge 1 commit intorefactorfrom
unknown repository
Closed

Convert newpipe/util/FilenameUtils.java to kotlin#12944
ghost wants to merge 1 commit intorefactorfrom
unknown repository

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Dec 26, 2025

What is it?

  • Bugfix (user facing)
  • Feature (user facing) ⚠️ Your PR must target the refactor branch
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

  • Converted to kotlin
  • Simplified if-else statements to when
  • Simplified handling of default value for selectedCharset
  • Removed unnecessary (thanks to kotlin) string conversion to patterrn

APK testing

The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration on this wiki page.

Due diligence

@github-actions github-actions Bot added the size/medium PRs with less than 250 changed lines label Dec 26, 2025
@ghost ghost force-pushed the kotlin_refactor3 branch from 5a9dbd0 to df69ddb Compare December 26, 2025 00:16
Comment thread app/src/main/java/org/schabi/newpipe/util/FilenameUtils.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/util/FilenameUtils.kt Outdated
Comment thread app/src/main/java/org/schabi/newpipe/util/FilenameUtils.kt Outdated
)!!
val selectedCharset = sharedPreferences.getString(
context.getString(R.string.settings_file_charset_key), ""
)!!.ifEmpty { defaultCharset }
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It should be okay to work with null values here as when will fallback to selectedCharsed in next line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  1. The same thing here. You can't omit second argument
  2. ifEmpty also catches situation whencontext.getString(R.string.settings_file_charset_key) is empty string not because it is not defined but because it is what was retrieved. That's how it was in original and that is what I preserved. I am not 100% sure that it can happen but if it happens the behavior (at least in this case) should be unchanged

Co-authored-by: Aayush Gupta <aayushgupta219@gmail.com>
@ghost ghost force-pushed the kotlin_refactor3 branch from df69ddb to 2afebb1 Compare December 28, 2025 16:45
@ghost ghost requested a review from theimpulson December 28, 2025 16:48
@ghost ghost closed this Dec 31, 2025
@ghost ghost deleted the kotlin_refactor3 branch January 7, 2026 18:53
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/medium PRs with less than 250 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant