this commit fixes #329 and improves labels design.

This commit is contained in:
Kosh 2017-05-01 02:24:36 +08:00
parent 9fbd759d86
commit 18b484e210
6 changed files with 46 additions and 35 deletions

View File

@ -81,10 +81,10 @@
<activity
android:name=".ui.modules.repos.issues.issue.details.IssuePagerActivity"
android:label="@string/issue"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>
<activity
@ -95,19 +95,19 @@
<activity
android:name=".ui.modules.repos.pull_requests.pull_request.details.PullRequestPagerActivity"
android:label="@string/pull_request"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>
<activity
android:name=".ui.modules.repos.code.commit.details.CommitPagerActivity"
android:label="@string/commit"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>
<activity
@ -168,24 +168,25 @@
<activity
android:name=".ui.modules.repos.code.files.activity.RepoFilesActivity"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>
<activity android:name=".ui.modules.filter.issues.FilterIssuesActivity"/>
<activity android:name=".ui.modules.main.donation.DonationActivity"/>
<activity android:name=".ui.modules.repos.code.commit.viewer.FullCommitFileActivity"/>
<activity
android:name=".ui.modules.search.repos.files.SearchFileActivity"
android:parentActivityName=".ui.modules.main.MainActivity">
android:parentActivityName=".ui.modules.repos.RepoPagerActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".ui.modules.main.MainActivity"/>
android:value=".ui.modules.repos.RepoPagerActivity"/>
</activity>
<activity
@ -232,13 +233,13 @@
<service android:name=".provider.tasks.notification.ReadNotificationService"/>
<service android:name=".provider.tasks.git.GithubActionService"/>
<service android:name=".provider.tasks.git.ReactionService"/>
<service android:name=".provider.tasks.slack.SlackInvitationService"/>
<service
android:name=".provider.fcm.PushNotificationService">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT"/>
</intent-filter>
</service>
<service android:name=".provider.tasks.slack.SlackInvitationService"/>
</application>
</manifest>

View File

