forked from github/szkolny
[Grades] Show custom plus/minus value annotation in GradeDetailsDialog.
This commit is contained in:
parent
9936d90ae2
commit
cc1b581d7e
@ -3,6 +3,7 @@ package pl.szczodrzynski.edziennik.ui.dialogs.grade
|
|||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.core.graphics.ColorUtils
|
import androidx.core.graphics.ColorUtils
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
@ -10,7 +11,9 @@ import pl.szczodrzynski.edziennik.App
|
|||||||
import pl.szczodrzynski.edziennik.R
|
import pl.szczodrzynski.edziennik.R
|
||||||
import pl.szczodrzynski.edziennik.data.db.full.GradeFull
|
import pl.szczodrzynski.edziennik.data.db.full.GradeFull
|
||||||
import pl.szczodrzynski.edziennik.databinding.DialogGradeDetailsBinding
|
import pl.szczodrzynski.edziennik.databinding.DialogGradeDetailsBinding
|
||||||
|
import pl.szczodrzynski.edziennik.onClick
|
||||||
import pl.szczodrzynski.edziennik.setTintColor
|
import pl.szczodrzynski.edziennik.setTintColor
|
||||||
|
import pl.szczodrzynski.edziennik.ui.dialogs.settings.GradesConfigDialog
|
||||||
import pl.szczodrzynski.edziennik.ui.modules.grades.GradesAdapter
|
import pl.szczodrzynski.edziennik.ui.modules.grades.GradesAdapter
|
||||||
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
import pl.szczodrzynski.edziennik.utils.SimpleDividerItemDecoration
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
@ -60,6 +63,12 @@ class GradeDetailsDialog(
|
|||||||
|
|
||||||
b.gradeValue = if (grade.weight == 0f || grade.value < 0f) -1f else manager.getGradeValue(grade)
|
b.gradeValue = if (grade.weight == 0f || grade.value < 0f) -1f else manager.getGradeValue(grade)
|
||||||
|
|
||||||
|
b.customValueDivider.isVisible = manager.plusValue != null || manager.minusValue != null
|
||||||
|
b.customValueLayout.isVisible = b.customValueDivider.isVisible
|
||||||
|
b.customValueButton.onClick {
|
||||||
|
GradesConfigDialog(activity, reloadOnDismiss = true)
|
||||||
|
}
|
||||||
|
|
||||||
launch {
|
launch {
|
||||||
val historyList = withContext(Dispatchers.Default) {
|
val historyList = withContext(Dispatchers.Default) {
|
||||||
app.db.gradeDao().getAllWithParentIdNow(App.profileId, grade.id)
|
app.db.gradeDao().getAllWithParentIdNow(App.profileId, grade.id)
|
||||||
|
@ -269,10 +269,45 @@
|
|||||||
android:id="@+id/gradeHistoryList"
|
android:id="@+id/gradeHistoryList"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
tools:listitem="@layout/grades_item_grade" />
|
tools:listitem="@layout/grades_item_grade"
|
||||||
|
tools:itemCount="2"/>
|
||||||
|
|
||||||
</androidx.core.widget.NestedScrollView>
|
</androidx.core.widget.NestedScrollView>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/customValueDivider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:background="@drawable/divider" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/customValueLayout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:layout_marginVertical="8dp"
|
||||||
|
android:layout_marginRight="8dp"
|
||||||
|
android:layout_marginEnd="8dp"
|
||||||
|
android:text="@string/grades_stats_custom_value_notice"
|
||||||
|
android:textAppearance="@style/NavView.TextView.Helper"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="italic" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/customValueButton"
|
||||||
|
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:minHeight="0dp"
|
||||||
|
android:text="@string/configure" />
|
||||||
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user