@@ -105,6 +105,7 @@ object UsageAnalytics {
105105 optIn = newValue
106106 }
107107 }
108+ initializePrefKeys(context)
108109 return sAnalytics
109110 }
110111
@@ -469,153 +470,162 @@ object UsageAnalytics {
469470 val CHANGED_SETTING = " Changed setting"
470471 }
471472
472- // TODO use some kind of constants instead of hardcoded strings
473- @Suppress(" ktlint:standard:discouraged-comment-location" ) // lots of work for little gain
474- val preferencesWhoseChangesShouldBeReported =
473+ @VisibleForTesting
474+ val reportablePrefKeys =
475475 setOf (
476476 // ******************************** General ************************************************
477- " reportErrorMode " , // Error reporting mode
478- " pastePNG " , // Paste clipboard images as PNG
479- " useCurrent " , // Deck for new cards
480- " exitViaDoubleTapBack " , // Press back twice to go back/exit
481- " anki_card_enable_external_context_menu " , // ‘Anki Card’ Menu
482- " card_browser_enable_external_context_menu " , // ‘Card Browser’ Menu
477+ R .string.error_reporting_mode_key , // Error reporting mode
478+ R .string.paste_png_key , // Paste clipboard images as PNG
479+ R .string.deck_for_new_cards_key , // Deck for new cards
480+ R .string.exit_via_double_tap_back_key , // Press back twice to go back/exit
481+ R .string.anki_card_external_context_menu_key , // ‘Anki Card’ Menu
482+ R .string.card_browser_external_context_menu_key , // ‘Card Browser’ Menu
483483 // ******************************** Reviewing **********************************************
484- " dayOffset " , // Start of next day
485- " learnCutoff " , // Learn ahead limit
486- " timeLimit " , // Timebox time limit
487- " keepScreenOn " , // Disable screen timeout
488- " doubleTapTimeInterval " , // Double tap time interval (milliseconds)
484+ R .string.day_offset_preference , // Start of next day
485+ R .string.learn_cutoff_preference , // Learn ahead limit
486+ R .string.time_limit_preference , // Timebox time limit
487+ R .string.keep_screen_on_preference , // Disable screen timeout
488+ R .string.double_tap_time_interval_preference , // Double tap time interval (milliseconds)
489489 // ******************************** Sync ***************************************************
490- " syncFetchMedia " , // Fetch media on sync
491- " automaticSyncMode " , // Automatic synchronization
492- " showSyncStatusBadge " , // Display synchronization status
493- " allowMetered " , // Allow sync on metered connections
494- " one_way_sync " , // One-way sync
490+ R .string.sync_fetch_media_key , // Fetch media on sync
491+ R .string.automatic_sync_choice_key , // Automatic synchronization
492+ R .string.sync_status_badge_key , // Display synchronization status
493+ R .string.metered_sync_key , // Allow sync on metered connections
494+ R .string.one_way_sync_key , // One-way sync
495495 // ******************************** Backup *************************************************
496- " minutes_between_automatic_backups " ,
497- " daily_backups_to_keep " ,
498- " weekly_backups_to_keep " ,
499- " monthly_backups_to_keep " ,
496+ R .string.pref_minutes_between_automatic_backups_key ,
497+ R .string.pref_daily_backups_to_keep_key ,
498+ R .string.pref_weekly_backups_to_keep_key ,
499+ R .string.pref_monthly_backups_to_keep_key ,
500500 // ******************************** Appearance *********************************************
501- " appTheme " , // Theme
502- " dayTheme " , // Day theme
503- " nightTheme " , // Night theme
504- " deckPickerBackground " , // Background image
505- " fullscreenMode " , // Fullscreen mode
506- " centerVertically " , // Center align
507- " showEstimates " , // Show button time
508- " answerButtonPosition " , // Answer buttons position
509- " showTopbar " , // Show top bar
510- " showProgress " , // Show remaining
511- " showETA " , // Show ETA
512- " showAudioPlayButtons " , // Show play buttons on cards with audio (reversed in collection: HIDE_AUDIO_PLAY_BUTTONS)
513- " card_browser_show_media_filenames " , // Display filenames in card browser
514- " showDeckTitle " , // Show deck title
501+ R .string.app_theme_key , // Theme
502+ R .string.day_theme_key , // Day theme
503+ R .string.night_theme_key , // Night theme
504+ R .string.pref_deck_picker_background_key , // Background image
505+ R .string.fullscreen_mode_preference , // Fullscreen mode
506+ R .string.center_vertically_preference , // Center align
507+ R .string.show_estimates_preference , // Show button time
508+ R .string.answer_buttons_position_preference , // Answer buttons position
509+ R .string.show_topbar_preference , // Show top bar
510+ R .string.show_progress_preference , // Show remaining
511+ R .string.show_eta_preference , // Show ETA
512+ R .string.show_audio_play_buttons_key , // Show play buttons on cards with audio (reversed in collection: HIDE_AUDIO_PLAY_BUTTONS)
513+ R .string.pref_display_filenames_in_browser_key , // Display filenames in card browser
514+ R .string.show_deck_title_key , // Show deck title
515515 // ******************************** Controls *********************************************
516- " gestures " , // Enable gestures
517- " gestureCornerTouch " , // 9-point touch
518- " gestureFullScreenNavigationDrawer " , // Full screen navigation drawer
519- " swipeSensitivity " , // Swipe sensitivity
520- " binding_SHOW_ANSWER " ,
521- " binding_FLIP_OR_ANSWER_EASE1 " ,
522- " binding_FLIP_OR_ANSWER_EASE2 " ,
523- " binding_FLIP_OR_ANSWER_EASE3 " ,
524- " binding_FLIP_OR_ANSWER_EASE4 " ,
525- " binding_UNDO " ,
526- " binding_REDO " ,
527- " binding_EDIT " ,
528- " binding_MARK " ,
529- " binding_BURY_CARD " ,
530- " binding_SUSPEND_CARD " ,
531- " binding_DELETE " ,
532- " binding_PLAY_MEDIA " ,
533- " binding_EXIT " ,
534- " binding_BURY_NOTE " ,
535- " binding_SUSPEND_NOTE " ,
536- " binding_TOGGLE_FLAG_RED " ,
537- " binding_TOGGLE_FLAG_ORANGE " ,
538- " binding_TOGGLE_FLAG_GREEN " ,
539- " binding_TOGGLE_FLAG_BLUE " ,
540- " binding_TOGGLE_FLAG_PINK " ,
541- " binding_TOGGLE_FLAG_TURQUOISE " ,
542- " binding_TOGGLE_FLAG_PURPLE " ,
543- " binding_UNSET_FLAG " ,
544- " binding_PAGE_UP " ,
545- " binding_PAGE_DOWN " ,
546- " binding_TAG " ,
547- " binding_CARD_INFO " ,
548- " binding_ABORT_AND_SYNC " ,
549- " binding_RECORD_VOICE " ,
550- " binding_REPLAY_VOICE " ,
551- " binding_SAVE_VOICE " ,
552- " binding_TOGGLE_WHITEBOARD " ,
553- " binding_CLEAR_WHITEBOARD " ,
554- " binding_CHANGE_WHITEBOARD_PEN_COLOR " ,
555- " binding_TOGGLE_AUTO_ADVANCE " ,
556- " binding_SHOW_HINT " ,
557- " binding_SHOW_ALL_HINTS " ,
558- " binding_ADD_NOTE " ,
559- " binding_RESCHEDULE_NOTE " ,
560- " binding_USER_ACTION_1 " ,
561- " binding_USER_ACTION_2 " ,
562- " binding_USER_ACTION_3 " ,
563- " binding_USER_ACTION_4 " ,
564- " binding_USER_ACTION_5 " ,
565- " binding_USER_ACTION_6 " ,
566- " binding_USER_ACTION_7 " ,
567- " binding_USER_ACTION_8 " ,
568- " binding_USER_ACTION_9 " ,
516+ R .string.gestures_preference , // Enable gestures
517+ R .string.gestures_corner_touch_preference , // 9-point touch
518+ R .string.nav_drawer_gesture_key , // Full screen navigation drawer
519+ R .string.pref_swipe_sensitivity_key , // Swipe sensitivity
520+ R .string.show_answer_command_key ,
521+ R .string.answer_again_command_key ,
522+ R .string.answer_hard_command_key ,
523+ R .string.answer_good_command_key ,
524+ R .string.answer_easy_command_key ,
525+ R .string.undo_command_key ,
526+ R .string.redo_command_key ,
527+ R .string.edit_command_key ,
528+ R .string.mark_command_key ,
529+ R .string.bury_card_command_key ,
530+ R .string.suspend_card_command_key ,
531+ R .string.delete_command_key ,
532+ R .string.play_media_command_key ,
533+ R .string.abort_command_key ,
534+ R .string.bury_note_command_key ,
535+ R .string.suspend_note_command_key ,
536+ R .string.flag_red_command_key ,
537+ R .string.flag_orange_command_key ,
538+ R .string.flag_green_command_key ,
539+ R .string.flag_blue_command_key ,
540+ R .string.flag_pink_command_key ,
541+ R .string.flag_turquoise_command_key ,
542+ R .string.flag_purple_command_key ,
543+ R .string.remove_flag_command_key ,
544+ R .string.page_up_command_key ,
545+ R .string.page_down_command_key ,
546+ R .string.tag_command_key ,
547+ R .string.card_info_command_key ,
548+ R .string.abort_and_sync_command_key ,
549+ R .string.record_voice_command_key ,
550+ R .string.replay_voice_command_key ,
551+ R .string.save_voice_command_key ,
552+ R .string.toggle_whiteboard_command_key ,
553+ R .string.clear_whiteboard_command_key ,
554+ R .string.change_whiteboard_pen_color_command_key ,
555+ R .string.toggle_auto_advance_command_key ,
556+ R .string.show_hint_command_key ,
557+ R .string.show_all_hints_command_key ,
558+ R .string.add_note_command_key ,
559+ R .string.reschedule_command_key ,
560+ R .string.user_action_1_key ,
561+ R .string.user_action_2_key ,
562+ R .string.user_action_3_key ,
563+ R .string.user_action_4_key ,
564+ R .string.user_action_5_key ,
565+ R .string.user_action_6_key ,
566+ R .string.user_action_7_key ,
567+ R .string.user_action_8_key ,
568+ R .string.user_action_9_key ,
569569 // ******************************** Accessibility ******************************************
570- " cardZoom " ,
571- " imageZoom " ,
572- " answerButtonSize " ,
573- " showLargeAnswerButtons " ,
574- " relativeCardBrowserFontSize " ,
575- " showCardAnswerButtonTime " ,
570+ R .string.card_zoom_preference ,
571+ R .string.image_zoom_preference ,
572+ R .string.answer_button_size_preference ,
573+ R .string.show_large_answer_buttons_preference ,
574+ R .string.pref_card_browser_font_scale_key ,
575+ R .string.pref_card_minimal_click_time ,
576576 // ******************************** Advanced ***********************************************
577- " deckPath " , // AnkiDroid directory
578- " double_scrolling " , // Double scrolling
579- " softwareRender " , // Disable card hardware render
580- " safeDisplay " , // Safe display mode
581- " useInputTag " , // Type answer into the card
582- " disableExtendedTextUi " , // Disable Single-Field Edit Mode
583- " noteEditorNewlineReplace " , // Replace newlines with HTML
584- " autoFocusTypeInAnswer " , // Focus ‘type in answer’
585- " mediaImportAllowAllFiles " , // Allow all files in media imports
586- " providerEnabled " , // Enable AnkiDroid API
577+ R .string.pref_ankidroid_directory_key , // AnkiDroid directory
578+ R .string.double_scrolling_gap_key , // Double scrolling
579+ R .string.disable_hardware_render_key , // Disable card hardware render
580+ R .string.safe_display_key , // Safe display mode
581+ R .string.use_input_tag_key , // Type answer into the card
582+ R .string.disable_single_field_edit_key , // Disable Single-Field Edit Mode
583+ R .string.note_editor_newline_replace_key , // Replace newlines with HTML
584+ R .string.type_in_answer_focus_key , // Focus ‘type in answer’
585+ R .string.media_import_allow_all_files_key , // Allow all files in media imports
586+ R .string.enable_api_key , // Enable AnkiDroid API
587587 // ******************************** App bar buttons ****************************************
588- " reset_custom_buttons " ,
589- " customButtonUndo " ,
590- " customButtonRedo " ,
591- " customButtonScheduleCard " ,
592- " customButtonFlag " ,
593- " customButtonEditCard " ,
594- " customButtonTags " ,
595- " customButtonAddCard " ,
596- " customButtonReplay " ,
597- " customButtonCardInfo " ,
598- " customButtonSelectTts " ,
599- " customButtonDeckOptions " ,
600- " customButtonMarkCard " ,
601- " customButtonToggleMicToolBar " ,
602- " customButtonBury " ,
603- " customButtonSuspend " ,
604- " customButtonDelete " ,
605- " customButtonEnableWhiteboard " ,
606- " customButtonToggleStylus " ,
607- " customButtonSaveWhiteboard " ,
608- " customButtonWhiteboardPenColor " ,
609- " customButtonShowHideWhiteboard " ,
610- " customButtonClearWhiteboard " ,
611- " customButtonUserAction1 " ,
612- " customButtonUserAction2 " ,
613- " customButtonUserAction3 " ,
614- " customButtonUserAction4 " ,
615- " customButtonUserAction5 " ,
616- " customButtonUserAction6 " ,
617- " customButtonUserAction7 " ,
618- " customButtonUserAction8 " ,
619- " customButtonUserAction9 " ,
588+ R .string.reset_custom_buttons_key ,
589+ R .string.custom_button_undo_key ,
590+ R .string.custom_button_redo_key ,
591+ R .string.custom_button_schedule_card_key ,
592+ R .string.custom_button_flag_key ,
593+ R .string.custom_button_edit_card_key ,
594+ R .string.custom_button_tags_key ,
595+ R .string.custom_button_add_card_key ,
596+ R .string.custom_button_replay_key ,
597+ R .string.custom_button_card_info_key ,
598+ R .string.custom_button_select_tts_key ,
599+ R .string.custom_button_deck_options_key ,
600+ R .string.custom_button_mark_card_key ,
601+ R .string.custom_button_toggle_mic_toolbar_key ,
602+ R .string.custom_button_bury_key ,
603+ R .string.custom_button_suspend_key ,
604+ R .string.custom_button_delete_key ,
605+ R .string.custom_button_enable_whiteboard_key ,
606+ R .string.custom_button_toggle_stylus_key ,
607+ R .string.custom_button_save_whiteboard_key ,
608+ R .string.custom_button_whiteboard_pen_color_key ,
609+ R .string.custom_button_show_hide_whiteboard_key ,
610+ R .string.custom_button_clear_whiteboard_key ,
611+ R .string.custom_button_user_action_1_key ,
612+ R .string.custom_button_user_action_2_key ,
613+ R .string.custom_button_user_action_3_key ,
614+ R .string.custom_button_user_action_4_key ,
615+ R .string.custom_button_user_action_5_key ,
616+ R .string.custom_button_user_action_6_key ,
617+ R .string.custom_button_user_action_7_key ,
618+ R .string.custom_button_user_action_8_key ,
619+ R .string.custom_button_user_action_9_key ,
620620 )
621+
622+ lateinit var preferencesWhoseChangesShouldBeReported: Set <String >
623+
624+ @Suppress(" ktlint:standard:discouraged-comment-location" ) // lots of work for little gain
625+ private fun initializePrefKeys (context : Context ) {
626+ preferencesWhoseChangesShouldBeReported =
627+ reportablePrefKeys.mapTo(mutableSetOf ()) { resId ->
628+ context.getString(resId)
629+ }
630+ }
621631}
0 commit comments