Commit 6088f953 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Merge remote-tracking branch 'remotes/origin/develop' into feature/project_tabs

# Conflicts:
#	app/src/main/java/ru/terrakok/gitlabclient/model/data/server/GitlabApi.kt
#	app/src/main/java/ru/terrakok/gitlabclient/model/repository/mergerequest/MergeRequestRepository.kt
#	app/src/main/res/layout/fragment_project_info.xml
parents cf7bf4b4 1606dadd
......@@ -10,11 +10,13 @@ android {
defaultConfig {
applicationId "ru.terrakok.gitlabclient"
minSdkVersion 19
targetSdkVersion 27
versionName "1.0"
versionCode getBuildNumber()
buildConfigField "String", "VERSION_UID", '"' + getBuildUid() + '"'
buildConfigField "String", "APP_DESCRIPTION", '"Gitfox is an Android client for Gitlab."'
buildConfigField "String", "FEEDBACK_URL", '"https://gitlab.com/terrakok/gitlab-client/issues"'
......@@ -50,69 +52,65 @@ android {
}
}
kapt {
generateStubs true
}
ext {
supportLibraryVersion = "27.0.2"
supportLibraryVersion = "27.1.0"
moxyVersion = "1.4.6"
toothpickVersion = "1.0.6"
retrofitVersion = "2.2.0"
markwonVersion = "1.0.3"
}
dependencies {
//Support
compile "com.android.support:appcompat-v7:$supportLibraryVersion"
compile "com.android.support:design:$supportLibraryVersion"
compile "com.android.support.constraint:constraint-layout:1.0.2"
implementation "com.android.support:appcompat-v7:$supportLibraryVersion"
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support.constraint:constraint-layout:1.0.2"
implementation "com.android.support:cardview-v7:$supportLibraryVersion"
//Kotlin
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
//Log
compile "com.jakewharton.timber:timber:4.5.1"
implementation "com.jakewharton.timber:timber:4.5.1"
//MVP Moxy
kapt "com.arello-mobile:moxy-compiler:$moxyVersion"
compile "com.arello-mobile:moxy-app-compat:$moxyVersion"
implementation "com.arello-mobile:moxy-app-compat:$moxyVersion"
//Cicerone Navigation
compile "ru.terrakok.cicerone:cicerone:3.0.0"
implementation "ru.terrakok.cicerone:cicerone:3.0.0"
//DI
compile "com.github.stephanenicolas.toothpick:toothpick-runtime:$toothpickVersion"
implementation "com.github.stephanenicolas.toothpick:toothpick-runtime:$toothpickVersion"
kapt "com.github.stephanenicolas.toothpick:toothpick-compiler:$toothpickVersion"
//Gson
compile "com.google.code.gson:gson:2.8.0"
implementation "com.google.code.gson:gson:2.8.0"
//Retrofit
compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
compile "com.squareup.okhttp3:logging-interceptor:3.6.0"
compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
implementation "com.squareup.okhttp3:logging-interceptor:3.6.0"
implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
//RxJava
compile "io.reactivex.rxjava2:rxandroid:2.0.1"
compile "io.reactivex.rxjava2:rxjava:2.1.0"
compile 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
implementation "io.reactivex.rxjava2:rxandroid:2.0.1"
implementation "io.reactivex.rxjava2:rxjava:2.1.0"
implementation 'com.jakewharton.rxrelay2:rxrelay:2.0.0'
//Adapter simplify
compile "com.hannesdorfmann:adapterdelegates3:3.0.1"
implementation "com.hannesdorfmann:adapterdelegates3:3.0.1"
//Image load and cache
compile "com.github.bumptech.glide:glide:3.8.0"
implementation "com.github.bumptech.glide:glide:3.8.0"
//Markdown to HTML converter
compile 'ru.noties:markwon:1.0.3'
implementation "ru.noties:markwon:$markwonVersion"
implementation "ru.noties:markwon-image-loader:$markwonVersion"
//Bottom navigation bar
compile 'com.aurelhubert:ahbottomnavigation:2.1.0'
//Custom fonts
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
//Lottie
compile 'com.airbnb.android:lottie:2.1.0'
implementation 'com.airbnb.android:lottie:2.1.0'
//Date
compile 'joda-time:joda-time:2.9.9'
implementation 'com.jakewharton.threetenabp:threetenabp:1.0.5'
//FlexBox Layout
compile 'com.google.android:flexbox:0.3.1'
implementation 'com.google.android:flexbox:0.3.1'
//JUnit
testCompile "junit:junit:4.12"
testImplementation "junit:junit:4.12"
//Mockito
testCompile "org.mockito:mockito-core:2.8.9"
testImplementation "org.mockito:mockito-core:2.8.9"
//Mockito Kotlin
testCompile "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
implementation 'com.android.support:cardview-v7:27.0.2'
testImplementation "com.nhaarman:mockito-kotlin-kt1.1:1.5.0"
}
configurations.all {
......
......@@ -2,6 +2,7 @@ package ru.terrakok.gitlabclient
import android.app.Application
import android.graphics.Color
import com.jakewharton.threetenabp.AndroidThreeTen
import ru.noties.markwon.SpannableConfiguration
import ru.noties.markwon.spans.SpannableTheme
import ru.terrakok.gitlabclient.model.data.auth.AuthHolder
......@@ -13,7 +14,6 @@ import toothpick.Toothpick
import toothpick.configuration.Configuration
import toothpick.registries.FactoryRegistryLocator
import toothpick.registries.MemberInjectorRegistryLocator
import uk.co.chrisjenx.calligraphy.CalligraphyConfig
/**
* @author Konstantin Tskhovrebov (aka terrakok) on 26.03.17.
......@@ -26,8 +26,8 @@ class App : Application() {
initLogger()
initToothpick()
initAppScope()
initCalligraphy()
initMarkwon()
initThreetenABP()
}
private fun initLogger() {
......@@ -56,13 +56,6 @@ class App : Application() {
serverScope.installModules(ServerModule(authHolder.serverPath))
}
private fun initCalligraphy() {
CalligraphyConfig.initDefault(CalligraphyConfig.Builder()
.setDefaultFontPath(getString(R.string.font_main_regular))
.setFontAttrId(R.attr.fontPath)
.build())
}
private fun initMarkwon() {
val theme = SpannableTheme.builderWithDefaults(this)
.codeTextColor(Color.parseColor("#C0341D"))
......@@ -72,4 +65,8 @@ class App : Application() {
.theme(theme)
.build()
}
private fun initThreetenABP() {
AndroidThreeTen.init(this)
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
import java.util.*
import org.threeten.bp.LocalDateTime
data class Milestone(
@SerializedName("id") val id: Long,
......@@ -10,7 +10,7 @@ data class Milestone(
@SerializedName("description") val description: String?,
@SerializedName("state") val state: String?,
@SerializedName("due_date") val dueDate: String?,
@SerializedName("created_at") val createdAt: Date?,
@SerializedName("created_at") val createdAt: LocalDateTime?,
@SerializedName("title") val title: String?,
@SerializedName("updated_at") val updatedAt: String?
)
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.event.EventTargetType
import java.util.*
data class Note(
@SerializedName("id") val id: Long,
@SerializedName("body") val body: String,
@SerializedName("author") val author: Author,
@SerializedName("created_at") val createdAt: Date,
@SerializedName("updated_at") val updatedAt: Date?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("system") val isSystem: Boolean,
@SerializedName("noteable_id") val noteableId: Long,
@SerializedName("noteable_type") val noteableType: EventTargetType?,
......
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
import java.util.*
import org.threeten.bp.LocalDateTime
data class Owner (
@SerializedName("id") val id: Long,
@SerializedName("name") val name: String,
@SerializedName("username") val username: String,
@SerializedName("created_at") val createdAt: Date?
@SerializedName("created_at") val createdAt: LocalDateTime?
)
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
import java.util.*
import org.threeten.bp.LocalDateTime
data class Project(
@SerializedName("id") val id: Long,
......@@ -24,8 +24,8 @@ data class Project(
@SerializedName("wiki_enabled") val wikiEnabled: Boolean,
@SerializedName("snippets_enabled") val snippetsEnabled: Boolean,
@SerializedName("container_registry_enabled") val containerRegistryEnabled: Boolean,
@SerializedName("created_at") val createdAt: Date?,
@SerializedName("last_activity_at") val lastActivityAt: Date?,
@SerializedName("created_at") val createdAt: LocalDateTime?,
@SerializedName("last_activity_at") val lastActivityAt: LocalDateTime?,
@SerializedName("creator_id") val creatorId: Long,
@SerializedName("namespace") val namespace: Namespace?,
@SerializedName("permissions") val permissions: Permissions?,
......
package ru.terrakok.gitlabclient.entity
import com.google.gson.annotations.SerializedName
import java.util.*
import org.threeten.bp.LocalDateTime
data class User(
@SerializedName("id") val id: Long,
......@@ -11,7 +11,7 @@ data class User(
@SerializedName("state") val state: String?,
@SerializedName("avatar_url") val avatarUrl: String?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("created_at") val createdAt: Date,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("is_admin") val isAdmin: Boolean,
@SerializedName("bio") val bio: String?,
@SerializedName("location") val location: String?,
......@@ -20,11 +20,11 @@ data class User(
@SerializedName("twitter") val twitter: String?,
@SerializedName("website_url") val websiteUrl: String?,
@SerializedName("organization") val organization: String?,
@SerializedName("last_sign_in_at") val lastSignInAt: Date,
@SerializedName("confirmed_at") val confirmedAt: Date,
@SerializedName("last_sign_in_at") val lastSignInAt: LocalDateTime,
@SerializedName("confirmed_at") val confirmedAt: LocalDateTime,
@SerializedName("color_scheme_id") val colorSchemeId: Long,
@SerializedName("projects_limit") val projectsLimit: Long,
@SerializedName("current_sign_in_at") val currentSignInAt: Date,
@SerializedName("current_sign_in_at") val currentSignInAt: LocalDateTime,
@SerializedName("identities") val identities: List<Identity>?,
@SerializedName("can_create_group") val canCreateGroup: Boolean,
@SerializedName("can_create_project") val canCreateProject: Boolean,
......
package ru.terrakok.gitlabclient.entity.app.target
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import java.util.*
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 24.12.17.
......@@ -10,8 +10,8 @@ data class TargetHeader(
val author: Author,
val icon: TargetHeaderIcon,
val title: TargetHeaderTitle,
val body: CharSequence?,
val date: Date,
val body: CharSequence,
val date: LocalDateTime,
val target: AppTarget,
val targetId: Long,
val internal: TargetInternal?,
......
package ru.terrakok.gitlabclient.entity.event
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Note
import ru.terrakok.gitlabclient.entity.PushData
import java.util.*
/**
......@@ -18,7 +18,7 @@ data class Event(
@SerializedName("target_type") val targetType: EventTargetType?,
@SerializedName("author_id") val authorId: Long,
@SerializedName("target_title") val targetTitle: String?,
@SerializedName("created_at") val createdAt: Date,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("author") val author: Author,
@SerializedName("author_username") val authorUsername: String,
@SerializedName("push_data") val pushData: PushData?,
......
package ru.terrakok.gitlabclient.entity.issue
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Assignee
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Milestone
import java.util.*
data class Issue(
@SerializedName("id") val id: Long,
......@@ -15,12 +15,12 @@ data class Issue(
@SerializedName("milestone") val milestone: Milestone?,
@SerializedName("project_id") val projectId: Long,
@SerializedName("assignees") val assignees: List<Assignee>,
@SerializedName("updated_at") val updatedAt: Date?,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("title") val title: String?,
@SerializedName("created_at") val createdAt: Date,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("labels") val labels: List<String>,
@SerializedName("user_notes_count") val userNotesCount: Int,
@SerializedName("due_date") val dueDate: Date?,
@SerializedName("due_date") val dueDate: LocalDateTime?,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("confidential") val confidential: Boolean,
@SerializedName("upvotes") val upvotes: Int,
......
package ru.terrakok.gitlabclient.entity.mergerequest
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Milestone
import ru.terrakok.gitlabclient.entity.User
import java.util.*
data class MergeRequest(
@SerializedName("id") val id: Long,
@SerializedName("iid") val iid: Long,
@SerializedName("created_at") val createdAt: Date,
@SerializedName("updated_at") val updatedAt: Date?,
@SerializedName("created_at") val createdAt: LocalDateTime,
@SerializedName("updated_at") val updatedAt: LocalDateTime?,
@SerializedName("target_branch") val targetBranch: String?,
@SerializedName("source_branch") val sourceBranch: String?,
@SerializedName("project_id") val projectId: Long,
......
package ru.terrakok.gitlabclient.entity.target
import com.google.gson.annotations.SerializedName
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Assignee
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Milestone
import java.util.*
/**
* @author Eugene Shapovalov (CraggyHaggy). Date: 13.09.17
......@@ -15,8 +15,8 @@ abstract class Target {
@SerializedName("project_id") private val _projectId: Long? = null
@SerializedName("title") private val _title: String? = null
@SerializedName("state") private val _state: TargetState? = null
@SerializedName("updated_at") val updatedAt: Date? = null
@SerializedName("created_at") val createdAt: Date? = null
@SerializedName("updated_at") val updatedAt: LocalDateTime? = null
@SerializedName("created_at") val createdAt: LocalDateTime? = null
@SerializedName("labels") private val _labels: List<String>? = null
@SerializedName("milestone") val milestone: Milestone? = null
@SerializedName("assignees") private val _assignees: List<Assignee>? = null
......
package ru.terrakok.gitlabclient.entity.todo
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.target.Target
import ru.terrakok.gitlabclient.entity.target.TargetType
import java.util.*
/**
* @author Eugene Shapovalov (CraggyHaggy). Date: 11.09.17
......@@ -19,5 +19,5 @@ data class Todo(
val targetUrl: String,
val body: String,
val state: TodoState,
val createdAt: Date
val createdAt: LocalDateTime
)
\ No newline at end of file
......@@ -3,8 +3,8 @@ package ru.terrakok.gitlabclient.extension
import android.content.Context
import android.content.res.Resources
import android.support.annotation.DrawableRes
import org.joda.time.DateTimeZone
import org.joda.time.format.DateTimeFormat
import org.threeten.bp.Duration
import org.threeten.bp.LocalDateTime
import retrofit2.HttpException
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.develop.LicenseType
......@@ -16,7 +16,6 @@ import ru.terrakok.gitlabclient.entity.todo.TodoAction
import ru.terrakok.gitlabclient.model.system.ResourceManager
import timber.log.Timber
import java.io.IOException
import java.util.*
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 14.02.18.
......@@ -39,21 +38,15 @@ fun Throwable.userMessage(resourceManager: ResourceManager) = when (this) {
else -> resourceManager.getString(R.string.unknown_error)
}
private val DATE_FORMAT = DateTimeFormat.forPattern("dd.MM.yyyy")
fun Date.humanTime(resources: Resources): String {
val localMillis = DateTimeZone.getDefault().convertUTCToLocal(this.time)
val timeDelta = (System.currentTimeMillis() - localMillis) / 1000L
fun LocalDateTime.humanTime(resources: Resources): String {
val delta = Duration.between(this, LocalDateTime.now()).seconds
val timeStr =
if (timeDelta < 60) {
resources.getString(R.string.time_sec, timeDelta)
} else if (timeDelta < 60 * 60) {
resources.getString(R.string.time_min, timeDelta / 60)
} else if (timeDelta < 60 * 60 * 24) {
resources.getString(R.string.time_hour, timeDelta / (60 * 60))
} else if (timeDelta < 60 * 60 * 24 * 7) {
resources.getString(R.string.time_day, timeDelta / (60 * 60 * 24))
} else {
return DATE_FORMAT.print(localMillis)
when {
delta < 60 -> resources.getString(R.string.time_sec, delta)
delta < 60 * 60 -> resources.getString(R.string.time_min, delta / 60)
delta < 60 * 60 * 24 -> resources.getString(R.string.time_hour, delta / (60 * 60))
delta < 60 * 60 * 24 * 7 -> resources.getString(R.string.time_day, delta / (60 * 60 * 24))
else -> return this.toLocalDate().toString()
}
return resources.getString(R.string.time_ago, timeStr)
......
......@@ -2,6 +2,7 @@ package ru.terrakok.gitlabclient.model.data.server
import io.reactivex.Completable
import io.reactivex.Single
import org.threeten.bp.LocalDateTime
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
......@@ -31,7 +32,6 @@ import ru.terrakok.gitlabclient.entity.target.TargetType
import ru.terrakok.gitlabclient.entity.todo.Todo
import ru.terrakok.gitlabclient.entity.todo.TodoAction
import ru.terrakok.gitlabclient.entity.todo.TodoState
import java.util.Date
/**
* @author Konstantin Tskhovrebov (aka terrakok). Date: 28.03.17
......@@ -132,6 +132,7 @@ interface GitlabApi {
@Query("before") beforeDay: String?,
@Query("after") afterDay: String?,
@Query("sort") sort: Sort?,
@Query("order_by") orderBy: OrderBy?,
@Query("page") page: Int,
@Query("per_page") pageSize: Int
): Single<List<Event>>
......@@ -142,8 +143,8 @@ interface GitlabApi {
@Query("milestone") milestone: String?,
@Query("view") viewType: MergeRequestViewType?,
@Query("labels") labels: String?,
@Query("created_before") createdBefore: Date?,
@Query("created_after") createdAfter: Date?,
@Query("created_before") createdBefore: LocalDateTime?,
@Query("created_after") createdAfter: LocalDateTime?,
@Query("scope") scope: MergeRequestScope?,
@Query("author_id") authorId: Int?,
@Query("assignee_id") assigneeId: Int?,
......@@ -161,8 +162,8 @@ interface GitlabApi {
@Query("milestone") milestone: String?,
@Query("view") viewType: MergeRequestViewType?,
@Query("labels") labels: String?,
@Query("created_before") createdBefore: Date?,
@Query("created_after") createdAfter: Date?,
@Query("created_before") createdBefore: LocalDateTime?,
@Query("created_after") createdAfter: LocalDateTime?,
@Query("scope") scope: MergeRequestScope?,
@Query("author_id") authorId: Int?,
@Query("assignee_id") assigneeId: Int?,
......
package ru.terrakok.gitlabclient.model.data.server.deserializer
import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import org.threeten.bp.LocalDateTime
import org.threeten.bp.ZonedDateTime
import java.lang.reflect.Type
import java.util.*
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 27.02.18.
*/
class DateDeserializer : JsonDeserializer<LocalDateTime> {
private val offset = TimeZone.getDefault().rawOffset / 1000L
override fun deserialize(
json: JsonElement,
type: Type,
jsonDeserializationContext: JsonDeserializationContext
): LocalDateTime {
return ZonedDateTime.parse(json.asJsonPrimitive.asString).plusSeconds(offset).toLocalDateTime()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.entity.todo
package ru.terrakok.gitlabclient.model.data.server.deserializer
import com.google.gson.JsonDeserializationContext
import com.google.gson.JsonDeserializer
import com.google.gson.JsonElement
import com.google.gson.JsonParseException
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.Author
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.target.Target
import ru.terrakok.gitlabclient.entity.target.TargetType
import ru.terrakok.gitlabclient.entity.target.issue.Issue
import ru.terrakok.gitlabclient.entity.target.mergerequest.MergeRequest
import ru.terrakok.gitlabclient.entity.todo.Todo
import ru.terrakok.gitlabclient.entity.todo.TodoAction
import ru.terrakok.gitlabclient.entity.todo.TodoState
import java.lang.reflect.Type
import java.util.*
/**
* @author Eugene Shapovalov (CraggyHaggy). Date: 13.09.17
......@@ -48,7 +51,7 @@ class TodoDeserializer : JsonDeserializer<Todo> {
jsonObject.get("target_url").asString,
jsonObject.get("body").asString,
context.deserialize<TodoState>(jsonObject.get("state"), TodoState::class.java),
context.deserialize<Date>(jsonObject.get("created_at"), Date::class.java)
context.deserialize<LocalDateTime>(jsonObject.get("created_at"), LocalDateTime::class.java)
)
} else {
throw JsonParseException("Configure Gson in GsonProvider.")
......
......@@ -3,6 +3,8 @@ package ru.terrakok.gitlabclient.model.repository.event
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.PushDataRefType
import ru.terrakok.gitlabclient.entity.Sort
......@@ -15,8 +17,6 @@ import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
/**
......@@ -28,23 +28,24 @@ class EventRepository @Inject constructor(
@DefaultPageSize private val defaultPageSizeWrapper: PrimitiveWrapper<Int>
) {
private val defaultPageSize = defaultPageSizeWrapper.value
private val dayFormat = SimpleDateFormat("yyyy-MM-dd")
fun getEvents(
action: EventAction? = null,
targetType: EventTarget? = null,
beforeDay: Date? = null,
afterDay: Date? = null,
sort: Sort? = null,
beforeDay: LocalDateTime? = null,
afterDay: LocalDateTime? = null,
sort: Sort? = Sort.DESC,
orderBy: OrderBy = OrderBy.UPDATED_AT,
page: Int,
pageSize: Int = defaultPageSize
): Single<List<TargetHeader>> = api
.getEvents(
action,
targetType,
beforeDay?.run { dayFormat.format(this) },
afterDay?.run { dayFormat.format(this) },
beforeDay?.run { this.toLocalDate().toString() },
afterDay?.run { this.toLocalDate().toString() },
sort,
orderBy,
page,
pageSize
)
......@@ -85,7 +86,7 @@ class EventRepository @Inject constructor(
targetData.name,
project?.name ?: ""
),
getBody(event),
getBody(event) ?: "",
event.createdAt,
targetData.target,
targetData.id,
......@@ -122,13 +123,17 @@ class EventRepository @Inject constructor(
EventTargetType.SNIPPET -> TargetData(AppTarget.SNIPPET, "${AppTarget.SNIPPET} ${event.targetIid!!}", event.targetId!!)
EventTargetType.DIFF_NOTE,
EventTargetType.NOTE -> {
when (event.note!!.noteableType) {
EventTargetType.ISSUE -> TargetData(AppTarget.ISSUE, "${AppTarget.ISSUE} #${event.note.noteableIid}", event.note.noteableId)
EventTargetType.MERGE_REQUEST -> TargetData(AppTarget.MERGE_REQUEST, "${AppTarget.MERGE_REQUEST} !${event.note.noteableIid}", event.note.noteableId)
EventTargetType.MILESTONE -> TargetData(AppTarget.MILESTONE, "${AppTarget.MILESTONE} ${event.note.noteableIid}", event.note.noteableId)
EventTargetType.SNIPPET -> TargetData(AppTarget.SNIPPET, "${AppTarget.SNIPPET} ${event.note.noteableIid}", event.note.noteableId)
null -> TargetData(AppTarget.COMMIT, "${AppTarget.COMMIT} ${event.note.id}", event.note.id)
else -> throw IllegalArgumentException("Unsupported noteable target type: ${event.note.noteableType}.")
if (event.note != null) {
when (event.note.noteableType) {
EventTargetType.ISSUE -> TargetData(AppTarget.ISSUE, "${AppTarget.ISSUE} #${event.note.noteableIid}", event.note.noteableId)
EventTargetType.MERGE_REQUEST -> TargetData(AppTarget.MERGE_REQUEST, "${AppTarget.MERGE_REQUEST} !${event.note.noteableIid}", event.note.noteableId)
EventTargetType.MILESTONE -> TargetData(AppTarget.MILESTONE, "${AppTarget.MILESTONE} ${event.note.noteableIid}", event.note.noteableId)
EventTargetType.SNIPPET -> TargetData(AppTarget.SNIPPET, "${AppTarget.SNIPPET} ${event.note.noteableIid}", event.note.noteableId)
null -> TargetData(AppTarget.COMMIT, "${AppTarget.COMMIT} ${event.note.id}", event.note.id)
else -> throw IllegalArgumentException("Unsupported noteable target type: ${event.note.noteableType}.")
}
} else {
throw IllegalArgumentException("Unsupported event type: $event.")
}
}
else -> {
......
......@@ -114,7 +114,7 @@ class IssueRepository @Inject constructor(
"${AppTarget.ISSUE} #${issue.iid}",
project.name
),
issue.title,
issue.title ?: "",
issue.createdAt,
AppTarget.ISSUE,
issue.id,
......
......@@ -3,6 +3,7 @@ package ru.terrakok.gitlabclient.model.repository.mergerequest
import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.functions.BiFunction
import org.threeten.bp.LocalDateTime
import ru.terrakok.gitlabclient.entity.OrderBy
import ru.terrakok.gitlabclient.entity.Project
import ru.terrakok.gitlabclient.entity.Sort
......@@ -23,7 +24,6 @@ import ru.terrakok.gitlabclient.model.data.server.GitlabApi
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
import java.util.Date
import javax.inject.Inject
class MergeRequestRepository @Inject constructor(
......@@ -39,8 +39,8 @@ class MergeRequestRepository @Inject constructor(
milestone: String? = null,
viewType: MergeRequestViewType? = null,
labels: String? = null,
createdBefore: Date? = null,
createdAfter: Date? = null,
createdBefore: LocalDateTime? = null,
createdAfter: LocalDateTime? = null,
scope: MergeRequestScope? = null,
authorId: Int? = null,
assigneeId: Int? = null,
......@@ -72,8 +72,8 @@ class MergeRequestRepository @Inject constructor(
milestone: String? = null,
viewType: MergeRequestViewType? = null,
labels: String? = null,
createdBefore: Date? = null,
createdAfter: Date? = null,