diff --git a/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt b/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt index f0d11b26..73a04d23 100644 --- a/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt +++ b/app/src/main/java/io/github/wulkanowy/data/db/Converters.kt @@ -1,6 +1,8 @@ package io.github.wulkanowy.data.db import androidx.room.TypeConverter +import com.google.gson.Gson +import com.google.gson.reflect.TypeToken import org.threeten.bp.DateTimeUtils import org.threeten.bp.Instant import org.threeten.bp.LocalDate @@ -8,8 +10,6 @@ import org.threeten.bp.LocalDateTime import org.threeten.bp.Month import org.threeten.bp.ZoneOffset import java.util.Date -import com.google.gson.Gson -import com.google.gson.reflect.TypeToken class Converters { diff --git a/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt b/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt index 571059bf..5996d949 100644 --- a/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt +++ b/app/src/main/java/io/github/wulkanowy/data/repositories/preferences/PreferencesRepository.kt @@ -30,6 +30,10 @@ class PreferencesRepository @Inject constructor( val gradeMinusModifier: Double get() = sharedPref.getString(context.getString(R.string.pref_key_grade_modifier_minus), "0.0")?.toDouble() ?: 0.0 + val gradeColorTheme: String + get() = sharedPref.getString(context.getString(R.string.pref_key_grade_color_scheme), "vulcan") ?: "vulcan" + + val serviceEnablesKey: String = context.getString(R.string.pref_key_services_enable) val isServiceEnabled: Boolean get() = sharedPref.getBoolean(serviceEnablesKey, true) diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt index 491caa06..0abeaeea 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsDialog.kt @@ -5,26 +5,30 @@ import android.view.LayoutInflater import android.view.View import android.view.View.GONE import android.view.ViewGroup -import androidx.core.content.ContextCompat import androidx.fragment.app.DialogFragment 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.toFormattedString -import io.github.wulkanowy.utils.valueBgColor import kotlinx.android.synthetic.main.dialog_grade.* - class GradeDetailsDialog : DialogFragment() { private lateinit var grade: Grade + private lateinit var colorScheme: String + companion object { private const val ARGUMENT_KEY = "Item" + private const val COLOR_SCHEME_KEY = "Scheme" - fun newInstance(grade: Grade): GradeDetailsDialog { + fun newInstance(grade: Grade, colorScheme: String): GradeDetailsDialog { return GradeDetailsDialog().apply { - arguments = Bundle().apply { putSerializable(ARGUMENT_KEY, grade) } + arguments = Bundle().apply { + putSerializable(ARGUMENT_KEY, grade) + putString(COLOR_SCHEME_KEY, colorScheme) + } } } } @@ -34,6 +38,7 @@ class GradeDetailsDialog : DialogFragment() { setStyle(STYLE_NO_TITLE, 0) arguments?.run { grade = getSerializable(ARGUMENT_KEY) as Grade + colorScheme = getString(COLOR_SCHEME_KEY) ?: "default" } } @@ -58,7 +63,7 @@ class GradeDetailsDialog : DialogFragment() { gradeDialogValue.run { text = grade.entry - setBackgroundResource(grade.valueBgColor) + setBackgroundResource(grade.getBackgroundColor(colorScheme)) } gradeDialogTeacherValue.text = if (grade.teacher.isBlank()) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt index 7a7ac0b5..048d8589 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsFragment.kt @@ -134,8 +134,8 @@ class GradeDetailsFragment : BaseSessionFragment(), GradeDetailsView, GradeView. gradeDetailsSwipe.isRefreshing = show } - override fun showGradeDialog(grade: Grade) { - (activity as? MainActivity)?.showDialogFragment(GradeDetailsDialog.newInstance(grade)) + override fun showGradeDialog(grade: Grade, colorScheme: String) { + (activity as? MainActivity)?.showDialogFragment(GradeDetailsDialog.newInstance(grade, colorScheme)) } override fun onParentLoadData(semesterId: Int, forceRefresh: Boolean) { diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt index ab958bc2..327eed27 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsItem.kt @@ -4,7 +4,6 @@ import android.annotation.SuppressLint import android.view.View import android.view.View.GONE import android.view.View.VISIBLE -import androidx.core.content.ContextCompat import eu.davidea.flexibleadapter.FlexibleAdapter import eu.davidea.flexibleadapter.items.AbstractFlexibleItem import eu.davidea.flexibleadapter.items.IFlexible diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt index a0d9d208..765af079 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsPresenter.kt @@ -12,7 +12,7 @@ import io.github.wulkanowy.utils.FirebaseAnalyticsHelper import io.github.wulkanowy.utils.SchedulersProvider import io.github.wulkanowy.utils.calcAverage import io.github.wulkanowy.utils.changeModifier -import io.github.wulkanowy.utils.valueBgColor +import io.github.wulkanowy.utils.getBackgroundColor import timber.log.Timber import javax.inject.Inject @@ -42,7 +42,7 @@ class GradeDetailsPresenter @Inject constructor( if (item is GradeDetailsItem) { Timber.i("Select grade item ${item.grade.id}") view?.apply { - showGradeDialog(item.grade) + showGradeDialog(item.grade, preferencesRepository.gradeColorTheme) if (!item.grade.isRead) { item.grade.isRead = true updateItem(item) @@ -151,7 +151,7 @@ class GradeDetailsPresenter @Inject constructor( GradeDetailsItem( grade = item, weightString = view?.weightString.orEmpty(), - valueBgColor = item.valueBgColor + valueBgColor = item.getBackgroundColor(preferencesRepository.gradeColorTheme) ) } } diff --git a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsView.kt b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsView.kt index 24254260..9c9349da 100644 --- a/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsView.kt +++ b/app/src/main/java/io/github/wulkanowy/ui/modules/grade/details/GradeDetailsView.kt @@ -28,7 +28,7 @@ interface GradeDetailsView : BaseSessionView { fun collapseAllItems() - fun showGradeDialog(grade: Grade) + fun showGradeDialog(grade: Grade, colorScheme: String) fun showContent(show: Boolean) diff --git a/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt b/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt index cb1967ad..092e9520 100644 --- a/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt +++ b/app/src/main/java/io/github/wulkanowy/utils/GradeExtension.kt @@ -22,18 +22,36 @@ fun List.calcAverage(): Double { }.average().let { if (it.isNaN()) 0.0 else it } } -inline val Grade.valueBgColor: Int - get() { - return when (value) { - 6 -> R.color.grade_six - 5 -> R.color.grade_five - 4 -> R.color.grade_four - 3 -> R.color.grade_three - 2 -> R.color.grade_two - 1 -> R.color.grade_one +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_default + } + "material" -> when (value) { + 6 -> R.color.grade_material_six + 5 -> R.color.grade_material_five + 4 -> R.color.grade_material_four + 3 -> R.color.grade_material_three + 2 -> R.color.grade_material_two + 1 -> R.color.grade_material_one + else -> R.color.grade_default + } + else -> when (value) { + 6 -> R.color.grade_vulcan_six + 5 -> R.color.grade_vulcan_five + 4 -> R.color.grade_vulcan_four + 3 -> R.color.grade_vulcan_three + 2 -> R.color.grade_vulcan_two + 1 -> R.color.grade_vulcan_one else -> R.color.grade_default } } +} inline val Grade.colorStringId: Int get() { diff --git a/app/src/main/res/layout/dialog_grade.xml b/app/src/main/res/layout/dialog_grade.xml index 13224afb..9c2f1006 100644 --- a/app/src/main/res/layout/dialog_grade.xml +++ b/app/src/main/res/layout/dialog_grade.xml @@ -26,9 +26,9 @@ android:layout_gravity="end" android:background="@color/grade_default" android:gravity="center" - android:text="@string/app_name" android:textColor="@color/grade_text" - android:textSize="30sp" /> + android:textSize="30sp" + tools:text="6" /> + android:textSize="16sp" + tools:text="6" /> Wartość plusa Wartość minusa Rozwiń oceny + Schemat kolorów ocen Powiadomienia Pokazuj powiadomienia diff --git a/app/src/main/res/values-pl/value_prefernces.xml b/app/src/main/res/values-pl/value_prefernces.xml index c15fa89e..05f2ed50 100644 --- a/app/src/main/res/values-pl/value_prefernces.xml +++ b/app/src/main/res/values-pl/value_prefernces.xml @@ -9,16 +9,24 @@ 12 godzin 24 godzin + Wyłączony Włączony Automatyczny Używaj ustawień systemowych + Domyślna 0,25 0,33 0,5 + + + Dzienniczek+ + Wulkanowy + Kolory ocen w dzienniku + diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index deff45fb..6de571d9 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -5,16 +5,29 @@ #ff6659 #f0f0f0 - #03a9f4 - #4caf50 - #92c400 - #ffa000 - #ff5722 - #d32f2f #607d8b - #ffffff + #424242 + #F44336 + #2196F3 + #8BC34A + #7E57C2 + + #03a9f4 + #4caf50 + #92c400 + #ffa000 + #ff5722 + #d32f2f + + #91b43c + #2cbd92 + #50b6d6 + #d2ab24 + #9071b3 + #d65757 + #303030 #ffffff diff --git a/app/src/main/res/values/preferences_keys.xml b/app/src/main/res/values/preferences_keys.xml index 54cc2bbd..9007b5df 100644 --- a/app/src/main/res/values/preferences_keys.xml +++ b/app/src/main/res/values/preferences_keys.xml @@ -5,6 +5,7 @@ theme grade_modifier_plus grade_modifier_minus + grade_color_scheme expand_grade services_enable services_interval diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d444a34..d6c3612e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -234,6 +234,7 @@ Value of the plus Value of the minus Expand grades + Grades color scheme Notifications Show notifications diff --git a/app/src/main/res/values/value_prefernces.xml b/app/src/main/res/values/value_prefernces.xml index 56c5de0e..1a1dceca 100644 --- a/app/src/main/res/values/value_prefernces.xml +++ b/app/src/main/res/values/value_prefernces.xml @@ -57,4 +57,15 @@ 0.33 0.5 + + + Dzienniczek+ + Wulkanowy + Grade colors in register + + + vulcan + material + grade_color + diff --git a/app/src/main/res/xml/scheme_preferences.xml b/app/src/main/res/xml/scheme_preferences.xml index 575fea63..a6e6da58 100644 --- a/app/src/main/res/xml/scheme_preferences.xml +++ b/app/src/main/res/xml/scheme_preferences.xml @@ -30,6 +30,14 @@ android:key="@string/pref_key_expand_grade" android:title="@string/pref_view_expand_grade" app:iconSpaceReserved="false" /> +