Custom color filter for reader (#434)

* [WIP] Custom color filter for reader

* Improvements

* temp image to prevent build error

* Shift all the bits

* Some improvements. Removed DiscreteSeekBar

* Improvements

* API 16 + fixes

* Reduced lag. Fixed brightness value being reset to 0

* Small fixes
This commit is contained in:
Bram van de Kerkhof
2016-09-21 21:26:08 +02:00
committed by inorichi
parent 58a2f7a874
commit 8be67a4431
20 changed files with 746 additions and 51 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 KiB

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
android:pathData="M20,8.69V4h-4.69L12,0.69 8.69,4H4v4.69L0.69,12 4,15.31V20h4.69L12,23.31 15.31,20H20v-4.69L23.31,12 20,8.69zM12,18c-0.89,0 -1.74,-0.2 -2.5,-0.55C11.56,16.5 13,14.42 13,12s-1.44,-4.5 -3.5,-5.45C10.26,6.2 11.11,6 12,6c3.31,0 6,2.69 6,6s-2.69,6 -6,6z"/>
</vector>

View File

@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M20,15.31L23.31,12 20,8.69V4h-4.69L12,0.69 8.69,4H4v4.69L0.69,12 4,15.31V20h4.69L12,23.31 15.31,20H20v-4.69zM12,18c-3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6 6,2.69 6,6 -2.69,6 -6,6z"/>
</vector>

View File

@@ -105,4 +105,10 @@
android:layout_height="match_parent"
android:visibility="gone"/>
<View
android:id="@+id/color_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"/>
</FrameLayout>

View File

@@ -0,0 +1,257 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="200dp"
android:scaleType="centerCrop"
android:src="@drawable/filter_mock" />
<View
android:id="@+id/brightness_overlay"
android:layout_width="match_parent"
android:layout_height="200dp"
android:visibility="gone" />
<View
android:id="@+id/color_overlay"
android:layout_width="match_parent"
android:layout_height="200dp"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/material_component_dialogs_padding_around_content_area">
<android.support.v7.widget.SwitchCompat
android:id="@+id/switch_color_filter"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_custom_color_filter" />
<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: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" />
</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_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>
</LinearLayout>

View File

@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:setting="http://schemas.android.com/tools"
android:orientation="vertical"
android:padding="@dimen/material_component_dialogs_padding_around_content_area"
android:divider="@drawable/empty_divider"
@@ -171,21 +171,4 @@
android:layout_height="wrap_content"
android:text="@string/pref_fullscreen"/>
<android.support.v7.widget.SwitchCompat
android:id="@+id/custom_brightness"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/pref_custom_brightness"/>
<org.adw.library.widgets.discreteseekbar.DiscreteSeekBar
android:id="@+id/brightness_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:dsb_min="-75"
app:dsb_max="100"
app:dsb_indicatorFormatter="%d%%"
app:dsb_indicatorTextAppearance="@style/TextAppearance.Regular"
app:dsb_indicatorColor="?colorAccent"
app:dsb_progressColor="?colorAccent" />
</LinearLayout>

View File

@@ -2,11 +2,18 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_custom_filter"
android:title="@string/label_settings"
android:icon="@drawable/ic_brightness_4_white_24dp"
app:showAsAction="ifRoom"
/>
<item
android:id="@+id/action_settings"
android:title="@string/label_settings"
android:icon="@drawable/ic_settings_white_24dp"
app:showAsAction="always"
app:showAsAction="ifRoom"
/>
</menu>

View File

@@ -17,6 +17,11 @@
<attr name="max" format="integer"/>
</declare-styleable>
<declare-styleable name="NegativeSeekBar">
<attr name="min_seek" format="integer"/>
<attr name="max_seek" format="integer"/>
</declare-styleable>
<attr name="navigation_view_theme" format="reference"/>
<attr name="selectable_list_drawable" format="reference|integer" />
<attr name="selectable_library_drawable" format="reference|integer"/>

View File

@@ -32,6 +32,9 @@
<string name="pref_keep_screen_on_key">pref_keep_screen_on_key</string>
<string name="pref_custom_brightness_key">pref_custom_brightness_key</string>
<string name="pref_custom_brightness_value_key">custom_brightness_value</string>
<string name="pref_color_filter_key">pref_color_filter_key</string>
<string name="pref_color_filter_value_key">color_filter_value</string>
<string name="pref_red_filter_value_key">pref_red_filter_value</string>
<string name="pref_reader_theme_key">pref_reader_theme_key</string>
<string name="pref_image_decoder_key">pref_image_decoder_key</string>
<string name="pref_read_with_volume_keys_key">reader_volume_keys</string>

View File

@@ -105,6 +105,7 @@
<string name="pref_enable_transitions">Enable transitions</string>
<string name="pref_show_page_number">Show page number</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>
<string name="pref_reader_navigation">Navigation</string>
<string name="pref_read_with_volume_keys">Volume keys</string>
@@ -138,6 +139,11 @@
<string name="rotation_lock">Lock</string>
<string name="rotation_force_portrait">Force portrait</string>
<string name="rotation_force_landscape">Force landscape</string>
<string name="color_filter_r_value">R</string>
<string name="color_filter_g_value">G</string>
<string name="color_filter_b_value">B</string>
<string name="color_filter_a_value">A</string>
<!-- Downloads section -->
<string name="pref_download_directory">Downloads directory</string>

View File

@@ -91,6 +91,10 @@
<item name="android:textSize">16sp</item>
</style>
<style name="TextAppearance.Regular.SubHeading.Secondary">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="TextAppearance.Regular.SubHeading.Light">
<item name="android:textColor">@color/textColorPrimaryDark</item>
</style>
@@ -107,6 +111,10 @@
<item name="android:textSize">20sp</item>
</style>
<style name="TextAppearance.Medium.Title.Secondary">
<item name="android:textColor">?android:attr/textColorSecondary</item>
</style>
<style name="TextAppearance.Medium.Body2">
<item name="android:textSize">14sp</item>
</style>

View File

@@ -69,11 +69,6 @@
android:key="@string/pref_show_page_number_key"
android:defaultValue="true" />
<SwitchPreference
android:title="@string/pref_custom_brightness"
android:key="@string/pref_custom_brightness_key"
android:defaultValue="false" />
<SwitchPreference
android:title="@string/pref_keep_screen_on"
android:key="@string/pref_keep_screen_on_key"