Explorar o código

Add crop borders functionality, #219

len %!s(int64=8) %!d(string=hai) anos
pai
achega
91c58640a7

+ 1 - 1
app/build.gradle

@@ -98,7 +98,7 @@ android {
 dependencies {
 
     // Modified dependencies
-    compile 'com.github.inorichi:subsampling-scale-image-view:44aa442'
+    compile 'com.github.inorichi:subsampling-scale-image-view:9048f23'
     compile 'com.github.inorichi:junrar-android:634c1f5'
 
     // Android support library

+ 2 - 0
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt

@@ -41,6 +41,8 @@ class PreferenceKeys(context: Context) {
 
     val readerTheme = context.getString(R.string.pref_reader_theme_key)
 
+    val cropBorders = context.getString(R.string.pref_crop_borders_key)
+
     val readWithTapping = context.getString(R.string.pref_read_with_tapping_key)
 
     val readWithVolumeKeys = context.getString(R.string.pref_read_with_volume_keys_key)

+ 3 - 1
app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt

@@ -34,7 +34,7 @@ class PreferencesHelper(val context: Context) {
 
     fun rotation() = rxPrefs.getInteger(keys.rotation, 1)
 
-    fun enableTransitions() = rxPrefs.getBoolean(keys.enableTransitions, true)
+    fun pageTransitions() = rxPrefs.getBoolean(keys.enableTransitions, true)
 
     fun showPageNumber() = rxPrefs.getBoolean(keys.showPageNumber, true)
 
@@ -60,6 +60,8 @@ class PreferencesHelper(val context: Context) {
 
     fun readerTheme() = rxPrefs.getInteger(keys.readerTheme, 0)
 
+    fun cropBorders() = rxPrefs.getBoolean(keys.cropBorders, false)
+
     fun readWithTapping() = rxPrefs.getBoolean(keys.readWithTapping, true)
 
     fun readWithVolumeKeys() = rxPrefs.getBoolean(keys.readWithVolumeKeys, false)

+ 5 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderSettingsDialog.kt

@@ -83,6 +83,11 @@ class ReaderSettingsDialog : DialogFragment() {
         fullscreen.setOnCheckedChangeListener { v, isChecked ->
             preferences.fullscreen().set(isChecked)
         }
+
+        crop_borders.isChecked = preferences.cropBorders().getOrDefault()
+        crop_borders.setOnCheckedChangeListener { v, isChecked ->
+            preferences.cropBorders().set(isChecked)
+        }
     }
 
     override fun onDestroyView() {

+ 1 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PageView.kt

@@ -70,6 +70,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
             setRegionDecoderClass(reader.regionDecoderClass)
             setBitmapDecoderClass(reader.bitmapDecoderClass)
             setVerticalScrollingParent(reader is VerticalReader)
+            setCropBorders(reader.cropBorders)
             setOnTouchListener { v, motionEvent -> reader.gestureDetector.onTouchEvent(motionEvent) }
             setOnLongClickListener { reader.onLongClick(page) }
             setOnImageEventListener(object : SubsamplingScaleImageView.DefaultOnImageEventListener() {

+ 14 - 1
app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.kt

@@ -79,6 +79,12 @@ abstract class PagerReader : BaseReader() {
     var transitions: Boolean = false
         private set
 
+    /**
+     * Whether to crop image borders.
+     */
+    var cropBorders: Boolean = false
+        private set
+
     /**
      * Scale type (fit width, fit screen, etc).
      */
@@ -150,9 +156,16 @@ abstract class PagerReader : BaseReader() {
                     .distinctUntilChanged()
                     .subscribe { refreshAdapter() })
 
-            add(preferences.enableTransitions()
+            add(preferences.pageTransitions()
                     .asObservable()
                     .subscribe { transitions = it })
+
+            add(preferences.cropBorders()
+                    .asObservable()
+                    .doOnNext { cropBorders = it }
+                    .skip(1)
+                    .distinctUntilChanged()
+                    .subscribe { refreshAdapter() })
         }
 
         setPagesOnAdapter()

+ 6 - 0
app/src/main/res/layout/dialog_reader_settings.xml

@@ -165,6 +165,12 @@
         android:layout_height="wrap_content"
         android:text="@string/pref_show_page_number"/>
 
+    <android.support.v7.widget.SwitchCompat
+        android:id="@+id/crop_borders"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/pref_crop_borders"/>
+
     <android.support.v7.widget.SwitchCompat
         android:id="@+id/fullscreen"
         android:layout_width="match_parent"

+ 1 - 1
app/src/main/res/values-bg/strings.xml

@@ -118,7 +118,7 @@
       <!-- Reader section -->
     <string name="pref_fullscreen">Цял екран</string>
     <string name="pref_lock_orientation">Заключи ориентацията</string>
-    <string name="pref_enable_transitions">Преходи</string>
+    <string name="pref_page_transitions">Преходи</string>
     <string name="pref_show_page_number">Номер на страница</string>
     <string name="pref_custom_brightness">Персонализирана яркост</string>
     <string name="pref_custom_color_filter">Персонализиран цветен филтър</string>

+ 1 - 1
app/src/main/res/values-es/strings.xml

@@ -95,7 +95,7 @@
       <!-- Reader section -->
     <string name="pref_fullscreen">Pantalla completa</string>
     <string name="pref_lock_orientation">Bloquear orientación</string>
-    <string name="pref_enable_transitions">Habilitar transiciones</string>
+    <string name="pref_page_transitions">Habilitar transiciones</string>
     <string name="pref_show_page_number">Mostrar el número de página</string>
     <string name="pref_custom_brightness">Utilizar brillo personalizado</string>
     <string name="pref_keep_screen_on">Mantener la pantalla encendida</string>

+ 1 - 1
app/src/main/res/values-fr/strings.xml

@@ -115,7 +115,7 @@
     <!-- Reader section -->
     <string name="pref_fullscreen">Plein écran</string>
     <string name="pref_lock_orientation">Verrouiller l\'orientation</string>
-    <string name="pref_enable_transitions">Activer les transitions</string>
+    <string name="pref_page_transitions">Activer les transitions</string>
     <string name="pref_show_page_number">Afficher le numéro de page</string>
     <string name="pref_custom_brightness">Utiliser une luminosité personnalisée</string>
     <string name="pref_custom_color_filter">Utiliser un filtre de couleur personnalisé</string>

+ 1 - 1
app/src/main/res/values-it/strings.xml

@@ -115,7 +115,7 @@
     <!-- Reader section -->
     <string name="pref_fullscreen">Schermo intero</string>
     <string name="pref_lock_orientation">Blocca orientamento</string>
-    <string name="pref_enable_transitions">Abilita transizioni</string>
+    <string name="pref_page_transitions">Abilita transizioni</string>
     <string name="pref_show_page_number">Mostra numero di pagina</string>
     <string name="pref_custom_brightness">Usa luminosità personalizzata</string>
     <string name="pref_custom_color_filter">Usa filtro colore personalizzato</string>

+ 1 - 1
app/src/main/res/values-pt/strings.xml

@@ -100,7 +100,7 @@
     <!-- Reader section -->
     <string name="pref_fullscreen">Ocultar barra de estado</string>
     <string name="pref_lock_orientation">Bloquear orientação</string>
-    <string name="pref_enable_transitions">Permitir transições</string>
+    <string name="pref_page_transitions">Permitir transições</string>
     <string name="pref_show_page_number">Mostrar número de página</string>
     <string name="pref_custom_brightness">Usar brilho personalizado</string>
     <string name="pref_keep_screen_on">Manter ecrã ligado</string>

+ 1 - 1
app/src/main/res/values-ru/strings.xml

@@ -213,7 +213,7 @@
     <string name="pref_enable_acra">Отсылать отчеты о падениях</string>
     <string name="pref_enable_automatic_updates">Проверять обновления</string>
     <string name="pref_enable_automatic_updates_summary">Автоматически проверять новые версии</string>
-    <string name="pref_enable_transitions">Включить переходы</string>
+    <string name="pref_page_transitions">Включить переходы</string>
     <string name="pref_fullscreen">Полноэкранный режим</string>
     <string name="pref_image_decoder">Декодер изображений</string>
     <string name="pref_image_scale_type">Масштабирование</string>

+ 1 - 1
app/src/main/res/values-vi/strings.xml

@@ -118,7 +118,7 @@
     <!-- Reader section -->
     <string name="pref_fullscreen">Đầy màn hình</string>
     <string name="pref_lock_orientation">Khóa xoay</string>
-    <string name="pref_enable_transitions">Bật hiệu ứng chuyển trang</string>
+    <string name="pref_page_transitions">Bật hiệu ứng chuyển trang</string>
     <string name="pref_show_page_number">Hiện số trang</string>
     <string name="pref_custom_brightness">Dùng độ sáng tùy chỉnh</string>
     <string name="pref_custom_color_filter">Dùng bộ lọc màu tùy chỉnh</string>

+ 2 - 0
app/src/main/res/values/keys.xml

@@ -37,8 +37,10 @@
     <string name="pref_red_filter_value_key" translatable="false">pref_red_filter_value</string>
     <string name="pref_reader_theme_key" translatable="false">pref_reader_theme_key</string>
     <string name="pref_image_decoder_key" translatable="false">image_decoder</string>
+    <string name="pref_crop_borders_key" translatable="false">crop_borders</string>
     <string name="pref_read_with_volume_keys_key" translatable="false">reader_volume_keys</string>
     <string name="pref_read_with_tapping_key" translatable="false">reader_tap</string>
+
     <string name="pref_filter_downloaded_key" translatable="false">pref_filter_downloaded_key</string>
     <string name="pref_filter_unread_key" translatable="false">pref_filter_unread_key</string>
     <string name="pref_library_sorting_mode_key" translatable="false">library_sorting_mode</string>

+ 2 - 1
app/src/main/res/values/strings.xml

@@ -120,8 +120,9 @@
       <!-- Reader section -->
     <string name="pref_fullscreen">Fullscreen</string>
     <string name="pref_lock_orientation">Lock orientation</string>
-    <string name="pref_enable_transitions">Enable transitions</string>
+    <string name="pref_page_transitions">Page transitions</string>
     <string name="pref_show_page_number">Show page number</string>
+    <string name="pref_crop_borders">Crop borders</string>
     <string name="pref_custom_brightness">Use custom brightness</string>
     <string name="pref_custom_color_filter">Use custom color filter</string>
     <string name="pref_keep_screen_on">Keep screen on</string>

+ 6 - 1
app/src/main/res/xml/pref_reader.xml

@@ -64,7 +64,7 @@
             android:defaultValue="true" />
 
         <SwitchPreference
-            android:title="@string/pref_enable_transitions"
+            android:title="@string/pref_page_transitions"
             android:key="@string/pref_enable_transitions_key"
             android:defaultValue="true" />
 
@@ -73,6 +73,11 @@
             android:key="@string/pref_show_page_number_key"
             android:defaultValue="true" />
 
+        <SwitchPreference
+            android:title="@string/pref_crop_borders"
+            android:key="@string/pref_crop_borders_key"
+            android:defaultValue="false" />
+
         <SwitchPreference
             android:title="@string/pref_keep_screen_on"
             android:key="@string/pref_keep_screen_on_key"

+ 1 - 0
build.gradle

@@ -17,5 +17,6 @@ allprojects {
     repositories {
         jcenter()
         maven { url "https://jitpack.io" }
+        maven { url "https://dl.bintray.com/inorichi/maven" }
     }
 }