Skip to content

Commit

Permalink
Added multiple themes
Browse files Browse the repository at this point in the history
  • Loading branch information
DonMarv00 committed Sep 7, 2023
1 parent 09d2234 commit e9c9c44
Show file tree
Hide file tree
Showing 20 changed files with 758 additions and 244 deletions.
3 changes: 3 additions & 0 deletions .idea/deploymentTargetDropDown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "de.msdevs.einschlafhilfe"
minSdkVersion 26
targetSdkVersion 33
versionCode 46
versionName "4.2"
versionCode 48
versionName "4.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "de.msdevs.einschlafhilfe";
public static final String BUILD_TYPE = "debug";
public static final int VERSION_CODE = 46;
public static final String VERSION_NAME = "4.2";
public static final int VERSION_CODE = 48;
public static final String VERSION_NAME = "4.3";
}
Binary file modified app/release/app-release.aab
Binary file not shown.
1 change: 0 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
android:label="@string/about" />



</application>
<queries>
<package android:name="com.spotify.music" />
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/java/de/msdevs/einschlafhilfe/AboutActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import de.msdevs.einschlafhilfe.databinding.ActivityAboutBinding
import net.cachapa.expandablelayout.ExpandableLayout


class AboutActivity : AppCompatActivity() {
class AboutActivity : BaseActivity() {

private lateinit var binding : ActivityAboutBinding
private lateinit var btnPrivacy : Button
Expand Down Expand Up @@ -75,7 +74,7 @@ class AboutActivity : AppCompatActivity() {
btnAppIntro.setOnClickListener{
opennUrl("https://github.com/AppIntro/AppIntro")
}
btnGlide.setOnClickListener {
btnContact.setOnClickListener {
val intent = Intent(Intent.ACTION_SENDTO)
intent.setData(Uri.parse("mailto:"))
intent.putExtra(Intent.EXTRA_EMAIL, arrayOf("[email protected]"))
Expand Down
39 changes: 39 additions & 0 deletions app/src/main/java/de/msdevs/einschlafhilfe/BaseActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.msdevs.einschlafhilfe


import android.os.Bundle
import android.view.WindowManager
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import de.msdevs.einschlafhilfe.utils.Utility.getTheme


open class BaseActivity : AppCompatActivity() {
public override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
updateTheme()
}

fun updateTheme() {
if (getTheme(applicationContext) <= THEME_RED) {
setTheme(R.style.AppTheme)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = resources.getColor(R.color.colorPrimary)
} else if (getTheme(applicationContext) == THEME_BLUE) {
setTheme(R.style.AppThemeBlue)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = resources.getColor(R.color.colorPrimaryBlue)
} else if (getTheme(applicationContext) == THEME_WHITE) {
setTheme(R.style.AppThemeWhite)
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS)
window.statusBarColor = resources.getColor(R.color.white)

}
}

companion object {
private const val THEME_WHITE = 4
private const val THEME_RED = 2
private const val THEME_BLUE = 3
}
}
56 changes: 48 additions & 8 deletions app/src/main/java/de/msdevs/einschlafhilfe/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
package de.msdevs.einschlafhilfe

import android.annotation.SuppressLint


import android.content.DialogInterface
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.PackageManager
import android.graphics.PorterDuff
import android.net.ConnectivityManager
import android.net.Uri
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.bumptech.glide.Glide
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import de.msdevs.einschlafhilfe.databinding.ActivityMainBinding
import de.msdevs.einschlafhilfe.utils.Utility
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
Expand All @@ -31,7 +32,7 @@ import java.io.BufferedReader
import java.io.IOException


class MainActivity : AppCompatActivity() {
class MainActivity : BaseActivity() { //Extends Base Activity

private lateinit var binding: ActivityMainBinding
private var urlExtraParameter = "folgen.json"
Expand All @@ -40,7 +41,9 @@ class MainActivity : AppCompatActivity() {
private lateinit var sharedPreferences: SharedPreferences
private lateinit var sharedPreferencesEditor: SharedPreferences.Editor
private lateinit var folgenListe : String
private var selectedTheme : Int = 0
var random : Int = 0

/*
Copyright 2017 - 2023 by Marvin Stelter
*/
Expand All @@ -52,6 +55,8 @@ class MainActivity : AppCompatActivity() {

sharedPreferences = getSharedPreferences(packageName,0)
sharedPreferencesEditor = sharedPreferences.edit()


if(sharedPreferences.getInt("first",0) == 0){
sharedPreferencesEditor.putBoolean("update_list", true)
sharedPreferencesEditor.putBoolean("spotify", false)
Expand Down Expand Up @@ -120,7 +125,12 @@ class MainActivity : AppCompatActivity() {
refresh()
}
binding.fabDescription.setOnClickListener {
val alert = MaterialAlertDialogBuilder(this, R.style.DialogTheme)
var alert : MaterialAlertDialogBuilder
if(Utility.getTheme(this) == 4){
alert = MaterialAlertDialogBuilder(this, R.style.DialogThemeWhite)
}else{
alert = MaterialAlertDialogBuilder(this, R.style.DialogTheme)
}

alert.setTitle(getString(R.string.output, (episodeNumber + 1).toString(), episodeList[episodeNumber].name)
)
Expand Down Expand Up @@ -155,7 +165,15 @@ class MainActivity : AppCompatActivity() {
}


val builder = MaterialAlertDialogBuilder(this, R.style.DialogTheme)


var builder : MaterialAlertDialogBuilder
if(Utility.getTheme(this) == 4){
builder = MaterialAlertDialogBuilder(this, R.style.DialogThemeWhite)
}else{
builder = MaterialAlertDialogBuilder(this, R.style.DialogTheme)
}

builder.setTitle("Links:")
builder.setItems(liste) { _: DialogInterface?, which: Int ->
var i = Intent(Intent.ACTION_VIEW)
Expand Down Expand Up @@ -284,7 +302,7 @@ class MainActivity : AppCompatActivity() {
}
when (binding.bottomBarViewFlipper.displayedChild) {
4 ->
loadEpisodeCover(getString(R.string.cover_citroncode_dd_url) + (episodeNumber + 1) + ".jpg")
loadEpisodeCover(getString(R.string.cover_citroncode_dd_url) + (episodeNumber + 1) + ".png")
else ->
if(binding.bottomBarViewFlipper.displayedChild == 6) {
loadEpisodeCover(getString(R.string.cover_citroncode_url) + "k" + (episodeNumber + 1) + ".png")
Expand All @@ -300,7 +318,7 @@ class MainActivity : AppCompatActivity() {
binding.fabLinks.hide()
}
if(random == 3){
loadEpisodeCover(getString(R.string.cover_citroncode_dd_url) + (episodeNumber + 1) + ".jpg")
loadEpisodeCover(getString(R.string.cover_citroncode_dd_url) + (episodeNumber + 1) + ".png")
binding.fabLinks.show()
}
if(random == 4){
Expand Down Expand Up @@ -402,5 +420,27 @@ class MainActivity : AppCompatActivity() {
}
}

override fun onResume() {
super.onResume()

sharedPreferences = getSharedPreferences(packageName,0)
sharedPreferencesEditor = sharedPreferences.edit()

if (sharedPreferences.getInt("theme_changed",0) == 1) {
val intent = intent
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
finish()
overridePendingTransition(0, 0)
startActivity(intent)
overridePendingTransition(0, 0)

sharedPreferencesEditor.putInt("theme_changed",0)
sharedPreferencesEditor.apply()
}
}

fun changeViewThemes(){

}
}

Loading

0 comments on commit e9c9c44

Please sign in to comment.