From b9b4b0036fa85e43f3f5a8432493328a3c44be59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 11 Mar 2020 16:25:54 +0100 Subject: [PATCH] [Grades] Update fonts and colors a bit. --- .../edziennik/ui/dialogs/QrScannerDialog.kt | 4 ++-- .../edziennik/ui/dialogs/grade/GradeDetailsDialog.kt | 2 +- .../edziennik/ui/modules/grades/GradeView.kt | 4 ++-- .../ui/modules/grades/editor/GradesEditorAdapter.kt | 4 +--- .../ui/modules/grades/editor/GradesEditorFragment.kt | 5 +---- .../ui/modules/grades/viewholder/SubjectViewHolder.kt | 9 ++++----- 6 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/QrScannerDialog.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/QrScannerDialog.kt index d43d9374..65bcff40 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/QrScannerDialog.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/dialogs/QrScannerDialog.kt @@ -40,7 +40,7 @@ class QrScannerDialog( onShowListener?.invoke(TAG) app = activity.applicationContext as App scannerView = ZXingScannerView(activity) - scannerView.setPadding(0, 16.dp, 0, 0) + scannerView.setPadding(0, 16.dp, 4.dp, 0) dialog = MaterialAlertDialogBuilder(activity) .setTitle(R.string.qr_scanner_dialog_title) .setView(scannerView) @@ -59,4 +59,4 @@ class QrScannerDialog( } scannerView.startCamera() }} -} \ No newline at end of file +} 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 1c6d5c01..0e063758 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 @@ -58,7 +58,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) 0x99000000.toInt() else 0x99ffffff.toInt()) + b.gradeName.setTextColor(if (ColorUtils.calculateLuminance(gradeColor) > 0.3) 0xaa000000.toInt() else 0xccffffff.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/grades/GradeView.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/GradeView.kt index 4d3e09ed..334ff238 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/GradeView.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/GradeView.kt @@ -77,9 +77,9 @@ class GradeView : AppCompatTextView { TYPE_SEMESTER2_PROPOSED, TYPE_YEAR_PROPOSED -> android.R.attr.textColorPrimary.resolveAttr(context) else -> if (ColorUtils.calculateLuminance(gradeColor) > 0.3) - 0x99000000.toInt() + 0xaa000000.toInt() else - 0x99ffffff.toInt() + 0xccffffff.toInt() }) //typeface = Typeface.create("sans-serif-light", Typeface.NORMAL) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorAdapter.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorAdapter.kt index c7553bb7..df9faad5 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorAdapter.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorAdapter.kt @@ -3,7 +3,6 @@ package pl.szczodrzynski.edziennik.ui.modules.grades.editor import android.content.Context import android.graphics.PorterDuff import android.graphics.PorterDuffColorFilter -import android.graphics.Typeface import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -49,8 +48,7 @@ class GradesEditorAdapter( holder.gradesListName.text = editorGrade.name holder.gradesListName.isSelected = true - holder.gradesListName.setTypeface(null, Typeface.BOLD) - holder.gradesListName.setTextColor(if (ColorUtils.calculateLuminance(gradeColor) > 0.25) -0x1000000 else -0x1) + holder.gradesListName.setTextColor(if (ColorUtils.calculateLuminance(gradeColor) > 0.25) 0xaa000000.toInt() else 0xccffffff.toInt()) holder.gradesListName.background.colorFilter = PorterDuffColorFilter(gradeColor, PorterDuff.Mode.MULTIPLY) holder.gradesListCategory.text = editorGrade.category if (editorGrade.weight < 0) { diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorFragment.kt index b2ffdd71..47e47a8c 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/editor/GradesEditorFragment.kt @@ -60,16 +60,13 @@ class GradesEditorFragment : Fragment() { if (context == null) return null app = activity.application as App - context!!.theme.applyStyle(Themes.appTheme, true) - if (app.profile == null) - return inflater.inflate(R.layout.fragment_loading, container, false) // activity, context and profile is valid b = FragmentGradesEditorBinding.inflate(inflater) return b.root } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { - if (app.profile == null || !isAdded) + if (!isAdded) return subjectId = arguments.getLong("subjectId", -1) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/viewholder/SubjectViewHolder.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/viewholder/SubjectViewHolder.kt index ecff434d..e20a5177 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/viewholder/SubjectViewHolder.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/grades/viewholder/SubjectViewHolder.kt @@ -16,11 +16,8 @@ import androidx.appcompat.view.ContextThemeWrapper import androidx.core.view.get import androidx.core.view.isVisible import androidx.recyclerview.widget.RecyclerView -import pl.szczodrzynski.edziennik.App -import pl.szczodrzynski.edziennik.R +import pl.szczodrzynski.edziennik.* import pl.szczodrzynski.edziennik.databinding.GradesItemSubjectBinding -import pl.szczodrzynski.edziennik.dp -import pl.szczodrzynski.edziennik.setText import pl.szczodrzynski.edziennik.ui.modules.grades.GradeView import pl.szczodrzynski.edziennik.ui.modules.grades.GradesAdapter import pl.szczodrzynski.edziennik.ui.modules.grades.GradesAdapter.Companion.STATE_CLOSED @@ -38,7 +35,7 @@ class SubjectViewHolder( override fun onBind(activity: AppCompatActivity, app: App, item: GradesSubject, position: Int, adapter: GradesAdapter) { val manager = app.gradesManager - val contextWrapper = ContextThemeWrapper(activity, Themes.themeInt) + val contextWrapper = ContextThemeWrapper(activity, Themes.appTheme) b.subjectName.text = item.subjectName b.dropdownIcon.rotation = when (item.state) { @@ -62,6 +59,7 @@ class SubjectViewHolder( if (firstSemester.number != item.semester) { b.gradesContainer.addView(TextView(contextWrapper).apply { + setTextColor(android.R.attr.textColorSecondary.resolveAttr(context)) setText(R.string.grades_preview_other_semester, firstSemester.number) setPadding(0, 0, 5.dp, 0) maxLines = 1 @@ -88,6 +86,7 @@ class SubjectViewHolder( } b.previewContainer.addView(TextView(contextWrapper).apply { + setTextColor(android.R.attr.textColorSecondary.resolveAttr(context)) text = manager.getAverageString(app, firstSemester.averages, nameSemester = true, showSemester = firstSemester.number) //gravity = Gravity.END layoutParams = LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT).apply {