Skip to content

Commit

Permalink
Beta 0.5.1, post-merge fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Jan 22, 2018
1 parent 3625083 commit 6deb69a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 58 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<activity android:name="io.github.feelfreelinux.wykopmobilny.ui.modules.mikroblog.entry.EntryActivity"
android:parentActivityName="io.github.feelfreelinux.wykopmobilny.ui.modules.mainnavigation.MainNavigationActivity"/>
<activity android:name="io.github.feelfreelinux.wykopmobilny.ui.modules.mikroblog.feed.tag.TagActivity"
<activity android:name="io.github.feelfreelinux.wykopmobilny.ui.modules.tag.TagActivity"
android:parentActivityName="io.github.feelfreelinux.wykopmobilny.ui.modules.mainnavigation.MainNavigationActivity"/>
<activity android:name="io.github.feelfreelinux.wykopmobilny.ui.modules.input.entry.add.AddEntryActivity" />
<activity android:name=".ui.modules.input.entry.edit.EditEntryActivity" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@ class LinkViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
image.isVisible = link.preview != null
link.preview?.let { image.loadImage(link.preview.stripImageCompression()) }
description.text = link.description.removeHtml()
diggCountTextView.text = link.voteCount.toString()
when(link.userVote) {
"dig" -> showDigged()
"bury" -> showBurried()
else -> diggCountTextView.setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
}
diggCountTextView.voteCount = link.voteCount
diggCountTextView.isEnabled = false
diggCountTextView.setVoteState(link.userVote)

commentsCountTextView.text = link.commentsCount.toString()
dateTextView.text = link.date.toPrettyDate()
hotBadgeStrip.isVisible = link.isHot
Expand All @@ -38,37 +36,4 @@ class LinkViewHolder(val view: View) : RecyclerView.ViewHolder(view) {
}
}

fun showBurried() {
view.apply {
diggCountTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.minusPressedColor))
diggCountTextView.isEnabled = false
diggCountTextView.isEnabled = true
setWykopColorDrawable(true)
}
}

fun showDigged() {
view.apply {
diggCountTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.plusPressedColor))
diggCountTextView.isEnabled = false
setWykopColorDrawable(true)
}
}

fun setWykopColorDrawable(isButtonSelected : Boolean) {
view.apply {
if (isButtonSelected) {
diggCountTextView.setTextColor(Color.WHITE)
diggCountTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_wypok_activ, 0, 0, 0);
} else {
diggCountTextView.setTextColor(description.currentTextColor)
val typedArray = context.obtainStyledAttributes(arrayOf(
R.attr.wypokDrawable).toIntArray())
diggCountTextView.setCompoundDrawablesWithIntrinsicBounds(typedArray.getDrawable(0), null, null, null)
typedArray.recycle()

}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import io.github.feelfreelinux.wykopmobilny.R
import io.github.feelfreelinux.wykopmobilny.base.BaseActivity
import io.github.feelfreelinux.wykopmobilny.models.pojo.apiv2.models.TagMetaResponse
import io.github.feelfreelinux.wykopmobilny.models.pojo.apiv2.models.TagStateResponse
import io.github.feelfreelinux.wykopmobilny.ui.modules.NavigatorApi
import io.github.feelfreelinux.wykopmobilny.ui.modules.tag.entries.TagEntriesFragment
import io.github.feelfreelinux.wykopmobilny.utils.isVisible
import io.github.feelfreelinux.wykopmobilny.utils.usermanager.UserManagerApi
import kotlinx.android.synthetic.main.activity_tag.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,30 @@ class DigVoteButton : VoteButton {

override fun setLightThemeDrawable() {
if (isSelected) {
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_plus_activ, 0, 0, 0);
setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_wypok_activ, 0, 0, 0);
} else {
val typedArray = context.obtainStyledAttributes(arrayOf(
R.attr.plusDrawable).toIntArray())
R.attr.wypokDrawable).toIntArray())
setCompoundDrawablesWithIntrinsicBounds(typedArray.getDrawable(0), null, null, null)
typedArray.recycle()

}
}

fun setVoteState(voteState : String?) {
when (voteState) {
"dig" -> {
isButtonSelected = true
setBackgroundColor(ContextCompat.getColor(context, R.color.plusPressedColor))
}
"bury" -> {
isButtonSelected = true
setBackgroundColor(ContextCompat.getColor(context, R.color.minusPressedColor))
}
else -> {
isButtonSelected = false
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,38 +126,36 @@ class LinkWidget(context: Context, attrs: AttributeSet) : CardView(context, attr
}

override fun showBurried() {
diggCountTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.minusPressedColor))
link.userVote = "bury"
diggCountTextView.isEnabled = true
diggCountTextView.setOnClickListener {
diggCountTextView.isButtonSelected = true
diggCountTextView.setVoteState("bury")
diggCountTextView.unvoteListener = {
presenter.voteRemove()
diggCountTextView.isEnabled = false
}
diggCountTextView.isEnabled = true
setWykopColorDrawable(true)
}

override fun showDigged() {
diggCountTextView.setBackgroundColor(ContextCompat.getColor(context, R.color.plusPressedColor))
link.userVote = "dig"
diggCountTextView.isEnabled = true
diggCountTextView.setOnClickListener {
diggCountTextView.isButtonSelected = true
diggCountTextView.setVoteState("dig")
diggCountTextView.unvoteListener = {
presenter.voteRemove()
diggCountTextView.isEnabled = false
}
diggCountTextView.isEnabled = true
setWykopColorDrawable(true)
}

override fun showUnvoted() {
diggCountTextView.setBackgroundColor(Color.TRANSPARENT)
diggCountTextView.setOnClickListener {
diggCountTextView.isButtonSelected = false
diggCountTextView.setVoteState(null)
diggCountTextView.voteListener = {
presenter.voteUp()
diggCountTextView.isEnabled = false
}
link.userVote = null
diggCountTextView.isEnabled = true
setWykopColorDrawable(false)
}

fun openOptionsMenu() {
Expand Down
4 changes: 1 addition & 3 deletions app/src/main/res/layout/link_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,9 @@
app:layout_constraintBottom_toBottomOf="parent"
tools:text="50"/>

<TextView
<io.github.feelfreelinux.wykopmobilny.ui.widgets.buttons.DigVoteButton
android:id="@+id/diggCountTextView"
style="@style/MikroButton"
android:background="?attr/voteButtonStatelist"
android:drawableStart="?attr/wypokDrawable"
android:drawablePadding="@dimen/link_layout_digg_drawable_padding"
app:layout_constraintEnd_toStartOf="@id/moreOptionsTextView"
app:layout_constraintTop_toTopOf="parent"
Expand Down

0 comments on commit 6deb69a

Please sign in to comment.