add a complete version of the addLesson Dialog
此提交包含在:
		@ -26,10 +26,16 @@ import android.os.Bundle
 | 
			
		||||
import android.view.LayoutInflater
 | 
			
		||||
import android.view.View
 | 
			
		||||
import android.view.ViewGroup
 | 
			
		||||
import android.widget.AdapterView
 | 
			
		||||
import android.widget.AdapterView.OnItemSelectedListener
 | 
			
		||||
import android.widget.ScrollView
 | 
			
		||||
import android.widget.Spinner
 | 
			
		||||
import androidx.fragment.app.Fragment
 | 
			
		||||
import com.afollestad.materialdialogs.MaterialDialog
 | 
			
		||||
import com.afollestad.materialdialogs.bottomsheets.BottomSheet
 | 
			
		||||
import com.afollestad.materialdialogs.bottomsheets.setPeekHeight
 | 
			
		||||
import com.afollestad.materialdialogs.customview.customView
 | 
			
		||||
import com.afollestad.materialdialogs.customview.getCustomView
 | 
			
		||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
 | 
			
		||||
import kotlinx.android.synthetic.main.fragment_timetable.*
 | 
			
		||||
import kotlinx.coroutines.*
 | 
			
		||||
@ -82,10 +88,7 @@ class TimeTableFragment : Fragment() {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            faBtnAddLesson.setOnClickListener {
 | 
			
		||||
                MaterialDialog(context!!, BottomSheet())
 | 
			
		||||
                    .title(text = resources.getString(R.string.add_lesson))
 | 
			
		||||
                    .message(text = "wähle einen Studiengang aus:\n\nWähle eine Vorlesung aus: \n\nDiese Funktion ist noch nicht verfügbar")
 | 
			
		||||
                    .show()
 | 
			
		||||
                initAddLessonDialog().show()
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // hide the btnCardValue if the user is scrolling down
 | 
			
		||||
@ -160,4 +163,43 @@ class TimeTableFragment : Fragment() {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // TODO move to separate class
 | 
			
		||||
    private fun initAddLessonDialog(): MaterialDialog {
 | 
			
		||||
        val dialog = MaterialDialog(context!!, BottomSheet())
 | 
			
		||||
            .title(R.string.add_lesson)
 | 
			
		||||
            .message(R.string.add_lesson_desc)
 | 
			
		||||
            .customView(R.layout.dialog_add_lesson)
 | 
			
		||||
            .setPeekHeight(900)
 | 
			
		||||
            .positiveButton(R.string.add) {
 | 
			
		||||
                println("add course")
 | 
			
		||||
            }
 | 
			
		||||
            .negativeButton(R.string.cancel) {  }
 | 
			
		||||
 | 
			
		||||
        val spinnerCourses: Spinner = dialog.getCustomView().findViewById(R.id.spinner_Courses)
 | 
			
		||||
        val spinnerLessons: Spinner = dialog.getCustomView().findViewById(R.id.spinner_Lessons)
 | 
			
		||||
 | 
			
		||||
        spinnerCourses.onItemSelectedListener = object : OnItemSelectedListener {
 | 
			
		||||
            override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) {
 | 
			
		||||
                println(parent.getItemAtPosition(pos))
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            override fun onNothingSelected(parent: AdapterView<*>) {
 | 
			
		||||
                // Another interface callback
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        spinnerLessons.onItemSelectedListener = object : OnItemSelectedListener {
 | 
			
		||||
            override fun onItemSelected(parent: AdapterView<*>, view: View, pos: Int, id: Long) {
 | 
			
		||||
                println(parent.getItemAtPosition(pos))
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            override fun onNothingSelected(parent: AdapterView<*>) {
 | 
			
		||||
                // Another interface callback
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return dialog
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,6 +3,40 @@
 | 
			
		||||
        android:id="@+id/linLayout_addlesson"
 | 
			
		||||
        android:layout_width="match_parent"
 | 
			
		||||
        android:layout_height="match_parent"
 | 
			
		||||
        android:orientation="vertical">
 | 
			
		||||
        android:orientation="vertical"
 | 
			
		||||
        android:paddingStart="24dp"
 | 
			
		||||
        android:paddingEnd="24dp">
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
            android:id="@+id/txtView_Course"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:paddingBottom="7dp"
 | 
			
		||||
            android:text="@string/courses"
 | 
			
		||||
            android:textSize="16sp" />
 | 
			
		||||
 | 
			
		||||
    <Spinner
 | 
			
		||||
            android:id="@+id/spinner_Courses"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:entries="@array/courses"
 | 
			
		||||
            android:paddingBottom="10dp"
 | 
			
		||||
            android:popupBackground="?themeSecondary"
 | 
			
		||||
            android:spinnerMode="dropdown" />
 | 
			
		||||
 | 
			
		||||
    <TextView
 | 
			
		||||
            android:id="@+id/txtView_Lesson"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:paddingBottom="7dp"
 | 
			
		||||
            android:text="@string/lessons"
 | 
			
		||||
            android:textSize="16sp" />
 | 
			
		||||
 | 
			
		||||
    <Spinner
 | 
			
		||||
            android:id="@+id/spinner_Lessons"
 | 
			
		||||
            android:layout_width="match_parent"
 | 
			
		||||
            android:layout_height="wrap_content"
 | 
			
		||||
            android:entries="@array/lessons"
 | 
			
		||||
            android:paddingBottom="10dp"
 | 
			
		||||
            android:popupBackground="?themeSecondary" />
 | 
			
		||||
</LinearLayout>
 | 
			
		||||
@ -34,6 +34,9 @@
 | 
			
		||||
 | 
			
		||||
    <!-- fragment_timetable -->
 | 
			
		||||
    <string name="add_lesson">Eine Vorlesung hinzufügen</string>
 | 
			
		||||
    <string name="add_lesson_desc">Füge eine Vorlesung eines anderen Studiengangs zu deinem Stundenplan hinzu.</string>
 | 
			
		||||
    <string name="courses">Studiengänge:</string>
 | 
			
		||||
    <string name="lessons">Vorlesungen:</string>
 | 
			
		||||
 | 
			
		||||
    <!-- fragment_settings -->
 | 
			
		||||
    <string name="info">Info</string>
 | 
			
		||||
@ -54,6 +57,8 @@
 | 
			
		||||
    <!-- dialogs -->
 | 
			
		||||
    <string name="select_course">Wähle deinen Studiengang</string>
 | 
			
		||||
    <string name="loading_timetable">lade Stundenplan …</string>
 | 
			
		||||
    <string name="add">hinzufügen</string>
 | 
			
		||||
    <string name="cancel">abbrechen</string>
 | 
			
		||||
    <string name="select">auswählen</string>
 | 
			
		||||
    <string name="close">schließen</string>
 | 
			
		||||
    <string name="mensa_credit">Mensa-Guthaben</string>
 | 
			
		||||
 | 
			
		||||
@ -36,6 +36,9 @@
 | 
			
		||||
 | 
			
		||||
    <!-- fragment_timetable -->
 | 
			
		||||
    <string name="add_lesson">Add a lesson</string>
 | 
			
		||||
    <string name="add_lesson_desc">Add a lesson from another course to your timetable.</string>
 | 
			
		||||
    <string name="courses">Courses:</string>
 | 
			
		||||
    <string name="lessons">Lessons:</string>
 | 
			
		||||
 | 
			
		||||
    <!-- fragment_settings -->
 | 
			
		||||
    <string name="info">Info</string>
 | 
			
		||||
@ -59,13 +62,14 @@
 | 
			
		||||
    <!-- dialogs -->
 | 
			
		||||
    <string name="select_course">Select your course</string>
 | 
			
		||||
    <string name="loading_timetable">loading timetable …</string>
 | 
			
		||||
    <string name="add">add</string>
 | 
			
		||||
    <string name="cancel">@android:string/cancel</string>
 | 
			
		||||
    <string name="select">select</string>
 | 
			
		||||
    <string name="close">close</string>
 | 
			
		||||
    <string name="mensa_credit">Mensa credit</string>
 | 
			
		||||
    <string name="mensa_current">current: %1$s\n</string>
 | 
			
		||||
    <string name="mensa_last">last: %1$s</string>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <!-- sample strings -->
 | 
			
		||||
    <string name="sample_user" translatable="false">spinefield@stud.hs-offenburg.de</string>
 | 
			
		||||
    <string name="sample_course" translatable="false">SampleCourse 3</string>
 | 
			
		||||
@ -100,4 +104,21 @@
 | 
			
		||||
    <string name="save_key_mensaCacheTime" translatable="false">org.mosad.seil0.projectlaogai.mensaCacheTime</string>
 | 
			
		||||
    <string name="save_key_timetableCacheTime" translatable="false">org.mosad.seil0.projectlaogai.timetableCacheTime</string>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    <string-array name="courses">
 | 
			
		||||
        <item>AI-1</item>
 | 
			
		||||
        <item>AI-2</item>
 | 
			
		||||
        <item>AI-3</item>
 | 
			
		||||
        <item>AI-4</item>
 | 
			
		||||
        <item>AI-5</item>
 | 
			
		||||
        <item>AI-6</item>
 | 
			
		||||
    </string-array>
 | 
			
		||||
 | 
			
		||||
    <string-array name="lessons">
 | 
			
		||||
        <item>Mathematik</item>
 | 
			
		||||
        <item>Verteilte Systemr</item>
 | 
			
		||||
        <item>EA 1</item>
 | 
			
		||||
        <item>IT Security</item>
 | 
			
		||||
    </string-array>
 | 
			
		||||
 | 
			
		||||
</resources>
 | 
			
		||||
 | 
			
		||||
		新增問題並參考
	
	封鎖使用者