Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Dec 12, 2017
1 parent 5af5a66 commit 0913651
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ android {
applicationId "io.github.feelfreelinux.wykopmobilny"
minSdkVersion 17
targetSdkVersion 26
versionCode 17
versionName "0.4.1.2"
versionCode 18
versionName "0.4.1.3"

def credentialsPropertiesFile = rootProject.file("credentials.properties")
def credentialsProperties = new Properties()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data class Entry(val id : Int,
var isFavorite : Boolean,
val survey : Survey?,
val embed : Embed?,
val voteCount : Int,
var voteCount : Int,
val commentsCount : Int,
val comments : List<EntryComment>,
val app : String?)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ data class Link(
val canVote : Boolean,
val isHot : Boolean,
val status : String,
val userVote : Int,
val userVote : String?,
val app : String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LinkResponse(
val status : String,

@Json(name="user_vote")
val userVote : Int,
val userVote : String?,

@Json(name="app")
val app : String?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package io.github.feelfreelinux.wykopmobilny.ui.adapters.viewholders

import android.support.v4.content.ContextCompat
import android.support.v7.widget.RecyclerView
import android.view.View
import io.github.feelfreelinux.wykopmobilny.R
import io.github.feelfreelinux.wykopmobilny.models.dataclass.Link
import io.github.feelfreelinux.wykopmobilny.utils.*
import io.github.feelfreelinux.wykopmobilny.utils.api.stripImageCompression
Expand All @@ -16,6 +18,7 @@ class LinkViewHolder(val view: View) : RecyclerView.ViewHolder(view), URLClicked
fun bindView(link : Link) {
view.apply {
title.text = link.title.removeHtml()
image.isVisible = link.preview != null
link.preview?.let { image.loadImage(link.preview.stripImageCompression()) }
description.text = link.description.removeHtml()
diggCountTextView.text = link.voteCount.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
JobUtil.hasBootPermission(this)

// Setup AppUpdater
AppUpdater(this)
/*AppUpdater(this)
.setUpdateFrom(UpdateFrom.GITHUB)
.setGitHubUserAndRepo("feelfreelinux", "WykopMobilny")
.setTitleOnUpdateAvailable(R.string.update_available)
.setContentOnUpdateAvailable(R.string.update_app)
.setButtonDismiss(R.string.cancel)
.setButtonDoNotShowAgain(R.string.do_not_show_again)
.setButtonUpdate(R.string.update)
.start()
.start()*/

if (settingsApi.showNotifications) {
// Schedules notification service
Expand Down Expand Up @@ -191,8 +191,10 @@ class NavigationActivity : BaseActivity(), MainNavigationView, NavigationView.On
}

fun openMainFragment() {
// @TODO Handle settings here
openFragment(HotFragment())
when (settingsApi.defaultScreen!!) {
"mainpage" -> openFragment(PromotedFragment.newInstance())
"mikroblog" -> openFragment(HotFragment.newInstance())
}
}

override fun openFragment(fragment: Fragment) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ class SettingsActivity : BaseActivity() {
(findPreference("hotEntriesScreen") as ListPreference).apply {
summary = entry
}

(findPreference("defaultScreen") as ListPreference).apply {
summary = entry
}
}

override fun onSharedPreferenceChanged(sharedPrefs: SharedPreferences, key: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ abstract class BaseVoteButton : TextView {
get() = text.toString().toInt()
set(value) {
text = context.getString(R.string.votes_count, value)
setButtonVoteCount(value)
}

abstract fun setButtonState(isSelected : Boolean)
abstract fun setButtonVoteCount(voteCount : Int)

var isButtonSelected: Boolean
get() = isSelected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class EntryVoteButton : BaseVoteButton, EntryVoteButtonView {
entryReference.get()?.isVoted = isSelected
}

override fun setButtonVoteCount(voteCount: Int) {
entryReference.get()?.voteCount = voteCount
}

fun setEntryData(entry : Entry) {
entryReference = WeakReference(entry)
presenter.entryId = entry.id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ class EntryCommentVoteButton : BaseVoteButton, EntryCommentVoteButtonView {
entryCommentReference.get()?.isVoted = isSelected
}

override fun setButtonVoteCount(voteCount: Int) {
entryCommentReference.get()?.voteCount = voteCount
}

fun setCommentData(comment : EntryComment) {
presenter.commentId = comment.id
voteCount = comment.voteCount
entryCommentReference = WeakReference(comment)
voteCount = comment.voteCount

if (comment.voteCount > 0) {
setOnLongClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.content.Context
interface SettingsPreferencesApi {
var notificationsSchedulerDelay : String?
var hotEntriesScreen : String?
var defaultScreen : String?
var showAdultContent : Boolean
var useDarkTheme : Boolean
var showNotifications : Boolean
Expand All @@ -15,6 +16,7 @@ class SettingsPreferences(context : Context) : Preferences(context, true), Setti
override var notificationsSchedulerDelay by stringPref(defaultValue = "15")
override var showAdultContent by booleanPref(defaultValue = false)
override var hotEntriesScreen by stringPref(defaultValue = "newest")
override var defaultScreen by stringPref(defaultValue = "mainpage")
override var useDarkTheme by booleanPref(defaultValue = false)
override var showNotifications by booleanPref(defaultValue = true)
}
10 changes: 10 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
<item>8 godzin</item>
</string-array>

<string-array name="preferences_default_screen">
<item>@string/main_page</item>
<item>@string/mikroblog</item>
</string-array>

<string-array name="preferences_default_screen_values">
<item>mainpage</item>
<item>mikroblog</item>
</string-array>

<string-array name="preferences_hot_screen">
<item>@string/period24</item>
<item>@string/period12</item>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
<string name="pref_content_plus18">Pokazuj treści 18+</string>
<string name="pref_content_filternsfw">Zamazuj treści z tagiem #nsfw</string>
<string name="not_implemented">Nie zaimplementowano</string>
<string name="defaultHotScreen">Domyślny ekran w gorących wpisach</string>
<string name="defaultScreen">Domyślny ekran aplikacji</string>


<string name="newest_entries">Najnowsze wpisy</string>
<string name="share">Udostępnij</string>
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/res/xml/app_preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
android:title="@string/pref_dark_style"
android:defaultValue="false"/>

<android.support.v7.preference.ListPreference
android:key="defaultScreen"
android:title="@string/defaultScreen"
android:entries="@array/preferences_default_screen"
android:entryValues="@array/preferences_default_screen_values"
android:defaultValue="mainpage"/>

<android.support.v7.preference.ListPreference
android:key="hotEntriesScreen"
android:title="Domyślny ekran w gorących wpisach"
android:title="@string/defaultHotScreen"
android:entries="@array/preferences_hot_screen"
android:entryValues="@array/preferences_hot_screen_values"
android:defaultValue="newest"/>
Expand Down

0 comments on commit 0913651

Please sign in to comment.