Skip to content

Commit

Permalink
Added logic for Black theme switcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotarun committed Sep 23, 2023
1 parent 0b48690 commit e3db798
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions app/src/main/java/org/hotarun/dashchan_monet/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.view.View
import android.widget.Button
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.SwitchCompat
import androidx.core.content.ContextCompat
import com.google.android.material.R.color
import com.google.android.material.snackbar.Snackbar
Expand Down Expand Up @@ -37,21 +38,27 @@ class MainActivity : AppCompatActivity() {
//Create Dashchan Light theme
buttonExportLight.setOnClickListener {
createTheme(baseFileName = "light_theme", generateLightTheme())

}

//Create Dashchan Dark theme
buttonExportDark.setOnClickListener {
createTheme(baseFileName = "dark_theme", generateDarkTheme())
val isBlackChecked: SwitchCompat = findViewById(R.id.blackSwitch)
if (isBlackChecked.isChecked) {
createTheme(baseFileName = "black_theme", generateDarkTheme(true, "Monet black"))
} else {
createTheme(baseFileName = "dark_theme", generateDarkTheme(false, "Monet dark"))
}
}

// Source code link
buttonSourceCode.setOnClickListener {
openLink("https://github.com/HotarunIchijou/Dashchan-Monet")
openLink()
}

}

private fun openLink(link: String) {
private fun openLink(link: String = "https://github.com/HotarunIchijou/Dashchan-Monet") {
val i = Intent(Intent.ACTION_VIEW)
i.data = Uri.parse(link)
startActivity(i)
Expand Down Expand Up @@ -126,16 +133,25 @@ class MainActivity : AppCompatActivity() {

@SuppressLint("PrivateResource")
private fun generateDarkTheme(
themeMode: String = "dark",
themeName: String = "Monet dark"
isBlack: Boolean,
themeName: String,
themeMode: String = "dark"
): String {

val windowColor = Integer.toHexString(
val windowColor = if (isBlack) {
Integer.toHexString(
ContextCompat.getColor(
this,
color.m3_ref_palette_black
)
)
} else {Integer.toHexString(
ContextCompat.getColor(
this,
color.m3_ref_palette_dynamic_neutral10
)
)
)
}

val accentColor = Integer.toHexString(
ContextCompat.getColor(
Expand Down

0 comments on commit e3db798

Please sign in to comment.