-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
base: main
Are you sure you want to change the base?
Specific id that were int #18393
Conversation
There was a problem hiding this 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( |
There was a problem hiding this comment.
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 thaneditText.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
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
AnkiDroid/src/main/java/com/ichi2/anki/dialogs/CardBrowserMySearchesDialog.kt
Outdated
Show resolved
Hide resolved
/** | ||
* @param actionEnum - How the item should display. | ||
*/ | ||
enum class ShowAsAction( |
There was a problem hiding this comment.
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).
03252b6
to
7d5179e
Compare
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
7d5179e
to
da02fab
Compare
@JvmInline | ||
value class CardOrNoteId( | ||
val cardOrNoteId: Long, | ||
val cardOrNoteId: CardOrNoteIdUnderlyingType, |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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 |
This commit ensure some values that are ID being int or long get a more specific type when possible, for the sake of typesafety