diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt index 71b6e316..b63d23ff 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/adapters/HomeAdapter.kt @@ -5,6 +5,7 @@ import android.content.ComponentName import android.content.Context import android.content.Intent import android.graphics.Bitmap +import android.graphics.Color import android.graphics.drawable.BitmapDrawable import android.graphics.drawable.ColorDrawable import android.net.Uri @@ -44,6 +45,8 @@ import com.pennapps.labs.pennmobile.classes.NewsCell import com.pennapps.labs.pennmobile.classes.PollCell import com.pennapps.labs.pennmobile.classes.PostCell import com.pennapps.labs.pennmobile.classes.GSRCell +import com.pennapps.labs.pennmobile.classes.Poll +import com.pennapps.labs.pennmobile.classes.Post import com.pennapps.labs.pennmobile.components.sneaker.Utils.convertToDp import com.pennapps.labs.pennmobile.utils.Utils import eightbitlab.com.blurview.RenderScriptBlur @@ -91,6 +94,9 @@ class HomeAdapter(private val dataModel: HomepageDataModel) : private const val POST = 7 private const val FEATURE = 8 private const val POLL = 9 + + private const val DRAFT_NOTE = " (NOTE: THIS IS A DRAFT THAT USERS CANNOT SEE)" + private const val DRAFT_COLOR = "#ffb300" } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { @@ -348,8 +354,18 @@ class HomeAdapter(private val dataModel: HomepageDataModel) : private fun bindPostCell(holder: ViewHolder, cell: PostCell) { val post = cell.post + + // if the post is a draft, then change the color and add a note + if (cell.post.status == Post.DRAFT) { + holder.itemView.home_post_title.setTextColor(Color.parseColor(DRAFT_COLOR)) + + val draftSubtitle = post.subtitle + DRAFT_NOTE + holder.itemView.home_post_subtitle.text = draftSubtitle + } else { + holder.itemView.home_post_subtitle.text = post.subtitle + } + holder.itemView.home_post_title.text = post.title - holder.itemView.home_post_subtitle.text = post.subtitle holder.itemView.home_post_source.text = "Penn Labs" //post?.clubCode?.capitalize() val time = post.startDate?.substring(5, 7) + " / " + post.startDate?.substring(8, 10) + " - " + @@ -371,7 +387,14 @@ class HomeAdapter(private val dataModel: HomepageDataModel) : mActivity.runOnUiThread { // Change all the components to match the accent color palette vibrantSwatch?.titleTextColor?.let { - holder.itemView.home_post_title.setTextColor(ColorUtils.setAlphaComponent(it, 150)) + if (cell.post.status != Post.DRAFT) { + holder.itemView.home_post_title.setTextColor( + ColorUtils.setAlphaComponent( + it, + 150 + ) + ) + } holder.itemView.home_post_subtitle.setTextColor(it) holder.itemView.home_post_timestamp.setTextColor(it) holder.itemView.home_post_source.setTextColor(it) @@ -423,7 +446,16 @@ class HomeAdapter(private val dataModel: HomepageDataModel) : private fun bindPollCell(holder: ViewHolder, cell: PollCell, position: Int) { val poll = cell.poll - holder.itemView.home_card_title?.text = poll.question + + // if the post is a draft, then change the color and add a note + if (poll.status == Poll.DRAFT) { + holder.itemView.home_card_title.setTextColor(Color.parseColor(DRAFT_COLOR)) + val draftQuestion = poll.question + DRAFT_NOTE + holder.itemView.home_card_title?.text = draftQuestion + } else { + holder.itemView.home_card_title?.text = poll.question + } + holder.itemView.home_card_subtitle_2?.text = "${poll.totalVotes} Votes" if(poll.clubCode != null) { holder.itemView.home_card_subtitle?.text = "POLL FROM ${poll.clubCode}" diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt index d5ce5ef1..05c7a4a6 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Poll.kt @@ -4,6 +4,9 @@ import com.google.gson.annotations.Expose import com.google.gson.annotations.SerializedName class Poll { + companion object { + const val DRAFT = "DRAFT" + } @SerializedName("id") @Expose @@ -41,6 +44,10 @@ class Poll { @Expose val options : List = ArrayList() + @SerializedName("status") + @Expose + internal val status : String? = null + @Expose var totalVotes : Int = 0 diff --git a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Post.kt b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Post.kt index 71a09eca..eed1c389 100644 --- a/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Post.kt +++ b/PennMobile/src/main/java/com/pennapps/labs/pennmobile/classes/Post.kt @@ -8,6 +8,9 @@ import com.google.gson.annotations.SerializedName * Data model for custom posts on homepage */ class Post { + companion object { + const val DRAFT = "DRAFT" + } @SerializedName("id") @Expose @@ -45,7 +48,6 @@ class Post { @Expose internal val expireDate : String? = null - @SerializedName("club_comment") @Expose internal val club_comment : String? = null @@ -67,7 +69,6 @@ class Post { clubCode + "" } override fun equals(other: Any?) : Boolean { - Log.i("CellUpdates", "fuck") // note: target_populations is not included because it's unused and structural return when (other) { is Post -> {