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

Merge remote-tracking branch 'origin/develop'

parents cbd7ebc0 f5eb33a1
No related branches found
No related tags found
No related merge requests found
Pipeline #
Showing
with 107 additions and 149 deletions
package com.commit451.gitlab.model.rss;
import org.parceler.Parcel;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import java.util.Date;
@Parcel
@Root(strict = false)
public class Entry {
@Element(name = "link", required = true)
Link link;
@Element(name = "title", required = true)
String title;
@Element(name = "updated", required = true)
Date updated;
@Element(name = "thumbnail", required = true)
Thumbnail thumbnail;
@Element(name = "summary", required = true)
String summary;
public Entry() {}
public Link getLink() {
return link;
}
public String getTitle() {
return title;
}
public Date getUpdated() {
return updated;
}
public Thumbnail getThumbnail() {
return thumbnail;
}
public String getSummary() {
return summary;
}
}
package com.commit451.gitlab.model.rss
import org.parceler.Parcel
import org.simpleframework.xml.Element
import org.simpleframework.xml.Root
import java.util.*
@Parcel(Parcel.Serialization.BEAN)
@Root(strict = false)
class Entry {
@field:Element(name = "link", required = true)
lateinit var link: Link
@field:Element(name = "title", required = true)
lateinit var title: String
@field:Element(name = "updated", required = true)
lateinit var updated: Date
@field:Element(name = "thumbnail", required = true)
lateinit var thumbnail: Thumbnail
@field:Element(name = "summary", required = true)
lateinit var summary: String
}
package com.commit451.gitlab.model.rss;
import org.parceler.Parcel;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.ElementList;
import org.simpleframework.xml.Root;
import java.util.List;
@Parcel
@Root(strict = false)
public class Feed {
@Element(name = "title", required = false)
String title;
@ElementList(name = "entry", required = false, inline = true)
List<Entry> entryList;
public Feed() {}
public String getTitle() {
return title;
}
public List<Entry> getEntries() {
return entryList;
}
}
package com.commit451.gitlab.model.rss
import org.parceler.Parcel
import org.simpleframework.xml.Element
import org.simpleframework.xml.ElementList
import org.simpleframework.xml.Root
@Parcel(Parcel.Serialization.BEAN)
@Root(strict = false)
class Feed {
@field:Element(name = "title", required = false)
lateinit var title: String
@field:ElementList(name = "entry", required = false, inline = true)
var entries: List<Entry>? = null
}
package com.commit451.gitlab.model.rss;
import android.net.Uri;
import org.parceler.Parcel;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Parcel
@Root(strict = false)
public class Link {
@Attribute(name = "href", required = true)
Uri href;
public Link() {}
public Uri getHref() {
return href;
}
}
package com.commit451.gitlab.model.rss
import org.parceler.Parcel
import org.simpleframework.xml.Attribute
import org.simpleframework.xml.Root
@Parcel(Parcel.Serialization.BEAN)
@Root(strict = false)
class Link {
@field:Attribute(name = "href", required = true)
lateinit var href: String
}
package com.commit451.gitlab.model.rss;
import android.net.Uri;
import org.parceler.Parcel;
import org.simpleframework.xml.Attribute;
import org.simpleframework.xml.Root;
@Parcel
@Root(strict = false)
public class Thumbnail {
@Attribute(name = "url", required = true)
Uri url;
public Thumbnail() {}
public Uri getUrl() {
return url;
}
}
package com.commit451.gitlab.model.rss
import org.parceler.Parcel
import org.simpleframework.xml.Attribute
import org.simpleframework.xml.Root
@Parcel(Parcel.Serialization.BEAN)
@Root(strict = false)
class Thumbnail {
@field:Attribute(name = "url", required = true)
lateinit var url: String
}
Loading
Loading
@@ -95,11 +95,11 @@ object Navigator {
activity.startActivity(SearchActivity.newIntent(activity))
}
 
