Add dark mode

This commit is contained in:
Jannis Mattheis
2020-05-08 18:13:18 +02:00
parent 91be6fa72e
commit ee36b6aa8a
19 changed files with 205 additions and 27 deletions

View File

@@ -1,10 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#dfe3e4"
android:endColor="#ecf0f1"
android:angle="0"/>
<corners
android:radius="0dp"/>
</shape>

View File

@@ -1,4 +1,6 @@
<vector android:height="24dp" android:viewportHeight="20"
android:viewportWidth="20" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M15.95,10.78c0.03,-0.25 0.05,-0.51 0.05,-0.78s-0.02,-0.53 -0.06,-0.78l1.69,-1.32c0.15,-0.12 0.19,-0.34 0.1,-0.51l-1.6,-2.77c-0.1,-0.18 -0.31,-0.24 -0.49,-0.18l-1.99,0.8c-0.42,-0.32 -0.86,-0.58 -1.35,-0.78L12,2.34c-0.03,-0.2 -0.2,-0.34 -0.4,-0.34H8.4c-0.2,0 -0.36,0.14 -0.39,0.34l-0.3,2.12c-0.49,0.2 -0.94,0.47 -1.35,0.78l-1.99,-0.8c-0.18,-0.07 -0.39,0 -0.49,0.18l-1.6,2.77c-0.1,0.18 -0.06,0.39 0.1,0.51l1.69,1.32c-0.04,0.25 -0.07,0.52 -0.07,0.78s0.02,0.53 0.06,0.78L2.37,12.1c-0.15,0.12 -0.19,0.34 -0.1,0.51l1.6,2.77c0.1,0.18 0.31,0.24 0.49,0.18l1.99,-0.8c0.42,0.32 0.86,0.58 1.35,0.78l0.3,2.12c0.04,0.2 0.2,0.34 0.4,0.34h3.2c0.2,0 0.37,-0.14 0.39,-0.34l0.3,-2.12c0.49,-0.2 0.94,-0.47 1.35,-0.78l1.99,0.8c0.18,0.07 0.39,0 0.49,-0.18l1.6,-2.77c0.1,-0.18 0.06,-0.39 -0.1,-0.51l-1.67,-1.32zM10,13c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"/>
<path
android:fillColor="@color/icons"
android:pathData="M15.95,10.78c0.03,-0.25 0.05,-0.51 0.05,-0.78s-0.02,-0.53 -0.06,-0.78l1.69,-1.32c0.15,-0.12 0.19,-0.34 0.1,-0.51l-1.6,-2.77c-0.1,-0.18 -0.31,-0.24 -0.49,-0.18l-1.99,0.8c-0.42,-0.32 -0.86,-0.58 -1.35,-0.78L12,2.34c-0.03,-0.2 -0.2,-0.34 -0.4,-0.34H8.4c-0.2,0 -0.36,0.14 -0.39,0.34l-0.3,2.12c-0.49,0.2 -0.94,0.47 -1.35,0.78l-1.99,-0.8c-0.18,-0.07 -0.39,0 -0.49,0.18l-1.6,2.77c-0.1,0.18 -0.06,0.39 0.1,0.51l1.69,1.32c-0.04,0.25 -0.07,0.52 -0.07,0.78s0.02,0.53 0.06,0.78L2.37,12.1c-0.15,0.12 -0.19,0.34 -0.1,0.51l1.6,2.77c0.1,0.18 0.31,0.24 0.49,0.18l1.99,-0.8c0.42,0.32 0.86,0.58 1.35,0.78l0.3,2.12c0.04,0.2 0.2,0.34 0.4,0.34h3.2c0.2,0 0.37,-0.14 0.39,-0.34l0.3,-2.12c0.49,-0.2 0.94,-0.47 1.35,-0.78l1.99,0.8c0.18,0.07 0.39,0 0.49,-0.18l1.6,-2.77c0.1,-0.18 0.06,-0.39 -0.1,-0.51l-1.67,-1.32zM10,13c-1.65,0 -3,-1.35 -3,-3s1.35,-3 3,-3 3,1.35 3,3 -1.35,3 -3,3z"/>
</vector>

