Adds basic dark-mode

This commit is contained in:
coderPaddyS 2023-12-11 14:19:35 +01:00
commit be0400c3ac
17 changed files with 171 additions and 141 deletions

3
.idea/misc.xml generated
View file

@ -1,4 +1,7 @@
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK" />
<component name="SuppressKotlinCodeStyleNotification">
<option name="disableForAll" value="true" />
</component>
</project>

Binary file not shown.

View file

@ -0,0 +1,31 @@
/*
This file is part of the application Privacy Friendly Notes.
Privacy Friendly Notes is free software:
you can redistribute it and/or modify it under the terms of the
GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or any later version.
Privacy Friendly Notes is distributed in the hope
that it will be useful, but WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Privacy Friendly Notes. If not, see <http://www.gnu.org/licenses/>.
*/
package org.secuso.aktivpause.activities.fragments;
import android.os.Bundle
import android.preference.PreferenceFragment
import androidx.appcompat.app.AppCompatDelegate
import org.secuso.aktivpause.R
class SettingsFragment : PreferenceFragment() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.preferences)
findPreference("settings_day_night_theme")?.setOnPreferenceChangeListener { _, newValue ->
AppCompatDelegate.setDefaultNightMode(newValue.toString().toInt())
true;
}
}
}

View file

@ -46,6 +46,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/colorBackground"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_drawer" />

View file

@ -85,6 +85,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/colorBackground"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_drawer" />

View file

@ -1,81 +1,13 @@
<?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"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
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
tools:context="org.secuso.aktivpause.activities.SettingsActivity">
<fragment
android:id="@+id/fragment_settings"
android:name="org.secuso.aktivpause.activities.fragments.SettingsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="org.secuso.aktivpause.activities.EditExerciseSetActivity">
android:layout_height="match_parent" />
<include layout="@layout/layout_toolbar"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:id="@+id/main_content"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1">
<LinearLayout
android:id="@+id/headers"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:drawSelectorOnTop="false"
android:cacheColorHint="@android:color/transparent"
android:listPreferredItemHeight="48dp"
android:scrollbarAlwaysDrawVerticalTrack="true" />
<FrameLayout android:id="@+id/list_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="@+id/prefs_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible" >
<android.preference.PreferenceFrameLayout android:id="@+id/prefs"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
tools:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
</RelativeLayout>

View file

@ -323,6 +323,7 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="?attr/colorBackground"
app:headerLayout="@layout/nav_header"
app:menu="@menu/nav_drawer" />

View file

@ -2,38 +2,41 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/nav_header_height"
android:background="@color/colorAccent"
android:background="?attr/colorNavbarHeaderBackground"
android:gravity="bottom"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_vertical_margin"
android:paddingRight="@dimen/activity_vertical_margin"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:orientation="horizontal"
android:background="?attr/colorNavbarHeaderSurface"
android:paddingTop="7dp"
android:paddingBottom="7dp"
android:orientation="horizontal">
android:paddingBottom="7dp">
<ImageView
android:paddingLeft="@dimen/activity_horizontal_margin"
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/ic_app"/>
android:paddingStart="@dimen/activity_horizontal_margin"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:src="@mipmap/ic_drawer"/>
<TextView
android:layout_width="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:text="@string/app_name_short"
android:textColor="@color/colorPrimary"
android:textSize="18sp"
android:text="@string/app_name"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/imageView" />
android:layout_toEndOf="@id/imageView"
android:layout_toRightOf="@id/imageView"
android:textColor="?attr/colorNavbarHeaderText"
android:textSize="18sp"/>
</RelativeLayout>

View file

@ -177,4 +177,12 @@
<string name="dialog_evaluation_yes">Ja</string>
<string name="menu_display_evaluation_dialog">Online-Befragung</string>
<string name="settings_appearance_heading">Darstellung</string>
<string-array name="array_day_night_theme">
<item>System</item>
<item>Hell</item>
<item>Dunkel</item>
</string-array>
<string name="select_day_night_theme">Aussehen</string>
</resources>

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorOnPrimary">@color/white</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="colorSurface">@color/colorSurfaceDark</item>
<item name="colorOnSurface">@color/white</item>
<item name="colorSurfaceSecondary">@color/colorSurfaceSecondaryDark</item>
<item name="colorBackground">@color/colorBackgroundDark</item>
<item name="colorOnBackground">@color/white</item>
<item name="android:windowBackground">@color/colorBackgroundDark</item>
<item name="colorNavbarHeaderBackground">@color/colorPrimaryDark</item>
<item name="colorNavbarHeaderSurface">#476885</item>
<item name="colorNavbarHeaderText">@color/white</item>
<item name="colorIconFill">@color/white</item>
</style>
<style name="AppTheme.PopupOverlay.DialogAlert" parent="Theme.MaterialComponents.DayNight.Dialog.Alert">
<item name="colorPrimary">?attr/colorOnSurface</item>
</style>
<style name="AppTheme.PopupOverlay.Calendar" parent="ThemeOverlay.MaterialComponents.MaterialCalendar">
<item name="buttonBarButtonStyle">@style/AppTheme.PopupOverlay.Button</item>
</style>
<style name="AppTheme.PopupOverlay.Button" parent="ThemeOverlay.MaterialComponents.MaterialAlertDialog">
<item name="android:textColor">?attr/colorOnSurface</item>
</style>
</resources>

