Add a dark theme
ClosedPublic

Authored by philipc on Mar 25 2018, 6:32 PM.

Details

Summary

BUG: 375376

This revision adds dark mode support to the app ( T7044 ). It does so by injecting
theme information into each activity, and making sure that all Views
define their colors by reference to theme attributes.

In order to make this work, all of the buttons with images (like the list
of available devices) now are tinted according to the theme.

While all versions of android support the theme, only devices running
Android ICS or higher will have a toggle button in the drawer.

Test Plan

Open all the screens, both with and without the dark theme on.

Diff Detail

Repository
R225 KDE Connect - Android application
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
philipc requested review of this revision.Mar 25 2018, 6:32 PM
philipc created this revision.
philipc retitled this revision from Use theme attributes for appearance of activity_main.xml to Add a dark theme.Mar 25 2018, 6:57 PM
nicolasfella edited the summary of this revision. (Show Details)Mar 26 2018, 11:33 AM
Restricted Application added a project: KDE Connect. · View Herald TranscriptMar 26 2018, 11:33 AM

Some icons not yet themed correctly:

  • The exclamation icon when you select a paired, but unconnected device
  • The volume icon in the MPRIS activity
philipc updated this revision to Diff 30801.EditedMar 28 2018, 4:47 PM

This should address the pieces I had overlooked (thanks Matthijs!)

  • Add a new attribute for 'high contrast' UI elements
  • Move error drawable (exclamation point) on activity_device.xml to its own View
  • Change colors of icons on mpris_control.xml and activity_device.xml with theme

I can't apply the patch cleanly, and it seems as if you removed all previous changes, only adding the newest update.

Ugh. I'm just not used to arcanist....let me try again.

philipc updated this revision to Diff 30873.Mar 29 2018, 7:51 PM

Include previously-omitted parts of the patch

mtijink accepted this revision.Mar 29 2018, 8:35 PM

Works nicely, thanks!

This revision is now accepted and ready to land.Mar 29 2018, 8:35 PM

hmm, I'm not entirely convinced.
IMHO orange does not really fit into the dark theme. But I can't think of something better either

The problem is: We use orange for things that need somecontrast to the background (e.g. media player buttons, selected device in the drawer) and for things that don't (e.g. the Actionbar). I would like to see at least the Actionbar dark as well.

Also, the icon of 'Send files' seems darker than the others

The icon used for 'Send files' is atypical - all of the other drawables are at least partially transparent, while that one is opaque. We should probably replace it with a more appropriate asset, possibly in a future change to vector assets.

How does the attached look as a potential dark-mode action bar style?

I think it's fine either way, so whatever @nicolasfella thinks 😃

Regarding the icon: if replacing it with a material (vector) icon looks better, go ahead!

philipc updated this revision to Diff 32136.Apr 14 2018, 6:24 PM

Use true black for window backgrounds, and two darker oranges for the toolbar (0x612e00) and statusbar (0x502600).

....and I seem to have lost the commit history

philipc updated this revision to Diff 32160.Apr 15 2018, 3:42 AM

Use true black (no code changes, just fixing commit history)

nicolasfella added a comment.EditedApr 15 2018, 10:16 AM

My suggestion:



With this patch on top

diff --git a/res/drawable/state_list_drawer_background_dark.xml b/res/drawable/state_list_drawer_background_dark.xml
index 0ff668f..bc85bfd 100644
--- a/res/drawable/state_list_drawer_background_dark.xml
+++ b/res/drawable/state_list_drawer_background_dark.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
-    <item android:drawable="@color/primary" android:state_checked="true" />
+    <item android:drawable="@color/accent" android:state_checked="true" />
     <item android:drawable="@android:color/black" android:state_checked="false" />
 </selector>
diff --git a/res/layout-v14/nav_dark_mode_switch.xml b/res/layout-v14/nav_dark_mode_switch.xml
index 8d5b590..a521b0c 100644
--- a/res/layout-v14/nav_dark_mode_switch.xml
+++ b/res/layout-v14/nav_dark_mode_switch.xml
@@ -12,7 +12,6 @@
     android:paddingStart="16dp"
     android:paddingTop="4dp"
     android:text="Dark theme"
