Skip to content

Commit

Permalink
settings: dark mode off by default (fixes #3929) (#3930)
Browse files Browse the repository at this point in the history
Co-authored-by: dogi <[email protected]>
  • Loading branch information
Okuro3499 and dogi authored Jul 24, 2024
1 parent fb6920b commit 9c567c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/ole/planet/myplanet/MainApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/pref.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
android:title="@string/save_username_and_password" />

<org.ole.planet.myplanet.views.RoundedListPreference
android:defaultValue="Follow System"
android:defaultValue="OFF"
android:entries="@array/dark_mode_options"
android:entryValues="@array/dark_mode_options"
android:key="dark_mode"
Expand Down

0 comments on commit 9c567c5

Please sign in to comment.