-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,9 +40,9 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() { | |
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | ||
super.onCreate(savedInstanceState) | ||
val dialog = AlertDialog.Builder(requireActivity()) | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. Why not serialise/deserialise the enum directly? |
||
if (type == SavedSearchesType.List) { | ||
savedFilters = requireArguments().getSerializableCompat(SAVED_FILTER_KEY) | ||
|
||
savedFilters?.let { | ||
savedFilterKeys = ArrayList(it.keys) | ||
|
@@ -66,8 +66,8 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() { | |
.title(text = resources.getString(R.string.card_browser_list_my_searches_title)) | ||
.customListAdapterWithDecoration(this, requireActivity()) | ||
} | ||
} else if (type == CARD_BROWSER_MY_SEARCHES_TYPE_SAVE) { | ||
val currentSearchTerms = requireArguments().getString("currentSearchTerms") | ||
} else if (type == SavedSearchesType.Save) { | ||
val currentSearchTerms = requireArguments().getString(SAVED_CURRENT_SEARCH_TERMS_KEY) | ||
return dialog | ||
.show { | ||
title(text = getString(R.string.card_browser_list_my_searches_save)) | ||
|
@@ -107,23 +107,36 @@ class CardBrowserMySearchesDialog : AnalyticsDialogFragment() { | |
} | ||
} | ||
|
||
enum class SavedSearchesType( | ||
val code: Int, | ||
) { | ||
List(0), | ||
Save(1), | ||
; | ||
|
||
companion object { | ||
fun fromCode(c: Int) = SavedSearchesType.entries.first { it.code == c } | ||
} | ||
} | ||
|
||
companion object { | ||
const val CARD_BROWSER_MY_SEARCHES_TYPE_LIST = 0 // list searches dialog | ||
const val CARD_BROWSER_MY_SEARCHES_TYPE_SAVE = 1 // save searches dialog | ||
const val SAVED_FILTER_KEY = "savedFilters" | ||
const val SAVED_TYPE_KEY = "type" | ||
const val SAVED_CURRENT_SEARCH_TERMS_KEY = "currentSearchTerms" | ||
private var mySearchesDialogListener: MySearchesDialogListener? = null | ||
|
||
fun newInstance( | ||
savedFilters: Map<String, String>?, | ||
mySearchesDialogListener: MySearchesDialogListener?, | ||
currentSearchTerms: String?, | ||
type: Int, | ||
type: SavedSearchesType, | ||
): CardBrowserMySearchesDialog { | ||
this.mySearchesDialogListener = mySearchesDialogListener | ||
val cardBrowserMySearchesDialog = CardBrowserMySearchesDialog() | ||
val args = Bundle() | ||
args.putSerializable("savedFilters", savedFilters?.let(::HashMap)) | ||
args.putInt("type", type) | ||
args.putString("currentSearchTerms", currentSearchTerms) | ||
args.putSerializable(SAVED_FILTER_KEY, savedFilters?.let(::HashMap)) | ||
args.putInt(SAVED_TYPE_KEY, type.code) | ||
args.putString(SAVED_CURRENT_SEARCH_TERMS_KEY, currentSearchTerms) | ||
cardBrowserMySearchesDialog.arguments = args | ||
return cardBrowserMySearchesDialog | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. make it private, I don't think it serves much purpose |
||
|
||
/** | ||
* A class containing all the information required to show an entry in the application help/support | ||
* menus. | ||
|
@@ -36,12 +38,12 @@ data class HelpItem( | |
/** | ||
* Unique(per menu) identifier for this menu item. | ||
*/ | ||
val id: Long, | ||
val id: HelpItemId, | ||
/** | ||
* If not null this property indicates that this menu item belongs to the submenu of the | ||
* referenced menu item. | ||
*/ | ||
val parentId: Long? = null, | ||
val parentId: HelpItemId? = null, | ||
/** | ||
* Reference to the action that needs to be done when the user selects this menu item. Can be | ||
* null, in which case this is a top level item(with or without children). | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Revert - we should remove this functionality |
||
optionsGroup.setOnCheckedChangeListener { _: RadioGroup?, checkedId: Int -> | ||
selectedOption = radioButtonIdToCardState(checkedId) | ||
selectedOption = CardStateFilter.fromCode(checkedId) | ||
} | ||
|
||
adjustToolbar(view) | ||
|
@@ -268,17 +268,6 @@ class TagsDialog : AnalyticsDialogFragment { | |
dialog?.window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM) | ||
} | ||
|
||
private fun radioButtonIdToCardState(id: Int) = | ||
when (id) { | ||
0 -> CardStateFilter.ALL_CARDS | ||
1 -> CardStateFilter.NEW | ||
2 -> CardStateFilter.DUE | ||
else -> { | ||
Timber.w("unexpected value: %d", id) | ||
CardStateFilter.ALL_CARDS | ||
} | ||
} | ||
|
||
private fun adjustToolbar(tagsDialogView: View) { | ||
val toolbar: Toolbar = tagsDialogView.findViewById(R.id.tags_dialog_toolbar) | ||
val titleRes = if (type == DialogType.EDIT_TAGS) R.string.card_details_tags else R.string.studyoptions_limit_select_tags | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,8 @@ import kotlinx.coroutines.launch | |
import org.json.JSONObject | ||
import timber.log.Timber | ||
|
||
internal typealias NoteOrNoteTypeId = Long | ||
|
||
class ImageOcclusion : PageFragment(R.layout.image_occlusion) { | ||
override fun onViewCreated( | ||
view: View, | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. revert? Or Document, or strongly type as a union |
||
imagePath: String?, | ||
editorWorkingDeckId: DeckId, | ||
): Intent { | ||
|
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