diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/grade/GradeDetailsDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/grade/GradeDetailsDialog.kt index 9ede3f68..80bee3c5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/grade/GradeDetailsDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/grade/GradeDetailsDialog.kt @@ -55,7 +55,7 @@ class GradeDetailsDialog( b.weightText = manager.getWeightString(app, grade) b.commentVisible = false b.devMode = App.debugMode - b.gradeName.setTextColor(if (ColorUtils.calculateLuminance(gradeColor) > 0.3) -0x1000000 else -0x1) + b.gradeName.setTextColor(if (ColorUtils.calculateLuminance(gradeColor) > 0.3) 0x99000000.toInt() else 0x99ffffff.toInt()) b.gradeName.background.setTintColor(gradeColor) b.gradeValue = if (grade.weight == 0f || grade.value < 0f) -1f else manager.getGradeValue(grade) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeGradesCard.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeGradesCard.kt index 4897c8e7..0e26eb2c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeGradesCard.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/home/cards/HomeGradesCard.kt @@ -4,8 +4,6 @@ package pl.szczodrzynski.edziennik.ui.modules.home.cards -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter import android.graphics.Typeface import android.os.Build import android.text.TextUtils @@ -18,7 +16,6 @@ import android.widget.LinearLayout import android.widget.LinearLayout.HORIZONTAL import android.widget.LinearLayout.LayoutParams.WRAP_CONTENT import android.widget.TextView -import androidx.core.graphics.ColorUtils import androidx.core.view.plusAssign import androidx.core.view.setMargins import androidx.lifecycle.Observer @@ -28,23 +25,16 @@ import kotlinx.coroutines.Job import pl.szczodrzynski.edziennik.App import pl.szczodrzynski.edziennik.MainActivity import pl.szczodrzynski.edziennik.R -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER1_FINAL -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER1_PROPOSED -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_FINAL -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_SEMESTER2_PROPOSED -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_FINAL -import pl.szczodrzynski.edziennik.data.db.entity.Grade.Companion.TYPE_YEAR_PROPOSED import pl.szczodrzynski.edziennik.data.db.entity.Profile import pl.szczodrzynski.edziennik.data.db.entity.Subject import pl.szczodrzynski.edziennik.data.db.full.GradeFull import pl.szczodrzynski.edziennik.databinding.CardHomeGradesBinding import pl.szczodrzynski.edziennik.dp +import pl.szczodrzynski.edziennik.ui.modules.grades.GradeView import pl.szczodrzynski.edziennik.ui.modules.home.HomeCard import pl.szczodrzynski.edziennik.ui.modules.home.HomeCardAdapter import pl.szczodrzynski.edziennik.ui.modules.home.HomeFragment -import pl.szczodrzynski.edziennik.utils.Colors import pl.szczodrzynski.edziennik.utils.Utils -import pl.szczodrzynski.edziennik.utils.managers.GradesManager.Companion.COLOR_MODE_DEFAULT import pl.szczodrzynski.edziennik.utils.models.ItemGradesSubjectModel import kotlin.coroutines.CoroutineContext @@ -127,32 +117,11 @@ class HomeGradesCard( 16 /*ellipsize width*/)) / 1.5f subject.grades1.onEach { grade -> - val gradeColor = when (App.config.forProfile().grades.colorMode) { - COLOR_MODE_DEFAULT -> grade.color - else -> Colors.gradeToColor(grade) - } - - val gradeName = TextView(gradeItem.context).apply { - text = when (grade.type) { - TYPE_SEMESTER1_PROPOSED, TYPE_SEMESTER2_PROPOSED -> app.getString(R.string.grade_semester_proposed_format, grade.name) - TYPE_SEMESTER1_FINAL, TYPE_SEMESTER2_FINAL -> app.getString(R.string.grade_semester_final_format, grade.name) - TYPE_YEAR_PROPOSED -> app.getString(R.string.grade_year_proposed_format, grade.name) - TYPE_YEAR_FINAL -> app.getString(R.string.grade_year_final_format, grade.name) - else -> grade.name - } - - setTextColor(when (ColorUtils.calculateLuminance(gradeColor) > 0.25) { - true -> 0xff000000 - else -> 0xffffffff - }.toInt()) - - setTypeface(null, Typeface.BOLD) - setBackgroundResource(R.drawable.bg_rounded_4dp) - background.colorFilter = PorterDuffColorFilter(gradeColor, PorterDuff.Mode.MULTIPLY) - setPadding(5.dp, 0, 5.dp, 0) - - measure(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) - } + val gradeName = GradeView( + gradeItem.context, + grade, + app.gradesManager + ) totalWidth += gradeName.measuredWidth + 5.dp diff --git a/app/src/main/res/layout/dialog_grade_details.xml b/app/src/main/res/layout/dialog_grade_details.xml index 4f8f0dda..79365b1b 100644 --- a/app/src/main/res/layout/dialog_grade_details.xml +++ b/app/src/main/res/layout/dialog_grade_details.xml @@ -55,13 +55,12 @@ android:layout_width="72dp" android:layout_height="72dp" android:background="@drawable/bg_rounded_16dp" - android:fontFamily="serif-monospace" android:gravity="center" android:padding="8dp" android:text="@{grade.name}" android:textIsSelectable="true" android:textSize="36sp" - android:textStyle="bold" + app:autoSizeMinTextSize="18sp" app:autoSizeMaxTextSize="56sp" app:autoSizeTextType="uniform" tools:background="#ff4caf50" @@ -270,7 +269,7 @@ android:id="@+id/gradeHistoryList" android:layout_width="match_parent" android:layout_height="wrap_content" - tools:listitem="@layout/row_grades_list_item" /> + tools:listitem="@layout/grades_item_grade" /> diff --git a/app/src/main/res/layout/row_grades_editor_item.xml b/app/src/main/res/layout/row_grades_editor_item.xml index d6b46610..0e78bbec 100644 --- a/app/src/main/res/layout/row_grades_editor_item.xml +++ b/app/src/main/res/layout/row_grades_editor_item.xml @@ -50,7 +50,8 @@ android:background="@drawable/bg_rounded_8dp" android:gravity="center" android:textSize="24sp" - app:autoSizeMaxTextSize="24sp" + app:autoSizeMinTextSize="14sp" + app:autoSizeMaxTextSize="32sp" app:autoSizeTextType="uniform" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -98,4 +99,4 @@ - \ No newline at end of file + diff --git a/app/src/main/res/layout/row_grades_list_item.xml b/app/src/main/res/layout/row_grades_list_item.xml deleted file mode 100644 index 70e06b1d..00000000 --- a/app/src/main/res/layout/row_grades_list_item.xml +++ /dev/null @@ -1,104 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/row_grades_subject_item.xml b/app/src/main/res/layout/row_grades_subject_item.xml deleted file mode 100644 index 2b31eb50..00000000 --- a/app/src/main/res/layout/row_grades_subject_item.xml +++ /dev/null @@ -1,459 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file