From 9c567c5b8c819d027b74db04768c97e8e8935856 Mon Sep 17 00:00:00 2001 From: Gideon Okuro Date: Wed, 24 Jul 2024 14:35:35 +0300 Subject: [PATCH] settings: dark mode off by default (fixes #3929) (#3930) Co-authored-by: dogi --- app/build.gradle | 4 ++-- app/src/main/java/org/ole/planet/myplanet/MainApplication.kt | 4 ++-- .../main/java/org/ole/planet/myplanet/ui/SettingActivity.kt | 3 +-- app/src/main/res/xml/pref.xml | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index b3ceb7a911..57b62b210d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "org.ole.planet.myplanet" minSdkVersion 21 targetSdkVersion 34 - versionCode 1719 - versionName "0.17.19" + versionCode 1720 + versionName "0.17.20" ndkVersion '21.3.6528147' testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt b/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt index a33c2daf9e..efdac6473f 100644 --- a/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt +++ b/app/src/main/java/org/ole/planet/myplanet/MainApplication.kt @@ -97,7 +97,7 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks { preferences = getSharedPreferences(PREFS_NAME, MODE_PRIVATE) nightMode() // UNCOMMENT BELOW TO FORCE DARK MODE FOR DARK MODE DEVELOPMENT - AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) +// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES) val builder = VmPolicy.Builder() StrictMode.setVmPolicy(builder.build()) builder.detectFileUriExposure() @@ -120,7 +120,7 @@ class MainApplication : Application(), Application.ActivityLifecycleCallbacks { } private fun nightMode() { - val preference = PreferenceManager.getDefaultSharedPreferences(this).getString("dark_mode", "Follow System") + val preference = PreferenceManager.getDefaultSharedPreferences(this).getString("dark_mode", "OFF") val options = listOf(*resources.getStringArray(R.array.dark_mode_options)) when (options.indexOf(preference)) { 0 -> AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) diff --git a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt index 7aca3a5fcb..3918c3c733 100644 --- a/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt +++ b/app/src/main/java/org/ole/planet/myplanet/ui/SettingActivity.kt @@ -3,7 +3,6 @@ package org.ole.planet.myplanet.ui import android.content.Context import android.content.DialogInterface import android.content.Intent -import android.content.SharedPreferences.OnSharedPreferenceChangeListener import android.os.Build import android.os.Bundle import android.view.MenuItem @@ -42,7 +41,7 @@ class SettingActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - supportActionBar!!.setDisplayHomeAsUpEnabled(true) + supportActionBar?.setDisplayHomeAsUpEnabled(true) supportFragmentManager.beginTransaction().replace(android.R.id.content, SettingFragment()).commit() title = getString(R.string.action_settings) } diff --git a/app/src/main/res/xml/pref.xml b/app/src/main/res/xml/pref.xml index 482704d213..d9a289597f 100644 --- a/app/src/main/res/xml/pref.xml +++ b/app/src/main/res/xml/pref.xml @@ -13,7 +13,7 @@ android:title="@string/save_username_and_password" />