From 6de260d73f131e3a8f9aad69a5e7c700a17c07a3 Mon Sep 17 00:00:00 2001
From: len <len@kanade.eu>
Date: Sun, 19 Feb 2017 23:39:53 +0100
Subject: [PATCH] Fix #660. Update subsampling

---
 app/build.gradle                              |   2 +-
 .../ui/reader/ReaderCustomFilterDialog.kt     |   3 +-
 .../tachiyomi/widget/NegativeSeekBar.kt       |   8 +
 .../layout/dialog_reader_custom_filter.xml    | 416 +++++++++---------
 4 files changed, 222 insertions(+), 207 deletions(-)

diff --git a/app/build.gradle b/app/build.gradle
index f133845804..0d622f3a32 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -98,7 +98,7 @@ android {
 dependencies {
 
     // Modified dependencies
-    compile 'com.github.inorichi:subsampling-scale-image-view:8a22092'
+    compile 'com.github.inorichi:subsampling-scale-image-view:4255750'
     compile 'com.github.inorichi:junrar-android:634c1f5'
 
     // Android support library
diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt
index dc820106ea..4dc26c487a 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderCustomFilterDialog.kt
@@ -96,6 +96,7 @@ class ReaderCustomFilterDialog : DialogFragment() {
 
         // Set brightness value
         txt_brightness_seekbar_value.text = brightness.toString()
+        brightness_seekbar.progress = brightness
 
         // Initialize seekBar progress
         seekbar_color_filter_alpha.progress = argb[0]
@@ -145,7 +146,7 @@ class ReaderCustomFilterDialog : DialogFragment() {
                 }
             }
         })
