Skip to content
This repository has been archived by the owner on Jan 29, 2023. It is now read-only.

View a single change details #316

Merged
merged 8 commits into from
Apr 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ dependencies {

implementation project(':features:settings')

implementation project(':features:change')

// Android support libraries
implementation Libs.AndroidX.appcompat
implementation Libs.AndroidX.cardView
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,6 +43,7 @@ import com.github.vase4kin.teamcityapp.helper.CustomActivityTestRule
import com.github.vase4kin.teamcityapp.helper.RecyclerViewMatcher.Companion.withRecyclerView
import com.github.vase4kin.teamcityapp.helper.TestUtils
import com.github.vase4kin.teamcityapp.helper.TestUtils.Companion.hasItemsCount
import com.github.vase4kin.teamcityapp.helper.TestUtils.Companion.matchToolbarTitle
import io.reactivex.Single
import it.cosenonjaviste.daggermock.DaggerMockRule
import org.junit.Before
Expand Down Expand Up @@ -150,17 +151,73 @@ class ChangesFragmentTest {
)
).check(matches(withText("21312fsd1321")))
// Checking data
onView(withRecyclerView(R.id.changes_recycler_view).atPositionOnView(0, R.id.commitDate)).check(
onView(
withRecyclerView(R.id.changes_recycler_view).atPositionOnView(
0,
R.id.commitDate
)
).check(
matches(withText("30 Jul 16 00:36"))
)

// Clicking on change
onView(withRecyclerView(R.id.changes_recycler_view).atPosition(0)).perform(click())

// Сhecking dialog content
onView(withId(R.id.md_content)).check(matches(withText("john-117 on 30 Jul 16 00:36")))
// Сheck files
onView(withText("filename!")).check(matches(isDisplayed()))
// Check toolbar
matchToolbarTitle("Change details")
// Check comment
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
0,
R.id.title
)
).check(
matches(withText("Do you believe?"))
)
// Check Revision
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
0,
R.id.version
)
).check(
matches(withText("21312fsd1321"))
)
// Check userName user_name
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
0,
R.id.user_name
)
).check(
matches(withText("By john-117 on 30 Jul 16 00:36"))
)
// Check files header
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
1,
R.id.title
)
).check(
matches(withText("Changed files (1)"))
)
// Check file name and type
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
2,
R.id.title
)
).check(
matches(withText("filename!"))
)
onView(
withRecyclerView(R.id.recycler_view).atPositionOnView(
2,
R.id.type_text
)
).check(
matches(withText("Edited"))
)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -31,13 +31,18 @@ import io.rx_cache2.DynamicKeyGroup
import io.rx_cache2.EvictDynamicKey
import io.rx_cache2.EvictDynamicKeyGroup
import io.rx_cache2.LifeCache
import io.rx_cache2.Migration
import io.rx_cache2.SchemeMigration
import teamcityapp.features.about.repository.models.ServerInfo
import teamcityapp.features.test_details.repository.models.TestOccurrence
import java.util.concurrent.TimeUnit