@ -13,7 +13,6 @@ import com.fastaccess.data.dao.model.Issue;
import com.fastaccess.data.dao.model.IssueEvent;
import com.fastaccess.data.dao.model.PullRequest;
import com.fastaccess.data.dao.types.IssueEventType;
import com.fastaccess.helper.InputHelper;
import com.fastaccess.helper.ParseDateFormat;
import com.fastaccess.ui.widgets.LabelSpan;
import com.fastaccess.ui.widgets.SpannableBuilder;
@ -163,8 +162,7 @@ import lombok.Setter;
for (List<IssueEvent> issueEvents : issueEventMap.values()) {
IssueEvent toAdd = null;
SpannableBuilder spannableBuilder = SpannableBuilder.builder();
for (int i = 0; i < issueEvents.size(); i++) {
IssueEvent issueEventModel = issueEvents.get(i);
for (IssueEvent issueEventModel : issueEvents) {
if (issueEventModel != null) {
IssueEventType event = issueEventModel.getEvent();
if (event != null) {
@ -177,14 +175,13 @@ import lombok.Setter;
if (event == IssueEventType.labeled || event == IssueEventType.unlabeled) {
LabelModel labelModel = issueEventModel.getLabel();
int color = Color.parseColor("#" + labelModel.getColor());
spannableBuilder
.append(" ")
.append(InputHelper.SPACE + labelModel.getName() + InputHelper.SPACE, new LabelSpan(color))
spannableBuilder.append(" ")
.append(" " + labelModel.getName() + " ", new LabelSpan(color))
.append(" ");
} else if (event == IssueEventType.assigned || event == IssueEventType.unassigned) {
spannableBuilder
.append(" ")
.bold(issueEventModel.getAssignee() != null ? issueEventModel.getAssignee().getLogin() : "");
spannableBuilder.append(" ")
.bold(issueEventModel.getAssignee() != null ? issueEventModel.getAssignee().getLogin() : "",
new LabelSpan(Color.TRANSPARENT));
}
} else {
models.add(new TimelineModel(issueEventModel));
@ -197,19 +194,19 @@ import lombok.Setter;
if (toAdd != null) {
SpannableBuilder builder = SpannableBuilder.builder();
if (toAdd.getAssignee() != null && toAdd.getAssigner() != null) {
builder.bold(toAdd.getAssigner().getLogin());
builder.bold(toAdd.getAssigner().getLogin(), new LabelSpan(Color.TRANSPARENT));
} else {
if (toAdd.getActor() != null) {
builder.bold(toAdd.getActor().getLogin());
builder.bold(toAdd.getActor().getLogin(), new LabelSpan(Color.TRANSPARENT));
}
}
builder.append(" ")
.append(toAdd.getEvent().name().replaceAll("_", " "));
toAdd.setLabels(SpannableBuilder.builder().append(builder)
.append(toAdd.getEvent().name().replaceAll("_", " "), new LabelSpan(Color.TRANSPARENT));
toAdd.setLabels(SpannableBuilder.builder()
.append(builder)
.append(spannableBuilder)
.append(" ")
.append(ParseDateFormat.getTimeAgo(toAdd.getCreatedAt()))
.append("\n")
.append(spannableBuilder));
.append(ParseDateFormat.getTimeAgo(toAdd.getCreatedAt()), new LabelSpan(Color.TRANSPARENT)));
models.add(new TimelineModel(toAdd));
}
}

View File

@ -185,10 +185,12 @@ import static com.fastaccess.data.dao.model.PullRequest.UPDATED_AT;
SpannableBuilder builder = SpannableBuilder.builder();
if (showRepoName) {
PullsIssuesParser parser = PullsIssuesParser.getForPullRequest(pullRequest.getHtmlUrl());
if (parser != null) builder.bold(parser.getLogin())
.append("/")
.bold(parser.getRepoId())
.append(" ");
if (parser != null) {
builder.bold(parser.getLogin())
.append("/")
.bold(parser.getRepoId())
.append(" ");
}
} else {
builder.bold("#" + pullRequest.getNumber())
.append(" ")
@ -198,6 +200,8 @@ import static com.fastaccess.data.dao.model.PullRequest.UPDATED_AT;
return builder
.bold(status.toLowerCase())
.append(" ")
.bold(pullRequest.getHead() != null ? pullRequest.getHead().getRef() : "")
.append(" ")
.append(ParseDateFormat.getTimeAgo(pullRequest.getState() == IssueState.closed
? pullRequest.getClosedAt() : pullRequest.getCreatedAt()));
}

View File

@ -29,10 +29,11 @@ public interface UserRestService {
@GET("users/{username}/received_events")
Observable<Pageable<Event>> getReceivedEvents(@NonNull @Path("username") String userName, @Query("page") int page);
@GET("users/{username}/repos?sort=pushed&direction=desc")
@GET("users/{username}/repos?affiliation=owner,collaborator&sort=pushed&direction=desc")
Observable<Pageable<Repo>> getRepos(@Path("username") @NonNull String username, @Query("page") int page);
@GET("/user/repos?sort=pushed&direction=desc") Observable<Pageable<Repo>> getRepos(@Query("page") int page);
@GET("/user/repos?affiliation=owner,collaborator&sort=pushed&direction=desc")
Observable<Pageable<Repo>> getRepos(@Query("page") int page);
@GET("users/{username}/starred") Observable<Pageable<Repo>>
getStarred(@Path("username") @NonNull String username, @Query("page") int page);

View File

@ -64,6 +64,14 @@ public class SpannableBuilder extends SpannableStringBuilder {
return this;
}
public SpannableBuilder bold(CharSequence text, final Object span) {
if (!InputHelper.isEmpty(text)) {
text = SpannableBuilder.builder().bold(text);
append(text, span);
}
return this;
}
public SpannableBuilder bold(final CharSequence text) {
if (!InputHelper.isEmpty(text)) return append(text, new StyleSpan(BOLD));
return this;

View File

@ -1,13 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:foreground="?selectableItemBackgroundBorderless">
xmlns:app="http://schemas.android.com/apk/res-auto">
<cn.gavinliu.android.lib.shapedimageview.ShapedImageView
android:id="@+id/avatar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?selectableItemBackgroundBorderless"
android:scaleType="centerCrop"
android:src="?colorPrimaryDark"
android:transitionName="@string/icon_transition"