-        brightness_seekbar.progress = preferences.customBrightnessValue().getOrDefault()
+
         brightness_seekbar.setOnSeekBarChangeListener(object : SimpleSeekBarListener() {
             override fun onProgressChanged(seekBar: SeekBar, value: Int, fromUser: Boolean) {
                 if (fromUser) {
diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt
index 44c9ee1506..807435b4e5 100644
--- a/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt
+++ b/app/src/main/java/eu/kanade/tachiyomi/widget/NegativeSeekBar.kt
@@ -1,6 +1,7 @@
 package eu.kanade.tachiyomi.widget
 
 import android.content.Context
+import android.os.Parcelable
 import android.util.AttributeSet
 import android.widget.SeekBar
 import eu.kanade.tachiyomi.R
@@ -58,4 +59,11 @@ class NegativeSeekBar @JvmOverloads constructor(context: Context, attrs: Attribu
         this.listener = listener
     }
 
+    override fun onRestoreInstanceState(state: Parcelable?) {
+        // We can't restore the progress from the saved state because it gets shifted.
+        val origProgress = progress
+        super.onRestoreInstanceState(state)
+        super.setProgress(origProgress)
+    }
+
 }
\ No newline at end of file
diff --git a/app/src/main/res/layout/dialog_reader_custom_filter.xml b/app/src/main/res/layout/dialog_reader_custom_filter.xml
index 4abe82fdd9..0f5483deaa 100644
--- a/app/src/main/res/layout/dialog_reader_custom_filter.xml
+++ b/app/src/main/res/layout/dialog_reader_custom_filter.xml
@@ -28,230 +28,236 @@
             android:visibility="gone" />
     </RelativeLayout>
 
-    <LinearLayout
+    <ScrollView
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical"
-        android:padding="@dimen/material_component_dialogs_padding_around_content_area">
+        android:layout_height="match_parent">
 
-        <android.support.v7.widget.SwitchCompat
-            android:id="@+id/switch_color_filter"
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="@string/pref_custom_color_filter" />
+            android:layout_height="match_parent"
+            android:orientation="vertical"
+            android:padding="@dimen/material_component_dialogs_padding_around_content_area">
 
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <TextView
-                android:id="@+id/txt_color_filter_red_symbol"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentStart="true"
-                android:layout_centerVertical="true"
-                android:text="@string/color_filter_r_value"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
-
-            <TextView
-                android:id="@+id/txt_color_filter_red_value"
-                android:layout_width="30dp"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
-
-            <SeekBar
-                android:id="@+id/seekbar_color_filter_red"
+            <android.support.v7.widget.SwitchCompat
+                android:id="@+id/switch_color_filter"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_centerVertical="true"
-                android:layout_marginEnd="8dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_toEndOf="@id/txt_color_filter_red_symbol"
-                android:layout_toLeftOf="@id/txt_color_filter_red_value"
-                android:layout_toRightOf="@id/txt_color_filter_red_symbol"
-                android:layout_toStartOf="@id/txt_color_filter_red_value"
-                android:max="255"
-                android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+                android:text="@string/pref_custom_color_filter" />
 
-        </RelativeLayout>
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
 
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+                <TextView
+                    android:id="@+id/txt_color_filter_red_symbol"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentStart="true"
+                    android:layout_centerVertical="true"
+                    android:text="@string/color_filter_r_value"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
 
-            <TextView
-                android:id="@+id/txt_color_filter_green_symbol"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentStart="true"
-                android:layout_centerVertical="true"
-                android:text="@string/color_filter_g_value"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+                <TextView
+                    android:id="@+id/txt_color_filter_red_value"
+                    android:layout_width="30dp"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentRight="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
 
-            <TextView
-                android:id="@+id/txt_color_filter_green_value"
-                android:layout_width="30dp"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+                <SeekBar
+                    android:id="@+id/seekbar_color_filter_red"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_toEndOf="@id/txt_color_filter_red_symbol"
+                    android:layout_toLeftOf="@id/txt_color_filter_red_value"
+                    android:layout_toRightOf="@id/txt_color_filter_red_symbol"
+                    android:layout_toStartOf="@id/txt_color_filter_red_value"
+                    android:max="255"
+                    android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
 
-            <SeekBar
-                android:id="@+id/seekbar_color_filter_green"
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <TextView
+                    android:id="@+id/txt_color_filter_green_symbol"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentStart="true"
+                    android:layout_centerVertical="true"
+                    android:text="@string/color_filter_g_value"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <TextView
+                    android:id="@+id/txt_color_filter_green_value"
+                    android:layout_width="30dp"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentRight="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <SeekBar
+                    android:id="@+id/seekbar_color_filter_green"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_toEndOf="@id/txt_color_filter_green_symbol"
+                    android:layout_toLeftOf="@id/txt_color_filter_green_value"
+                    android:layout_toRightOf="@id/txt_color_filter_green_symbol"
+                    android:layout_toStartOf="@id/txt_color_filter_green_value"
+                    android:max="255"
+                    android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <TextView
+                    android:id="@+id/txt_color_filter_blue_symbol"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentStart="true"
+                    android:layout_centerVertical="true"
+                    android:text="@string/color_filter_b_value"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <TextView
+                    android:id="@+id/txt_color_filter_blue_value"
+                    android:layout_width="30dp"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentRight="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <SeekBar
+                    android:id="@+id/seekbar_color_filter_blue"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_toEndOf="@id/txt_color_filter_blue_symbol"
+                    android:layout_toLeftOf="@id/txt_color_filter_blue_value"
+                    android:layout_toRightOf="@id/txt_color_filter_blue_symbol"
+                    android:layout_toStartOf="@id/txt_color_filter_blue_value"
+                    android:max="255"
+                    android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+            </RelativeLayout>
+
+            <RelativeLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <TextView
+                    android:id="@+id/txt_color_filter_alpha_symbol"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentStart="true"
+                    android:layout_centerVertical="true"
+                    android:text="@string/color_filter_a_value"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <TextView
+                    android:id="@+id/txt_color_filter_alpha_value"
+                    android:layout_width="30dp"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentRight="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+
+                <SeekBar
+                    android:id="@+id/seekbar_color_filter_alpha"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_toEndOf="@id/txt_color_filter_alpha_symbol"
+                    android:layout_toLeftOf="@id/txt_color_filter_alpha_value"
+                    android:layout_toRightOf="@id/txt_color_filter_alpha_symbol"
+                    android:layout_toStartOf="@id/txt_color_filter_alpha_value"
+                    android:max="255"
+                    android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+
+            </RelativeLayout>
+
+            <android.support.v7.widget.SwitchCompat
+                android:id="@+id/custom_brightness"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"
-                android:layout_centerVertical="true"
-                android:layout_marginEnd="8dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_toEndOf="@id/txt_color_filter_green_symbol"
-                android:layout_toLeftOf="@id/txt_color_filter_green_value"
-                android:layout_toRightOf="@id/txt_color_filter_green_symbol"
-                android:layout_toStartOf="@id/txt_color_filter_green_value"
-                android:max="255"
-                android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+                android:layout_marginTop="@dimen/material_component_cards_primary_title_top_padding"
+                android:text="@string/pref_custom_brightness" />
 
-        </RelativeLayout>
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <TextView
-                android:id="@+id/txt_color_filter_blue_symbol"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentStart="true"
-                android:layout_centerVertical="true"
-                android:text="@string/color_filter_b_value"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
-
-            <TextView
-                android:id="@+id/txt_color_filter_blue_value"
-                android:layout_width="30dp"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
-
-            <SeekBar
-                android:id="@+id/seekbar_color_filter_blue"
+            <RelativeLayout
                 android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_centerVertical="true"
-                android:layout_marginEnd="8dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_toEndOf="@id/txt_color_filter_blue_symbol"
-                android:layout_toLeftOf="@id/txt_color_filter_blue_value"
-                android:layout_toRightOf="@id/txt_color_filter_blue_symbol"
-                android:layout_toStartOf="@id/txt_color_filter_blue_value"
-                android:max="255"
-                android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
-        </RelativeLayout>
+                android:layout_height="wrap_content">
 
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
+                <android.support.v7.widget.AppCompatImageView
+                    android:id="@+id/txt_brightness_seekbar_icon"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentLeft="true"
+                    android:layout_alignParentStart="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary"
+                    android:tint="?android:attr/textColorSecondary"
+                    app:srcCompat="@drawable/ic_brightness_5_black_24dp" />
 
-            <TextView
-                android:id="@+id/txt_color_filter_alpha_symbol"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentStart="true"
-                android:layout_centerVertical="true"
-                android:text="@string/color_filter_a_value"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+                <TextView
+                    android:id="@+id/txt_brightness_seekbar_value"
+                    android:layout_width="30dp"
+                    android:layout_height="wrap_content"
+                    android:layout_alignParentEnd="true"
+                    android:layout_alignParentRight="true"
+                    android:layout_centerVertical="true"
+                    android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
 
-            <TextView
-                android:id="@+id/txt_color_filter_alpha_value"
-                android:layout_width="30dp"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
+                <eu.kanade.tachiyomi.widget.NegativeSeekBar
+                    android:id="@+id/brightness_seekbar"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_centerVertical="true"
+                    android:layout_marginEnd="8dp"
+                    android:layout_marginLeft="8dp"
+                    android:layout_marginRight="8dp"
+                    android:layout_marginStart="8dp"
+                    android:layout_toEndOf="@id/txt_brightness_seekbar_icon"
+                    android:layout_toLeftOf="@id/txt_brightness_seekbar_value"
+                    android:layout_toRightOf="@id/txt_brightness_seekbar_icon"
+                    android:layout_toStartOf="@id/txt_brightness_seekbar_value"
+                    android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text"
+                    app:max_seek="100"
+                    app:min_seek="-75" />
 
-            <SeekBar
-                android:id="@+id/seekbar_color_filter_alpha"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_centerVertical="true"
-                android:layout_marginEnd="8dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_toEndOf="@id/txt_color_filter_alpha_symbol"
-                android:layout_toLeftOf="@id/txt_color_filter_alpha_value"
-                android:layout_toRightOf="@id/txt_color_filter_alpha_symbol"
-                android:layout_toStartOf="@id/txt_color_filter_alpha_value"
-                android:max="255"
-                android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text" />
+            </RelativeLayout>
+        </LinearLayout>
 
-        </RelativeLayout>
-
-        <android.support.v7.widget.SwitchCompat
-            android:id="@+id/custom_brightness"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:layout_marginTop="@dimen/material_component_cards_primary_title_top_padding"
-            android:text="@string/pref_custom_brightness" />
-
-        <RelativeLayout
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content">
-
-            <android.support.v7.widget.AppCompatImageView
-                android:id="@+id/txt_brightness_seekbar_icon"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentStart="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary"
-                android:tint="?android:attr/textColorSecondary"
-                app:srcCompat="@drawable/ic_brightness_5_black_24dp" />
-
-            <TextView
-                android:id="@+id/txt_brightness_seekbar_value"
-                android:layout_width="30dp"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentRight="true"
-                android:layout_centerVertical="true"
-                android:textAppearance="@style/TextAppearance.Regular.SubHeading.Secondary" />
-
-            <eu.kanade.tachiyomi.widget.NegativeSeekBar
-                android:id="@+id/brightness_seekbar"
-                android:layout_width="match_parent"
-                android:layout_height="wrap_content"
-                android:layout_centerVertical="true"
-                android:layout_marginEnd="8dp"
-                android:layout_marginLeft="8dp"
-                android:layout_marginRight="8dp"
-                android:layout_marginStart="8dp"
-                android:layout_toEndOf="@id/txt_brightness_seekbar_icon"
-                android:layout_toLeftOf="@id/txt_brightness_seekbar_value"
-                android:layout_toRightOf="@id/txt_brightness_seekbar_icon"
-                android:layout_toStartOf="@id/txt_brightness_seekbar_value"
-                android:padding="@dimen/material_component_text_fields_floating_label_padding_between_label_and_input_text"
-                app:max_seek="100"
-                app:min_seek="-75" />
-
-        </RelativeLayout>
-    </LinearLayout>
+    </ScrollView>
 
 </LinearLayout>
\ No newline at end of file