Commit 60bd38c2 by Paktalin

Tag marking in progress

parent 16f12c22
......@@ -35,7 +35,7 @@
</value>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
......
......@@ -16,12 +16,14 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(wordPojo: WordPojo,
position: Int,
isActivated: Boolean,
color: Int,
showPopupMenu: (View, Int) -> Unit) {
tvWord.setText(wordPojo.word)
tvTranslation.setText(wordPojo.translation)
visible(itemView.clickable_view)
itemView.clickable_view.setOnClickListener { showPopupMenu(itemView, position) }
itemView.isActivated = isActivated
itemView.tag_marker.setTextColor(color)
}
fun getItemDetails(): ItemDetailsLookup.ItemDetails<Long> =
......@@ -30,6 +32,10 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
override fun getSelectionKey(): Long? = itemId
}
private fun generateColor() {
}
companion object {
private val TAG = "VN/" + ViewHolder::class.simpleName
}
......
......@@ -66,8 +66,9 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
viewHolder.bind(
vocabulary.displayedAt(position),
position,
(selectionTracker.selected(position.toLong())) && state.notAddOrEdit())
{ view, p -> showPopupMenu(view, p) }
(selectionTracker.selected(position.toLong())) && state.notAddOrEdit(),
vocabulary.getColorForTag(vocabulary.displayedAt(position).tag)
) { view, p -> showPopupMenu(view, p) }
// TODO not allow to edit when tag is being selected
}
......
package com.paktalin.vocabularynotebook.vocabulary
import android.graphics.Color
import com.google.firebase.Timestamp
import com.google.firebase.firestore.QueryDocumentSnapshot
import com.google.firebase.firestore.QuerySnapshot
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import java.util.*
class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
var fullVocabulary = BasicVocabulary(wordList)
private var displayedVocabulary = DisplayedVocabulary(wordList)
var modifiedVocabulary = ModifiedVocabulary()
var colorMap = mutableMapOf<String?, Int>()
companion object {
fun createFromSnapshot(querySnapshot: QuerySnapshot): VocabSet {
......@@ -30,6 +33,14 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
private val TAG = "VN/" + VocabSet::class.java.simpleName
}
init {
// TODO link specific colors to specific TAGs
val rnd = Random()
wordList.forEach { w ->
colorMap[w.tag] = Color.argb(255, rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))
}
}
override fun addAll(words: MutableList<WordPojo>) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.addAll(words) }
......@@ -84,4 +95,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
modifiedVocabulary.addWord(displayedAt(position.toInt()))
}
}
fun getColorForTag(tag: String?): Int {
return colorMap[tag] ?: Color.TRANSPARENT
}
}
\ No newline at end of file
......@@ -33,11 +33,19 @@
android:paddingRight="16dp"
android:paddingBottom="8dp">
<TextView
android:id="@+id/tag_marker"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/tag_point"
android:textSize="@dimen/text_size" />
<EditText
android:id="@+id/word"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="14"
android:background="@android:color/transparent"
android:hint="@string/hint_word"
android:inputType="textMultiLine"
......@@ -54,7 +62,7 @@
android:id="@+id/translation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_weight="14"
android:background="@android:color/transparent"
android:hint="@string/hint_translation"
android:inputType="textMultiLine"
......
......@@ -14,6 +14,7 @@
<string name="sign_up">Sign Up</string>
<string name="log_in">Log In</string>
<string name="enter_tag">Add tag</string>
<string name="tag_point" translatable="false">\u2022</string>
<!--Toast messages-->
<string name="toast_empty_vocabulary">Your vocabulary is empty. Add your fist word!</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment