-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1921 from dedis/work-fe2-maxime-deterministic-use…
…rname Displaying Deterministic Username for a given Token
- Loading branch information
Showing
25 changed files
with
381 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 37 additions & 9 deletions
46
...p/src/main/java/com/github/dedis/popstellar/ui/lao/event/rollcall/RollCallArrayAdapter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,64 @@ | ||
package com.github.dedis.popstellar.ui.lao.event.rollcall | ||
|
||
import android.content.Context | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.widget.ArrayAdapter | ||
import android.widget.TextView | ||
import androidx.core.content.ContextCompat | ||
import com.github.dedis.popstellar.R | ||
import com.github.dedis.popstellar.model.objects.security.PoPToken | ||
import com.github.dedis.popstellar.model.objects.security.PublicKey | ||
|
||
class RollCallArrayAdapter( | ||
private val context: Context, | ||
private val layout: Int, | ||
private val attendeesList: List<String>, | ||
private val attendeesList: List<PublicKey>, | ||
private val myToken: PoPToken?, | ||
private val fragment: RollCallFragment | ||
) : ArrayAdapter<String>(context, layout, attendeesList) { | ||
) : ArrayAdapter<PublicKey>(context, layout, attendeesList) { | ||
|
||
init { | ||
fragment.isAttendeeListSorted(attendeesList, context) | ||
fragment.isAttendeeListSorted(attendeesList.map { it.encoded }, context) | ||
} | ||
|
||
override fun getView(position: Int, convertView: View?, parent: ViewGroup): View { | ||
val view = super.getView(position, convertView, parent) | ||
val view: View | ||
val holder: ViewHolder | ||
|
||
// highlights our token in the list | ||
val currentToken = getItem(position) | ||
if (myToken != null && currentToken == myToken.publicKey.encoded) { | ||
val colorAccent = ContextCompat.getColor(context, R.color.colorAccent) | ||
(view as TextView).setTextColor(colorAccent) | ||
if (convertView == null) { | ||
view = LayoutInflater.from(context).inflate(R.layout.list_item_attendee, parent, false) | ||
holder = ViewHolder(view) | ||
view.tag = holder | ||
} else { | ||
view = convertView | ||
holder = view.tag as ViewHolder | ||
} | ||
|
||
val publicKey = getItem(position) | ||
if (publicKey != null) { | ||
holder.usernameTextView.text = publicKey.getLabel() | ||
holder.hashTextView.text = publicKey.encoded | ||
|
||
// Set the default color | ||
val defaultColor = ContextCompat.getColor(context, R.color.textOnBackground) | ||
holder.usernameTextView.setTextColor(defaultColor) | ||
holder.hashTextView.setTextColor(defaultColor) | ||
|
||
// highlights our token in the list | ||
if (myToken != null && publicKey.encoded == myToken.publicKey.encoded) { | ||
val colorAccent = ContextCompat.getColor(context, R.color.colorAccent) | ||
holder.usernameTextView.setTextColor(colorAccent) | ||
holder.hashTextView.setTextColor(colorAccent) | ||
} | ||
} | ||
|
||
return view | ||
} | ||
|
||
private class ViewHolder(view: View) { | ||
val usernameTextView: TextView = view.findViewById(R.id.username_text_view) | ||
val hashTextView: TextView = view.findViewById(R.id.hash_text_view) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.