-    android:textColor="@android:color/white"
     app:switchPadding="12dp"
     tools:background="@drawable/drawer_header"
     />
\ No newline at end of file
diff --git a/res/layout/nav_header.xml b/res/layout/nav_header.xml
index 18f0ed4..fca00a0 100644
--- a/res/layout/nav_header.xml
+++ b/res/layout/nav_header.xml
@@ -2,7 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:layout_width="match_parent"
     android:layout_height="160dp"
-    android:background="@drawable/drawer_header"
+    android:background="@drawable/konqui"
     android:gravity="bottom"
     android:orientation="vertical">
 
@@ -16,7 +16,6 @@
         android:paddingStart="16dp"
         android:paddingTop="8dp"
         android:text="KDE Connect"
-        android:textColor="#FFF"
         android:textStyle="bold" />
 
     <TextView
@@ -30,7 +29,6 @@
         android:paddingRight="48dp"
         android:paddingStart="16dp"
         android:paddingTop="4dp"
-        android:text="My device"
-        android:textColor="#fff" />
+        android:text="My device" />
 
 </LinearLayout>
diff --git a/res/values/styles-dark.xml b/res/values/styles-dark.xml
index 5051e15..f0de2f9 100644
--- a/res/values/styles-dark.xml
+++ b/res/values/styles-dark.xml
@@ -1,7 +1,7 @@
 <resources>
 
-    <color name="darkToolbarBackground">#612e00</color>
-    <color name="darkStatusBarBackground">#502600</color>
+    <color name="darkToolbarBackground">#222222</color>
+    <color name="darkStatusBarBackground">#333333</color>
 
     <!-- KdeConnectThemeBase styles must only be defined in the main res/values/ folder -->
     <style name="KdeConnectThemeBase.Dark" parent="Theme.AppCompat">

I don't like some of the new changes. I understand this is all opinions, so we can't have everything, but I think that the following things are especially bad changes:

  • The sidebar navigation should be visually distinct from the main view. In the light view, the main view is shaded and the sidebar has a drop shadow, we could do that here too. Or, if not possible, we should change the sidebar color.
  • The dark-orange toolbar doesn't match the other places where the orange color is used. I'd say they should be different hues or be exactly the same color. So either bright orange or black-ish, as @nicolasfella suggested.

Finally, a remark about black saving energy: KDE Connect is mostly a background app, so saving energy isn't that important. I'd prefer a grey background myself, but I guess other people like black more.

res/values/styles-dark.xml
9

Should be dark as well, see my comment

apol added a subscriber: apol.Apr 16 2018, 6:52 PM

Changing the header is out of scope for this patch and I would suggest doing it at least in a later patch.

Furthermore, if it's done, please make sure we adhere to material design guidelines:
https://material.io/guidelines/patterns/navigation-drawer.html#navigation-drawer-specs

@philipc Mind if I take over this revision and incorporate my changes?

By all means. Sorry for not being more on top of the revision.

philipc updated this revision to Diff 32682.Apr 21 2018, 3:04 AM

@mtijink I tried to take account of your suggestions. The toolbar and statusbar
now match the colors @nicolasfella proposed, and we have a light grey for the
drawer to establish contrast. I'll upload a screenshot or two as well.

  • Switch dark theme's toolbar and scroll effect from orange tints to greyscale
  • Make drawer background a little lighter so it doesn't blend into view below

Screenshots from Android 7.1 device:

Medium quality screen-recording from an Android 4.3 Emulator:

mtijink accepted this revision.Apr 21 2018, 6:06 PM

Looks good to me!

nicolasfella accepted this revision.Apr 23 2018, 10:52 AM

Looks pretty good!

You don't have commit rights, do you?

I'm afraid I don't.

This revision was automatically updated to reflect the committed changes.