forked from github/wulkanowy-mirror
Improve grades dialog layout (#631)
This commit is contained in:
parent
77e7e4e6e9
commit
c5cadbd004
@ -1,7 +1,7 @@
|
||||
apply plugin: "jacoco"
|
||||
|
||||
jacoco {
|
||||
toolVersion "0.8.4"
|
||||
toolVersion "0.8.5"
|
||||
reportsDir = file("$buildDir/reports")
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Grade
|
||||
import io.github.wulkanowy.utils.colorStringId
|
||||
import io.github.wulkanowy.utils.getBackgroundColor
|
||||
import io.github.wulkanowy.utils.getGradeColor
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import kotlinx.android.synthetic.main.dialog_grade.*
|
||||
|
||||
@ -50,7 +51,12 @@ class GradeDetailsDialog : DialogFragment() {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
gradeDialogSubject.text = grade.subject
|
||||
gradeDialogWeightValue.text = grade.weight
|
||||
|
||||
gradeDialogColorAndWeightValue.run {
|
||||
text = context.getString(R.string.grade_weight_value, grade.weight)
|
||||
setBackgroundResource(grade.getGradeColor())
|
||||
}
|
||||
|
||||
gradeDialogDateValue.text = grade.date.toFormattedString()
|
||||
gradeDialogColorValue.text = getString(grade.colorStringId)
|
||||
|
||||
|
@ -24,14 +24,7 @@ fun List<GradeSummary>.calcAverage(): Double {
|
||||
|
||||
fun Grade.getBackgroundColor(theme: String): Int {
|
||||
return when (theme) {
|
||||
"grade_color" -> when (color) {
|
||||
"000000" -> R.color.grade_black
|
||||
"F04C4C" -> R.color.grade_red
|
||||
"20A4F7" -> R.color.grade_blue
|
||||
"6ECD07" -> R.color.grade_green
|
||||
"B16CF1" -> R.color.grade_purple
|
||||
else -> R.color.grade_material_default
|
||||
}
|
||||
"grade_color" -> getGradeColor()
|
||||
"material" -> when (value.toInt()) {
|
||||
6 -> R.color.grade_material_six
|
||||
5 -> R.color.grade_material_five
|
||||
@ -53,6 +46,17 @@ fun Grade.getBackgroundColor(theme: String): Int {
|
||||
}
|
||||
}
|
||||
|
||||
fun Grade.getGradeColor(): Int {
|
||||
return when (color) {
|
||||
"000000" -> R.color.grade_black
|
||||
"F04C4C" -> R.color.grade_red
|
||||
"20A4F7" -> R.color.grade_blue
|
||||
"6ECD07" -> R.color.grade_green
|
||||
"B16CF1" -> R.color.grade_purple
|
||||
else -> R.color.grade_material_default
|
||||
}
|
||||
}
|
||||
|
||||
inline val Grade.colorStringId: Int
|
||||
get() {
|
||||
return when (color) {
|
||||
|
@ -17,90 +17,83 @@
|
||||
android:padding="20dp"
|
||||
tools:ignore="UselessParent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogValue"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="80dp"
|
||||
<LinearLayout
|
||||
android:id="@+id/gradeDialogValueLayout"
|
||||
android:layout_width="86dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_gravity="end"
|
||||
android:background="@color/grade_material_default"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="30sp"
|
||||
tools:text="6" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogSubject"
|
||||
android:layout_width="match_parent"
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="86dp"
|
||||
android:background="@color/grade_material_default"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="30sp"
|
||||
tools:text="6" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogColorAndWeightValue"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_marginTop="2dp"
|
||||
android:minHeight="32dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end"
|
||||
android:background="@color/grade_black"
|
||||
android:gravity="center"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp"
|
||||
android:textIsSelectable="true"
|
||||
android:maxLines="2"
|
||||
tools:text="Waga: 1.00" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gradeDialogHeader"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="120dp"
|
||||
android:gravity="center_vertical"
|
||||
android:layout_toLeftOf="@+id/gradeDialogValueLayout"
|
||||
android:layout_toStartOf="@+id/gradeDialogValueLayout"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_gravity="start"
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginRight="90dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="5"
|
||||
android:minHeight="80dp"
|
||||
android:minLines="2"
|
||||
android:text="@string/grade_header"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="20sp" />
|
||||
android:layout_marginRight="12dp"
|
||||
android:layout_marginEnd="12dp"
|
||||
android:orientation="vertical">
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogSubject"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="start"
|
||||
android:gravity="center_vertical"
|
||||
android:maxLines="2"
|
||||
android:text="@string/grade_header"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="20sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogDescription"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gradeDialogSubject"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:text="@string/all_description"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogDescriptionValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gradeDialogDescription"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/all_no_description"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogWeight"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gradeDialogDescriptionValue"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/grade_weight"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogWeightValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gradeDialogWeight"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/grade_weight"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12sp" />
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogDescriptionValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="@string/all_no_description"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gradeDialogComment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/gradeDialogWeightValue"
|
||||
android:layout_below="@+id/gradeDialogHeader"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_marginTop="10dp"
|
||||
|
@ -66,6 +66,7 @@
|
||||
<string name="grade_switch_semester">Zmień semestr</string>
|
||||
<string name="grade_no_items">Brak ocen</string>
|
||||
<string name="grade_weight">Waga</string>
|
||||
<string name="grade_weight_value">Waga: %s</string>
|
||||
<string name="grade_comment">Komentarz</string>
|
||||
<string name="grade_no_new_items">Brak nowych ocen</string>
|
||||
<string name="grade_number_new_items">Ilość nowych ocen: %1$d</string>
|
||||
|
@ -68,6 +68,7 @@
|
||||
<string name="grade_switch_semester">Change semester</string>
|
||||
<string name="grade_no_items">No grades</string>
|
||||
<string name="grade_weight">Weight</string>
|
||||
<string name="grade_weight_value">Weight: %s</string>
|
||||
<string name="grade_comment">Comment</string>
|
||||
<string name="grade_no_new_items">No new grades</string>
|
||||
<string name="grade_number_new_items">Number of new ratings: %1$d</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user