Skip to content
Snippets Groups Projects
Commit af468b9a authored by John Carlson's avatar John Carlson
Browse files

Use iid instead of id for posting merge request comments

parent 5545df76
No related branches found
No related tags found
No related merge requests found
Showing
with 226 additions and 30 deletions
Change Log
==========
 
Version 2.4.11
----------------------------
- Reverse the order of notes on merge requests and issues to make it more logical, like a chat app
- Crash fixes related to viewing a project
- Fix issue with Android Oreo auto-fill
- Adding a comment to a merge request or accepting one was not working. Now it will!
Version 2.4.10
----------------------------
 
Loading
Loading
Loading
Loading
@@ -18,7 +18,7 @@ apply plugin: 'io.fabric'
 
def versionMajor = 2
def versionMinor = 4
def versionPatch = 10
def versionPatch = 11
def versionBuild = 0 // bump for dogfood builds, public betas, etc.
 
android {
Loading
Loading
Loading
Loading
@@ -87,7 +87,7 @@ class MergeRequestActivity : BaseActivity() {
 
fun merge() {
progress.visibility = View.VISIBLE
App.get().gitLab.acceptMergeRequest(project.id, mergeRequest.id)
App.get().gitLab.acceptMergeRequest(project.id, mergeRequest.iid)
.setup(bindToLifecycle())
.subscribe(object : CustomResponseSingleObserver<MergeRequest>() {
 
Loading
Loading
Loading
Loading
@@ -7,6 +7,7 @@ import android.support.v4.app.FragmentPagerAdapter
 
import com.commit451.gitlab.R
import com.commit451.gitlab.fragment.MergeRequestCommitsFragment
import com.commit451.gitlab.fragment.MergeRequestDetailsFragment
import com.commit451.gitlab.fragment.MergeRequestDiscussionFragment
import com.commit451.gitlab.model.api.MergeRequest
import com.commit451.gitlab.model.api.Project
Loading
Loading
@@ -20,8 +21,9 @@ class MergeRequestSectionsPagerAdapter(context: Context, fm: FragmentManager, pr
override fun getItem(position: Int): Fragment {
 
when (position) {
0 -> return MergeRequestDiscussionFragment.newInstance(project, mergeRequest)
1 -> return MergeRequestCommitsFragment.newInstance(project, mergeRequest)
0 -> return MergeRequestDetailsFragment.newInstance(project, mergeRequest)
1 -> return MergeRequestDiscussionFragment.newInstance(project, mergeRequest)
2 -> return MergeRequestCommitsFragment.newInstance(project, mergeRequest)
}
 
throw IllegalStateException("Position exceeded on view pager")
Loading
Loading
Loading
Loading
@@ -238,9 +238,6 @@ interface GitLabService {
fun getIssue(@Path("id") projectId: Long,
@Path("issue_id") issueId: String): Single<Issue>
 
@GET(API_VERSION + "/projects/{id}/issues")
fun getIssuesByIid(@Path("id") projectId: Long): Single<List<Issue>>
@FormUrlEncoded
@POST(API_VERSION + "/projects/{id}/issues")
fun createIssue(@Path("id") projectId: Long,
Loading
Loading
Loading
Loading
@@ -19,7 +19,6 @@ import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.activity.AttachActivity
import com.commit451.gitlab.adapter.IssueNotesAdapter
import com.commit451.gitlab.adapter.MergeRequestDetailAdapter
import com.commit451.gitlab.api.response.FileUploadResponse
import com.commit451.gitlab.event.IssueChangedEvent
import com.commit451.gitlab.extension.setup
Loading
Loading
@@ -169,7 +168,7 @@ class IssueDiscussionFragment : ButterKnifeFragment() {
 
fun loadMoreNotes() {
adapter.setLoading(true)
App.get().gitLab.getMergeRequestNotes(nextPageUrl!!.toString())
App.get().gitLab.getIssueNotes(nextPageUrl!!.toString())
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomResponseSingleObserver<List<Note>>() {
 
Loading
Loading
@@ -192,7 +191,7 @@ class IssueDiscussionFragment : ButterKnifeFragment() {
 
fun postNote(message: String) {
 
if (message.isNullOrBlank()) {
if (message.isBlank()) {
return
}
 
Loading
Loading
@@ -217,7 +216,7 @@ class IssueDiscussionFragment : ButterKnifeFragment() {
override fun success(note: Note) {
progress.visibility = View.GONE
adapter.addNote(note)
listNotes.smoothScrollToPosition(MergeRequestDetailAdapter.headerCount)
listNotes.smoothScrollToPosition(0)
}
})
}
Loading
Loading
package com.commit451.gitlab.fragment
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import butterknife.BindView
import com.commit451.adapterflowlayout.AdapterFlowLayout
import com.commit451.addendum.parceler.getParcelerParcelable
import com.commit451.addendum.parceler.putParcelerParcelable
import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.adapter.IssueLabelsAdapter
import com.commit451.gitlab.event.MergeRequestChangedEvent
import com.commit451.gitlab.extension.setMarkdownText
import com.commit451.gitlab.model.api.MergeRequest
import com.commit451.gitlab.model.api.Project
import com.commit451.gitlab.transformation.CircleTransformation
import com.commit451.gitlab.util.DateUtil
import com.commit451.gitlab.util.ImageUtil
import com.commit451.gitlab.util.InternalLinkMovementMethod
import com.commit451.gitlab.viewHolder.IssueLabelViewHolder
import org.greenrobot.eventbus.Subscribe
/**
* Shows the discussion of an issue
*/
class MergeRequestDetailsFragment : ButterKnifeFragment() {
companion object {
private val KEY_PROJECT = "project"
private val KEY_MERGE_REQUEST = "merge_request"
fun newInstance(project: Project, mergeRequest: MergeRequest): MergeRequestDetailsFragment {
val fragment = MergeRequestDetailsFragment()
val args = Bundle()
args.putParcelerParcelable(KEY_PROJECT, project)
args.putParcelerParcelable(KEY_MERGE_REQUEST, mergeRequest)
fragment.arguments = args
return fragment
}
}
@BindView(R.id.root) lateinit var root: ViewGroup
@BindView(R.id.text_description) lateinit var textDescription: TextView
@BindView(R.id.author_image) lateinit var imageAuthor: ImageView
@BindView(R.id.author) lateinit var textAuthor: TextView
@BindView(R.id.milestone_root) lateinit var rootMilestone: ViewGroup
@BindView(R.id.milestone_text) lateinit var textMilestone: TextView
@BindView(R.id.list_labels) lateinit var listLabels: AdapterFlowLayout
lateinit var adapterLabels: IssueLabelsAdapter
lateinit var project: Project
lateinit var mergeRequest: MergeRequest
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
project = arguments.getParcelerParcelable<Project>(KEY_PROJECT)!!
mergeRequest = arguments.getParcelerParcelable<MergeRequest>(KEY_MERGE_REQUEST)!!
}
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return inflater?.inflate(R.layout.fragment_issue_details, container, false)
}
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
adapterLabels = IssueLabelsAdapter(object : IssueLabelsAdapter.Listener {
override fun onLabelClicked(label: String, viewHolder: IssueLabelViewHolder) {
}
})
listLabels.adapter = adapterLabels
bind(mergeRequest, project)
App.bus().register(this)
}
override fun onDestroyView() {
App.bus().unregister(this)
super.onDestroyView()
}
fun bind(mergeRequest: MergeRequest, project: Project) {
if (mergeRequest.description.isNullOrEmpty()) {
textDescription.visibility = View.GONE
} else {
textDescription.visibility = View.VISIBLE
textDescription.setMarkdownText(mergeRequest.description!!, project)
textDescription.movementMethod = InternalLinkMovementMethod(App.get().getAccount().serverUrl!!)
}
App.get().picasso
.load(ImageUtil.getAvatarUrl(mergeRequest.author, resources.getDimensionPixelSize(R.dimen.image_size)))
.transform(CircleTransformation())
.into(imageAuthor)
var author = ""
if (mergeRequest.author != null) {
author = mergeRequest.author!!.name + " "
}
author += resources.getString(R.string.created_issue)
if (mergeRequest.createdAt != null) {
author = author + " " + DateUtil.getRelativeTimeSpanString(context, mergeRequest.createdAt)
}
textAuthor.text = author
if (mergeRequest.milestone != null) {
rootMilestone.visibility = View.VISIBLE
textMilestone.text = mergeRequest.milestone!!.title
} else {
rootMilestone.visibility = View.GONE
}
adapterLabels.setLabels(mergeRequest.labels)
}
@Subscribe
fun onEvent(event: MergeRequestChangedEvent) {
if (mergeRequest.iid == event.mergeRequest.iid) {
mergeRequest = event.mergeRequest
bind(mergeRequest, project)
}
}
}
\ No newline at end of file
Loading
Loading
@@ -191,7 +191,7 @@ class MergeRequestDiscussionFragment : ButterKnifeFragment() {
 
fun postNote(message: String) {
 
if (message.isNullOrBlank()) {
if (message.isBlank()) {
return
}
 
Loading
Loading
@@ -202,7 +202,7 @@ class MergeRequestDiscussionFragment : ButterKnifeFragment() {
teleprinter.hideKeyboard()
sendMessageView.clearText()
 
App.get().gitLab.addMergeRequestNote(project.id, mergeRequest.id, message)
App.get().gitLab.addMergeRequestNote(project.id, mergeRequest.iid, message)
.setup(bindUntilEvent(FragmentEvent.DESTROY_VIEW))
.subscribe(object : CustomSingleObserver<Note>() {
 
Loading
Loading
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
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:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"
android:layout_marginTop="8dp"
android:orientation="vertical">
<TextView
android:id="@+id/text_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="8dp">
<ImageView
android:id="@+id/author_image"
android:layout_width="@dimen/image_size"
android:layout_height="@dimen/image_size"
android:contentDescription="@null"/>
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/padding_normal"
android:layout_marginRight="@dimen/padding_normal"
android:layout_gravity="center_vertical"
tools:text="Jawnnypoo created issue 8 hours ago"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
android:layout_height="match_parent">
 
<com.commit451.gitlab.view.LabCoatSwipeRefreshLayout
android:id="@+id/swipe_layout"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
android:layout_height="match_parent"
android:orientation="vertical">
 
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
<com.commit451.gitlab.view.LabCoatSwipeRefreshLayout
android:id="@+id/swipe_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
android:layout_height="0dp"
android:layout_weight="1">
 
</com.commit451.gitlab.view.LabCoatSwipeRefreshLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
 
<com.commit451.gitlab.view.SendMessageView
android:id="@+id/send_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</com.commit451.gitlab.view.LabCoatSwipeRefreshLayout>
<com.commit451.gitlab.view.SendMessageView
android:id="@+id/send_message_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"/>
</LinearLayout>
 
<include layout="@layout/progress_fullscreen" />
 
</LinearLayout>
\ No newline at end of file
</FrameLayout>
\ No newline at end of file
Loading
Loading
@@ -309,7 +309,9 @@
<!-- Merge Requests -->
<string name="title_merge_discussion">discussion</string>
<string name="title_merge_commits">Commits</string>
<string name="title_merge_details">Details</string>
<string-array name="merge_request_tabs">
<item>@string/title_merge_details</item>
<item>@string/title_merge_discussion</item>
<item>@string/title_merge_commits</item>
</string-array>
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment