M app/src/main/java/kvj/taskw/ui/AccountAddDialog.kt => app/src/main/java/kvj/taskw/ui/AccountAddDialog.kt +4 -1
@@ 8,10 8,13 @@ import android.widget.ArrayAdapter
import kvj.taskw.App
import kvj.taskw.R
import kvj.taskw.data.Controller
+import kvj.taskw.ui.AppActivity.Companion.Style
import kotlinx.android.synthetic.main.dialog_add_account.*
-class AccountAddDialog : AppDialog() {
+class AccountAddDialog : AppActivity() {
+ override val style = Style.DIALOG
+
private var controller = App.controller<Controller>()
private var response: AccountAuthenticatorResponse? = null
private var result = Bundle()
M app/src/main/java/kvj/taskw/ui/AnnotationDialog.kt => app/src/main/java/kvj/taskw/ui/AnnotationDialog.kt +3 -1
@@ 10,12 10,14 @@ import android.text.TextUtils
import kvj.taskw.App
import kvj.taskw.R
-import kvj.taskw.data.Controller
+import kvj.taskw.ui.AppActivity.Companion.Style
import kotlinx.android.parcel.Parcelize
import kotlinx.android.synthetic.main.dialog_add_annotation.*
class AnnotationDialog : AppDialog() {
+ override val style = Style.DIALOG
+
internal var controller = App.controller<Controller>()
private lateinit var form: Form
M app/src/main/java/kvj/taskw/ui/AppActivity.kt => app/src/main/java/kvj/taskw/ui/AppActivity.kt +17 -7
@@ 11,16 11,15 @@ import kvj.taskw.R
* Base class of all activities of the application
*/
abstract class AppActivity : AppCompatActivity() {
- protected var activeTheme: Theme = Companion.Theme.LIGHT
+ open val style = Style.NORMAL
+ private var activeTheme: Theme = Theme.LIGHT
@JvmField var preferences: SharedPreferences? = null
override fun onCreate(savedInstanceState: Bundle?) {
preferences = PreferenceManager.getDefaultSharedPreferences(this)
-
loadPreferences()
activeTheme = globalTheme
-
setTheme(getThemeResource())
super.onCreate(savedInstanceState)
@@ 39,9 38,15 @@ abstract class AppActivity : AppCompatActivity() {
globalTheme = if (darkMode == true) Companion.Theme.DARK else Companion.Theme.LIGHT
}
- open fun getThemeResource() = when (activeTheme) {
- Companion.Theme.LIGHT -> R.style.Theme_App_Light
- Companion.Theme.DARK -> R.style.Theme_App_Dark
+ open fun getThemeResource() = when (style) {
+ Style.NORMAL -> when (activeTheme) {
+ Companion.Theme.LIGHT -> R.style.Theme_App_Light
+ Companion.Theme.DARK -> R.style.Theme_App_Dark
+ }
+ Style.DIALOG -> when (activeTheme) {
+ Companion.Theme.LIGHT -> R.style.Theme_App_Light_Dialog
+ Companion.Theme.DARK -> R.style.Theme_App_Dark_Dialog
+ }
}
companion object {
@@ 49,7 54,12 @@ abstract class AppActivity : AppCompatActivity() {
enum class Theme {
LIGHT,
- DARK
+ DARK,
+ }
+
+ enum class Style {
+ NORMAL,
+ DIALOG,
}
var darkMode: Boolean? = null
M app/src/main/java/kvj/taskw/ui/AppDialog.kt => app/src/main/java/kvj/taskw/ui/AppDialog.kt +0 -8
@@ 1,10 1,2 @@
package kvj.taskw.ui
-import kvj.taskw.R
-
-abstract class AppDialog : AppActivity() {
- override fun getThemeResource() = when (activeTheme) {
- Companion.Theme.LIGHT -> R.style.Theme_App_Light_Dialog
- Companion.Theme.DARK -> R.style.Theme_App_Dark_Dialog
- }
-}
M app/src/main/java/kvj/taskw/ui/TagDialog.kt => app/src/main/java/kvj/taskw/ui/TagDialog.kt +4 -1
@@ 8,10 8,13 @@ import android.text.TextUtils
import kvj.taskw.App
import kvj.taskw.R
import kvj.taskw.data.Controller
+import kvj.taskw.ui.AppActivity.Companion.Style
import kotlinx.android.synthetic.main.dialog_add_tag.*
-class TagDialog : AppDialog() {
+class TagDialog : AppActivity() {
+ override val style = Style.DIALOG
+
internal var controller = App.controller<Controller>()
private val form = Form()