/**
* Cache providers
*/
@SchemeMigration(
value = [Migration(version = 1, evictClasses = [Changes.Change::class])]
)
interface CacheProviders {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,11 +16,11 @@

package com.github.vase4kin.teamcityapp.changes.api;

import teamcityapp.libraries.api.BaseObject;

import java.util.ArrayList;
import java.util.List;

import teamcityapp.libraries.api.BaseObject;

/**
* Changes
*/
Expand All @@ -36,16 +36,26 @@ public List<String> getFiles() {
return files;
}

public List<ChangeFile> getFile() {
return file;
}

public static class ChangeFile extends BaseObject {

private String file;
private String changeType;

public String getFile() {
return file;
}

public ChangeFile(String file) {
public String getChangeType() {
return changeType;
}

public ChangeFile(String file, String type) {
this.file = file;
this.changeType = type;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,12 +16,15 @@

package com.github.vase4kin.teamcityapp.changes.api;

import androidx.annotation.NonNull;

import com.github.vase4kin.teamcityapp.api.interfaces.Collectible;
import teamcityapp.libraries.api.BaseObject;
import com.github.vase4kin.teamcityapp.utils.DateUtils;

import java.util.List;

import teamcityapp.libraries.api.BaseObject;

/**
* Changes
*/
Expand Down Expand Up @@ -56,6 +59,7 @@ public static class Change extends BaseObject {
private String version;
private String username;
private String date;
private String webUrl;
private String comment;
private ChangeFiles files;

Expand All @@ -75,6 +79,11 @@ public String getDate() {
return DateUtils.initWithDate(date).formatStartDateToBuildTitle();
}

@NonNull
public String getWebUrl() {
return webUrl;
}

public String getComment() {
return comment;
}
Expand All @@ -87,12 +96,14 @@ public Change(String href) {
this.href = href;
}

public Change(String version, String username, String date, String comment, ChangeFiles files) {
public Change(String version, String username, String date, String comment, ChangeFiles files, String webUrl, String id) {
this.version = version;
this.username = username;
this.date = date;
this.comment = comment;
this.files = files;
this.webUrl = webUrl;
this.id = id;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,18 +17,18 @@
package com.github.vase4kin.teamcityapp.changes.view

import android.app.Activity
import android.text.TextUtils
import android.view.View
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity

import com.afollestad.materialdialogs.MaterialDialog
import com.github.vase4kin.teamcityapp.R
import com.github.vase4kin.teamcityapp.base.list.view.BaseListViewImpl
import com.github.vase4kin.teamcityapp.changes.api.Changes
import com.github.vase4kin.teamcityapp.changes.data.ChangesDataModel
import com.google.android.material.snackbar.Snackbar
import com.mugen.Mugen
import com.mugen.MugenCallbacks
import teamcityapp.features.change.view.ChangeActivity

/**
* Impl of [ChangesView]
Expand Down Expand Up @@ -102,21 +102,21 @@ class ChangesViewImpl(
* {@inheritDoc}
*/
override fun onClick(change: Changes.Change) {
val content = change.username + " on " + change.date
val builder = MaterialDialog.Builder(activity)
.title(change.comment)
.content(content)
.positiveText(R.string.dialog_ok_title)
if (change.files.files.isEmpty()) {
builder.items(activity.getString(R.string.empty_list_files))
} else {
builder.items(change.files.files)
}
val dialog = builder.build()
dialog.titleView.ellipsize = TextUtils.TruncateAt.END
dialog.titleView.maxLines = 2

dialog.show()
ChangeActivity.start(
activity = activity as AppCompatActivity,
commitName = change.comment,
userName = change.username,
date = change.date,
changeFileNames = change.files.file.map {
Pair<String, String>(
first = it.file,
second = it.changeType
)
},
version = change.version,
webUrl = change.webUrl,
changeId = change.getId()
)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ import teamcityapp.features.about.AboutFragment
import teamcityapp.features.about.dagger.AboutActivityScope
import teamcityapp.features.about.dagger.AboutFragmentModule
import teamcityapp.features.about.dagger.AboutFragmentScope
import teamcityapp.features.change.dagger.ChangeActivityModule
import teamcityapp.features.change.dagger.ChangeActivityScope
import teamcityapp.features.change.view.ChangeActivity
import teamcityapp.features.manage_accounts.dagger.ManageAccountsActivityScope
import teamcityapp.features.manage_accounts.dagger.ManageAccountsModule
import teamcityapp.features.manage_accounts.view.ManageAccountsActivity
Expand Down Expand Up @@ -95,6 +98,10 @@ abstract class ActivityBindingModule {
)
abstract fun testDetailsActivity(): TestDetailsActivity

@ChangeActivityScope
@ContributesAndroidInjector(modules = [ChangeActivityModule::class])
abstract fun changeActivity(): ChangeActivity

@CreateAccountActivityScope
@ContributesAndroidInjector(modules = [CreateAccountModule::class])
abstract fun createAccountActivity(): CreateAccountActivity
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
<string name="empty_list_message_projects_or_build_types">No projects or build configurations</string>
<string name="empty_list_message_favorites">No favorite configurations added</string>
<string name="empty_passed_tests">There are no failed tests</string>
<string name="empty_list_files">No files</string>

<!--Build elements-->
<string name="unknown_trigger_type_text">Unknown trigger type!</string>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019 Andrey Tolpeev
* Copyright 2020 Andrey Tolpeev
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -360,13 +360,15 @@ class Mocks {
* @return single change
*/
fun singleChange(): Changes.Change {
val changeFiles = ChangeFiles(listOf(ChangeFiles.ChangeFile("filename!")))
val changeFiles = ChangeFiles(listOf(ChangeFiles.ChangeFile("filename!", "Edited")))
return Changes.Change(
"21312fsd1321",
"john-117",
"20160730T003638+0300",
"Do you believe?",
changeFiles
changeFiles,
"https://google.com/",
"id"
)
}

Expand Down
1 change: 1 addition & 0 deletions features/change/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
Loading