mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:21:52 +01:00
Remove "Locked" orientation, replace with explicit orientations
Portrait/Landscape allow sensor, Locked Portrait/Landscape don't.
This commit is contained in:
parent
4cefbce7c3
commit
e8d8621f06
@ -139,6 +139,10 @@ object Migrations {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (oldVersion < 59) {
|
||||||
|
// Reset rotation to Free after replacing Lock
|
||||||
|
preferences.rotation().set(1)
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,8 +372,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|||||||
setTooltip(R.string.pref_rotation_type)
|
setTooltip(R.string.pref_rotation_type)
|
||||||
|
|
||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
val newOrientation =
|
val newOrientation = OrientationType.getNextOrientation(preferences.rotation().get())
|
||||||
OrientationType.getNextOrientation(preferences.rotation().get(), resources)
|
|
||||||
|
|
||||||
preferences.rotation().set(newOrientation.prefValue)
|
preferences.rotation().set(newOrientation.prefValue)
|
||||||
setOrientation(newOrientation.flag)
|
setOrientation(newOrientation.flag)
|
||||||
@ -422,7 +421,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun updateRotationShortcut(preference: Int) {
|
private fun updateRotationShortcut(preference: Int) {
|
||||||
val orientation = OrientationType.fromPreference(preference, resources)
|
val orientation = OrientationType.fromPreference(preference)
|
||||||
binding.actionRotation.setImageResource(orientation.iconRes)
|
binding.actionRotation.setImageResource(orientation.iconRes)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +767,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
|||||||
* Forces the user preferred [orientation] on the activity.
|
* Forces the user preferred [orientation] on the activity.
|
||||||
*/
|
*/
|
||||||
private fun setOrientation(orientation: Int) {
|
private fun setOrientation(orientation: Int) {
|
||||||
val newOrientation = OrientationType.fromPreference(orientation, resources)
|
val newOrientation = OrientationType.fromPreference(orientation)
|
||||||
if (newOrientation.flag != requestedOrientation) {
|
if (newOrientation.flag != requestedOrientation) {
|
||||||
requestedOrientation = newOrientation.flag
|
requestedOrientation = newOrientation.flag
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package eu.kanade.tachiyomi.ui.reader.setting
|
package eu.kanade.tachiyomi.ui.reader.setting
|
||||||
|
|
||||||
import android.content.pm.ActivityInfo
|
import android.content.pm.ActivityInfo
|
||||||
import android.content.res.Configuration
|
|
||||||
import android.content.res.Resources
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
import eu.kanade.tachiyomi.R
|
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) {
|
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),
|
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),
|
PORTRAIT(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT, R.string.rotation_portrait, R.drawable.ic_stay_current_portrait_24dp),
|
||||||
LOCKED_LANDSCAPE(2, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_lock, R.drawable.ic_screen_lock_rotation_24dp),
|
LANDSCAPE(3, ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE, R.string.rotation_landscape, R.drawable.ic_stay_current_landscape_24dp),
|
||||||
PORTRAIT(3, ActivityInfo.SCREEN_ORIENTATION_PORTRAIT, R.string.rotation_force_portrait, R.drawable.ic_screen_lock_portrait_24dp),
|
LOCKED_PORTRAIT(4, 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);
|
LOCKED_LANDSCAPE(5, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE, R.string.rotation_force_landscape, R.drawable.ic_screen_lock_landscape_24dp),
|
||||||
|
;
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun fromPreference(preference: Int, resources: Resources): OrientationType = when (preference) {
|
fun fromPreference(preference: Int): OrientationType =
|
||||||
2 -> {
|
values().find { it.prefValue == preference } ?: FREE
|
||||||
val currentOrientation = resources.configuration.orientation
|
|
||||||
if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
|
|
||||||
LOCKED_PORTRAIT
|
|
||||||
} else {
|
|
||||||
LOCKED_LANDSCAPE
|
|
||||||
}
|
|
||||||
}
|
|
||||||
3 -> PORTRAIT
|
|
||||||
4 -> LANDSCAPE
|
|
||||||
else -> FREE
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getNextOrientation(preference: Int, resources: Resources): OrientationType {
|
fun getNextOrientation(preference: Int): OrientationType {
|
||||||
val current = if (preference == 2) {
|
val current = fromPreference(preference)
|
||||||
// Avoid issue due to 2 types having the same prefValue
|
|
||||||
LOCKED_LANDSCAPE
|
|
||||||
} else {
|
|
||||||
fromPreference(preference, resources)
|
|
||||||
}
|
|
||||||
return current.next()
|
return current.next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,11 +78,12 @@ class SettingsReaderController : SettingsController() {
|
|||||||
titleRes = R.string.pref_rotation_type
|
titleRes = R.string.pref_rotation_type
|
||||||
entriesRes = arrayOf(
|
entriesRes = arrayOf(
|
||||||
R.string.rotation_free,
|
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_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"
|
defaultValue = "1"
|
||||||
summary = "%s"
|
summary = "%s"
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M1.01,7L1,17c0,1.1 0.9,2 2,2h18c1.1,0 2,-0.9 2,-2V7c0,-1.1 -0.9,-2 -2,-2H3c-1.1,0 -1.99,0.9 -1.99,2zM19,7v10H5V7h14z" />
|
||||||
|
</vector>
|
@ -0,0 +1,9 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/black"
|
||||||
|
android:pathData="M17,1.01L7,1c-1.1,0 -1.99,0.9 -1.99,2v18c0,1.1 0.89,2 1.99,2h10c1.1,0 2,-0.9 2,-2V3c0,-1.1 -0.9,-1.99 -2,-1.99zM17,19H7V5h10v14z" />
|
||||||
|
</vector>
|
@ -62,7 +62,8 @@
|
|||||||
|
|
||||||
<string-array name="rotation_type">
|
<string-array name="rotation_type">
|
||||||
<item>@string/rotation_free</item>
|
<item>@string/rotation_free</item>
|
||||||
<item>@string/rotation_lock</item>
|
<item>@string/rotation_portrait</item>
|
||||||
|
<item>@string/rotation_landscape</item>
|
||||||
<item>@string/rotation_force_portrait</item>
|
<item>@string/rotation_force_portrait</item>
|
||||||
<item>@string/rotation_force_landscape</item>
|
<item>@string/rotation_force_landscape</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
@ -72,6 +73,7 @@
|
|||||||
<item>2</item>
|
<item>2</item>
|
||||||
<item>3</item>
|
<item>3</item>
|
||||||
<item>4</item>
|
<item>4</item>
|
||||||
|
<item>5</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="color_filter_modes">
|
<string-array name="color_filter_modes">
|
||||||
|
@ -332,9 +332,10 @@
|
|||||||
<string name="double_tap_anim_speed_fast">Fast</string>
|
<string name="double_tap_anim_speed_fast">Fast</string>
|
||||||
<string name="pref_rotation_type">Rotation</string>
|
<string name="pref_rotation_type">Rotation</string>
|
||||||
<string name="rotation_free">Free</string>
|
<string name="rotation_free">Free</string>
|
||||||
<string name="rotation_lock">Lock</string>
|
<string name="rotation_portrait">Portrait</string>
|
||||||
<string name="rotation_force_portrait">Force portrait</string>
|
<string name="rotation_landscape">Landscape</string>
|
||||||
<string name="rotation_force_landscape">Force landscape</string>
|
<string name="rotation_force_portrait">Locked portrait</string>
|
||||||
|
<string name="rotation_force_landscape">Locked landscape</string>
|
||||||
<string name="color_filter_r_value">R</string>
|
<string name="color_filter_r_value">R</string>
|
||||||
<string name="color_filter_g_value">G</string>
|
<string name="color_filter_g_value">G</string>
|
||||||
<string name="color_filter_b_value">B</string>
|
<string name="color_filter_b_value">B</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user