mirror of
https://github.com/wulkanowy/wulkanowy.git
synced 2025-01-19 13:46:51 -06:00
Make strings in grade class stats translatable (#1092)
This commit is contained in:
parent
2b6386c522
commit
a70ccbb0d0
@ -138,7 +138,7 @@ ext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation "io.github.wulkanowy:sdk:0.24.1"
|
implementation "io.github.wulkanowy:sdk:a722e777"
|
||||||
|
|
||||||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1'
|
||||||
|
|
||||||
|
@ -78,18 +78,18 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
|
|
||||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||||
when (holder) {
|
when (holder) {
|
||||||
is PartialViewHolder -> bindPartialChart(holder, items[position].partial!!)
|
is PartialViewHolder -> bindPartialChart(holder.binding, items[position].partial!!)
|
||||||
is SemesterViewHolder -> bindSemesterChart(holder, items[position].semester!!)
|
is SemesterViewHolder -> bindSemesterChart(holder.binding, items[position].semester!!)
|
||||||
is PointsViewHolder -> bindBarChart(holder, items[position].points!!)
|
is PointsViewHolder -> bindBarChart(holder.binding, items[position].points!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindPartialChart(holder: PartialViewHolder, partials: GradePartialStatistics) {
|
private fun bindPartialChart(binding: ItemGradeStatisticsPieBinding, partials: GradePartialStatistics) {
|
||||||
bindPieChart(holder.binding, partials.subject, partials.classAverage, partials.classAmounts)
|
bindPieChart(binding, partials.subject, partials.classAverage, partials.classAmounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindSemesterChart(holder: SemesterViewHolder, semester: GradeSemesterStatistics) {
|
private fun bindSemesterChart(binding: ItemGradeStatisticsPieBinding, semester: GradeSemesterStatistics) {
|
||||||
bindPieChart(holder.binding, semester.subject, semester.average, semester.amounts)
|
bindPieChart(binding, semester.subject, semester.average, semester.amounts)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindPieChart(binding: ItemGradeStatisticsPieBinding, subject: String, average: String, amounts: List<Int>) {
|
private fun bindPieChart(binding: ItemGradeStatisticsPieBinding, subject: String, average: String, amounts: List<Int>) {
|
||||||
@ -103,9 +103,12 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
else -> materialGradeColors
|
else -> materialGradeColors
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataset = PieDataSet(amounts.mapIndexed { grade, amount ->
|
val dataset = PieDataSet(
|
||||||
PieEntry(amount.toFloat(), (grade + 1).toString())
|
amounts.mapIndexed { grade, amount ->
|
||||||
}.reversed().filterNot { it.value == 0f }, "Legenda")
|
PieEntry(amount.toFloat(), (grade + 1).toString())
|
||||||
|
}.reversed().filterNot { it.value == 0f },
|
||||||
|
binding.root.context.getString(R.string.grade_statistics_legend)
|
||||||
|
)
|
||||||
|
|
||||||
with(dataset) {
|
with(dataset) {
|
||||||
valueTextSize = 12f
|
valueTextSize = 12f
|
||||||
@ -138,11 +141,13 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val numberOfGradesString = amounts.fold(0) { acc, it -> acc + it }
|
||||||
|
.let { resources.getQuantityString(R.plurals.grade_number_item, it, it) }
|
||||||
|
val averageString = binding.root.context.getString(R.string.grade_statistics_average, average)
|
||||||
|
|
||||||
minAngleForSlices = 25f
|
minAngleForSlices = 25f
|
||||||
description.isEnabled = false
|
description.isEnabled = false
|
||||||
centerText = amounts.fold(0) { acc, it -> acc + it }
|
centerText = numberOfGradesString + ("\n\n" + averageString).takeIf { average.isNotBlank() }.orEmpty()
|
||||||
.let { resources.getQuantityString(R.plurals.grade_number_item, it, it) } +
|
|
||||||
("\n\nŚrednia: $average").takeIf { average.isNotBlank() }.orEmpty()
|
|
||||||
|
|
||||||
setHoleColor(context.getThemeAttrColor(android.R.attr.windowBackground))
|
setHoleColor(context.getThemeAttrColor(android.R.attr.windowBackground))
|
||||||
setCenterTextColor(context.getThemeAttrColor(android.R.attr.textColorPrimary))
|
setCenterTextColor(context.getThemeAttrColor(android.R.attr.textColorPrimary))
|
||||||
@ -150,8 +155,8 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun bindBarChart(holder: PointsViewHolder, points: GradePointsStatistics) {
|
private fun bindBarChart(binding: ItemGradeStatisticsBarBinding, points: GradePointsStatistics) {
|
||||||
with(holder.binding.gradeStatisticsBarTitle) {
|
with(binding.gradeStatisticsBarTitle) {
|
||||||
text = points.subject
|
text = points.subject
|
||||||
visibility = if (items.size == 1) GONE else VISIBLE
|
visibility = if (items.size == 1) GONE else VISIBLE
|
||||||
}
|
}
|
||||||
@ -159,18 +164,18 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
val dataset = BarDataSet(listOf(
|
val dataset = BarDataSet(listOf(
|
||||||
BarEntry(1f, points.others.toFloat()),
|
BarEntry(1f, points.others.toFloat()),
|
||||||
BarEntry(2f, points.student.toFloat())
|
BarEntry(2f, points.student.toFloat())
|
||||||
), "Legenda")
|
), binding.root.context.getString(R.string.grade_statistics_legend))
|
||||||
|
|
||||||
with(dataset) {
|
with(dataset) {
|
||||||
valueTextSize = 12f
|
valueTextSize = 12f
|
||||||
valueTextColor = holder.binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
valueTextColor = binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||||
valueFormatter = object : ValueFormatter() {
|
valueFormatter = object : ValueFormatter() {
|
||||||
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}%"
|
override fun getBarLabel(barEntry: BarEntry) = "${barEntry.y}%"
|
||||||
}
|
}
|
||||||
colors = gradePointsColors
|
colors = gradePointsColors
|
||||||
}
|
}
|
||||||
|
|
||||||
with(holder.binding.gradeStatisticsBar) {
|
with(binding.gradeStatisticsBar) {
|
||||||
setTouchEnabled(false)
|
setTouchEnabled(false)
|
||||||
if (items.size == 1) animateXY(1000, 1000)
|
if (items.size == 1) animateXY(1000, 1000)
|
||||||
data = BarData(dataset).apply {
|
data = BarData(dataset).apply {
|
||||||
@ -179,12 +184,12 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
}
|
}
|
||||||
legend.setCustom(listOf(
|
legend.setCustom(listOf(
|
||||||
LegendEntry().apply {
|
LegendEntry().apply {
|
||||||
label = "Średnia klasy"
|
label = binding.root.context.getString(R.string.grade_statistics_average_class)
|
||||||
formColor = gradePointsColors[0]
|
formColor = gradePointsColors[0]
|
||||||
form = Legend.LegendForm.SQUARE
|
form = Legend.LegendForm.SQUARE
|
||||||
},
|
},
|
||||||
LegendEntry().apply {
|
LegendEntry().apply {
|
||||||
label = "Uczeń"
|
label = binding.root.context.getString(R.string.grade_statistics_average_student)
|
||||||
formColor = gradePointsColors[1]
|
formColor = gradePointsColors[1]
|
||||||
form = Legend.LegendForm.SQUARE
|
form = Legend.LegendForm.SQUARE
|
||||||
}
|
}
|
||||||
@ -193,7 +198,7 @@ class GradeStatisticsAdapter @Inject constructor() :
|
|||||||
|
|
||||||
description.isEnabled = false
|
description.isEnabled = false
|
||||||
|
|
||||||
holder.binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary).let {
|
binding.root.context.getThemeAttrColor(android.R.attr.textColorPrimary).let {
|
||||||
axisLeft.textColor = it
|
axisLeft.textColor = it
|
||||||
axisRight.textColor = it
|
axisRight.textColor = it
|
||||||
}
|
}
|
||||||
|
@ -172,6 +172,7 @@ class GradeStatisticsPresenter @Inject constructor(
|
|||||||
showErrorView(false)
|
showErrorView(false)
|
||||||
enableSwipe(true)
|
enableSwipe(true)
|
||||||
showRefresh(true)
|
showRefresh(true)
|
||||||
|
showProgress(false)
|
||||||
updateData(it.data!!, preferencesRepository.gradeColorTheme, preferencesRepository.showAllSubjectsOnStatisticsList)
|
updateData(it.data!!, preferencesRepository.gradeColorTheme, preferencesRepository.showAllSubjectsOnStatisticsList)
|
||||||
showSubjects(!preferencesRepository.showAllSubjectsOnStatisticsList)
|
showSubjects(!preferencesRepository.showAllSubjectsOnStatisticsList)
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,10 @@
|
|||||||
<string name="grade_statistics_partial">Partial</string>
|
<string name="grade_statistics_partial">Partial</string>
|
||||||
<string name="grade_statistics_semester">Semester</string>
|
<string name="grade_statistics_semester">Semester</string>
|
||||||
<string name="grade_statistics_points">Points</string>
|
<string name="grade_statistics_points">Points</string>
|
||||||
|
<string name="grade_statistics_legend">Legend</string>
|
||||||
|
<string name="grade_statistics_average">Average: %1$s</string>
|
||||||
|
<string name="grade_statistics_average_class">Class</string>
|
||||||
|
<string name="grade_statistics_average_student">Student</string>
|
||||||
<plurals name="grade_number_item">
|
<plurals name="grade_number_item">
|
||||||
<item quantity="one">%d grade</item>
|
<item quantity="one">%d grade</item>
|
||||||
<item quantity="other">%d grades</item>
|
<item quantity="other">%d grades</item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user