View File

@@ -6,22 +6,22 @@
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:orientation="vertical"
tools:context=".login.LoginActivity"
tools:layout_editor_absoluteY="25dp">
<Button
android:id="@+id/open_logs"
android:layout_width="50dp"
android:layout_width="70dp"
android:layout_height="40dp"
android:background="@null"
android:insetTop="0dp"
style="@style/Widget.AppCompat.Button.Borderless.Colored"
android:text="@string/logs"
app:backgroundTint="#00FFFFFF"
android:textColor="@color/colorNavPrimary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

View File

@@ -91,6 +91,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:theme="@style/AppTheme.Nav"
app:headerLayout="@layout/nav_header_drawer"
app:menu="@menu/messages_menu" />

View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/settings"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<include
layout="@layout/app_bar_drawer"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.drawerlayout.widget.DrawerLayout>

View File

@@ -16,15 +16,20 @@
</group>
<group android:checkableBehavior="single">
<item
android:icon="@drawable/ic_power_setting"
android:icon="@drawable/ic_settings"
android:orderInCategory="2"
android:id="@+id/logout"
android:title="@string/logout" />
android:id="@+id/settings"
android:title="@string/title_activity_settings" />
<item
android:orderInCategory="2"
android:icon="@drawable/ic_bug_report"
android:id="@+id/nav_logs"
android:title="@string/logs" />
<item
android:icon="@drawable/ic_power_setting"
android:orderInCategory="2"
android:id="@+id/logout"
android:title="@string/logout" />
</group>
</menu>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorNavPrimary">#000000</color>
<color name="colorPrimaryDark">#3867d6</color>
<color name="colorAccent">#1c49b4</color>
<color name="icons">#434343</color>
<color name="swipeBackground">#E74C3C</color>
<color name="swipeIcon">#FFFFFF</color>
</resources>

View File

@@ -0,0 +1,10 @@
<resources>
<string-array name="mode">
<item>@string/theme_light</item>
<item>@string/theme_dark</item>
<item>@string/theme_default</item>
</string-array>
<string name="theme_light">Light</string>
<string name="theme_dark">Dark</string>
<string name="theme_default">System Default</string>
</resources>

View File

@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorNavPrimary">#FFFFFF</color>
<color name="colorPrimaryDark">#3867d6</color>
<color name="colorAccent">#1c49b4</color>
<color name="icons">#434343</color>
<color name="icons">#797979</color>
<color name="swipeBackground">#E74C3C</color>
<color name="swipeIcon">#FFFFFF</color>
</resources>

View File

@@ -64,4 +64,8 @@
<string name="websocket_no_network">Waiting for network</string>
<string name="connection">%s@%s</string>
<string name="no_messages_yet">There are no messages, yet.\nSend a message to Gotify\nand it will appear here.</string>
<string name="title_activity_settings">Settings</string>
<string name="settings_appearance">Appearance</string>
<string name="setting_theme">Theme</string>
<string name="setting_key_theme">theme</string>
</resources>

View File

@@ -1,20 +1,27 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.Nav">
<item name="colorPrimary">@color/colorNavPrimary</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.PopupOverlay" parent="AppTheme" />
<style name="AppTheme.Dialog" parent="AppTheme" >
<item name="colorPrimary">@color/colorNavPrimary</item>
</style>
</resources>

View File

@@ -0,0 +1,13 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory app:title="@string/settings_appearance" >
<ListPreference
android:defaultValue="@string/theme_default"
android:entries="@array/mode"
android:entryValues="@array/mode"
android:key="@string/setting_key_theme"
android:title="@string/setting_theme" />
</PreferenceCategory>
</PreferenceScreen>