mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-31 14:27:57 +01:00 
			
		
		
		
	Make default category translatable (#5751)
* Make default category translatable * Replace duplicate strings with common one
This commit is contained in:
		| @@ -1,5 +1,7 @@ | ||||
| package eu.kanade.tachiyomi.data.database.models | ||||
|  | ||||
| import android.content.Context | ||||
| import eu.kanade.tachiyomi.R | ||||
| import eu.kanade.tachiyomi.ui.library.setting.DisplayModeSetting | ||||
| import eu.kanade.tachiyomi.ui.library.setting.SortDirectionSetting | ||||
| import eu.kanade.tachiyomi.ui.library.setting.SortModeSetting | ||||
| @@ -37,6 +39,6 @@ interface Category : Serializable { | ||||
|             this.name = name | ||||
|         } | ||||
|  | ||||
|         fun createDefault(): Category = create("Default").apply { id = 0 } | ||||
|         fun createDefault(context: Context): Category = create(context.getString(R.string.label_default)).apply { id = 0 } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -22,7 +22,7 @@ object PreferenceValues { | ||||
|     /* ktlint-enable experimental:enum-entry-name-case */ | ||||
|  | ||||
|     enum class AppTheme(val titleResId: Int?) { | ||||
|         DEFAULT(R.string.theme_default), | ||||
|         DEFAULT(R.string.label_default), | ||||
|         MONET(R.string.theme_monet), | ||||
|         BLUE(R.string.theme_blue), | ||||
|         GREEN_APPLE(R.string.theme_greenapple), | ||||
|   | ||||
| @@ -327,7 +327,7 @@ class LibraryPresenter( | ||||
|     private fun getLibraryObservable(): Observable<Library> { | ||||
|         return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) { dbCategories, libraryManga -> | ||||
|             val categories = if (libraryManga.containsKey(0)) { | ||||
|                 arrayListOf(Category.createDefault()) + dbCategories | ||||
|                 arrayListOf(Category.createDefault(context)) + dbCategories | ||||
|             } else { | ||||
|                 dbCategories | ||||
|             } | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import eu.kanade.tachiyomi.R | ||||
|  | ||||
| enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { | ||||
|     // TODO Default icon | ||||
|     DEFAULT(0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.default_rotation_type, R.drawable.ic_screen_rotation_24dp, 0x00000000), | ||||
|     DEFAULT(0, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.label_default, R.drawable.ic_screen_rotation_24dp, 0x00000000), | ||||
|     FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.rotation_free, R.drawable.ic_screen_rotation_24dp, 0x00000008), | ||||
|     PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_portrait, R.drawable.ic_stay_current_portrait_24dp, 0x00000010), | ||||
|     LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp, 0x00000018), | ||||
|   | ||||
| @@ -11,7 +11,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.VerticalPagerViewer | ||||
| import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonViewer | ||||
|  | ||||
| enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int, val flagValue: Int) { | ||||
|     DEFAULT(0, R.string.default_viewer, R.drawable.ic_reader_default_24dp, 0x00000000), | ||||
|     DEFAULT(0, R.string.label_default, R.drawable.ic_reader_default_24dp, 0x00000000), | ||||
|     LEFT_TO_RIGHT(1, R.string.left_to_right_viewer, R.drawable.ic_reader_ltr_24dp, 0x00000001), | ||||
|     RIGHT_TO_LEFT(2, R.string.right_to_left_viewer, R.drawable.ic_reader_rtl_24dp, 0x00000002), | ||||
|     VERTICAL(3, R.string.vertical_viewer, R.drawable.ic_reader_vertical_24dp, 0x00000003), | ||||
|   | ||||
| @@ -96,7 +96,7 @@ class SettingsDownloadController : SettingsController() { | ||||
|         } | ||||
|  | ||||
|         val dbCategories = db.getCategories().executeAsBlocking() | ||||
|         val categories = listOf(Category.createDefault()) + dbCategories | ||||
|         val categories = listOf(Category.createDefault(context)) + dbCategories | ||||
|  | ||||
|         preferenceCategory { | ||||
|             titleRes = R.string.pref_category_auto_download | ||||
| @@ -228,7 +228,7 @@ class SettingsDownloadController : SettingsController() { | ||||
|  | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             val dbCategories = db.getCategories().executeAsBlocking() | ||||
|             val categories = listOf(Category.createDefault()) + dbCategories | ||||
|             val categories = listOf(Category.createDefault(activity!!)) + dbCategories | ||||
|  | ||||
|             val items = categories.map { it.name } | ||||
|             var selected = categories | ||||
|   | ||||
| @@ -103,7 +103,7 @@ class SettingsGeneralController : SettingsController() { | ||||
|             entries = entryValues.map { value -> | ||||
|                 val formattedDate = preferences.dateFormat(value.toString()).format(now) | ||||
|                 if (value == "") { | ||||
|                     "${context.getString(R.string.system_default)} ($formattedDate)" | ||||
|                     "${context.getString(R.string.label_default)} ($formattedDate)" | ||||
|                 } else { | ||||
|                     "$value ($formattedDate)" | ||||
|                 } | ||||
|   | ||||
| @@ -51,7 +51,7 @@ class SettingsLibraryController : SettingsController() { | ||||
|         titleRes = R.string.pref_category_library | ||||
|  | ||||
|         val dbCategories = db.getCategories().executeAsBlocking() | ||||
|         val categories = listOf(Category.createDefault()) + dbCategories | ||||
|         val categories = listOf(Category.createDefault(context)) + dbCategories | ||||
|  | ||||
|         preferenceCategory { | ||||
|             titleRes = R.string.pref_category_display | ||||
| @@ -65,7 +65,7 @@ class SettingsLibraryController : SettingsController() { | ||||
|  | ||||
|                 fun getColumnValue(value: Int): String { | ||||
|                     return if (value == 0) { | ||||
|                         context.getString(R.string.default_columns) | ||||
|                         context.getString(R.string.label_default) | ||||
|                     } else { | ||||
|                         value.toString() | ||||
|                     } | ||||
| @@ -313,7 +313,7 @@ class SettingsLibraryController : SettingsController() { | ||||
|  | ||||
|         fun onViewCreated(binding: PrefLibraryColumnsBinding) { | ||||
|             with(binding.portraitColumns) { | ||||
|                 displayedValues = arrayOf(context.getString(R.string.default_columns)) + | ||||
|                 displayedValues = arrayOf(context.getString(R.string.label_default)) + | ||||
|                     IntRange(1, 10).map(Int::toString) | ||||
|                 value = portrait | ||||
|  | ||||
| @@ -322,7 +322,7 @@ class SettingsLibraryController : SettingsController() { | ||||
|                 } | ||||
|             } | ||||
|             with(binding.landscapeColumns) { | ||||
|                 displayedValues = arrayOf(context.getString(R.string.default_columns)) + | ||||
|                 displayedValues = arrayOf(context.getString(R.string.label_default)) + | ||||
|                     IntRange(1, 10).map(Int::toString) | ||||
|                 value = landscape | ||||
|  | ||||
| @@ -340,7 +340,7 @@ class SettingsLibraryController : SettingsController() { | ||||
|  | ||||
|         override fun onCreateDialog(savedViewState: Bundle?): Dialog { | ||||
|             val dbCategories = db.getCategories().executeAsBlocking() | ||||
|             val categories = listOf(Category.createDefault()) + dbCategories | ||||
|             val categories = listOf(Category.createDefault(activity!!)) + dbCategories | ||||
|  | ||||
|             val items = categories.map { it.name } | ||||
|             var selected = categories | ||||
|   | ||||
| @@ -122,5 +122,3 @@ fun Date.toRelativeString( | ||||
|         else -> dateFormat.format(this) | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user