diff --git a/app/build.gradle.kts b/app/build.gradle.kts index eb8d1dbc3..a5eb60f98 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -34,7 +34,7 @@ android { minSdkVersion(AndroidConfig.minSdk) targetSdkVersion(AndroidConfig.targetSdk) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - versionCode = 15 + versionCode = 16 versionName = "1.6.1" buildConfigField("String", "COMMIT_COUNT", "\"${getCommitCount()}\"") diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index f2e050aca..9f3f2eeaf 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -141,6 +141,10 @@ object Migrations { } } } + if (oldVersion < 59) { + // Reset rotation to Free after replacing Lock + preferences.rotation().set(1) + } return true } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 0a44a5857..acd753465 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -473,8 +473,7 @@ class ReaderActivity : BaseRxActivity() setTooltip(R.string.pref_rotation_type) setOnClickListener { - val newOrientation = - OrientationType.getNextOrientation(preferences.rotation().get(), resources) + val newOrientation = OrientationType.getNextOrientation(preferences.rotation().get()) preferences.rotation().set(newOrientation.prefValue) setOrientation(newOrientation.flag) @@ -722,7 +721,7 @@ class ReaderActivity : BaseRxActivity() // EXH <-- /*private fun updateRotationShortcut(preference: Int) { - val orientation = OrientationType.fromPreference(preference, resources) + val orientation = OrientationType.fromPreference(preference) binding.actionRotation.setImageResource(orientation.iconRes) }*/ @@ -1182,7 +1181,7 @@ class ReaderActivity : BaseRxActivity() * Forces the user preferred [orientation] on the activity. */ private fun setOrientation(orientation: Int) { - val newOrientation = OrientationType.fromPreference(orientation, resources) + val newOrientation = OrientationType.fromPreference(orientation) if (newOrientation.flag != requestedOrientation) { requestedOrientation = newOrientation.flag } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt index f5f79027a..5f358a670 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/setting/OrientationType.kt @@ -1,8 +1,6 @@ package eu.kanade.tachiyomi.ui.reader.setting import android.content.pm.ActivityInfo -import android.content.res.Configuration -import android.content.res.Resources import androidx.annotation.DrawableRes import androidx.annotation.StringRes import eu.kanade.tachiyomi.R @@ -10,33 +8,18 @@ import eu.kanade.tachiyomi.util.lang.next enum class OrientationType(val prefValue: Int, val flag: Int, @StringRes val stringRes: Int, @DrawableRes val iconRes: Int) { FREE(1, ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED, R.string.rotation_free, R.drawable.ic_screen_rotation_24dp), - LOCKED_PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_lock, R.drawable.ic_screen_lock_rotation_24dp), - LOCKED_LANDSCAPE(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_lock, R.drawable.ic_screen_lock_rotation_24dp), - PORTRAIT(3, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp), - LANDSCAPE(4, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp); + PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_portrait, R.drawable.ic_stay_current_portrait_24dp), + LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp), + LOCKED_PORTRAIT(4, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp), + LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp), + ; companion object { - fun fromPreference(preference: Int, resources: Resources): OrientationType = when (preference) { - 2 -> { - val currentOrientation = resources.configuration.orientation - if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) { - LOCKED_PORTRAIT - } else { - LOCKED_LANDSCAPE - } - } - 3 -> PORTRAIT - 4 -> LANDSCAPE - else -> FREE - } + fun fromPreference(preference: Int): OrientationType = + values().find { it.prefValue == preference } ?: FREE - fun getNextOrientation(preference: Int, resources: Resources): OrientationType { - val current = if (preference == 2) { - // Avoid issue due to 2 types having the same prefValue - LOCKED_LANDSCAPE - } else { - fromPreference(preference, resources) - } + fun getNextOrientation(preference: Int): OrientationType { + val current = fromPreference(preference) return current.next() } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt index ffc99a348..b77c171ad 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/setting/SettingsReaderController.kt @@ -93,11 +93,12 @@ class SettingsReaderController : SettingsController() { titleRes = R.string.pref_rotation_type entriesRes = arrayOf( R.string.rotation_free, - R.string.rotation_lock, + R.string.rotation_portrait, + R.string.rotation_landscape, R.string.rotation_force_portrait, - R.string.rotation_force_landscape + R.string.rotation_force_landscape, ) - entryValues = arrayOf("1", "2", "3", "4") + entryValues = arrayOf("1", "2", "3", "4", "5") defaultValue = "1" summary = "%s" } diff --git a/app/src/main/java/exh/EXHMigrations.kt b/app/src/main/java/exh/EXHMigrations.kt index 53fc58c08..748e198cf 100644 --- a/app/src/main/java/exh/EXHMigrations.kt +++ b/app/src/main/java/exh/EXHMigrations.kt @@ -225,6 +225,10 @@ object EXHMigrations { } } } + if (oldVersion < 16) { + // Reset rotation to Free after replacing Lock + preferences.rotation().set(1) + } // if (oldVersion < 1) { } (1 is current release version) // do stuff here when releasing changed crap diff --git a/app/src/main/res/drawable/ic_stay_current_landscape_24dp.xml b/app/src/main/res/drawable/ic_stay_current_landscape_24dp.xml new file mode 100644 index 000000000..ac185cda4 --- /dev/null +++ b/app/src/main/res/drawable/ic_stay_current_landscape_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_stay_current_portrait_24dp.xml b/app/src/main/res/drawable/ic_stay_current_portrait_24dp.xml new file mode 100644 index 000000000..23e9f4f26 --- /dev/null +++ b/app/src/main/res/drawable/ic_stay_current_portrait_24dp.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 6212d19ed..9efa706fc 100755 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -66,7 +66,8 @@ @string/rotation_free - @string/rotation_lock + @string/rotation_portrait + @string/rotation_landscape @string/rotation_force_portrait @string/rotation_force_landscape @@ -76,6 +77,7 @@ 2 3 4 + 5 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 09c9f1b9b..ec917e877 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -332,9 +332,10 @@ Fast Rotation Free - Lock - Force portrait - Force landscape + Portrait + Landscape + Locked portrait + Locked landscape R G B