Skip to content

Specific id that were int #18393

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Arthur-Milchior
Copy link
Member

This commit ensure some values that are ID being int or long get a more specific type when possible, for the sake of typesafety

Copy link
Member

@lukstbit lukstbit left a comment

Choose a reason for hiding this comment

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

Tests are broken...

/**
* @param inputType an [InputType]
*/
enum class AlertType(
Copy link
Member

Choose a reason for hiding this comment

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

Nope, I'm not ok with this change:

  • the input types are well known by anyone that has work even a bit with the Android EditText and it makes no sense to replace them with an enum just for type safety
  • the name is strange and a bit unrelated
  • at the call site, editText.inputType = InputType.TYPE_CLASS_NUMBER is better than editText.inputType = AlertType.Number.inputType
  • this class was intended just as a thin layer over AlertDialog, there's no need to introduce this kind of customization IMO

Copy link
Member

@david-allison david-allison Jun 3, 2025

Choose a reason for hiding this comment

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

I'd be happy with removing AlertDialogFacade

The point was to make a transition away from afollestad.material-dialogs easier, which we've accomplished.

I personally still like the class, but the consensus was to remove it

@@ -107,23 +107,36 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() {
}
}

enum class CardBrowserMySearches(
Copy link
Member

Choose a reason for hiding this comment

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

As it's scoped to CardBrowserMySearchesDialog already I would use the name: SavedSearchesType.

/**
* @param actionEnum - How the item should display.
*/
enum class ShowAsAction(
Copy link
Member

Choose a reason for hiding this comment

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

This change doesn't look too valuable as the enum is used only in this class. And outside isn't valuable as well because it has one item that doesn't correspond to Android behavior(so it's no a perfect model).

@lukstbit lukstbit added the Needs Author Reply Waiting for a reply from the original author label May 30, 2025
@Arthur-Milchior Arthur-Milchior removed Needs Author Reply Waiting for a reply from the original author Has Conflicts labels Jun 15, 2025
This makes clearer what the type is.
Sadly, this can't be done everywhere when the Int is a Android enum
encoded as an interface
@david-allison david-allison added Needs Review Needs Author Reply Waiting for a reply from the original author and removed Needs Review labels Jun 17, 2025
@JvmInline
value class CardOrNoteId(
val cardOrNoteId: Long,
val cardOrNoteId: CardOrNoteIdUnderlyingType,
Copy link
Member

Choose a reason for hiding this comment

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

revert - no purpose

val type = requireArguments().getInt("type")
if (type == CARD_BROWSER_MY_SEARCHES_TYPE_LIST) {
savedFilters = requireArguments().getSerializableCompat("savedFilters")
val type = SavedSearchesType.fromCode(requireArguments().getInt(SAVED_TYPE_KEY))
Copy link
Member

Choose a reason for hiding this comment

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

Why not serialise/deserialise the enum directly?

@@ -18,6 +18,8 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import kotlinx.parcelize.Parcelize

typealias HelpItemId = Long
Copy link
Member

Choose a reason for hiding this comment

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

make it private, I don't think it serves much purpose

@@ -183,9 +183,9 @@ class TagsDialog : AnalyticsDialogFragment {
}
check(0)
}
selectedOption = radioButtonIdToCardState(optionsGroup.checkedRadioButtonId)
selectedOption = CardStateFilter.fromCode(optionsGroup.checkedRadioButtonId)
Copy link
Member

Choose a reason for hiding this comment

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

Revert - we should remove this functionality

@@ -122,7 +124,7 @@ class ImageOcclusion : PageFragment(R.layout.image_occlusion) {
fun getIntent(
context: Context,
kind: String,
noteOrNotetypeId: Long,
noteOrNotetypeId: NoteOrNoteTypeId,
Copy link
Member

Choose a reason for hiding this comment

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

revert? Or Document, or strongly type as a union

@@ -42,6 +42,8 @@ import com.ichi2.widget.setRecurringAlarm
import kotlinx.coroutines.launch
import timber.log.Timber

typealias AppWidgetId = Int
Copy link
Member

Choose a reason for hiding this comment

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

make this a value class

Copy link
Contributor

github-actions bot commented Jul 6, 2025

Hello 👋, this PR has had no activity for more than 2 weeks and needs a reply from the author. If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing! You have 7 days until this gets closed automatically

@github-actions github-actions bot added the Stale label Jul 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Has Conflicts Needs Author Reply Waiting for a reply from the original author Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants