update to kotlin 1.3.40, added theme choose option
* added missing dividers in settings * added a black theme * closes #15
This commit is contained in:
@ -205,7 +205,6 @@ class MainActivity : AppCompatActivity(), NavigationView.OnNavigationItemSelecte
|
||||
SettingsFragment().selectCourse(this)
|
||||
} else {
|
||||
Aesthetic.config {
|
||||
// activityTheme(R.style.AppTheme_Light)
|
||||
colorPrimary(cColorPrimary)
|
||||
colorPrimaryDark(cColorPrimary)
|
||||
colorAccent(cColorAccent)
|
||||
|
@ -51,6 +51,7 @@ import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
|
||||
import org.mosad.seil0.projectlaogai.hsoparser.DataTypes
|
||||
import java.util.*
|
||||
import android.util.TypedValue
|
||||
import com.afollestad.materialdialogs.list.listItemsSingleChoice
|
||||
|
||||
/**
|
||||
* The settings controller class
|
||||
@ -61,6 +62,7 @@ class SettingsFragment : Fragment() {
|
||||
private lateinit var linLayoutUser: LinearLayout
|
||||
private lateinit var linLayoutCourse: LinearLayout
|
||||
private lateinit var linLayoutAbout: LinearLayout
|
||||
private lateinit var linLayoutTheme: LinearLayout
|
||||
private lateinit var linLayoutPrimaryColor: LinearLayout
|
||||
private lateinit var linLayoutAccentColor: LinearLayout
|
||||
private lateinit var switchBuffet: Switch
|
||||
@ -72,6 +74,7 @@ class SettingsFragment : Fragment() {
|
||||
linLayoutUser = view.findViewById(R.id.linLayout_User)
|
||||
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
|
||||
linLayoutAbout = view.findViewById(R.id.linLayout_About)
|
||||
linLayoutTheme = view.findViewById(R.id.linLayout_Theme)
|
||||
linLayoutPrimaryColor = view.findViewById(R.id.linLayout_PrimaryColor)
|
||||
linLayoutAccentColor = view.findViewById(R.id.linLayout_AccentColor)
|
||||
switchBuffet = view.findViewById(R.id.switch_buffet)
|
||||
@ -85,17 +88,28 @@ class SettingsFragment : Fragment() {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
||||
// initialize the settings gui
|
||||
txtView_Course.text = cCourse.courseName
|
||||
txtView_AboutDesc.text = resources.getString(R.string.about_version, BuildConfig.VERSION_NAME, getString(R.string.build_time))
|
||||
switch_buffet.isChecked = cShowBuffet // init switch
|
||||
|
||||
val outValue = TypedValue()
|
||||
activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
||||
if (outValue.string == "dark") {
|
||||
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
|
||||
} else {
|
||||
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
|
||||
when(outValue.string) {
|
||||
"light" -> {
|
||||
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
|
||||
txtView_SelectedTheme.text = resources.getString(R.string.themeLight)
|
||||
}
|
||||
"dark" -> {
|
||||
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
|
||||
txtView_SelectedTheme.text = resources.getString(R.string.themeDark)
|
||||
}
|
||||
"black" -> {
|
||||
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryDark, activity!!.theme))
|
||||
txtView_SelectedTheme.text = resources.getString(R.string.themeBlack)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,19 +118,6 @@ class SettingsFragment : Fragment() {
|
||||
private fun initActions() {
|
||||
linLayoutUser.setOnClickListener {
|
||||
// open a new dialog
|
||||
// TODO move and save
|
||||
// val outValue = TypedValue()
|
||||
// activity!!.theme.resolveAttribute(R.attr.themeName, outValue, true)
|
||||
// if (outValue.string == "dark") {
|
||||
// Aesthetic.config {
|
||||
// activityTheme(R.style.AppTheme_Light)
|
||||
// }
|
||||
// } else {
|
||||
// Aesthetic.config {
|
||||
// activityTheme(R.style.AppTheme_Dark)
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
linLayoutCourse.setOnClickListener {
|
||||
@ -132,6 +133,26 @@ class SettingsFragment : Fragment() {
|
||||
.show()
|
||||
}
|
||||
|
||||
linLayoutTheme.setOnClickListener {
|
||||
val themes = listOf(
|
||||
resources.getString(R.string.themeLight),
|
||||
resources.getString(R.string.themeDark),
|
||||
resources.getString(R.string.themeBlack)
|
||||
)
|
||||
MaterialDialog(context!!).show {
|
||||
listItemsSingleChoice(items = themes) { _, index, _ ->
|
||||
Aesthetic.config {
|
||||
when (index) {
|
||||
0 -> activityTheme(R.style.AppTheme_Light)
|
||||
1 -> activityTheme(R.style.AppTheme_Dark)
|
||||
2 -> activityTheme(R.style.AppTheme_Black)
|
||||
else -> activityTheme(R.style.AppTheme_Light)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
linLayoutPrimaryColor.setOnClickListener {
|
||||
// open a new color chooser dialog
|
||||
MaterialDialog(context!!)
|
||||
|
@ -94,7 +94,7 @@ class TimeTableFragment : Fragment() {
|
||||
}
|
||||
|
||||
// hide the btnCardValue if the user is scrolling down
|
||||
scrollViewTimetable.setOnScrollChangeListener { v, scrollX, scrollY, oldScrollX, oldScrollY ->
|
||||
scrollViewTimetable.setOnScrollChangeListener { _, _, scrollY, _, oldScrollY ->
|
||||
if (scrollY > oldScrollY) {
|
||||
faBtnAddLesson.hide()
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user