mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-05 18:45:07 +01:00
Add crop borders shortcut
This commit is contained in:
parent
9daf0e78b8
commit
d501c02f8b
@ -36,6 +36,10 @@ operator fun <T> Preference<Set<T>>.minusAssign(item: T) {
|
||||
set(get() - item)
|
||||
}
|
||||
|
||||
fun Preference<Boolean>.toggle() {
|
||||
set(!get())
|
||||
}
|
||||
|
||||
class PreferencesHelper(val context: Context) {
|
||||
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
|
@ -34,6 +34,7 @@ import eu.kanade.tachiyomi.data.notification.NotificationReceiver
|
||||
import eu.kanade.tachiyomi.data.notification.Notifications
|
||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
import eu.kanade.tachiyomi.data.preference.asImmediateFlow
|
||||
import eu.kanade.tachiyomi.data.preference.toggle
|
||||
import eu.kanade.tachiyomi.databinding.ReaderActivityBinding
|
||||
import eu.kanade.tachiyomi.ui.base.activity.BaseRxActivity
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
@ -375,6 +376,19 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||
}
|
||||
.launchIn(lifecycleScope)
|
||||
|
||||
with(binding.actionCropBorders) {
|
||||
setTooltip(R.string.pref_crop_borders)
|
||||
|
||||
setOnClickListener {
|
||||
val isPagerType = ReadingModeType.isPagerType(presenter.getMangaViewer())
|
||||
if (isPagerType) {
|
||||
preferences.cropBorders().toggle()
|
||||
} else {
|
||||
preferences.cropBordersWebtoon().toggle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
with(binding.actionSettings) {
|
||||
setTooltip(R.string.action_settings)
|
||||
|
||||
|
@ -21,5 +21,10 @@ enum class ReadingModeType(val prefValue: Int, @StringRes val stringRes: Int, @D
|
||||
val current = fromPreference(preference)
|
||||
return current.next()
|
||||
}
|
||||
|
||||
fun isPagerType(preference: Int): Boolean {
|
||||
val mode = fromPreference(preference)
|
||||
return mode == LEFT_TO_RIGHT || mode == RIGHT_TO_LEFT || mode == VERTICAL
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
app/src/main/res/drawable/ic_crop_free_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_crop_free_24dp.xml
Normal file
@ -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="M3,5v4h2L5,5h4L9,3L5,3c-1.1,0 -2,0.9 -2,2zM5,15L3,15v4c0,1.1 0.9,2 2,2h4v-2L5,19v-4zM19,19h-4v2h4c1.1,0 2,-0.9 2,-2v-4h-2v4zM19,3h-4v2h4v4h2L21,5c0,-1.1 -0.9,-2 -2,-2z" />
|
||||
</vector>
|
@ -171,12 +171,25 @@
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/pref_rotation_type"
|
||||
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_settings"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_crop_borders"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_reader_mode"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_screen_rotation_24dp"
|
||||
app:tint="?attr/colorOnPrimary" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/action_crop_borders"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/pref_crop_borders"
|
||||
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
||||
app:layout_constraintEnd_toStartOf="@id/action_settings"
|
||||
app:layout_constraintStart_toEndOf="@+id/action_rotation"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_crop_free_24dp"
|
||||
app:tint="?attr/colorOnPrimary" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/action_settings"
|
||||
android:layout_width="wrap_content"
|
||||
@ -185,7 +198,7 @@
|
||||
android:contentDescription="@string/action_settings"
|
||||
android:padding="@dimen/material_layout_keylines_screen_edge_margin"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@id/action_rotation"
|
||||
app:layout_constraintStart_toEndOf="@id/action_crop_borders"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/ic_settings_24dp"
|
||||
app:tint="?attr/colorOnPrimary" />
|
||||
|
Loading…
Reference in New Issue
Block a user