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

Merge branch 'feature/user_activity_badges_ui' into 'feature/user_activity_badges'

Implement user activity assigned badges.

See merge request terrakok/gitlab-client!185
parents 2f19b07c b79f1ab9
...@@ -131,7 +131,7 @@ dependencies { ...@@ -131,7 +131,7 @@ dependencies {
implementation("ru.noties:markwon:$markwonVersion") implementation("ru.noties:markwon:$markwonVersion")
implementation("ru.noties:markwon-image-loader:$markwonVersion") implementation("ru.noties:markwon-image-loader:$markwonVersion")
//Bottom navigation bar //Bottom navigation bar
implementation("com.aurelhubert:ahbottomnavigation:2.1.0") implementation("com.aurelhubert:ahbottomnavigation:2.3.4")
//Lottie //Lottie
implementation("com.airbnb.android:lottie:2.5.1") implementation("com.airbnb.android:lottie:2.5.1")
//Date //Date
......
...@@ -380,18 +380,18 @@ interface GitlabApi { ...@@ -380,18 +380,18 @@ interface GitlabApi {
@Query("scope") scope: MergeRequestScope = MergeRequestScope.ASSIGNED_TO_ME, @Query("scope") scope: MergeRequestScope = MergeRequestScope.ASSIGNED_TO_ME,
@Query("state") state: MergeRequestState = MergeRequestState.OPENED, @Query("state") state: MergeRequestState = MergeRequestState.OPENED,
@Query("per_page") pageSize: Int = 1 @Query("per_page") pageSize: Int = 1
): Single<Result<Unit>> ): Single<Result<Void>>
@HEAD("$API_PATH/issues") @HEAD("$API_PATH/issues")
fun getMyAssignedIssueHeaders( fun getMyAssignedIssueHeaders(
@Query("scope") scope: IssueScope = IssueScope.ASSIGNED_BY_ME, @Query("scope") scope: IssueScope = IssueScope.ASSIGNED_BY_ME,
@Query("state") state: IssueState = IssueState.OPENED, @Query("state") state: IssueState = IssueState.OPENED,
@Query("per_page") pageSize: Int = 1 @Query("per_page") pageSize: Int = 1
): Single<Result<Unit>> ): Single<Result<Void>>
@HEAD("$API_PATH/todos") @HEAD("$API_PATH/todos")
fun getMyAssignedTodoHeaders( fun getMyAssignedTodoHeaders(
@Query("state") state: TodoState = TodoState.PENDING, @Query("state") state: TodoState = TodoState.PENDING,
@Query("per_page") pageSize: Int = 1 @Query("per_page") pageSize: Int = 1
): Single<Result<Unit>> ): Single<Result<Void>>
} }
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.main
import com.arellomobile.mvp.InjectViewState
import io.reactivex.Single
import io.reactivex.functions.Function3
import ru.terrakok.gitlabclient.model.interactor.issue.IssueInteractor
import ru.terrakok.gitlabclient.model.interactor.mergerequest.MergeRequestInteractor
import ru.terrakok.gitlabclient.model.interactor.todo.TodoInteractor
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import javax.inject.Inject
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 20.05.19.
*/
@InjectViewState
class MainPresenter @Inject constructor(
private val issueInteractor: IssueInteractor,
private val mergeRequestInteractor: MergeRequestInteractor,
private val todoInteractor: TodoInteractor
) : BasePresenter<MainView>() {
override fun onFirstViewAttach() {
super.onFirstViewAttach()
Single
.zip(
issueInteractor.getMyAssignedIssueCount(),
mergeRequestInteractor.getMyAssignedMergeRequestCount(),
todoInteractor.getMyAssignedTodoCount(),
Function3<Int, Int, Int, Triple<Int, Int, Int>> { issueCount, mergeRequestCount, todoCount ->
Triple(issueCount, mergeRequestCount, todoCount)
}
)
.subscribe(
{ viewState.setAssignedNotifications(it.first, it.second, it.third) },
{
// TODO: user activity badges (Maybe we can retry this request, until it finishes correctly?).
}
)
.connect()
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.presentation.main
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.viewstate.strategy.OneExecutionStateStrategy
import com.arellomobile.mvp.viewstate.strategy.StateStrategyType
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 20.05.19.
*/
@StateStrategyType(OneExecutionStateStrategy::class)
interface MainView : MvpView {
fun setAssignedNotifications(issueCount: Int, mergeRequestCount: Int, todoCount: Int)
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.main package ru.terrakok.gitlabclient.ui.main
import android.os.Bundle import android.os.Bundle
import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter
import com.aurelhubert.ahbottomnavigation.notification.AHNotification
import kotlinx.android.synthetic.main.fragment_main.* import kotlinx.android.synthetic.main.fragment_main.*
import ru.terrakok.cicerone.android.support.SupportAppScreen import ru.terrakok.cicerone.android.support.SupportAppScreen
import ru.terrakok.gitlabclient.R import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.color import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.presentation.main.MainPresenter
import ru.terrakok.gitlabclient.presentation.main.MainView
import ru.terrakok.gitlabclient.ui.global.BaseFragment import ru.terrakok.gitlabclient.ui.global.BaseFragment
/** /**
* @author Konstantin Tskhovrebov (aka terrakok). Date: 02.04.17 * @author Konstantin Tskhovrebov (aka terrakok). Date: 02.04.17
*/ */
class MainFragment : BaseFragment() { class MainFragment : BaseFragment(), MainView {
override val layoutRes = R.layout.fragment_main override val layoutRes = R.layout.fragment_main
private val currentTabFragment: BaseFragment? private val currentTabFragment: BaseFragment?
get() = childFragmentManager.fragments.firstOrNull { !it.isHidden } as? BaseFragment get() = childFragmentManager.fragments.firstOrNull { !it.isHidden } as? BaseFragment
@InjectPresenter
lateinit var presenter: MainPresenter
@ProvidePresenter
fun providePresenter(): MainPresenter = scope.getInstance(MainPresenter::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) { override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState) super.onActivityCreated(savedInstanceState)
...@@ -39,6 +52,8 @@ class MainFragment : BaseFragment() { ...@@ -39,6 +52,8 @@ class MainFragment : BaseFragment() {
) )
true true
} }
val leftMargin = resources.getDimension(R.dimen.bottom_bar_notification_left_margin).toInt()
setNotificationMarginLeft(leftMargin, leftMargin)
} }
selectTab( selectTab(
...@@ -78,6 +93,20 @@ class MainFragment : BaseFragment() { ...@@ -78,6 +93,20 @@ class MainFragment : BaseFragment() {
currentTabFragment?.onBackPressed() currentTabFragment?.onBackPressed()
} }
override fun setAssignedNotifications(issueCount: Int, mergeRequestCount: Int, todoCount: Int) {
with(bottomBar) {
setNotification(buildBottomBarNotification(R.color.fruit_salad, issueCount), 1)
setNotification(buildBottomBarNotification(R.color.brandy_punch, mergeRequestCount), 2)
setNotification(buildBottomBarNotification(R.color.mariner, todoCount), 3)
}
}
private fun buildBottomBarNotification(@ColorRes backgroundColor: Int, count: Int) =
AHNotification.Builder()
.setBackgroundColor(ContextCompat.getColor(requireContext(), backgroundColor))
.setText(count.toString())
.build()
companion object { companion object {
private val eventsTab = Screens.MyEvents private val eventsTab = Screens.MyEvents
private val issuesTab = Screens.MyIssuesContainer private val issuesTab = Screens.MyIssuesContainer
......
...@@ -19,12 +19,15 @@ ...@@ -19,12 +19,15 @@
<color name="green">#5AC54F</color> <color name="green">#5AC54F</color>
<color name="lightGreen">#EEF9ED</color> <color name="lightGreen">#EEF9ED</color>
<color name="fruit_salad">#50A164</color>
<color name="red">#F23117</color> <color name="red">#F23117</color>
<color name="lightRed">#FDEAE7</color> <color name="lightRed">#FDEAE7</color>
<color name="brandy_punch">#D88138</color>
<color name="blue">#17d1f2</color> <color name="blue">#17d1f2</color>
<color name="lightBlue">#e7fafd</color> <color name="lightBlue">#e7fafd</color>
<color name="mariner">#397BCE</color>
<color name="beige">#fff8e1</color> <color name="beige">#fff8e1</color>
......
...@@ -3,4 +3,5 @@ ...@@ -3,4 +3,5 @@
<dimen name="navigation_drawer_width">300dp</dimen> <dimen name="navigation_drawer_width">300dp</dimen>
<dimen name="divider_size">1dp</dimen> <dimen name="divider_size">1dp</dimen>
<dimen name="toolbar_elevation">8dp</dimen> <dimen name="toolbar_elevation">8dp</dimen>
<dimen name="bottom_bar_notification_left_margin">12dp</dimen>
</resources> </resources>
\ No newline at end of file
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