forked from github/wulkanowy-mirror
Add points to notes (#738)
This commit is contained in:
parent
d9c8bb399b
commit
6f697eff47
@ -123,7 +123,7 @@ configurations.all {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "io.github.wulkanowy:sdk:be7ed9c"
|
||||
implementation "io.github.wulkanowy:sdk:4ea879b"
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
|
||||
implementation "androidx.core:core-ktx:1.2.0"
|
||||
|
1682
app/schemas/io.github.wulkanowy.data.db.AppDatabase/23.json
Normal file
1682
app/schemas/io.github.wulkanowy.data.db.AppDatabase/23.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -63,6 +63,7 @@ import io.github.wulkanowy.data.db.migrations.Migration2
|
||||
import io.github.wulkanowy.data.db.migrations.Migration20
|
||||
import io.github.wulkanowy.data.db.migrations.Migration21
|
||||
import io.github.wulkanowy.data.db.migrations.Migration22
|
||||
import io.github.wulkanowy.data.db.migrations.Migration23
|
||||
import io.github.wulkanowy.data.db.migrations.Migration3
|
||||
import io.github.wulkanowy.data.db.migrations.Migration4
|
||||
import io.github.wulkanowy.data.db.migrations.Migration5
|
||||
@ -104,7 +105,7 @@ import javax.inject.Singleton
|
||||
abstract class AppDatabase : RoomDatabase() {
|
||||
|
||||
companion object {
|
||||
const val VERSION_SCHEMA = 22
|
||||
const val VERSION_SCHEMA = 23
|
||||
|
||||
fun getMigrations(sharedPrefProvider: SharedPrefProvider): Array<Migration> {
|
||||
return arrayOf(
|
||||
@ -128,7 +129,8 @@ abstract class AppDatabase : RoomDatabase() {
|
||||
Migration19(sharedPrefProvider),
|
||||
Migration20(),
|
||||
Migration21(),
|
||||
Migration22()
|
||||
Migration22(),
|
||||
Migration23()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -16,8 +16,19 @@ data class Note(
|
||||
|
||||
val teacher: String,
|
||||
|
||||
@ColumnInfo(name = "teacher_symbol")
|
||||
val teacherSymbol: String,
|
||||
|
||||
val category: String,
|
||||
|
||||
@ColumnInfo(name = "category_type")
|
||||
val categoryType: Int,
|
||||
|
||||
@ColumnInfo(name = "is_points_show")
|
||||
val isPointsShow: Boolean,
|
||||
|
||||
val points: Int,
|
||||
|
||||
val content: String
|
||||
) : Serializable {
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.github.wulkanowy.data.db.migrations
|
||||
|
||||
import androidx.room.migration.Migration
|
||||
import androidx.sqlite.db.SupportSQLiteDatabase
|
||||
|
||||
class Migration23 : Migration(22, 23) {
|
||||
|
||||
override fun migrate(database: SupportSQLiteDatabase) {
|
||||
database.execSQL("ALTER TABLE Notes ADD COLUMN teacher_symbol TEXT NOT NULL DEFAULT ''")
|
||||
database.execSQL("ALTER TABLE Notes ADD COLUMN category_type INTEGER NOT NULL DEFAULT 0")
|
||||
database.execSQL("ALTER TABLE Notes ADD COLUMN is_points_show INTEGER NOT NULL DEFAULT 0")
|
||||
database.execSQL("ALTER TABLE Notes ADD COLUMN points INTEGER NOT NULL DEFAULT 0")
|
||||
}
|
||||
}
|
@ -18,7 +18,11 @@ class NoteRemote @Inject constructor(private val sdk: Sdk) {
|
||||
studentId = semester.studentId,
|
||||
date = it.date,
|
||||
teacher = it.teacher,
|
||||
teacherSymbol = it.teacherSymbol,
|
||||
category = it.category,
|
||||
categoryType = it.categoryType.id,
|
||||
isPointsShow = it.showPoints,
|
||||
points = it.points,
|
||||
content = it.content
|
||||
)
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
package io.github.wulkanowy.ui.modules.note
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
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.Note
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import kotlinx.android.synthetic.main.dialog_note.*
|
||||
import io.github.wulkanowy.sdk.scrapper.notes.Note.CategoryType
|
||||
|
||||
class NoteDialog : DialogFragment() {
|
||||
|
||||
@ -36,6 +40,7 @@ class NoteDialog : DialogFragment() {
|
||||
return inflater.inflate(R.layout.dialog_note, container, false)
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
|
||||
@ -43,6 +48,16 @@ class NoteDialog : DialogFragment() {
|
||||
noteDialogCategory.text = note.category
|
||||
noteDialogTeacher.text = note.teacher
|
||||
noteDialogContent.text = note.content
|
||||
if (note.isPointsShow) {
|
||||
with(noteDialogPoints) {
|
||||
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
||||
setTextColor(when (CategoryType.getByValue(note.categoryType)) {
|
||||
CategoryType.POSITIVE -> ContextCompat.getColor(requireContext(), R.color.note_positive)
|
||||
CategoryType.NEGATIVE -> ContextCompat.getColor(requireContext(), R.color.note_negative)
|
||||
else -> requireContext().getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||
})
|
||||
}
|
||||
}
|
||||
noteDialogClose.setOnClickListener { dismiss() }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,20 @@
|
||||
package io.github.wulkanowy.ui.modules.note
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.graphics.Typeface.BOLD
|
||||
import android.graphics.Typeface.NORMAL
|
||||
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
|
||||
import eu.davidea.viewholders.FlexibleViewHolder
|
||||
import io.github.wulkanowy.R
|
||||
import io.github.wulkanowy.data.db.entities.Note
|
||||
import io.github.wulkanowy.sdk.scrapper.notes.Note.CategoryType
|
||||
import io.github.wulkanowy.utils.getThemeAttrColor
|
||||
import io.github.wulkanowy.utils.toFormattedString
|
||||
import kotlinx.android.extensions.LayoutContainer
|
||||
import kotlinx.android.synthetic.main.item_note.*
|
||||
@ -17,20 +23,30 @@ class NoteItem(val note: Note) : AbstractFlexibleItem<NoteItem.ViewHolder>() {
|
||||
|
||||
override fun getLayoutRes() = R.layout.item_note
|
||||
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): NoteItem.ViewHolder {
|
||||
return NoteItem.ViewHolder(view, adapter)
|
||||
override fun createViewHolder(view: View, adapter: FlexibleAdapter<IFlexible<*>>): ViewHolder {
|
||||
return ViewHolder(view, adapter)
|
||||
}
|
||||
|
||||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: NoteItem.ViewHolder, position: Int, payloads: MutableList<Any>?) {
|
||||
@SuppressLint("SetTextI18n")
|
||||
override fun bindViewHolder(adapter: FlexibleAdapter<IFlexible<*>>, holder: ViewHolder, position: Int, payloads: MutableList<Any>?) {
|
||||
holder.apply {
|
||||
noteItemDate.apply {
|
||||
with(noteItemDate) {
|
||||
text = note.date.toFormattedString()
|
||||
setTypeface(null, if (note.isRead) NORMAL else BOLD)
|
||||
}
|
||||
noteItemType.apply {
|
||||
with(noteItemType) {
|
||||
text = note.category
|
||||
setTypeface(null, if (note.isRead) NORMAL else BOLD)
|
||||
}
|
||||
with(noteItemPoints) {
|
||||
text = "${if (note.points > 0) "+" else ""}${note.points}"
|
||||
visibility = if (note.isPointsShow) VISIBLE else GONE
|
||||
setTextColor(when(CategoryType.getByValue(note.categoryType)) {
|
||||
CategoryType.POSITIVE -> ContextCompat.getColor(context, R.color.note_positive)
|
||||
CategoryType.NEGATIVE -> ContextCompat.getColor(context, R.color.note_negative)
|
||||
else -> context.getThemeAttrColor(android.R.attr.textColorPrimary)
|
||||
})
|
||||
}
|
||||
noteItemTeacher.text = note.teacher
|
||||
noteItemContent.text = note.content
|
||||
}
|
||||
@ -53,7 +69,8 @@ class NoteItem(val note: Note) : AbstractFlexibleItem<NoteItem.ViewHolder>() {
|
||||
return result
|
||||
}
|
||||
|
||||
class ViewHolder(val view: View, adapter: FlexibleAdapter<*>) : FlexibleViewHolder(view, adapter), LayoutContainer {
|
||||
class ViewHolder(val view: View, adapter: FlexibleAdapter<*>) :
|
||||
FlexibleViewHolder(view, adapter), LayoutContainer {
|
||||
override val containerView: View
|
||||
get() = contentView
|
||||
}
|
||||
|
@ -64,6 +64,22 @@
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="10dp"
|
||||
android:text="@string/note_points"
|
||||
android:textSize="17sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteDialogPoints"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:text="@string/all_no_data"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@ -1,4 +1,5 @@
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/note_subitem_container"
|
||||
android:layout_width="match_parent"
|
||||
@ -8,54 +9,76 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteItemDate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
android:textSize="15sp"
|
||||
app:layout_constraintRight_toLeftOf="@+id/noteItemTeacher"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/date/ddmmyy" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteItemTeacher"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_toEndOf="@id/noteItemDate"
|
||||
android:layout_toRightOf="@id/noteItemDate"
|
||||
android:ellipsize="end"
|
||||
android:gravity="end"
|
||||
android:singleLine="true"
|
||||
android:textSize="13sp"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/noteItemDate"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="@tools:sample/full_names" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteItemType"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/noteItemDate"
|
||||
android:layout_alignStart="@id/noteItemDate"
|
||||
android:layout_alignLeft="@id/noteItemDate"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:textSize="13sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:textSize="16sp"
|
||||
app:layout_constraintLeft_toLeftOf="@id/noteItemDate"
|
||||
app:layout_constraintRight_toLeftOf="@id/noteItemPoints"
|
||||
app:layout_constraintTop_toBottomOf="@id/noteItemDate"
|
||||
app:layout_goneMarginEnd="0dp"
|
||||
tools:text="@tools:sample/lorem" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteItemContent"
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/noteItemPoints"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/noteItemType"
|
||||
android:layout_alignStart="@id/noteItemDate"
|
||||
android:layout_alignLeft="@id/noteItemDate"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintRight_toRightOf="@id/noteItemTeacher"
|
||||
app:layout_constraintTop_toBottomOf="@id/noteItemTeacher"
|
||||
tools:text="-5"
|
||||
tools:textColor="@color/note_positive"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/noteItemContent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:ellipsize="end"
|
||||
android:lineSpacingMultiplier="1.2"
|
||||
android:maxLines="2"
|
||||
android:textSize="14sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="@id/noteItemDate"
|
||||
app:layout_constraintRight_toRightOf="@+id/noteItemTeacher"
|
||||
app:layout_constraintTop_toBottomOf="@id/noteItemType"
|
||||
tools:text="@tools:sample/lorem/random" />
|
||||
</RelativeLayout>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
@ -201,6 +201,7 @@
|
||||
|
||||
<!--Note-->
|
||||
<string name="note_no_items">Keine Informationen über Eintragen</string>
|
||||
<string name="note_points">Punkte</string>
|
||||
<plurals name="note_number_item">
|
||||
<item quantity="one">%d Eintrag</item>
|
||||
<item quantity="other">%d Eintragen</item>
|
||||
|
@ -220,6 +220,7 @@
|
||||
|
||||
<!--Note-->
|
||||
<string name="note_no_items">Brak informacji o uwagach</string>
|
||||
<string name="note_points">Punkty</string>
|
||||
<plurals name="note_number_item">
|
||||
<item quantity="one">%d uwaga</item>
|
||||
<item quantity="few">%d uwagi</item>
|
||||
|
@ -216,6 +216,7 @@
|
||||
|
||||
<!--Note-->
|
||||
<string name="note_no_items">Нет данных о предупреждениях</string>
|
||||
<string name="note_points">точек</string>
|
||||
<plurals name="note_number_item">
|
||||
<item quantity="one">%d предупреждение</item>
|
||||
<item quantity="few">%d предупреждения</item>
|
||||
|
@ -217,6 +217,7 @@
|
||||
|
||||
<!--Note-->
|
||||
<string name="note_no_items">Немає даних про нотатки</string>
|
||||
<string name="note_points">точок</string>
|
||||
<plurals name="note_number_item">
|
||||
<item quantity="one">%d нотатка</item>
|
||||
<item quantity="few">%d нотатки</item>
|
||||
|
@ -12,6 +12,9 @@
|
||||
<color name="colorDivider">#1f000000</color>
|
||||
<color name="colorDividerInverse">#1fffffff</color>
|
||||
|
||||
<color name="note_positive">#a0c431</color>
|
||||
<color name="note_negative">#d43f3f</color>
|
||||
|
||||
<color name="grade_black">#424242</color>
|
||||
<color name="grade_red">#d43f3f</color>
|
||||
<color name="grade_blue">#49a6f2</color>
|
||||
|
@ -209,6 +209,7 @@
|
||||
|
||||
<!--Note-->
|
||||
<string name="note_no_items">No info about notes</string>
|
||||
<string name="note_points">Points</string>
|
||||
<plurals name="note_number_item">
|
||||
<item quantity="one">%d note</item>
|
||||
<item quantity="other">%d notes</item>
|
||||
|
Loading…
Reference in New Issue
Block a user