fun navigateToUser(activity: Activity, user: UserBasic) {
fun navigateToUser(activity: Activity, user: User) {
navigateToUser(activity, null, user)
}
 
fun navigateToUser(activity: Activity, profileImage: ImageView?, user: UserBasic) {
fun navigateToUser(activity: Activity, profileImage: ImageView?, user: User) {
val intent = UserActivity.newIntent(activity, user)
if (Build.VERSION.SDK_INT >= 21 && profileImage != null) {
val options = ActivityOptionsCompat.makeSceneTransitionAnimation(activity, profileImage, activity.getString(R.string.transition_user))
Loading
Loading
@@ -219,8 +219,9 @@ object Navigator {
}
}
 
fun navigateToUrl(activity: Activity, uri: Uri, account: Account) {
Timber.d("navigateToUrl: %s", uri)
fun navigateToUrl(activity: Activity, url: String, account: Account) {
Timber.d("navigateToUrl: $url")
val uri = Uri.parse(url)
val serverUri = Uri.parse(account.serverUrl)
if (serverUri.host == uri.host) {
activity.startActivity(DeepLinker.generateDeeplinkIntentFromUri(activity, uri))
Loading
Loading
Loading
Loading
@@ -12,8 +12,11 @@ import java.util.concurrent.TimeUnit
*/
object DateUtil {
 
fun getRelativeTimeSpanString(context: Context, startTime: Date): CharSequence {
fun getRelativeTimeSpanString(context: Context, startTime: Date?): CharSequence {
val now = Date()
if (startTime == null) {
return context.getString(R.string.unknown)
}
if (Math.abs(now.time - startTime.time) < android.text.format.DateUtils.SECOND_IN_MILLIS) {
return context.getString(R.string.just_now)
}
Loading
Loading
package com.commit451.gitlab.util
 
import android.net.Uri
import com.commit451.gitlab.model.api.UserBasic
import com.commit451.gitlab.model.api.UserFull
import com.commit451.gitlab.model.api.User
 
/**
* Utility for doing various image related things
*/
object ImageUtil {
fun getAvatarUrl(user: UserBasic?, size: Int): Uri {
fun getAvatarUrl(user: User?, size: Int): Uri {
if (user != null) {
val avatarUrl = Uri.parse(user.avatarUrl)
if (avatarUrl != null && avatarUrl != Uri.EMPTY) {
return avatarUrl.buildUpon()
.appendQueryParameter("s", Integer.toString(size))
.build()
if (user.avatarUrl != null) {
val avatarUrl = Uri.parse(user.avatarUrl)
if (avatarUrl != null && avatarUrl != Uri.EMPTY) {
return avatarUrl.buildUpon()
.appendQueryParameter("s", Integer.toString(size))
.build()
}
}
 
if (user is UserFull) {
return getAvatarUrl(user.email, size)
val email = user.email
if (email != null) {
return getAvatarUrl(email, size)
}
}
 
Loading
Loading
package com.commit451.gitlab.view
 
import android.annotation.SuppressLint
import android.app.Activity
import android.content.Context
import android.support.design.widget.NavigationView
Loading
Loading
@@ -25,7 +26,7 @@ import com.commit451.gitlab.event.CloseDrawerEvent
import com.commit451.gitlab.event.LoginEvent
import com.commit451.gitlab.event.ReloadDataEvent
import com.commit451.gitlab.model.Account
import com.commit451.gitlab.model.api.UserFull
import com.commit451.gitlab.model.api.User
import com.commit451.gitlab.navigation.Navigator
import com.commit451.gitlab.rx.CustomResponseSingleObserver
import com.commit451.gitlab.transformation.CircleTransformation
Loading
Loading
@@ -102,7 +103,7 @@ class LabCoatNavigationView : NavigationView {
false
}
 
private val mAccountsAdapterListener = object : AccountAdapter.Listener {
private val accountsAdapterListener = object : AccountAdapter.Listener {
override fun onAccountClicked(account: Account) {
switchToAccount(account)
}
Loading
Loading
@@ -115,7 +116,7 @@ class LabCoatNavigationView : NavigationView {
 
override fun onAccountLogoutClicked(account: Account) {
Prefs.removeAccount(account)
val accounts = Account.getAccounts()
val accounts = Prefs.getAccounts()
 
if (accounts.isEmpty()) {
Navigator.navigateToLogin(context as Activity)
Loading
Loading
@@ -130,7 +131,7 @@ class LabCoatNavigationView : NavigationView {
 
@OnClick(R.id.profile_image)
fun onUserImageClick(imageView: ImageView) {
Navigator.navigateToUser(context as Activity, imageView, App.get().getAccount().user)
Navigator.navigateToUser(context as Activity, imageView, App.get().getAccount().user!!)
}
 
@OnClick(R.id.button_debug)
Loading
Loading
@@ -175,13 +176,14 @@ class LabCoatNavigationView : NavigationView {
params.setMargins(0, resources.getDimensionPixelSize(R.dimen.account_header_height), 0, 0)
listAccounts.setBackgroundColor(colorPrimary)
listAccounts.visibility = View.GONE
adapterAccounts = AccountAdapter(context, mAccountsAdapterListener)
adapterAccounts = AccountAdapter(context, accountsAdapterListener)
listAccounts.adapter = adapterAccounts
setSelectedNavigationItem()
setAccounts()
loadCurrentUser()
}
 
@SuppressLint("RestrictedApi")
override fun onDetachedFromWindow() {
App.bus().unregister(this)
super.onDetachedFromWindow()
Loading
Loading
@@ -204,8 +206,6 @@ class LabCoatNavigationView : NavigationView {
fun setAccounts() {
val accounts = Prefs.getAccounts()
Timber.d("Got %s accounts", accounts.size)
Collections.sort(accounts)
Collections.reverse(accounts)
adapterAccounts.setAccounts(accounts)
}
 
Loading
Loading
@@ -213,13 +213,13 @@ class LabCoatNavigationView : NavigationView {
App.get().gitLab.getThisUser()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : CustomResponseSingleObserver<UserFull>() {
.subscribe(object : CustomResponseSingleObserver<User>() {
 
override fun error(e: Throwable) {
Timber.e(e)
}
 
override fun responseNonNullSuccess(userFull: UserFull) {
override fun responseNonNullSuccess(userFull: User) {
//Store the newly retrieved user to the account so that it stays up to date
// in local storage
val account = App.get().getAccount()
Loading
Loading
@@ -230,7 +230,7 @@ class LabCoatNavigationView : NavigationView {
})
}
 
fun bindUser(user: UserFull) {
fun bindUser(user: User) {
if (context == null) {
return
}
Loading
Loading
@@ -267,7 +267,7 @@ class LabCoatNavigationView : NavigationView {
account.lastUsed = Date()
App.get().setAccount(account)
Prefs.updateAccount(account)
bindUser(account.user)
bindUser(account.user!!)
toggleAccounts()
App.bus().post(ReloadDataEvent())
App.bus().post(CloseDrawerEvent())
Loading
Loading
Loading
Loading
@@ -47,7 +47,7 @@ class AccountViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(account: Account, isActive: Boolean, colorSelected: Int) {
textServer.text = account.serverUrl.toString()
textUsername.text = account.user.username
textUsername.text = account.user!!.username
 
if (isActive) {
itemView.setBackgroundColor(colorSelected)
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@ import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.getColor
import com.commit451.gitlab.model.api.Label
 
/**
Loading
Loading
@@ -32,6 +33,6 @@ class AddLabelViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(label: Label) {
textTitle.text = label.name
textTitle.setBackgroundColor(label.color)
textTitle.setBackgroundColor(label.getColor())
}
}
\ No newline at end of file
Loading
Loading
@@ -10,7 +10,7 @@ import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.App
import com.commit451.gitlab.R
import com.commit451.gitlab.model.api.Member
import com.commit451.gitlab.model.api.User
import com.commit451.gitlab.transformation.CircleTransformation
import com.commit451.gitlab.util.ImageUtil
 
Loading
Loading
@@ -35,7 +35,7 @@ class AssigneeSpinnerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
ButterKnife.bind(this, view)
}
 
fun bind(user: Member?) {
fun bind(user: User?) {
if (user == null) {
textUsername.setText(R.string.no_assignee)
image.setImageResource(R.drawable.ic_assign_24dp)
Loading
Loading
Loading
Loading
@@ -53,7 +53,7 @@ class DiffHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
 
textTitle.text = commit.title
val message = extractMessage(commit.title, commit.message)
val message = extractMessage(commit.title!!, commit.message)
textMessage.text = message
textMessage.visibility = if (message.isEmpty()) View.GONE else View.VISIBLE
}
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@ import butterknife.BindView
import butterknife.ButterKnife
import com.alorma.diff.lib.DiffTextView
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.fileName
import com.commit451.gitlab.model.api.Diff
 
/**
Loading
Loading
Loading
Loading
@@ -48,8 +48,8 @@ class IssueHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
textDescription.visibility = View.GONE
} else {
textDescription.visibility = View.VISIBLE
textDescription.setMarkdownText(issue.description, project)
textDescription.movementMethod = InternalLinkMovementMethod(App.get().getAccount().serverUrl)
textDescription.setMarkdownText(issue.description!!, project)
textDescription.movementMethod = InternalLinkMovementMethod(App.get().getAccount().serverUrl!!)
}
 
App.get().picasso
Loading
Loading
@@ -59,7 +59,7 @@ class IssueHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
var author = ""
if (issue.author != null) {
author = issue.author.name + " "
author = issue.author!!.name + " "
}
author += itemView.resources.getString(R.string.created_issue)
if (issue.createdAt != null) {
Loading
Loading
@@ -68,7 +68,7 @@ class IssueHeaderViewHolder(view: View) : RecyclerView.ViewHolder(view) {
textAuthor.text = author
if (issue.milestone != null) {
rootMilestone.visibility = View.VISIBLE
textMilestone.text = issue.milestone.title
textMilestone.text = issue.milestone!!.title
} else {
rootMilestone.visibility = View.GONE
}
Loading
Loading
Loading
Loading
@@ -67,7 +67,7 @@ class IssueViewHolder(view: View) : RecyclerView.ViewHolder(view) {
}
var author = ""
if (issue.author != null) {
author += issue.author.username
author += issue.author!!.username
}
val id: String
var issueId = issue.iid
Loading
Loading
Loading
Loading
@@ -8,6 +8,7 @@ import android.widget.TextView
import butterknife.BindView
import butterknife.ButterKnife
import com.commit451.gitlab.R
import com.commit451.gitlab.extension.getColor
import com.commit451.gitlab.model.api.Label
 
/**
Loading
Loading
@@ -33,6 +34,6 @@ class LabelViewHolder(view: View) : RecyclerView.ViewHolder(view) {
 
fun bind(label: Label) {
textTitle.text = label.name
viewColor.setBackgroundColor(label.color)
viewColor.setBackgroundColor(label.getColor())
}
}
\ No newline at end of file
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