View MainActivity_nd3_3.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dm.tutorialdaynight3 | |
import android.content.Context | |
import android.content.SharedPreferences //Importazione della Classe SharedPreferences | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.widget.RadioButton | |
import android.widget.TextView | |
import androidx.appcompat.app.AppCompatDelegate //Importazione della Classe AppCompactDelegate |
View MainActivity_nd3_2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val appSettingPrefs: SharedPreferences = getSharedPreferences("AppSettingPrefs", Context.MODE_PRIVATE) | |
val sharedPrefsEdit: SharedPreferences.Editor = appSettingPrefs.edit() | |
val isNightMode = appSettingPrefs.getInt("NightMode", -1) | |
/*MODE_NIGHT_FOLLOW_SYSTEM = -1 | |
* MODE_NIGHT_AUTO = 0 (deprecated) | |
* MODE_NIGHT_NO = 1 | |
* MODE_NIGHT_YES = 2 | |
* MODE_NIGHT_AUTO_BATTERY = 3*/ | |
when (isNightMode) { |
View MainActivity_nd3_1.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val mode = AppCompatDelegate.getDefaultNightMode() | |
sharedPrefsEdit.putInt("NightMode", mode) | |
sharedPrefsEdit.apply() |
View MainActivity_nd2.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dm.tutorialdaynight2 | |
import androidx.appcompat.app.AppCompatActivity | |
import android.os.Bundle | |
import android.widget.RadioButton | |
import androidx.appcompat.app.AppCompatDelegate //Importazione della Classe AppCompactDelegate | |
class MainActivity : AppCompatActivity() { | |
private var rbDay: RadioButton? = null |
View activity_main_nd2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:orientation="vertical" | |
tools:context=".MainActivity"> | |
<TextView |
View styles_nd1_2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> | |
<item name="colorPrimary">@color/colorPrimary</item> | |
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> | |
<item name="colorAccent">@color/colorAccent</item> | |
<item name="android:windowBackground">@color/backgroundwindow</item> | |
</style> |
View styles_nd1_1.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<item name="android:windowBackground">@color/backgroundwindow</item> |
View ActivityMain_nd1_5.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Imposta il tema in base all'attivazione della modalità risparmio energia | |
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_AUTO_BATTERY) |
View ActivityMain_nd1_4.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Imposta il tema in base all'impostazione di sistema | |
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM) |
View ActivityMain_nd1_3.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Imposta il tema chiaro | |
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO) |
NewerOlder