Commit 4d521966 authored by Eugene Shapovalov's avatar Eugene Shapovalov 💬

Removed project name as param for ProjectInfo screen.

parent 3f036963
......@@ -11,8 +11,7 @@ sealed class TargetHeaderTitle {
val userName: String,
val action: EventAction,
val targetName: String,
val projectName: String,
val projectNameWithNamespace: String
val projectName: String
) : TargetHeaderTitle()
data class Todo(
......
......@@ -168,7 +168,7 @@ fun TodoAction.getHumanName(resources: Resources): String = when (this) {
fun TargetHeaderTitle.getHumanName(resources: Resources) = when (this) {
is TargetHeaderTitle.Event -> {
"$userName ${action.getHumanName(resources)} $targetName ${resources.getString(R.string.at)} $projectNameWithNamespace"
"$userName ${action.getHumanName(resources)} $targetName ${resources.getString(R.string.at)} $projectName"
}
is TargetHeaderTitle.Todo -> {
val actionName = action.getHumanName(resources)
......@@ -265,8 +265,7 @@ fun ImageView.loadRoundedImage(
fun TargetHeader.openInfo(router: FlowRouter) {
when (target) {
AppTarget.PROJECT -> {
val title = title as TargetHeaderTitle.Event
router.startFlow(Screens.PROJECT_FLOW, Pair(targetId, title.projectName))
router.startFlow(Screens.PROJECT_FLOW, targetId)
}
AppTarget.USER -> {
router.startFlow(Screens.USER_FLOW, targetId)
......
......@@ -15,10 +15,6 @@ class ProjectInteractor @Inject constructor(
private val base64Tools: Base64Tools
) {
companion object {
private val README_FILE_NAME = "readme.md"
}
fun getMainProjects(page: Int) = projectRepository
.getProjectsList(
page = page,
......@@ -45,6 +41,15 @@ class ProjectInteractor @Inject constructor(
fun getProject(id: Long) = projectRepository.getProject(id)
/**
* Returns the project readme file at the specified project and branch.
* The project readme is searched ignoring case.
*
* @param id project id
* @param branchName project branch name to search readme
* @return decoded project readme as String
* @throws NoSuchElementException if project readme with name {@value README_FILE_NAME} not found.
*/
fun getProjectReadme(id: Long, branchName: String) =
projectRepository.getRepositoryTree(projectId = id, branchName = branchName)
.map { treeNodes ->
......@@ -57,4 +62,8 @@ class ProjectInteractor @Inject constructor(
.map { file -> base64Tools.decode(file.content) }
.observeOn(schedulers.ui())
}
companion object {
private const val README_FILE_NAME = "readme.md"
}
}
\ No newline at end of file
......@@ -83,8 +83,7 @@ class EventRepository @Inject constructor(
event.author.name,
event.actionName,
targetData.name,
project?.name ?: "",
project?.nameWithNamespace ?: ""
project?.name ?: ""
),
getBody(event),
event.createdAt,
......
......@@ -79,8 +79,7 @@ class IssueRepository @Inject constructor(
issue.author.name,
EventAction.CREATED,
"${AppTarget.ISSUE} #${issue.iid}",
project.name,
project.nameWithNamespace
project.name
),
issue.title,
issue.createdAt,
......
......@@ -86,8 +86,7 @@ class MergeRequestRepository @Inject constructor(
mr.author.name,
EventAction.CREATED,
"${AppTarget.MERGE_REQUEST} !${mr.iid}",
project.name,
project.nameWithNamespace
project.name
),
mr.title,
mr.createdAt,
......
......@@ -89,6 +89,6 @@ class ProjectsListPresenter @Inject constructor(
fun refreshProjects() = paginator.refresh()
fun loadNextProjectsPage() = paginator.loadNewPage()
fun onProjectClicked(id: Long, name: String) = router.startFlow(Screens.PROJECT_FLOW, Pair(id, name))
fun onProjectClicked(id: Long) = router.startFlow(Screens.PROJECT_FLOW, id)
fun onBackPressed() = router.exit()
}
\ No newline at end of file
......@@ -12,7 +12,6 @@ import javax.inject.Qualifier
@Qualifier annotation class IssueId
@Qualifier annotation class MergeRequestId
@Qualifier annotation class ProjectId
@Qualifier annotation class ProjectName
@Qualifier annotation class ProjectListMode
@Qualifier annotation class TodoListPendingState
@Qualifier annotation class UserId
\ No newline at end of file
......@@ -28,14 +28,11 @@ abstract class BaseActivity : MvpAppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(layoutRes)
}
protected fun getFlowIntent(flowKey: String, data: Any?): Intent? = when (flowKey) {
Screens.AUTH_FLOW -> AuthActivity.getStartIntent(this)
Screens.MAIN_FLOW -> MainActivity.getStartIntent(this)
Screens.PROJECT_FLOW -> {
val (projectId, projectName) = data as Pair<Long, String>
ProjectActivity.getStartIntent(projectId, projectName, this)
}
Screens.PROJECT_FLOW -> ProjectActivity.getStartIntent(data as Long, this)
Screens.USER_FLOW -> UserActivity.getStartIntent(data as Long, this)
Screens.MR_FLOW -> {
val (projectId, mrId) = data as Pair<Long, Long>
......
......@@ -11,7 +11,6 @@ import ru.terrakok.gitlabclient.model.system.flow.FlowNavigator
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectId
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectName
import ru.terrakok.gitlabclient.ui.global.BaseActivity
import toothpick.Toothpick
import toothpick.config.Module
......@@ -25,7 +24,6 @@ class ProjectActivity : BaseActivity() {
override val layoutRes = R.layout.activity_container
private val projectId get() = intent.getLongExtra(ARG_PROJECT_ID, 0)
private val projectName get() = intent.getStringExtra(ARG_PROJECT_NAME)
override fun onCreate(savedInstanceState: Bundle?) {
Toothpick.inject(this, Toothpick.openScope(DI.APP_SCOPE))
......@@ -37,9 +35,6 @@ class ProjectActivity : BaseActivity() {
bind(PrimitiveWrapper::class.java)
.withName(ProjectId::class.java)
.toInstance(PrimitiveWrapper(projectId))
bind(PrimitiveWrapper::class.java)
.withName(ProjectName::class.java)
.toInstance(PrimitiveWrapper(projectName))
}
})
}
......@@ -75,11 +70,9 @@ class ProjectActivity : BaseActivity() {
companion object {
private val ARG_PROJECT_ID = "arg_project_id"
private val ARG_PROJECT_NAME = "arg_project_name"
fun getStartIntent(projectId: Long, projectName: String, context: Context) =
fun getStartIntent(projectId: Long, context: Context) =
Intent(context, ProjectActivity::class.java).apply {
putExtra(ARG_PROJECT_ID, projectId)
putExtra(ARG_PROJECT_NAME, projectName)
}
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.project
import android.os.Bundle
import com.arellomobile.mvp.presenter.InjectPresenter
import com.arellomobile.mvp.presenter.ProvidePresenter
import com.aurelhubert.ahbottomnavigation.AHBottomNavigationAdapter
import kotlinx.android.synthetic.main.fragment_project.*
import ru.terrakok.gitlabclient.R
import ru.terrakok.gitlabclient.extension.color
import ru.terrakok.gitlabclient.toothpick.DI
import ru.terrakok.gitlabclient.ui.global.BaseFragment
import ru.terrakok.gitlabclient.ui.project.info.ProjectInfoFragment
import toothpick.Toothpick
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 10.02.18.
*/
class ProjectFragment : BaseFragment(), ProjectView {
class ProjectFragment : BaseFragment() {
override val layoutRes: Int = R.layout.fragment_project
......@@ -28,16 +24,6 @@ class ProjectFragment : BaseFragment(), ProjectView {
private fun tabIdToFragmentTag(id: Int) = "tab_$id"
@InjectPresenter
lateinit var presenter: ProjectPresenter
@ProvidePresenter
fun providePresenter(): ProjectPresenter {
return Toothpick
.openScope(DI.PROJECT_SCOPE)
.getInstance(ProjectPresenter::class.java)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
......@@ -63,7 +49,6 @@ class ProjectFragment : BaseFragment(), ProjectView {
true
}
}
toolbar.setNavigationOnClickListener { presenter.onBackPressed() }
}
private fun createNewFragments(): HashMap<String, BaseFragment> = hashMapOf(
......@@ -80,8 +65,4 @@ class ProjectFragment : BaseFragment(), ProjectView {
.attach(tabs[tabKeys[position]])
.commit()
}
override fun setProjectName(name: String) {
toolbar.title = name
}
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.project
import com.arellomobile.mvp.InjectViewState
import ru.terrakok.cicerone.Router
import ru.terrakok.gitlabclient.presentation.global.BasePresenter
import ru.terrakok.gitlabclient.toothpick.PrimitiveWrapper
import ru.terrakok.gitlabclient.toothpick.qualifier.ProjectName
import javax.inject.Inject
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 10.02.18.
*/
@InjectViewState
class ProjectPresenter @Inject constructor(
@ProjectName private val projectNameWrapper: PrimitiveWrapper<String>,
private val router: Router
) : BasePresenter<ProjectView>() {
private val projectName = projectNameWrapper.value
override fun onFirstViewAttach() {
super.onFirstViewAttach()
viewState.setProjectName(projectName)
}
fun onBackPressed() = router.exit()
}
\ No newline at end of file
package ru.terrakok.gitlabclient.ui.project
import com.arellomobile.mvp.MvpView
/**
* Created by Eugene Shapovalov (@CraggyHaggy) on 10.02.18.
*/
interface ProjectView : MvpView {
fun setProjectName(name: String)
}
\ No newline at end of file
......@@ -112,7 +112,7 @@ class ProjectsListFragment : BaseFragment(), ProjectsListView {
inner class ProjectsAdapter : ListDelegationAdapter<MutableList<Any>>() {
init {
items = mutableListOf()
delegatesManager.addDelegate(ProjectAdapterDelegate({ presenter.onProjectClicked(it.id, it.name) }))
delegatesManager.addDelegate(ProjectAdapterDelegate({ presenter.onProjectClicked(it.id) }))
delegatesManager.addDelegate(ProgressAdapterDelegate())
}
......
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