Commit 60bd38c2 by Paktalin

Tag marking in progress

parent 16f12c22
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</value> </value>
</option> </option>
</component> </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" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">
......
...@@ -16,12 +16,14 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { ...@@ -16,12 +16,14 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
fun bind(wordPojo: WordPojo, fun bind(wordPojo: WordPojo,
position: Int, position: Int,
isActivated: Boolean, isActivated: Boolean,
color: Int,
showPopupMenu: (View, Int) -> Unit) { showPopupMenu: (View, Int) -> Unit) {
tvWord.setText(wordPojo.word) tvWord.setText(wordPojo.word)
tvTranslation.setText(wordPojo.translation) tvTranslation.setText(wordPojo.translation)
visible(itemView.clickable_view) visible(itemView.clickable_view)
itemView.clickable_view.setOnClickListener { showPopupMenu(itemView, position) } itemView.clickable_view.setOnClickListener { showPopupMenu(itemView, position) }
itemView.isActivated = isActivated itemView.isActivated = isActivated
itemView.tag_marker.setTextColor(color)
} }
fun getItemDetails(): ItemDetailsLookup.ItemDetails<Long> = fun getItemDetails(): ItemDetailsLookup.ItemDetails<Long> =
...@@ -30,6 +32,10 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { ...@@ -30,6 +32,10 @@ class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
override fun getSelectionKey(): Long? = itemId override fun getSelectionKey(): Long? = itemId
} }
private fun generateColor() {
}
companion object { companion object {
private val TAG = "VN/" + ViewHolder::class.simpleName private val TAG = "VN/" + ViewHolder::class.simpleName
} }
......
...@@ -66,8 +66,9 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi ...@@ -66,8 +66,9 @@ class VocabularyAdapter(private val vocabulary: VocabSet, private val mainActivi
viewHolder.bind( viewHolder.bind(
vocabulary.displayedAt(position), vocabulary.displayedAt(position),
position, position,
(selectionTracker.selected(position.toLong())) && state.notAddOrEdit()) (selectionTracker.selected(position.toLong())) && state.notAddOrEdit(),
{ view, p -> showPopupMenu(view, p) } vocabulary.getColorForTag(vocabulary.displayedAt(position).tag)
) { view, p -> showPopupMenu(view, p) }
// TODO not allow to edit when tag is being selected // TODO not allow to edit when tag is being selected
} }
......
package com.paktalin.vocabularynotebook.vocabulary package com.paktalin.vocabularynotebook.vocabulary
import android.graphics.Color
import com.google.firebase.Timestamp import com.google.firebase.Timestamp
import com.google.firebase.firestore.QueryDocumentSnapshot import com.google.firebase.firestore.QueryDocumentSnapshot
import com.google.firebase.firestore.QuerySnapshot import com.google.firebase.firestore.QuerySnapshot
import com.paktalin.vocabularynotebook.firestoreitems.WordPojo import com.paktalin.vocabularynotebook.firestoreitems.WordPojo
import java.util.*
class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary { class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
var fullVocabulary = BasicVocabulary(wordList) var fullVocabulary = BasicVocabulary(wordList)
private var displayedVocabulary = DisplayedVocabulary(wordList) private var displayedVocabulary = DisplayedVocabulary(wordList)
var modifiedVocabulary = ModifiedVocabulary() var modifiedVocabulary = ModifiedVocabulary()
var colorMap = mutableMapOf<String?, Int>()
companion object { companion object {
fun createFromSnapshot(querySnapshot: QuerySnapshot): VocabSet { fun createFromSnapshot(querySnapshot: QuerySnapshot): VocabSet {
...@@ -30,6 +33,14 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary { ...@@ -30,6 +33,14 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
private val TAG = "VN/" + VocabSet::class.java.simpleName 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>) { override fun addAll(words: MutableList<WordPojo>) {
listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary) listOf(fullVocabulary, displayedVocabulary, modifiedVocabulary)
.forEach { v -> v.addAll(words) } .forEach { v -> v.addAll(words) }
...@@ -84,4 +95,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary { ...@@ -84,4 +95,8 @@ class VocabSet(var wordList: MutableList<WordPojo>) : Vocabulary {
modifiedVocabulary.addWord(displayedAt(position.toInt())) 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 @@ ...@@ -33,11 +33,19 @@
android:paddingRight="16dp" android:paddingRight="16dp"
android:paddingBottom="8dp"> 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 <EditText
android:id="@+id/word" android:id="@+id/word"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="14"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:hint="@string/hint_word" android:hint="@string/hint_word"
android:inputType="textMultiLine" android:inputType="textMultiLine"
...@@ -54,7 +62,7 @@ ...@@ -54,7 +62,7 @@
android:id="@+id/translation" android:id="@+id/translation"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:layout_weight="14"
android:background="@android:color/transparent" android:background="@android:color/transparent"
android:hint="@string/hint_translation" android:hint="@string/hint_translation"
android:inputType="textMultiLine" android:inputType="textMultiLine"
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<string name="sign_up">Sign Up</string> <string name="sign_up">Sign Up</string>
<string name="log_in">Log In</string> <string name="log_in">Log In</string>
<string name="enter_tag">Add tag</string> <string name="enter_tag">Add tag</string>
<string name="tag_point" translatable="false">\u2022</string>
<!--Toast messages--> <!--Toast messages-->
<string name="toast_empty_vocabulary">Your vocabulary is empty. Add your fist word!</string> <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