View file

@ -18,4 +18,9 @@
<item>Sa</item>
<item>So</item>
</string-array>
<string-array name="array_day_night_theme_values">
<item>-1</item>
<item>1</item>
<item>2</item>
</string-array>
</resources>

View file

@ -8,4 +8,12 @@
<attr name="layout_breakLine" format="boolean" />
<attr name="layout_horizontalSpacing" format="dimension" />
</declare-styleable>
<declare-styleable name="AppTheme">
<attr name="colorSurfaceSecondary" format="color" />
<attr name="colorBackground" format="color" />
<attr name="colorNavbarHeaderBackground" format="color" />
<attr name="colorNavbarHeaderSurface" format="color" />
<attr name="colorNavbarHeaderText" format="color"/>
<attr name="colorIconFill" format="color" />
</declare-styleable>
</resources>

View file

@ -2,18 +2,25 @@
<resources>
<color name="colorPrimary">#024265</color>
<color name="colorPrimaryDark">#024265</color>
<color name="colorAccent">#0274B2</color>
<color name="colorSurface">#FFFFFF</color>
<color name="colorSurfaceDark">#373a3d</color>
<color name="colorBackground">#FFFFFF</color>
<color name="colorBackgroundDark">#050a0f</color>
<color name="colorSurfaceSecondary">#FFFFFF</color>
<color name="colorSurfaceSecondaryDark">#222222</color>
<color name="colorLightAccent">#8aa5ce</color>
<color name="colorAccent">#0274B2</color>
<color name="transparent">#00000000</color>
<color name="white">#ffffff</color>
<color name="black">#000000</color>
<color name="lightblue">#0274B2</color>
<color name="middleblue">#8aa5ce</color>
<color name="darkblue">#024265</color>
<color name="middlegrey">#A8A8A8</color>
<color name="white">#ffffff</color>
<color name="yellow">#f6d126</color>
<color name="black">#000000</color>
<color name="middleblue">#8aa5ce</color>
<color name="lightblue">#0274B2</color>
<color name="darkblue">#024265</color>
<color name="red">#B71C1C</color>
<color name="green">#388E3C</color>
<color name="KITgreen">#008C84</color>
<color name="aktivpauseGreen">#00d67d</color>
<color name="KITlightgreen">#3BAAA2</color>

View file

@ -169,5 +169,12 @@
<string name="dialog_evaluation_yes">Yes</string>
<string name="menu_display_evaluation_dialog">Online Evaluation</string>
<string name="settings_appearance_heading">Appearance</string>
<string-array name="array_day_night_theme">
<item>System</item>
<item>Light</item>
<item>Dark</item>
</string-array>
<string name="select_day_night_theme">Design</string>
</resources>

View file

@ -1,35 +0,0 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/pref_category_exercise">
<SwitchPreference
android:defaultValue="true"
android:key="pref_keep_screen_on_during_exercise"
android:title="@string/pref_keep_screen_on_during_exercise" />
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:numeric="integer"
android:maxLength="2"
android:key="pref_exercise_time"
android:title="@string/pref_exercise_time"/>
<SwitchPreference
android:defaultValue="false"
android:key="pref_exercise_continuous"
android:title="@string/pref_exercise_continuous"
android:summary="@string/pref_exercise_continuous_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_default_exercise_sets">
<SwitchPreference
android:defaultValue="false"
android:key="pref_hide_default_exercise_sets"
android:title="@string/pref_hide_default_exercise_sets" />
</PreferenceCategory>
</PreferenceScreen>

View file

@ -1,15 +0,0 @@
<preference-headers xmlns:android="http://schemas.android.com/apk/res/android">
<!-- These settings headers are only used on tablets. -->
<header
android:fragment="org.secuso.aktivpause.activities.SettingsActivity$ExercisePreferenceFragment"
android:icon="@drawable/ic_info_black"
android:title="@string/pref_header_exercises" />
<header
android:fragment="org.secuso.aktivpause.activities.SettingsActivity$TimerSchedulePreferenceFragment"
android:icon="@drawable/ic_alarm_black"
android:title="@string/pref_header_schedule" />
</preference-headers>

View file

@ -1,5 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/settings_appearance_heading">
<ListPreference
android:key="settings_day_night_theme"
android:title="@string/select_day_night_theme"
android:summary="%s"
android:defaultValue="-1"
android:entries="@array/array_day_night_theme"
android:entryValues="@array/array_day_night_theme_values"
/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_exercise">
<SwitchPreference
android:defaultValue="true"
android:key="pref_keep_screen_on_during_exercise"
android:title="@string/pref_keep_screen_on_during_exercise" />
<EditTextPreference
android:defaultValue="30"
android:inputType="number"
android:numeric="integer"
android:maxLength="2"
android:key="pref_exercise_time"
android:title="@string/pref_exercise_time"/>
<SwitchPreference
android:defaultValue="false"
android:key="pref_exercise_continuous"
android:title="@string/pref_exercise_continuous"
android:summary="@string/pref_exercise_continuous_summary"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_default_exercise_sets">
<SwitchPreference
android:defaultValue="false"
android:key="pref_hide_default_exercise_sets"
android:title="@string/pref_hide_default_exercise_sets" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/pref_category_schedule">
<SwitchPreference