Skip to content

Commit

Permalink
fix: Integer overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
feelfreelinux committed Apr 10, 2019
1 parent 3933492 commit 773aba2
Show file tree
Hide file tree
Showing 24 changed files with 444 additions and 60 deletions.
9 changes: 5 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ android {
buildConfigField 'String', 'APP_SECRET', credentialsProperties['apiSecret']
buildConfigField 'String', 'APP_KEY', credentialsProperties['apiKey']
buildConfigField 'String', 'GOOGLE_KEY', credentialsProperties['googleKey']
resValue 'string', 'GOOGLE_API_KEY', credentialsProperties['googleKey']
}

signingConfigs {
Expand Down Expand Up @@ -98,13 +99,13 @@ dependencies {

// Support library
implementation 'androidx.appcompat:appcompat:1.1.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha01'
implementation "android.arch.work:work-runtime:1.0.0-beta02"
implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha02'
implementation "android.arch.work:work-runtime:1.0.0-beta03"
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.preference:preference:1.1.0-alpha02'
implementation 'androidx.legacy:legacy-preference-v14:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha02'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation "androidx.preference:preference:1.1.0-alpha02"
implementation 'com.takisoft.preferencex:preferencex:1.0.0-alpha2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
Expand All @@ -116,7 +117,7 @@ dependencies {
implementation 'com.google.android.exoplayer:extension-okhttp:2.6.0'
implementation 'com.davemorrissey.labs:subsampling-scale-image-view:3.10.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'androidx.core:core-ktx:1.1.0-alpha03'
implementation 'androidx.core:core-ktx:1.1.0-alpha04'

// Utils
implementation 'com.bugsnag:bugsnag-android:4.5.0'
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
<activity android:name=".ui.modules.embedview.YoutubeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="sensor"
android:theme="@style/FullscreenActivityTheme"/>


<receiver android:name=".ui.modules.notifications.notificationsservice.WykopNotificationsBroadcastReceiver">
<intent-filter>
Expand Down Expand Up @@ -175,6 +172,12 @@
<action android:name="android.service.notification.NotificationListenerService"/>
</intent-filter>
</service>

<activity android:name=".ui.modules.embedview.YTPlayer"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="sensor"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ interface LinksApi {
inputStream: WykopImageFile,
linkId: Int, linkComment: Int
): Single<LinkComment>
fun relatedAdd(
title: String,
url: String,
plus18: Boolean,
linkId: Int
): Single<Related>

fun commentAdd(
body: String, embed: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,17 @@ class LinksRepository(
.compose<LinkCommentResponse>(ErrorHandlerTransformer())
.map { LinkCommentMapper.map(it, owmContentFilter) }

override fun relatedAdd(
title: String,
url: String,
plus18: Boolean,
linkId: Int
): Single<Related> =
linksApi.addRelated(title, linkId, url, plus18)
.retryWhen(userTokenRefresher)
.compose<RelatedResponse>(ErrorHandlerTransformer())
.map { RelatedMapper.map(it) }

override fun commentAdd(
body: String,
plus18: Boolean,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ interface LinksRetrofitApi {
@Field("adultmedia") plus18: Boolean
): Single<WykopApiResponse<LinkCommentResponse>>

@FormUrlEncoded
@POST("/links/relatedadd/{linkId}/appkey/$APP_KEY")
fun addRelated(
@Field("title") body: String,
@Path("linkId") linkId: Int,
@Field("url") url: String,
@Field("plus18") plus18: Boolean
): Single<WykopApiResponse<RelatedResponse>>

@FormUrlEncoded
@POST("/links/commentedit/{linkId}/appkey/$APP_KEY")
fun editComment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ abstract class ActivityBuilder {
@ContributesAndroidInjector(modules = [RelatedModule::class])
abstract fun bindRelatedActivity(): RelatedActivity

@ContributesAndroidInjector(modules = [])
abstract fun bindYoutubeActivity(): YoutubeActivity

@ContributesAndroidInjector(modules = [ProfileModule::class, ProfileFragmentProvider::class])
abstract fun bindProfileActivity(): ProfileActivity

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.github.feelfreelinux.wykopmobilny.models.dataclass

open class Notification(
val id: Int,
val id: Long,
val author: Author?,
val body: String,
val date: String,
Expand All @@ -19,6 +19,6 @@ open class Notification(
}

override fun hashCode(): Int {
return id
return id.toInt()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.fasterxml.jackson.annotation.JsonProperty

@JsonIgnoreProperties(ignoreUnknown = true)
data class NotificationResponse(
@JsonProperty("id") val id: Int,
@JsonProperty("id") val id: Long,
@JsonProperty("author") val author: AuthorResponse?,
@JsonProperty("date") val date: String,
@JsonProperty("body") val body: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ class LinkHeaderViewHolder(
description.text = link.description.removeHtml()
relatedCountTextView.text = link.relatedCount.toString()
relatedCountTextView.setOnClickListener {
if (link.relatedCount > 0) {
navigatorApi.openLinkRelatedActivity(link.id)
}
navigatorApi.openLinkRelatedActivity(link.id)
}
containerView.setOnClickListener {
linkHandlerApi.handleUrl(link.sourceUrl)
Expand Down Expand Up @@ -179,9 +177,7 @@ class LinkHeaderViewHolder(
}

link_related.setOnClickListener {
if (link.relatedCount > 0) {
navigatorApi.openLinkRelatedActivity(link.id)
}
navigatorApi.openLinkRelatedActivity(link.id)
dialog.dismiss()
}
link_bury.isVisible = userManagerApi.isUserAuthorized()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import android.content.Context
import android.view.View
import io.github.feelfreelinux.wykopmobilny.R
import kotlinx.android.synthetic.main.dialog_edittext.view.*
import kotlinx.android.synthetic.main.dialog_insert_link.view.*

typealias formatDialogCallback = (String) -> Unit
typealias addRelatedDialogCallback = (String, String) -> Unit

fun editTextFormatDialog(titleId: Int, context: Context, callback: formatDialogCallback): AlertDialog {
val editTextLayout = getEditTextView(context)
Expand Down Expand Up @@ -37,4 +39,14 @@ fun confirmationDialog(context: Context, callback: () -> Unit): AlertDialog {
}
}

fun addRelatedDialog(context: Context, callback: addRelatedDialogCallback): AlertDialog {
val editTextLayout = View.inflate(context, R.layout.dialog_insert_link, null)
context.createAlertBuilder().run {
setTitle("Dodaj powiązane")
setView(editTextLayout)
setPositiveButton(android.R.string.ok) { _, _ -> callback.invoke(editTextLayout.link.text.toString(), editTextLayout.description.text.toString()) }
return create()
}
}

private fun getEditTextView(context: Context) = View.inflate(context, R.layout.dialog_edittext, null)
Loading

0 comments on commit 773aba2

Please sign in to comment.