Skip to content

Commit 4c87522

Browse files
authored
Merge pull request #231 from tpb1908/issue_226
Issue 226
2 parents b0e2663 + 63603a2 commit 4c87522

File tree

14 files changed

+440
-25
lines changed

14 files changed

+440
-25
lines changed

app/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,12 @@ android {
3636
it.buildConfigField('String', 'BUG_EMAIL', project.hasProperty('BUG_EMAIL') ? BUG_EMAIL : System.getenv('BUG_EMAIL'))
3737
it.buildConfigField('String', 'IMGUR_CLIENT_ID', project.hasProperty('IMGUR_CLIENT_ID') ? IMGUR_CLIENT_ID : System.getenv('IMGUR_CLIENT_ID'))
3838
it.buildConfigField('String', 'IMGUR_CLIENT_SECRET', project.hasProperty('IMGUR_CLIENT_SECRET') ? IMGUR_CLIENT_SECRET : System.getenv('IMGUR_CLIENT_SECRET'))
39+
it.buildConfigField('Boolean', 'IS_IN_DEBUG', 'true')
3940
}
4041

4142
buildTypes {
4243
release {
44+
it.buildConfigField('Boolean', 'IS_IN_DEBUG', 'true')
4345
minifyEnabled false
4446
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
4547
}

app/src/main/java/com/tpb/projects/commits/fragments/CommitInfoFragment.java

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,25 @@
99
import android.view.View;
1010
import android.view.ViewGroup;
1111
import android.view.ViewTreeObserver;
12+
import android.widget.TextView;
1213

1314
import com.tpb.animatingrecyclerview.AnimatingRecyclerView;
1415
import com.tpb.github.data.APIHandler;
1516
import com.tpb.github.data.Loader;
1617
import com.tpb.github.data.models.Commit;
18+
import com.tpb.github.data.models.CompleteStatus;
19+
import com.tpb.github.data.models.Status;
20+
import com.tpb.mdtext.Markdown;
21+
import com.tpb.mdtext.views.MarkdownTextView;
1722
import com.tpb.projects.R;
1823
import com.tpb.projects.commits.CommitActivity;
1924
import com.tpb.projects.commits.CommitDiffAdapter;
20-
import com.tpb.projects.flow.IntentHandler;
21-
import com.tpb.mdtext.Markdown;
22-
import com.tpb.projects.markdown.Spanner;
2325
import com.tpb.projects.common.FixedLinearLayoutManger;
2426
import com.tpb.projects.common.NetworkImageView;
27+
import com.tpb.projects.flow.IntentHandler;
28+
import com.tpb.projects.markdown.Spanner;
2529
import com.tpb.projects.util.Util;
2630

27-
import com.tpb.mdtext.views.MarkdownTextView;
28-
2931
import java.util.Date;
3032

3133
import butterknife.BindView;
@@ -37,6 +39,7 @@
3739
*/
3840

3941
public class CommitInfoFragment extends CommitFragment {
42+
private static final String TAG = CommitInfoFragment.class.getSimpleName();
4043

4144
private Unbinder unbinder;
4245

@@ -66,6 +69,7 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
6669
mRecyclerView.setLayoutManager(new FixedLinearLayoutManger(getContext()));
6770
mRecyclerView.setAdapter(mAdapter);
6871
mRefresher.setOnRefreshListener(() -> {
72+
ButterKnife.findById(getActivity(), R.id.commit_status).setVisibility(View.GONE);
6973
mAdapter.clear();
7074
new Loader(getContext()).loadCommit(new Loader.ItemLoader<Commit>() {
7175
@Override
@@ -103,7 +107,6 @@ public void commitLoaded(Commit commit) {
103107
user = mCommit.getCommitterName();
104108
IntentHandler.addOnClickHandler(getActivity(), mAvatar, user);
105109
}
106-
107110
if(mCommit.getFiles() != null) {
108111
String builder =
109112
"<br>" +
@@ -128,9 +131,44 @@ public void commitLoaded(Commit commit) {
128131
mRefresher.setRefreshing(false);
129132
mAdapter.setDiffs(mCommit.getFiles());
130133
}
134+
new Loader(getContext()).loadCommitStatuses(new Loader.ItemLoader<CompleteStatus>() {
135+
@Override
136+
public void loadComplete(CompleteStatus data) {
137+
if(data.getTotalCount() == 0) return; //We don't care if there is no integration
138+
ButterKnife.findById(getActivity(), R.id.commit_status).setVisibility(View.VISIBLE);
139+
final NetworkImageView niv = ButterKnife.findById(getActivity(), R.id.status_image);
140+
final TextView status = ButterKnife.findById(getActivity(), R.id.status_state);
141+
final TextView desc = ButterKnife.findById(getActivity(), R.id.status_context);
142+
if("success".equals(data.getState())) {
143+
niv.setImageResource(R.drawable.ic_check);
144+
} else if("pending".equals(data.getState())) {
145+
niv.setImageResource(R.drawable.ic_loading);
146+
} else {
147+
niv.setImageResource(R.drawable.ic_failure);
148+
}
149+
status.setText(String.format(getString(R.string.text_ci_status), data.getState()));
150+
final StringBuilder builder = new StringBuilder();
151+
if(data.getStatuses() != null) {
152+
for(Status s: data.getStatuses()) {
153+
builder.append(
154+
String.format(getString(R.string.text_ci_info),
155+
s.getContext(),
156+
s.getDescription())
157+
);
158+
builder.append('\n');
159+
}
160+
}
161+
desc.setText(builder.toString());
162+
}
163+
164+
@Override
165+
public void loadError(APIHandler.APIError error) {
131166

167+
}
168+
}, mCommit.getFullRepoName(), mCommit.getSha());
132169
}
133170

171+
134172
private void checkSharedElementEntry() {
135173
final Intent i = getActivity().getIntent();
136174
if(i.hasExtra(getString(R.string.transition_card))) {

app/src/main/java/com/tpb/projects/issues/fragments/IssueInfoFragment.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ public class IssueInfoFragment extends IssueFragment {
6565

6666
@BindView(R.id.issue_header_card) CardView mHeader;
6767
@BindView(R.id.issue_events_recycler) RecyclerView mRecycler;
68-
@BindView(R.id.issue_assignees) LinearLayout mAssigneesLayout; //http://stackoverflow.com/a/29430226/4191572
68+
@BindView(R.id.issue_assignees) LinearLayout mAssigneesLayout;
69+
@BindView(R.id.text_issue_assignees) View mAssigneesTitle;
6970
@BindView(R.id.issue_menu_button) ImageButton mOverflowButton;
7071
@BindView(R.id.issue_user_avatar) NetworkImageView mUserAvatar;
7172
@BindView(R.id.issue_state) ImageView mImageState;
@@ -157,21 +158,22 @@ private void displayAssignees(Issue issue) {
157158
mAssigneesLayout.removeAllViews();
158159
if(issue != null && issue.getAssignees() != null && issue.getAssignees().length > 0) {
159160
mAssigneesLayout.setVisibility(View.VISIBLE);
160-
for(int i = 0; i < issue.getAssignees().length; i++) {
161-
final User u = issue.getAssignees()[i];
161+
mAssigneesTitle.setVisibility(View.VISIBLE);
162+
for(User u : issue.getAssignees()) {
162163
final LinearLayout user = (LinearLayout) getActivity().getLayoutInflater()
163164
.inflate(R.layout.shard_user,
164-
null
165+
mAssigneesLayout,
166+
false
165167
);
166-
user.setId(i);
168+
user.setId(View.generateViewId());
167169
mAssigneesLayout.addView(user);
168170
final NetworkImageView imageView = ButterKnife.findById(user, R.id.user_avatar);
169171
imageView.setId(View.generateViewId());
170172
imageView.setImageUrl(u.getAvatarUrl());
171173
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
172174
final TextView login = ButterKnife.findById(user, R.id.user_login);
173175
login.setId(View.generateViewId()); //Max 10 assignees
174-
login.setText(issue.getAssignees()[i].getLogin());
176+
login.setText(u.getLogin());
175177
user.setOnClickListener((v) -> {
176178
final Intent us = new Intent(getActivity(), UserActivity.class);
177179
us.putExtra(getString(R.string.intent_username), u.getLogin());
@@ -192,6 +194,7 @@ private void displayAssignees(Issue issue) {
192194
}
193195
} else {
194196
mAssigneesLayout.setVisibility(View.GONE);
197+
mAssigneesTitle.setVisibility(View.GONE);
195198
}
196199
}
197200

app/src/main/java/com/tpb/projects/util/Logger.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
package com.tpb.projects.util;
22

3-
import android.support.compat.BuildConfig;
43
import android.util.Log;
54

65
/**
76
* Created by theo on 11/03/17.
87
*/
98

109
public class Logger {
11-
public static final boolean DEBUG = BuildConfig.DEBUG;
10+
private static final boolean DEBUG = com.tpb.projects.BuildConfig.IS_IN_DEBUG;
1211

1312

1413
public static void logLong(String TAG, String s) {
@@ -55,4 +54,12 @@ public static void i(String tag, String msg, Throwable tr) {
5554
if(DEBUG) Log.i(tag, msg, tr);
5655
}
5756

57+
public static void e(String tag, String msg) {
58+
if(DEBUG) Log.e(tag, msg);
59+
}
60+
61+
public static void e(String tag, String msg, Throwable tr) {
62+
if(DEBUG) Log.e(tag, msg, tr);
63+
}
64+
5865
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="#6cc644"
9+
android:pathData="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="#bd2c00"
9+
android:pathData="M7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm0 1.3c1.3 0 2.5.44 3.47 1.17l-8 8A5.755 5.755 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zm0 11.41c-1.3 0-2.5-.44-3.47-1.17l8-8c.73.97 1.17 2.17 1.17 3.47 0 3.14-2.56 5.7-5.7 5.7z"/>
10+
</vector>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:height="24dp"
4+
android:width="24dp"
5+
android:viewportWidth="24"
6+
android:viewportHeight="24">
7+
<path
8+
android:fillColor="#FF5722"
9+
android:pathData="M10.24 7.4a4.15 4.15 0 0 1-1.2 3.6 4.346 4.346 0 0 1-5.41.54L4.8 10.4.5 9.8l.6 4.2 1.31-1.26c2.36 1.74 5.7 1.57 7.84-.54a5.876 5.876 0 0 0 1.74-4.46l-1.75-.34zM2.96 5a4.346 4.346 0 0 1 5.41-.54L7.2 5.6l4.3.6-.6-4.2-1.31 1.26c-2.36-1.74-5.7-1.57-7.85.54C.5 5.03-.06 6.65.01 8.26l1.75.35A4.17 4.17 0 0 1 2.96 5z"/>
10+
</vector>

app/src/main/res/layout/fragment_commit_info.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,44 @@
7171

7272
</android.support.v7.widget.CardView>
7373

74+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
75+
android:id="@+id/commit_status"
76+
android:orientation="horizontal"
77+
android:layout_width="wrap_content"
78+
android:layout_height="wrap_content"
79+
android:paddingStart="16dp"
80+
android:paddingEnd="16dp"
81+
android:visibility="gone">
82+
83+
<com.tpb.projects.common.NetworkImageView
84+
android:id="@+id/status_image"
85+
android:layout_width="48dp"
86+
android:layout_height="48dp"
87+
android:layout_marginStart="8dp"
88+
android:layout_marginBottom="8dp"
89+
android:layout_marginTop="8dp"
90+
android:layout_gravity="center_horizontal|top"/>
91+
92+
<LinearLayout
93+
android:layout_width="wrap_content"
94+
android:layout_height="wrap_content"
95+
android:orientation="vertical">
96+
97+
<TextView
98+
android:id="@+id/status_state"
99+
android:layout_width="wrap_content"
100+
android:layout_height="wrap_content"
101+
android:textAppearance="@android:style/TextAppearance.Material.Subhead"/>
102+
103+
<TextView
104+
android:id="@+id/status_context"
105+
android:layout_width="wrap_content"
106+
android:layout_height="wrap_content"
107+
android:textAppearance="@android:style/TextAppearance.Material.Small"/>
108+
</LinearLayout>
109+
110+
</LinearLayout>
111+
74112
<com.tpb.animatingrecyclerview.AnimatingRecyclerView
75113
android:id="@+id/commit_diff_recycler"
76114
android:layout_width="match_parent"

app/src/main/res/layout/fragment_issue_info.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@
8888
</android.support.v7.widget.CardView>
8989

9090
<TextView
91+
android:id="@+id/text_issue_assignees"
9192
android:layout_width="match_parent"
9293
android:layout_height="wrap_content"
9394
android:layout_marginStart="8dp"
9495
android:layout_marginEnd="8dp"
95-
android:text="@string/text_collaborators"/>
96+
android:text="@string/text_assignees"
97+
android:visibility="gone"/>
9698

9799
<HorizontalScrollView
98100
android:layout_width="match_parent"
@@ -103,7 +105,8 @@
103105
android:layout_width="wrap_content"
104106
android:layout_height="wrap_content"
105107
android:orientation="horizontal"
106-
android:layout_margin="8dp">
108+
android:layout_margin="8dp"
109+
android:visibility="gone">
107110

108111
</LinearLayout>
109112

app/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
<string name="text_committed_by">%1$s committed on %2$s</string>
7171
<string name="text_committed_by_with_has">%1$s committed %2$s on with %3$s</string>
7272
<string name="text_diff_changes">%1$s with %2$s and %3$s</string>
73+
<string name="text_ci_status">Continuous integration status: %1$s</string>
74+
<string name="text_ci_info">%1$s \n%2$s</string>
7375
<plurals name="text_commit_additions">
7476
<item quantity="one">%d addition</item>
7577
<item quantity="other">%d additions</item>
@@ -170,6 +172,7 @@
170172

171173
<!-- Issue strings -->
172174
<string name="text_loading_collaborators">Loading collaborators</string>
175+
<string name="text_assignees">Assignee</string>
173176
<string name="text_loading_labels">Loading labels</string>
174177
<string name="text_assigned_to">Assigned to </string>
175178
<string name="text_closed_by_link">Closed by [%1$s](%2$s) %3$s</string>

0 commit comments

Comments
 (0)