Commit ec9681ec authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'feature/details_closed_merged_by' into 'develop'

Implemented closed/merged details for Issue/MergeRequest.

See merge request terrakok/gitlab-client!79
parents cbc1f47e 026ba585
......@@ -147,4 +147,4 @@
</indentOptions>
</codeStyleSettings>
</code_scheme>
</component>
\ No newline at end of file
</component>
......@@ -24,5 +24,10 @@ data class Issue(
@SerializedName("web_url") val webUrl: String?,
@SerializedName("confidential") val confidential: Boolean,
@SerializedName("upvotes") val upvotes: Int,
@SerializedName("downvotes") val downvotes: Int
@SerializedName("downvotes") val downvotes: Int,
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for issues which were closed after GitLab 10.6 and
// when the user account that closed the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_at") val closedAt: LocalDateTime?
)
\ No newline at end of file
......@@ -34,5 +34,12 @@ data class MergeRequest(
@SerializedName("force_remove_source_branch") val forceRemoveSourceBranch: Boolean,
@SerializedName("web_url") val webUrl: String?,
@SerializedName("time_stats") val timeStats: MergeRequestTimeStats?,
@SerializedName("labels") val labels: List<String>
@SerializedName("labels") val labels: List<String>,
// The closed_by attribute was introduced in GitLab 10.6.
// This value will only be present for merge requests which were closed/merged after GitLab 10.6
// and when the user account that closed/merged the issue still exists.
@SerializedName("closed_by") val closedBy: Author?,
@SerializedName("closed_at") val closedAt: LocalDateTime?,
@SerializedName("merged_by") val mergedBy: Author?,
@SerializedName("merged_at") val mergedAt: LocalDateTime?
)
......@@ -39,8 +39,6 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
titleTextView.text = issue.title
stateImageView.setImageResource(R.drawable.circle)
// TODO: issue info (Display action user name for the CLOSED states).
// Wait for https://gitlab.com/gitlab-org/gitlab-ce/issues/41967
when (issue.state) {
IssueState.OPENED -> {
stateImageView.setColorFilter(context!!.color(R.color.green))
......@@ -53,7 +51,16 @@ class IssueInfoFragment : BaseFragment(), IssueInfoView {
}
IssueState.CLOSED -> {
stateImageView.setColorFilter(context!!.color(R.color.red))
subtitleTextView.text = getString(R.string.target_status_closed)
subtitleTextView.text = if (issue.closedBy != null && issue.closedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_closed),
issue.closedBy.name,
issue.closedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_closed)
}
}
}
avatarImageView.loadRoundedImage(issue.author.avatarUrl, context)
......
......@@ -35,8 +35,6 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
?.setTitle("!${mergeRequest.iid}", mrInfo.project.name)
titleTextView.text = mergeRequest.title
// TODO: merge request info (Display action user name for the MERGED/CLOSED states).
// Wait for https://gitlab.com/gitlab-org/gitlab-ce/issues/41905.
when (mergeRequest.state) {
MergeRequestState.OPENED -> {
stateImageView.tint(R.color.green)
......@@ -49,11 +47,31 @@ class MergeRequestInfoFragment : BaseFragment(), MergeRequestInfoView {
}
MergeRequestState.MERGED -> {
stateImageView.tint(R.color.blue)
subtitleTextView.text = getString(R.string.target_status_merged)
subtitleTextView.text =
if (mergeRequest.mergedBy != null && mergeRequest.mergedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_merged),
mergeRequest.mergedBy.name,
mergeRequest.mergedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_merged)
}
}
MergeRequestState.CLOSED -> {
stateImageView.tint(R.color.red)
subtitleTextView.text = getString(R.string.target_status_closed)
subtitleTextView.text =
if (mergeRequest.closedBy != null && mergeRequest.closedAt != null) {
String.format(
getString(R.string.issue_info_subtitle),
getString(R.string.target_status_closed),
mergeRequest.closedBy.name,
mergeRequest.closedAt.humanTime(resources)
)
} else {
getString(R.string.target_status_closed)
}
}
}
avatarImageView.loadRoundedImage(mergeRequest.author.avatarUrl, context)
......
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/avatarImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_img"/>
<ImageView
android:id="@+id/avatarImageView"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_img" />
<TextView
android:id="@+id/titleTextView"
app:fontFamily="@font/roboto_medium"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:textColor="@color/primary_text"
android:textSize="18sp"
app:layout_constraintLeft_toRightOf="@id/avatarImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="Issue title"/>
<TextView
android:id="@+id/titleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textColor="@color/primary_text"
android:textSize="18sp"
app:fontFamily="@font/roboto_medium"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/avatarImageView"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="Issue title" />
<ImageView
android:id="@+id/stateImageView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="6dp"
app:layout_constraintStart_toStartOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:src="@drawable/circle"/>
<ImageView
android:id="@+id/stateImageView"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginTop="6dp"
android:src="@drawable/circle"
app:layout_constraintEnd_toStartOf="@id/subtitleTextView"
app:layout_constraintStart_toStartOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView" />
<TextView
android:id="@+id/subtitleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:textColor="@color/secondary_text"
android:textSize="14sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="@id/stateImageView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="Opened by CraggyHaggy 3d ago"/>
<TextView
android:id="@+id/subtitleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="16dp"
android:textColor="@color/secondary_text"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/stateImageView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="Opened by CraggyHaggy 3d ago" />
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="@dimen/divider_size"
android:layout_marginTop="16dp"
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView"/>
<View
android:id="@+id/divider"
android:layout_width="0dp"
android:layout_height="@dimen/divider_size"
android:layout_marginTop="16dp"
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView" />
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:linksClickable="true"
android:padding="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"/>
<TextView
android:id="@+id/descriptionTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:linksClickable="true"
android:padding="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
</ScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content">
<ImageView
android:id="@+id/avatarImageView"
......@@ -16,23 +16,23 @@
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/default_img"/>
tools:src="@drawable/default_img" />
<TextView
android:id="@+id/titleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:textColor="@color/primary_text"
android:textSize="18sp"
app:fontFamily="@font/roboto_medium"
app:layout_constraintLeft_toRightOf="@id/avatarImageView"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/avatarImageView"
app:layout_constraintTop_toTopOf="@id/avatarImageView"
tools:text="MergeRequest title"/>
tools:text="MergeRequest title" />
<ImageView
android:id="@+id/stateImageView"
......@@ -40,22 +40,23 @@
android:layout_height="16dp"
android:layout_marginTop="6dp"
android:src="@drawable/circle"
app:layout_constraintEnd_toStartOf="@id/subtitleTextView"
app:layout_constraintStart_toStartOf="@id/titleTextView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"/>
app:layout_constraintTop_toBottomOf="@id/titleTextView" />
<TextView
android:id="@+id/subtitleTextView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="16dp"
android:textColor="@color/secondary_text"
android:textSize="14sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/stateImageView"
app:layout_constraintTop_toBottomOf="@id/titleTextView"
tools:text="Opened by CraggyHaggy 3d ago"/>
tools:text="Opened by CraggyHaggy 3d ago" />
<View
android:id="@+id/divider"
......@@ -65,7 +66,7 @@
android:background="@color/divider"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView"/>
app:layout_constraintTop_toBottomOf="@+id/subtitleTextView" />
<TextView
android:id="@+id/descriptionTextView"
......@@ -75,7 +76,7 @@
android:padding="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider"/>
app:layout_constraintTop_toBottomOf="@+id/divider" />
</android.support.constraint.ConstraintLayout>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment