Commit 3f77d742 authored by Konstantin Tskhovrebov's avatar Konstantin Tskhovrebov 🤖

Merge branch 'develop'

parents 4386af90 50ab5551
/build
google-services.json
/src/release/google-services.json
......@@ -15,8 +15,8 @@ android {
minSdkVersion 19
targetSdkVersion 28
versionName "1.1"
versionCode 5
versionName "1.1.1"
versionCode 6
buildConfigField "String", "VERSION_UID", '"' + getBuildUid() + '"'
buildConfigField "String", "APP_DESCRIPTION", '"Gitfox is an Android client for Gitlab."'
......
{
"project_info": {
"project_number": "0",
"firebase_url": "debug",
"project_id": "gitfox-gitlab-client",
"storage_bucket": "debug"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:0:android:0",
"android_client_info": {
"package_name": "com.gitlab.terrakok.gitfox"
}
},
"oauth_client": [
{
"client_id": "debug",
"client_type": 3
}
],
"api_key": [
{
"current_key": "debug"
},
{
"current_key": "debug"
}
],
"services": {
"analytics_service": {
"status": 1
},
"appinvite_service": {
"status": 1,
"other_platform_oauth_client": []
},
"ads_service": {
"status": 2
}
}
}
],
"configuration_version": "1"
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import android.content.Intent
import android.net.Uri
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.entity.mergerequest.MergeRequestState
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.about.AboutFragment
import ru.terrakok.gitlabclient.ui.auth.AuthFlowFragment
import ru.terrakok.gitlabclient.ui.auth.AuthFragment
......@@ -112,52 +113,51 @@ object Screens {
fun createFragment(screenKey: String, data: Any? = null): BaseFragment? =
when (screenKey) {
//DRAWER SCOPE SCREENS
Screens.DRAWER_FLOW -> DrawerFlowFragment()
Screens.MAIN_FLOW -> MainFlowFragment()
Screens.MY_EVENTS_SCREEN -> MyEventsFragment()
Screens.MY_ISSUES_CONTAINER_SCREEN -> MyIssuesContainerFragment()
Screens.MY_ISSUES_SCREEN -> {
val (createdByMe, onlyOpened) = data as Pair<Boolean, Boolean>
MyIssuesFragment.create(createdByMe, onlyOpened)
}
Screens.MY_MR_CONTAINER_SCREEN -> MyMergeRequestsContainerFragment()
Screens.MY_MR_SCREEN -> {
val (createdByMe, onlyOpened) = data as Pair<Boolean, Boolean>
MyMergeRequestsFragment.create(createdByMe, onlyOpened)
}
Screens.MY_TODOS_CONTAINER_SCREEN -> MyTodosContainerFragment()
Screens.MY_TODOS_SCREEN -> MyTodosFragment.create(data as Boolean)
Screens.PROJECTS_CONTAINER_SCREEN -> ProjectsContainerFragment()
Screens.PROJECTS_SCREEN -> ProjectsListFragment.create(data as Int)
Screens.ABOUT_SCREEN -> AboutFragment()
Screens.APP_LIBRARIES_FLOW -> LibrariesFragment()
//AUTH SCREENS
Screens.AUTH_FLOW -> AuthFlowFragment()
Screens.AUTH_SCREEN -> AuthFragment()
//USER SCOPE SCREENS
Screens.USER_FLOW -> UserFlowFragment.create(data as Long)
Screens.USER_INFO_SCREEN -> UserInfoFragment()
Screens.PROJECT_FLOW -> ProjectFlowFragment.create(data as Long)
Screens.PROJECT_MAIN_FLOW -> ProjectFragment()
Screens.PROJECT_INFO_CONTAINER_SCREEN -> ProjectInfoContainerFragment()
Screens.PROJECT_INFO_SCREEN -> ProjectInfoFragment()
Screens.PROJECT_EVENTS_SCREEN -> ProjectEventsFragment()
Screens.PROJECT_ISSUES_CONTAINER_SCREEN -> ProjectIssuesContainerFragment()
Screens.PROJECT_ISSUES_SCREEN -> ProjectIssuesFragment.create(data as IssueState)
Screens.PROJECT_MR_CONTAINER_SCREEN -> ProjectMergeRequestsContainerFragment()
Screens.PROJECT_MR_SCREEN -> ProjectMergeRequestsFragment.create(data as MergeRequestState)
//PROJECT SCOPE SCREENS
Screens.PROJECT_FLOW -> {
ProjectFlowFragment.create(data as Long, DI.PROJECT_FLOW_SCOPE + " " + System.currentTimeMillis())
}
Screens.PROJECT_MAIN_FLOW -> ProjectFragment.create(data as String)
Screens.PROJECT_INFO_CONTAINER_SCREEN -> ProjectInfoContainerFragment.create(data as String)
Screens.PROJECT_INFO_SCREEN -> ProjectInfoFragment.create(data as String)
Screens.PROJECT_EVENTS_SCREEN -> ProjectEventsFragment.create(data as String)
Screens.PROJECT_ISSUES_CONTAINER_SCREEN -> ProjectIssuesContainerFragment.create(data as String)
Screens.PROJECT_ISSUES_SCREEN -> (data as Pair<IssueState, String>).let { (issueState, scope) ->
ProjectIssuesFragment.create(issueState, scope)
}
Screens.PROJECT_MR_CONTAINER_SCREEN -> ProjectMergeRequestsContainerFragment.create(data as String)
Screens.PROJECT_MR_SCREEN -> (data as Pair<MergeRequestState, String>).let { (mrState, scope) ->
ProjectMergeRequestsFragment.create(mrState, scope)
}
//MR SCOPE SCREENS
Screens.MR_FLOW -> {
val (projectId, mrId) = data as Pair<Long, Long>
MergeRequestFlowFragment.create(projectId, mrId)
......@@ -166,6 +166,7 @@ object Screens {
Screens.MR_INFO_SCREEN -> MergeRequestInfoFragment()
Screens.MR_NOTES_SCREEN -> MergeRequestNotesFragment()
//ISSUE SCOPE SCREENS
Screens.ISSUE_FLOW -> {
val (projectId, issueId) = data as Pair<Long, Long>
IssueFlowFragment.create(projectId, issueId)
......@@ -175,6 +176,8 @@ object Screens {
Screens.ISSUE_NOTES_SCREEN -> IssueNotesFragment()
Screens.PRIVACY_POLICY_FLOW -> PrivacyPolicyFragment()
Screens.ABOUT_SCREEN -> AboutFragment()
Screens.APP_LIBRARIES_FLOW -> LibrariesFragment()
else -> null
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.model.system.flow
import ru.terrakok.cicerone.Router
import ru.terrakok.cicerone.commands.BackTo
import ru.terrakok.cicerone.commands.Forward
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 27.09.18.
*/
open class AppRouter : Router() {
fun navigateTo(vararg screens: Pair<String, Any?>) {
executeCommands(
*screens
.map { (screenKey, data) -> Forward(screenKey, data) }
.toTypedArray()
)
}
fun newRootScreens(vararg screens: Pair<String, Any?>) {
val commands =
listOf(BackTo(null))
.plus(screens.map { (screenKey, data) -> Forward(screenKey, data) })
executeCommands(*commands.toTypedArray())
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.model.system.flow
import ru.terrakok.cicerone.Router
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 19.12.17.
*/
class FlowRouter(private val appRouter: Router) : Router() {
class FlowRouter(private val appRouter: AppRouter) : AppRouter() {
fun startFlow(screenKey: String, data: Any? = null) {
appRouter.navigateTo(screenKey, data)
......
......@@ -2,30 +2,34 @@ package ru.terrakok.gitlabclient.presentation
import com.arellomobile.mvp.MvpPresenter
import com.arellomobile.mvp.MvpView
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.model.interactor.auth.AuthInteractor
import ru.terrakok.gitlabclient.model.interactor.launch.LaunchInteractor
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import javax.inject.Inject
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 03.09.18.
*/
class AppPresenter @Inject constructor(
private val router: Router,
private val router: AppRouter,
private val authInteractor: AuthInteractor,
private val launchInteractor: LaunchInteractor
) : MvpPresenter<MvpView>() {
fun coldStart() {
if (authInteractor.isSignedIn()) {
router.newRootScreen(Screens.DRAWER_FLOW)
} else {
router.newRootScreen(Screens.AUTH_FLOW)
}
val rootScreen =
if (authInteractor.isSignedIn()) Screens.DRAWER_FLOW
else Screens.AUTH_FLOW
if (launchInteractor.isFirstLaunch) {
router.navigateTo(Screens.PRIVACY_POLICY_FLOW)
router.navigateTo(
Pair(rootScreen, null),
Pair(Screens.PRIVACY_POLICY_FLOW, null)
)
} else {
router.newRootScreen(rootScreen)
}
}
}
\ No newline at end of file
......@@ -3,7 +3,7 @@ package ru.terrakok.gitlabclient.presentation.project
import com.arellomobile.mvp.MvpView
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.toothpick.DI
import toothpick.Scope
import toothpick.Toothpick
import javax.inject.Inject
......@@ -11,11 +11,12 @@ import javax.inject.Inject
* Created by Konstantin Tskhovrebov (aka @terrakok) on 03.09.18.
*/
class ProjectFlowPresenter @Inject constructor(
private val router: Router
private val router: Router,
private val scope: Scope
) : BasePresenter<MvpView>() {
override fun onDestroy() {
Toothpick.closeScope(DI.PROJECT_FLOW_SCOPE)
Toothpick.closeScope(scope.name)
super.onDestroy()
}
......
......@@ -4,13 +4,15 @@ package ru.terrakok.gitlabclient.toothpick
* @author Konstantin Tskhovrebov (aka terrakok) on 09.07.17.
*/
object DI {
//single scopes
const val APP_SCOPE = "app scope"
const val SERVER_SCOPE = "server scope"
const val DRAWER_FLOW_SCOPE = "drawer flow scope"
const val AUTH_FLOW_SCOPE = "auth flow scope"
const val USER_FLOW_SCOPE = "user flow scope"
const val PROJECT_FLOW_SCOPE = "project flow scope"
const val MERGE_REQUEST_FLOW_SCOPE = "merge request flow scope"
const val ISSUE_FLOW_SCOPE = "issue flow scope"
//multi scopes
const val USER_FLOW_SCOPE = "user flow scope: "
const val PROJECT_FLOW_SCOPE = "project flow scope: "
const val MERGE_REQUEST_FLOW_SCOPE = "merge request flow scope: "
const val ISSUE_FLOW_SCOPE = "issue flow scope: "
}
\ No newline at end of file
......@@ -16,6 +16,7 @@ import ru.terrakok.gitlabclient.model.repository.tools.Base64Tools
import ru.terrakok.gitlabclient.model.system.AppSchedulers
import ru.terrakok.gitlabclient.model.system.ResourceManager
import ru.terrakok.gitlabclient.model.system.SchedulersProvider
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.model.system.message.SystemMessageNotifier
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.DefaultPageSize
......@@ -39,8 +40,9 @@ class AppModule(context: Context) : Module() {
bind(SystemMessageNotifier::class.java).toInstance(SystemMessageNotifier())
//Navigation
val cicerone = Cicerone.create()
val cicerone = Cicerone.create(AppRouter())
bind(Router::class.java).toInstance(cicerone.router)
bind(AppRouter::class.java).toInstance(cicerone.router)
bind(NavigatorHolder::class.java).toInstance(cicerone.navigatorHolder)
//Auth
......
......@@ -2,14 +2,14 @@ package ru.terrakok.gitlabclient.toothpick.module
import ru.terrakok.cicerone.Cicerone
import ru.terrakok.cicerone.NavigatorHolder
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import toothpick.config.Module
/**
* Created by Konstantin Tskhovrebov (aka @terrakok) on 03.09.18.
*/
class FlowNavigationModule(globalRouter: Router) : Module() {
class FlowNavigationModule(globalRouter: AppRouter) : Module() {
init {
val cicerone = Cicerone.create(FlowRouter(globalRouter))
bind(FlowRouter::class.java).toInstance(cicerone.router)
......
......@@ -4,9 +4,9 @@ import android.os.Bundle
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.setLaunchScreen
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.presentation.auth.AuthFlowPresenter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.toothpick.module.FlowNavigationModule
......@@ -37,7 +37,7 @@ class AuthFlowFragment : FlowFragment(), MvpView {
private fun initScope() {
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, DI.AUTH_FLOW_SCOPE)
scope.installModules(
FlowNavigationModule(scope.getInstance(Router::class.java))
FlowNavigationModule(scope.getInstance(AppRouter::class.java))
)
Toothpick.inject(this, scope)
}
......
......@@ -11,12 +11,12 @@ import io.reactivex.disposables.Disposable
import kotlinx.android.synthetic.main.drawer_flow_fragment.*
import ru.terrakok.cicerone.Navigator
import ru.terrakok.cicerone.NavigatorHolder
import ru.terrakok.cicerone.Router
import ru.terrakok.cicerone.android.SupportFragmentNavigator
import ru.terrakok.cicerone.commands.Command
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.setLaunchScreen
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.presentation.drawer.NavigationDrawerView
import ru.terrakok.gitlabclient.presentation.global.GlobalMenuController
import ru.terrakok.gitlabclient.presentation.launch.DrawerFlowPresenter
......@@ -103,7 +103,7 @@ class DrawerFlowFragment : BaseFragment(), MvpView {
private fun initScope() {
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, DI.DRAWER_FLOW_SCOPE)
scope.installModules(
FlowNavigationModule(scope.getInstance(Router::class.java)),
FlowNavigationModule(scope.getInstance(AppRouter::class.java)),
GlobalMenuModule()
)
Toothpick.inject(this@DrawerFlowFragment, scope)
......
......@@ -4,10 +4,10 @@ import android.os.Bundle
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.setLaunchScreen
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.presentation.issue.IssueFlowPresenter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
......@@ -45,7 +45,7 @@ class IssueFlowFragment : FlowFragment(), MvpView {
private fun initScope() {
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, DI.ISSUE_FLOW_SCOPE)
scope.installModules(
FlowNavigationModule(scope.getInstance(Router::class.java)),
FlowNavigationModule(scope.getInstance(AppRouter::class.java)),
object : Module() {
init {
bind(PrimitiveWrapper::class.java)
......
......@@ -4,10 +4,10 @@ import android.os.Bundle
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.setLaunchScreen
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.presentation.mergerequest.MergeRequestFlowPresenter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
......@@ -45,7 +45,7 @@ class MergeRequestFlowFragment : FlowFragment(), MvpView {
private fun initScope() {
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, DI.MERGE_REQUEST_FLOW_SCOPE)
scope.installModules(
FlowNavigationModule(scope.getInstance(Router::class.java)),
FlowNavigationModule(scope.getInstance(AppRouter::class.java)),
object : Module() {
init {
bind(PrimitiveWrapper::class.java)
......
......@@ -4,10 +4,10 @@ import android.os.Bundle
import com.arellomobile.mvp.MvpView
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.setLaunchScreen
import ru.terrakok.gitlabclient.model.system.flow.AppRouter
import ru.terrakok.gitlabclient.presentation.project.ProjectFlowPresenter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
......@@ -23,27 +23,28 @@ import toothpick.config.Module
class ProjectFlowFragment : FlowFragment(), MvpView {
private val projectId by argument(ARG_PROJECT_ID, 0L)
private val scopeName: String? by argument(ARG_SCOPE_NAME)
@InjectPresenter
lateinit var presenter: ProjectFlowPresenter
@ProvidePresenter
fun providePresenter() =
Toothpick.openScope(DI.PROJECT_FLOW_SCOPE)
Toothpick.openScope(scopeName)
.getInstance(ProjectFlowPresenter::class.java)
override fun onCreate(savedInstanceState: Bundle?) {
initScope()
super.onCreate(savedInstanceState)
if (childFragmentManager.fragments.isEmpty()) {
navigator.setLaunchScreen(Screens.PROJECT_MAIN_FLOW, null)
navigator.setLaunchScreen(Screens.PROJECT_MAIN_FLOW, scopeName)
}
}
private fun initScope() {
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, DI.PROJECT_FLOW_SCOPE)
val scope = Toothpick.openScopes(DI.SERVER_SCOPE, scopeName)
scope.installModules(
FlowNavigationModule(scope.getInstance(Router::class.java)),
FlowNavigationModule(scope.getInstance(AppRouter::class.java)),
object : Module() {
init {
bind(PrimitiveWrapper::class.java)
......@@ -61,10 +62,12 @@ class ProjectFlowFragment : FlowFragment(), MvpView {
companion object {
private const val ARG_PROJECT_ID = "arg_project_id"
fun create(projectId: Long) =
private const val ARG_SCOPE_NAME = "arg_scope_name"
fun create(projectId: Long, scope: String) =
ProjectFlowFragment().apply {
arguments = Bundle().apply {
putLong(ARG_PROJECT_ID, projectId)
putString(ARG_SCOPE_NAME, scope)
}
}
}
......
......@@ -5,10 +5,10 @@ import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter
import kotlinx.android.synthetic.main.fragment_project.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.extension.shareText
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.project.info.ProjectInfoFragment
import toothpick.Toothpick
......@@ -19,6 +19,7 @@ import javax.inject.Inject
*/
class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
override val layoutRes: Int = R.layout.fragment_project
private val scopeName: String? by argument(ARG_SCOPE_NAME)
private val currentTabFragment: BaseFragment?
get() = childFragmentManager.fragments.firstOrNull { !it.isHidden } as? BaseFragment
......@@ -29,7 +30,7 @@ class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
private var shareUrl: String? = null
override fun onCreate(savedInstanceState: Bundle?) {
Toothpick.inject(this, Toothpick.openScope(DI.PROJECT_FLOW_SCOPE))
Toothpick.inject(this, Toothpick.openScope(scopeName))
super.onCreate(savedInstanceState)
}
......@@ -89,7 +90,7 @@ class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
}
private fun createTabFragment(tab: String) =
Screens.createFragment(tab) ?: throw RuntimeException("Unknown tab $tab")
Screens.createFragment(tab, scopeName) ?: throw RuntimeException("Unknown tab $tab")
override fun onBackPressed() {
super.onBackPressed()
......@@ -104,4 +105,14 @@ class ProjectFragment : BaseFragment(), ProjectInfoFragment.ProjectInfoToolbar {
override fun setShareUrl(url: String?) {
shareUrl = url
}
companion object {
private const val ARG_SCOPE_NAME = "arg_scope_name"
fun create(scope: String) =
ProjectFragment().apply {
arguments = Bundle().apply {
putString(ARG_SCOPE_NAME, scope)
}
}
}
}
\ No newline at end of file
......@@ -8,11 +8,11 @@ import kotlinx.android.synthetic.main.layout_base_list.*
import kotlinx.android.synthetic.main.layout_zero.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.entity.app.target.TargetHeader
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.extension.showSnackMessage
import ru.terrakok.gitlabclient.extension.visible
import ru.terrakok.gitlabclient.presentation.project.events.ProjectEventsPresenter
import ru.terrakok.gitlabclient.presentation.project.events.ProjectEventsView
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.global.ZeroViewHolder
import ru.terrakok.gitlabclient.ui.my.TargetsAdapter
......@@ -23,6 +23,7 @@ import toothpick.Toothpick
*/
class ProjectEventsFragment : BaseFragment(), ProjectEventsView {
override val layoutRes = R.layout.fragment_project_events
private val scopeName: String? by argument(ARG_SCOPE_NAME)
@InjectPresenter
lateinit var presenter: ProjectEventsPresenter
......@@ -39,7 +40,7 @@ class ProjectEventsFragment : BaseFragment(), ProjectEventsView {
@ProvidePresenter
fun providePresenter(): ProjectEventsPresenter =
Toothpick
.openScope(DI.PROJECT_FLOW_SCOPE)
.openScope(scopeName)
.getInstance(ProjectEventsPresenter::class.java)
override fun onActivityCreated(savedInstanceState: Bundle?) {
......@@ -93,4 +94,14 @@ class ProjectEventsFragment : BaseFragment(), ProjectEventsView {
override fun onBackPressed() {
presenter.onBackPressed()
}
companion object {
private const val ARG_SCOPE_NAME = "arg_scope_name"
fun create(scope: String) =
ProjectEventsFragment().apply {
arguments = Bundle().apply {
putString(ARG_SCOPE_NAME, scope)
}
}
}
}
\ No newline at end of file
......@@ -5,8 +5,8 @@ import android.support.v4.app.FragmentPagerAdapter
import kotlinx.android.synthetic.main.fragment_project_info_container.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.model.system.flow.FlowRouter
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import toothpick.Toothpick
import javax.inject.Inject
......@@ -17,11 +17,12 @@ class ProjectInfoContainerFragment : BaseFragment(), ProjectInfoFragment.Project
lateinit var router: FlowRouter
override val layoutRes = R.layout.fragment_project_info_container
private val scopeName: String? by argument(ARG_SCOPE_NAME)
private val adapter: ProjectInfoPagesAdapter by lazy { ProjectInfoPagesAdapter() }
override fun onCreate(savedInstanceState: Bundle?) {
Toothpick.inject(this, Toothpick.openScope(DI.PROJECT_FLOW_SCOPE))
Toothpick.inject(this, Toothpick.openScope(scopeName))
super.onCreate(savedInstanceState)
}
......@@ -44,8 +45,8 @@ class ProjectInfoContainerFragment : BaseFragment(), ProjectInfoFragment.Project
private inner class ProjectInfoPagesAdapter : FragmentPagerAdapter(childFragmentManager) {
override fun getItem(position: Int) = when (position) {
0 -> Screens.createFragment(Screens.PROJECT_INFO_SCREEN)
1 -> Screens.createFragment(Screens.PROJECT_EVENTS_SCREEN)
0 -> Screens.createFragment(Screens.PROJECT_INFO_SCREEN, scopeName)
1 -> Screens.createFragment(Screens.PROJECT_EVENTS_SCREEN, scopeName)
else -> null
}
......@@ -57,4 +58,14 @@ class ProjectInfoContainerFragment : BaseFragment(), ProjectInfoFragment.Project
else -> null
}
}
companion object {
private const val ARG_SCOPE_NAME = "arg_scope_name"
fun create(scope: String) =
ProjectInfoContainerFragment().apply {
arguments = Bundle().apply {
putString(ARG_SCOPE_NAME, scope)
}
}
}
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import ru.terrakok.gitlabclient.entity.Visibility
import ru.terrakok.gitlabclient.extension.*
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoPresenter
import ru.terrakok.gitlabclient.presentation.project.info.ProjectInfoView
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import toothpick.Toothpick
......@@ -22,6 +21,7 @@ import toothpick.Toothpick
class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
override val layoutRes = R.layout.fragment_project_info
private val scopeName: String? by argument(ARG_SCOPE_NAME)
@InjectPresenter
lateinit var presenter: ProjectInfoPresenter
......@@ -29,7 +29,7 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
@ProvidePresenter
fun providePresenter(): ProjectInfoPresenter =
Toothpick
.openScopes(DI.PROJECT_FLOW_SCOPE)
.openScopes(scopeName)
.getInstance(ProjectInfoPresenter::class.java)
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
......@@ -77,4 +77,14 @@ class ProjectInfoFragment : BaseFragment(), ProjectInfoView {
fun setTitle(title: String)
fun setShareUrl(url: String?)
}
companion object {
private const val ARG_SCOPE_NAME = "arg_scope_name"
fun create(scope: String) =
ProjectInfoFragment().apply {
arguments = Bundle().apply {
putString(ARG_SCOPE_NAME, scope)
}
}
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@ import kotlinx.android.synthetic.main.fragment_my_issues_container.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.Screens
import ru.terrakok.gitlabclient.entity.issue.IssueState
import ru.terrakok.gitlabclient.extension.argument
import ru.terrakok.gitlabclient.ui.global.BaseFragment
/**
......@@ -13,6 +14,7 @@ import ru.terrakok.gitlabclient.ui.global.BaseFragment
*/
class ProjectIssuesContainerFragment : BaseFragment() {
override val layoutRes = R.layout.fragment_project_issues_container
private val scopeName: String? by argument(ARG_SCOPE_NAME)
private val adapter: ProjectIssuesPagesAdapter by lazy { ProjectIssuesPagesAdapter() }
......@@ -25,8 +27,8 @@ class ProjectIssuesContainerFragment : BaseFragment() {
private inner class ProjectIssuesPagesAdapter : FragmentPagerAdapter(childFragmentManager) {
override fun getItem(position: Int) = when (position) {
0 -> Screens.createFragment(Screens.PROJECT_ISSUES_SCREEN, IssueState.OPENED)
1 -> Screens.createFragment(Screens.PROJECT_ISSUES_SCREEN, IssueState.CLOSED)
0 -> Screens.createFragment(Screens.PROJECT_ISSUES_SCREEN, Pair(IssueState.OPENED, scopeName))
1 -> Screens.createFragment(Screens.PROJECT_ISSUES_SCREEN, Pair(IssueState.CLOSED, scopeName))
else -> null
}