Browse Source

Initial AMOLED theme + some CardView fixes (#787)

* Initial AMOLED theme + some CardView fixes

* small fix
Bram van de Kerkhof 8 năm trước cách đây
mục cha
commit
2118434823

+ 1 - 0
app/src/main/java/eu/kanade/tachiyomi/ui/base/activity/ActivityMixin.kt

@@ -32,6 +32,7 @@ interface ActivityMixin {
     fun setAppTheme() {
         setTheme(when (Injekt.get<PreferencesHelper>().theme()) {
             2 -> R.style.Theme_Tachiyomi_Dark
+            3 -> R.style.Theme_Tachiyomi_Amoled
             else -> R.style.Theme_Tachiyomi
         })
     }

+ 23 - 0
app/src/main/res/drawable-v21/library_item_selector_amoled.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ripple
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:color="@color/colorAccentDark"
+    >
+    <item>
+        <selector>
+            <item android:state_selected="true">
+                <color android:color="@color/selectorColorDark"/>
+            </item>
+
+            <item android:state_activated="true">
+                <color android:color="@color/selectorColorDark"/>
+            </item>
+
+            <item>
+                <color android:color="@color/md_black_1000"/>
+            </item>
+        </selector>
+    </item>
+
+
+</ripple>

+ 19 - 0
app/src/main/res/drawable-v21/list_item_selector_amoled.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+        android:color="@color/rippleColorDark">
+    <item>
+        <selector>
+            <item android:state_selected="true">
+                <color android:color="@color/rippleColorDark"/>
+            </item>
+
+            <item android:state_activated="true">
+                <color android:color="@color/rippleColorDark"/>
+            </item>
+
+            <item>
+                <color android:color="@color/md_black_1000"/>
+            </item>
+        </selector>
+    </item>
+</ripple>

+ 10 - 0
app/src/main/res/drawable/library_item_selector_amoled.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector android:exitFadeDuration="@android:integer/config_longAnimTime"
+          xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:state_focused="true" android:drawable="@color/selectorColorDark"/>
+    <item android:state_pressed="true" android:drawable="@color/selectorColorDark"/>
+    <item android:state_activated="true" android:drawable="@color/selectorColorDark"/>
+    <item android:drawable="@color/md_black_1000"/>
+
+</selector>

+ 10 - 0
app/src/main/res/drawable/list_item_selector_amoled.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android"
+          android:exitFadeDuration="@android:integer/config_longAnimTime">
+
+    <item android:drawable="@color/rippleColorDark" android:state_focused="true"/>
+    <item android:drawable="@color/rippleColorDark" android:state_pressed="true"/>
+    <item android:drawable="@color/rippleColorDark" android:state_activated="true"/>
+    <item android:drawable="@color/md_black_1000"/>
+
+</selector>

+ 4 - 0
app/src/main/res/layout/fragment_recently_read.xml

@@ -9,6 +9,10 @@
         android:id="@+id/recycler"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
+        android:paddingBottom="4dp"
+        android:paddingTop="4dp"
+        android:paddingStart="2dp"
+        android:paddingEnd="2dp"
         tools:listitem="@layout/item_recently_read">
 
     </android.support.v7.widget.RecyclerView>

+ 0 - 1
app/src/main/res/layout/item_recently_read.xml

@@ -3,7 +3,6 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/cv_manga"
     style="@style/Theme.Widget.CardView"
-    android:layout_marginBottom="0dp"
     >
 
     <LinearLayout

+ 9 - 0
app/src/main/res/values-v21/themes.xml

@@ -20,6 +20,15 @@
         <item name="android:navigationBarColor">@color/colorPrimaryDark</item>
     </style>
 
+    <!--==============-->
+    <!-- Amoled Theme -->
+    <!--==============-->
+    <style name="Theme.Tachiyomi.Amoled" parent="Theme.Base.Amoled">
+        <!-- Attributes specific for SDK 21 and up  -->
+        <item name="android:windowDrawsSystemBarBackgrounds">true</item>
+        <item name="android:statusBarColor">@android:color/transparent</item>
+    </style>
+
     <!--==============-->
     <!-- Reader Theme -->
     <!--==============-->

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

@@ -25,11 +25,13 @@
     <string-array name="themes_values">
         <item>1</item>
         <item>2</item>
+        <item>3</item>
     </string-array>
 
     <string-array name="themes">
         <item>@string/light_theme</item>
         <item>@string/dark_theme</item>
+        <item>@string/amoled_theme</item>
     </string-array>
 
     <string-array name="reader_themes">

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

@@ -131,6 +131,7 @@
     <string name="pref_theme">Application theme</string>
     <string name="light_theme">Main theme</string>
     <string name="dark_theme">Dark theme</string>
+    <string name="amoled_theme">AMOLED theme</string>
     <string name="pref_start_screen">Start screen</string>
     <string name="pref_language">Language</string>
     <string name="system_default">System default</string>

+ 5 - 4
app/src/main/res/values/styles.xml

@@ -147,10 +147,11 @@
         <item name="android:layout_width">match_parent</item>
         <item name="android:layout_height">wrap_content</item>
         <item name="cardBackgroundColor">?attr/background_card</item>
-        <item name="android:layout_marginLeft">@dimen/card_margin</item>
-        <item name="android:layout_marginRight">@dimen/card_margin</item>
-        <item name="android:layout_marginTop">@dimen/card_margin</item>
-        <item name="android:layout_marginBottom">@dimen/card_margin</item>
+        <item name="cardElevation">3dp</item>
+        <item name="cardUseCompatPadding">true</item>
+        <item name="cardCornerRadius">2dp</item>
+        <item name="android:layout_marginLeft">2dp</item>
+        <item name="android:layout_marginRight">2dp</item>
     </style>
 
     <style name="Theme.Widget.GridView">

+ 16 - 0
app/src/main/res/values/themes.xml

@@ -84,6 +84,22 @@
         <!-- Attributes specific for SDK 16 to SDK 20 -->
     </style>
 
+    <!--==============-->
+    <!-- Amoled Theme -->
+    <!--==============-->
+    <style name="Theme.Base.Amoled" parent="Theme.Base.Dark">
+        <item name="android:colorBackground">@color/md_black_1000</item>
+
+        <!-- Custom Attributes-->
+        <item name="selectable_list_drawable">@drawable/list_item_selector_amoled</item>
+        <item name="selectable_library_drawable">@drawable/library_item_selector_amoled</item>
+        <item name="background_card">@color/md_black_1000</item>
+    </style>
+
+    <style name="Theme.Tachiyomi.Amoled" parent="Theme.Base.Amoled">
+        <!-- Attributes specific for SDK 16 to SDK 20 -->
+    </style>
+
     <!--==============-->
     <!-- Reader Theme -->
     <!--==============-->