Browse Source

add "Manage Lessons" Dialog to Settings, minor style fixes

* initially select the current theme in the select theme dialog
* set the correct accent color for all dialogs (needs to be done manually for every dialog)
pull/46/head
Jannik 2 years ago
parent
commit
bdfeb46faf
Signed by: Seil0
GPG Key ID: E8459F3723C52C24
  1. 59
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt
  2. 8
      app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt
  3. 10
      app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt
  4. 2
      app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddLessonDialog.kt
  5. 27
      app/src/main/res/layouts/fragments/layout/fragment_settings.xml
  6. 3
      app/src/main/res/values-de-rDE/strings.xml
  7. 7
      app/src/main/res/values/strings.xml

59
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/SettingsFragment.kt

@ -34,10 +34,13 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import com.afollestad.aesthetic.Aesthetic
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.WhichButton
import com.afollestad.materialdialogs.actions.getActionButton
import com.afollestad.materialdialogs.callbacks.onDismiss
import com.afollestad.materialdialogs.color.colorChooser
import com.afollestad.materialdialogs.customview.customView
import com.afollestad.materialdialogs.list.listItems
import com.afollestad.materialdialogs.list.listItemsMultiChoice
import com.afollestad.materialdialogs.list.listItemsSingleChoice
import de.psdev.licensesdialog.LicensesDialog
import kotlinx.android.synthetic.main.fragment_settings.*
@ -63,6 +66,7 @@ class SettingsFragment : Fragment() {
private lateinit var linLayoutUser: LinearLayout
private lateinit var linLayoutCourse: LinearLayout
private lateinit var linLayoutManageLessons: LinearLayout
private lateinit var linLayoutAbout: LinearLayout
private lateinit var linLayoutLicence: LinearLayout
private lateinit var linLayoutTheme: LinearLayout
@ -71,12 +75,15 @@ class SettingsFragment : Fragment() {
private lateinit var switchBuffet: Switch
private lateinit var txtViewCourse: TextView
private var selectedTheme = DataTypes.Theme.Light
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater.inflate(R.layout.fragment_settings, container, false)
linLayoutUser = view.findViewById(R.id.linLayout_User)
linLayoutCourse = view.findViewById(R.id.linLayout_Course)
linLayoutManageLessons = view.findViewById(R.id.linLayout_ManageLessons)
linLayoutAbout = view.findViewById(R.id.linLayout_About)
linLayoutLicence = view.findViewById(R.id.linLayout_Licence)
linLayoutTheme = view.findViewById(R.id.linLayout_Theme)
@ -105,18 +112,21 @@ class SettingsFragment : Fragment() {
when(outValue.string) {
"light" -> {
switch_buffet.setTextColor(activity!!.resources.getColor(R.color.textPrimaryLight, activity!!.theme))
txtView_SelectedTheme.text = resources.getString(R.string.themeLight)
selectedTheme = DataTypes.Theme.Light
selectedTheme.string = 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)
selectedTheme = DataTypes.Theme.Dark
selectedTheme.string = 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)
selectedTheme = DataTypes.Theme.Black
selectedTheme.string = resources.getString(R.string.themeBlack)
}
}
txtView_SelectedTheme.text = selectedTheme.string
}
/**
@ -140,6 +150,21 @@ class SettingsFragment : Fragment() {
}
}
linLayoutManageLessons.setOnClickListener {
val myItems = listOf("Hello", "World")
MaterialDialog(context!!).show {
title(R.string.manage_lessons)
listItemsMultiChoice(items = myItems)
positiveButton(R.string.delete) {
//TODO call delete action
}
negativeButton(R.string.cancel)
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
getActionButton(WhichButton.NEGATIVE).updateTextColor(cColorAccent)
}
}
linLayoutAbout.setOnClickListener {
// open a new info dialog
MaterialDialog(context!!)
@ -180,10 +205,10 @@ class SettingsFragment : Fragment() {
resources.getString(R.string.themeDark),
resources.getString(R.string.themeBlack)
)
MaterialDialog(context!!)
.title(R.string.theme)
.show {
listItemsSingleChoice(items = themes) { _, index, _ ->
MaterialDialog(context!!).show {
title(R.string.theme)
listItemsSingleChoice(items = themes, initialSelection = selectedTheme.ordinal) { _, index, _ ->
Aesthetic.config {
when (index) {
0 -> activityTheme(R.style.AppTheme_Light)
@ -200,7 +225,6 @@ class SettingsFragment : Fragment() {
linLayoutPrimaryColor.setOnClickListener {
// open a new color chooser dialog
MaterialDialog(context!!)
.title(R.string.primary_color)
.colorChooser(DataTypes().primaryColors, allowCustomArgb = true, initialSelection = cColorPrimary) { _, color ->
view_PrimaryColor.setBackgroundColor(color)
Aesthetic.config {
@ -208,17 +232,19 @@ class SettingsFragment : Fragment() {
colorPrimaryDark(color)
apply()
}
PreferencesController.saveColorPrimary(context!!, color)
}
.positiveButton(R.string.select)
.show()
.show {
title(R.string.primary_color)
positiveButton(R.string.select)
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
}
}
linLayoutAccentColor.setOnClickListener {
// open a new color chooser dialog
MaterialDialog(context!!)
.title(R.string.accent_color)
.colorChooser(DataTypes().accentColors, allowCustomArgb = true, initialSelection = cColorAccent) { _, color ->
view_AccentColor.setBackgroundColor(color)
Aesthetic.config {
@ -228,8 +254,11 @@ class SettingsFragment : Fragment() {
PreferencesController.saveColorAccent(context!!, color)
}
.positiveButton(R.string.select)
.show()
.show{
title(R.string.accent_color)
positiveButton(R.string.select)
getActionButton(WhichButton.POSITIVE).updateTextColor(cColorAccent)
}
}
switchBuffet.setOnClickListener {

8
app/src/main/java/org/mosad/seil0/projectlaogai/fragments/TimeTableFragment.kt

@ -29,12 +29,15 @@ import android.view.ViewGroup
import android.widget.ScrollView
import androidx.fragment.app.Fragment
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.WhichButton
import com.afollestad.materialdialogs.actions.getActionButton
import com.google.android.material.floatingactionbutton.FloatingActionButton
import kotlinx.android.synthetic.main.fragment_timetable.*
import kotlinx.coroutines.*
import org.mosad.seil0.projectlaogai.R
import org.mosad.seil0.projectlaogai.controller.CacheController
import org.mosad.seil0.projectlaogai.controller.CacheController.Companion.timetables
import org.mosad.seil0.projectlaogai.controller.PreferencesController
import org.mosad.seil0.projectlaogai.controller.PreferencesController.Companion.cCourse
import org.mosad.seil0.projectlaogai.controller.TCoRAPIController
import org.mosad.seil0.projectlaogai.hsoparser.NotRetardedCalendar
@ -82,7 +85,10 @@ class TimeTableFragment : Fragment() {
// show the AddLessonDialog if the ftaBtn is clicked
faBtnAddLesson.setOnClickListener {
AddLessonDialog(context!!).initAddLessonDialog().show()
AddLessonDialog(context!!).initAddLessonDialog().show{
getActionButton(WhichButton.POSITIVE).updateTextColor(PreferencesController.cColorAccent)
getActionButton(WhichButton.NEGATIVE).updateTextColor(PreferencesController.cColorAccent)
}
}
// hide the btnCardValue if the user is scrolling down

10
app/src/main/java/org/mosad/seil0/projectlaogai/hsoparser/DataTypes.kt

@ -23,12 +23,12 @@
package org.mosad.seil0.projectlaogai.hsoparser
import android.graphics.Color
import org.mosad.seil0.projectlaogai.R
import java.util.*
import kotlin.collections.ArrayList
class DataTypes {
val times =
arrayOf("8.00 - 9.30", "9.45 - 11.15", "11.35 - 13.05", "14.00 -15.30", "15.45 - 17.15", "17.30 - 19.00")
val times = arrayOf("8.00 - 9.30", "9.45 - 11.15", "11.35 - 13.05", "14.00 -15.30", "15.45 - 17.15", "17.30 - 19.00")
val primaryColors = intArrayOf(
Color.parseColor("#E53935"),
@ -72,6 +72,12 @@ class DataTypes {
Color.parseColor("#000000")
)
enum class Theme(var string: String) {
Light("Light"),
Dark("Dark"),
Black("Black")
}
init {
// do something
}

2
app/src/main/java/org/mosad/seil0/projectlaogai/uicomponents/AddLessonDialog.kt

@ -74,7 +74,7 @@ class AddLessonDialog(_context: Context) {
// TODO save lesson
// TODO refresh timetable (add a function to show additional lessons)
}
.negativeButton(R.string.cancel) { }
.negativeButton(R.string.cancel)
// initialize the spinners
spinnerCourses = dialog.getCustomView().findViewById(R.id.spinner_Courses)

27
app/src/main/res/layouts/fragments/layout/fragment_settings.xml

@ -93,6 +93,33 @@
android:layout_height="1dp"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="7dp"
android:id="@+id/linLayout_ManageLessons">
<TextView
android:id="@+id/txtView_ManageLessons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/manage_lessons"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/txtView_ManageLessonsDesc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/manage_lessons_desc" />
</LinearLayout>
<View
android:id="@+id/divider7"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="?dividerColor"
/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"

3
app/src/main/res/values-de-rDE/strings.xml

@ -42,6 +42,8 @@
<string name="info">Info</string>
<string name="user">Benutzer</string>
<string name="course_desc">Tippe um den Kurs zu ändern</string>
<string name="manage_lessons">Bearbeite Zusätzliche Vorlesungen</string>
<string name="manage_lessons_desc">Tippe um zusätzliche Vorlesungen zu bearbeiten</string>
<string name="about_dialog_heading">Über</string>
<string name="licenses">Lizenzen</string>
<string name="theme">Design</string>
@ -58,6 +60,7 @@
<string name="select_course">Wähle deinen Studiengang</string>
<string name="loading_timetable">lade Stundenplan …</string>
<string name="add">hinzufügen</string>
<string name="delete">löschen</string>
<string name="cancel">abbrechen</string>
<string name="select">auswählen</string>
<string name="close">schließen</string>

7
app/src/main/res/values/strings.xml

@ -44,10 +44,12 @@
<string name="info">Info</string>
<string name="user">User</string>
<string name="course_desc">Tap to change course</string>
<string name="about_dialog_heading">About</string>
<string name="about_dialog_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2020 seil0@mosad.xyz "</string>
<string name="manage_lessons">Manage Additional Lessons</string>
<string name="manage_lessons_desc">Tap to manage additional lessons</string>
<string name="about_txtView" translatable="false">hso App by @Seil0</string>
<string name="about_version" translatable="false">Version %1$s (%2$s)</string>
<string name="about_dialog_heading">About</string>
<string name="about_dialog_text" translatable="false">"This software is made by @Seil0 and is published under the terms and conditions of GPL 3. For further information visit \ngit.mosad.xyz/Seil0/ProjectLaogai \n\n© 2018-2020 seil0@mosad.xyz "</string>
<string name="licenses">Licenses</string>
<string name="theme">Theme</string>
<string name="themeLight">Light</string>
@ -63,6 +65,7 @@
<string name="select_course">Select your course</string>
<string name="loading_timetable">loading timetable …</string>
<string name="add">add</string>
<string name="delete">delete</string>
<string name="cancel">@android:string/cancel</string>
<string name="select">select</string>
<string name="close">close</string>

Loading…
Cancel
Save

Du besuchst diese Seite mit einem veralteten IPv4-Internetzugang. Möglicherweise treten in Zukunft Probleme mit der Erreichbarkeit und Performance auf. Bitte frage deinen Internetanbieter oder Netzwerkadministrator nach IPv6-Unterstützung.
You are visiting this site with an outdated IPv4 internet access. You may experience problems with accessibility and performance in the future. Please ask your ISP or network administrator for IPv6 support.
Weitere Infos | More Information
Klicke zum schließen | Click to close