Improvements and fixes (#1387) All checks were successful ci/woodpecker/push/finish Pipeline was successful ci/woodpecker/cron/locale Pipeline was successful ci/woodpecker/cron/build Pipeline was successful ci/woodpecker/cron/check Pipeline was successful ci/woodpecker/push/locale Pipeline was successful ci/woodpecker/push/build Pipeline was successful ci/woodpecker/push/check Pipeline was successful
All checks were successful
ci/woodpecker/push/finish Pipeline was successful
ci/woodpecker/cron/locale Pipeline was successful
ci/woodpecker/cron/build Pipeline was successful
ci/woodpecker/cron/check Pipeline was successful
ci/woodpecker/push/locale Pipeline was successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/check Pipeline was successful
Fixes #1254 Closes #1372 Reviewed-on: #1387 Co-authored-by: M M Arif <mmarif@swatian.com> Co-committed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent 027d9a6c80
commit c94b6e8ceb
7 changed files with 177 additions and 16 deletions
| @ -149,7 +149,7 @@ public class CommitsActivity extends BaseActivity { | |||
if (response.code() == 200) { | ||||
| ||||
assert response.body() != null; | ||||
if (response.body().size() > 0) { | ||||
if (!response.body().isEmpty()) { | ||||
| ||||
commitsList.clear(); | ||||
commitsList.addAll(response.body()); | ||||
| @ -214,7 +214,7 @@ public class CommitsActivity extends BaseActivity { | |||
List<Commit> result = response.body(); | ||||
assert result != null; | ||||
| ||||
if (result.size() > 0) { | ||||
if (!result.isEmpty()) { | ||||
| ||||
pageSize = result.size(); | ||||
commitsList.addAll(result); | ||||
| |
| @ -66,6 +66,7 @@ import okhttp3.ResponseBody; | |||
import org.apache.commons.io.FilenameUtils; | ||||
import org.gitnex.tea4j.v2.models.Attachment; | ||||
import org.gitnex.tea4j.v2.models.Comment; | ||||
import org.gitnex.tea4j.v2.models.CommitStatus; | ||||
import org.gitnex.tea4j.v2.models.CreateIssueCommentOption; | ||||
import org.gitnex.tea4j.v2.models.EditIssueOption; | ||||
import org.gitnex.tea4j.v2.models.Issue; | ||||
| @ -82,6 +83,7 @@ import org.mian.gitnex.actions.IssueActions; | |||
import org.mian.gitnex.actions.LabelsActions; | ||||
import org.mian.gitnex.adapters.AssigneesListAdapter; | ||||
import org.mian.gitnex.adapters.AttachmentsAdapter; | ||||
import org.mian.gitnex.adapters.CommitStatusesAdapter; | ||||
import org.mian.gitnex.adapters.IssueCommentsAdapter; | ||||
import org.mian.gitnex.adapters.LabelsListAdapter; | ||||
import org.mian.gitnex.clients.RetrofitClient; | ||||
| @ -165,6 +167,7 @@ public class IssueDetailActivity extends BaseActivity | |||
private InputMethodManager imm; | ||||
private final float buttonAlphaStatDisabled = .5F; | ||||
private final float buttonAlphaStatEnabled = 1F; | ||||
private int loadingFinished = 0; | ||||
| ||||
private enum Mode { | ||||
EDIT, | ||||
| @ -391,6 +394,19 @@ public class IssueDetailActivity extends BaseActivity | |||
getAttachments(); | ||||
fetchDataAsync(repoOwner, repoName, issueIndex); | ||||
| ||||
viewBinding.statuses.setOnClickListener( | ||||
view -> { | ||||
if (viewBinding.statusesLv.getVisibility() == View.GONE) { | ||||
viewBinding.statusesExpandCollapse.setImageResource( | ||||
R.drawable.ic_chevron_up); | ||||
viewBinding.statusesLv.setVisibility(View.VISIBLE); | ||||
} else { | ||||
viewBinding.statusesExpandCollapse.setImageResource( | ||||
R.drawable.ic_chevron_down); | ||||
viewBinding.statusesLv.setVisibility(View.GONE); | ||||
} | ||||
}); | ||||
| ||||
if (getIntent().getStringExtra("openPrDiff") != null | ||||
&& Objects.equals(getIntent().getStringExtra("openPrDiff"), "true")) { | ||||
startActivity(issue.getIntent(ctx, DiffActivity.class)); | ||||
| @ -1109,6 +1125,10 @@ public class IssueDetailActivity extends BaseActivity | |||
viewBinding.issuePrState.setVisibility(View.VISIBLE); | ||||
| ||||
if (issue.getIssue().getPullRequest() != null) { | ||||
| ||||
viewBinding.statusesLvMain.setVisibility(View.VISIBLE); | ||||
| ||||
getStatuses(); | ||||
getPullRequest(); | ||||
if (issue.getIssue().getPullRequest().isMerged()) { // merged | ||||
| ||||
| @ -1786,4 +1806,83 @@ public class IssueDetailActivity extends BaseActivity | |||
} | ||||
}); | ||||
} | ||||
| ||||
private void getStatuses() { | ||||
| ||||
RetrofitClient.getApiInterface(ctx) | ||||
.repoListStatuses( | ||||
repoOwner, | ||||
repoName, | ||||
issue.getRepository().getBranchRef(), | ||||
null, | ||||
null, | ||||
null, | ||||
null) | ||||
.enqueue( | ||||
new Callback<>() { | ||||
| ||||
@Override | ||||
public void onResponse( | ||||
@NonNull Call<List<CommitStatus>> call, | ||||
@NonNull Response<List<CommitStatus>> response) { | ||||
| ||||
checkLoading(); | ||||
| ||||
if (!response.isSuccessful() || response.body() == null) { | ||||
onFailure(call, new Throwable()); | ||||
return; | ||||
} | ||||
| ||||
if (response.body().isEmpty()) { | ||||
viewBinding.statusesLvMain.setVisibility(View.GONE); | ||||
return; | ||||
} | ||||
| ||||
// merge statuses: a status can be added multiple times with the | ||||
// same context, so we only use the newest one | ||||
ArrayList<CommitStatus> result = new ArrayList<>(); | ||||
for (CommitStatus c : response.body()) { | ||||
CommitStatus statusInList = null; | ||||
for (CommitStatus s : result) { | ||||
if (Objects.equals(s.getContext(), c.getContext())) { | ||||
statusInList = s; | ||||
break; | ||||
} | ||||
} | ||||
if (statusInList != null) { | ||||
// if the status that's already in the list was created | ||||
// before this one, replace it | ||||
if (statusInList.getCreatedAt().before(c.getCreatedAt())) { | ||||
result.remove(statusInList); | ||||
result.add(c); | ||||
} | ||||
} else { | ||||
result.add(c); | ||||
} | ||||
} | ||||
| ||||
viewBinding.statusesList.setLayoutManager( | ||||
new LinearLayoutManager(ctx)); | ||||
viewBinding.statusesList.setAdapter( | ||||
new CommitStatusesAdapter(result)); | ||||
} | ||||
| ||||
@Override | ||||
public void onFailure( | ||||
@NonNull Call<List<CommitStatus>> call, @NonNull Throwable t) { | ||||
| ||||
checkLoading(); | ||||
if (ctx != null) { | ||||
Toasty.error(ctx, getString(R.string.genericError)); | ||||
} | ||||
} | ||||
}); | ||||
} | ||||
| ||||
private void checkLoading() { | ||||
loadingFinished += 1; | ||||
if (loadingFinished >= 3) { | ||||
viewBinding.progressBar.setVisibility(View.GONE); | ||||
} | ||||
} | ||||
} | ||||
| |
| @ -1295,7 +1295,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View | |||
context.getString( | ||||
R.string.timelineRefIssue, | ||||
issueComment.getUser().getLogin(), | ||||
issueComment.getRefIssue().getNumber(), | ||||
timelineComment.getRefIssue().getHtmlUrl(), | ||||
info); | ||||
Markdown.render(context, text, recyclerView, issue.getRepository()); | ||||
} else if (issue.getIssueType().equalsIgnoreCase("Pull")) { | ||||
| @ -1303,7 +1303,7 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View | |||
context.getString( | ||||
R.string.timelineRefPr, | ||||
issueComment.getUser().getLogin(), | ||||
issueComment.getRefIssue().getNumber(), | ||||
timelineComment.getRefIssue().getHtmlUrl(), | ||||
info); | ||||
Markdown.render(context, text, recyclerView, issue.getRepository()); | ||||
} | ||||
| |
| @ -392,7 +392,7 @@ public class CommitDetailFragment extends Fragment { | |||
return; | ||||
} | ||||
| ||||
if (response.body().size() < 1) { | ||||
if (response.body().isEmpty()) { | ||||
binding.statusesLvMain.setVisibility(View.GONE); | ||||
return; | ||||
} | ||||
| |
| @ -321,6 +321,68 @@ | |||
| ||||
</LinearLayout> | ||||
| ||||
<LinearLayout | ||||
android:id="@+id/statusesLvMain" | ||||
android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | ||||
android:foreground="?android:attr/selectableItemBackground" | ||||
android:background="?attr/materialCardBackgroundColor" | ||||
android:paddingStart="@dimen/dimen12dp" | ||||
android:paddingEnd="@dimen/dimen12dp" | ||||
android:paddingBottom="@dimen/dimen12dp" | ||||
android:visibility="gone" | ||||
android:orientation="vertical"> | ||||
| ||||
<LinearLayout | ||||
android:id="@+id/statuses" | ||||
android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | ||||
android:gravity="center" | ||||
android:minHeight="@dimen/dimen48dp" | ||||
android:orientation="horizontal"> | ||||
| ||||
<TextView | ||||
android:layout_width="0dp" | ||||
android:layout_height="wrap_content" | ||||
android:text="@string/commitStatuses" | ||||
android:textSize="@dimen/dimen16sp" | ||||
android:layout_weight="0.9" | ||||
android:gravity="center_vertical" | ||||
android:paddingBottom="@dimen/dimen12dp" | ||||
android:paddingStart="@dimen/dimen0dp" | ||||
android:paddingEnd="@dimen/dimen0dp" | ||||
android:textColor="?attr/primaryTextColor"/> | ||||
| ||||
<ImageView | ||||
android:id="@+id/statusesExpandCollapse" | ||||
android:layout_width="0dp" | ||||
android:layout_height="wrap_content" | ||||
android:layout_weight="0.1" | ||||
android:layout_gravity="center_vertical|end" | ||||
android:background="?android:attr/selectableItemBackgroundBorderless" | ||||
android:contentDescription="@string/generalImgContentText" | ||||
app:srcCompat="@drawable/ic_chevron_down"/> | ||||
| ||||
</LinearLayout> | ||||
| ||||
<LinearLayout | ||||
android:visibility="gone" | ||||
android:id="@+id/statusesLv" | ||||
android:orientation="vertical" | ||||
android:layout_width="match_parent" | ||||
android:layout_height="wrap_content"> | ||||
| ||||
<androidx.recyclerview.widget.RecyclerView | ||||
android:id="@+id/statusesList" | ||||
android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | ||||
android:textSize="@dimen/dimen16sp" | ||||
android:textColor="?attr/primaryTextColor"/> | ||||
| ||||
</LinearLayout> | ||||
| ||||
</LinearLayout> | ||||
| ||||
<LinearLayout | ||||
android:id="@+id/attachmentFrame" | ||||
android:layout_width="match_parent" | ||||
| |
| @ -119,12 +119,12 @@ | |||
| ||||
<com.google.android.material.card.MaterialCardView | ||||
android:id="@+id/commitAuthorAvatarFrame" | ||||
android:layout_width="@dimen/dimen24dp" | ||||
android:layout_height="@dimen/dimen24dp" | ||||
android:layout_width="@dimen/dimen32dp" | ||||
android:layout_height="@dimen/dimen32dp" | ||||
style="?attr/materialCardViewFilledStyle" | ||||
app:cardElevation="@dimen/dimen0dp" | ||||
android:layout_marginEnd="@dimen/dimen6dp" | ||||
app:cardCornerRadius="@dimen/dimen12dp"> | ||||
app:cardCornerRadius="@dimen/dimen8dp"> | ||||
| ||||
<ImageView | ||||
android:id="@+id/commitAuthorAvatar" | ||||
| @ -137,18 +137,18 @@ | |||
| ||||
<com.google.android.material.card.MaterialCardView | ||||
android:id="@+id/commitCommitterAvatarFrame" | ||||
android:layout_width="@dimen/dimen24dp" | ||||
android:layout_height="@dimen/dimen24dp" | ||||
android:layout_width="@dimen/dimen32dp" | ||||
android:layout_height="@dimen/dimen32dp" | ||||
style="?attr/materialCardViewFilledStyle" | ||||
app:cardElevation="@dimen/dimen0dp" | ||||
android:layout_marginEnd="@dimen/dimen6dp" | ||||
app:cardCornerRadius="@dimen/dimen12dp"> | ||||
app:cardCornerRadius="@dimen/dimen8dp"> | ||||
| ||||
<ImageView | ||||
android:id="@+id/commitCommitterAvatar" | ||||
android:layout_width="@dimen/dimen24dp" | ||||
android:layout_height="@dimen/dimen24dp" | ||||
android:layout_marginEnd="5dp" | ||||
android:layout_width="match_parent" | ||||
android:layout_height="match_parent" | ||||
android:layout_marginEnd="@dimen/dimen6dp" | ||||
android:contentDescription="@string/generalImgContentText" | ||||
tools:srcCompat="@tools:sample/avatars"/> | ||||
| ||||
| |
| @ -902,8 +902,8 @@ | |||
<string name="timelineTimeTrackingAddManualTime">%1$s added spent time %2$s %3$s</string> | ||||
<string name="timelineTimeTrackingDeleteManualTime">%1$s deleted spent time %2$s %3$s</string> | ||||
<string name="timelineChangeIssueRef">%1$s added reference %2$s %3$s</string> | ||||
<string name="timelineRefIssue">%1$s referenced this issue in #%2$d %3$s</string> | ||||
<string name="timelineRefPr">%1$s referenced this pull request in #%2$d %3$s</string> | ||||
<string name="timelineRefIssue">%1$s referenced this issue in %2$s %3$s</string> | ||||
<string name="timelineRefPr">%1$s referenced this pull request in %2$s %3$s</string> | ||||
<string name="timelineStatusRefIssue"><![CDATA[%1$s referenced this issue from a <font color=\'%2$d\'>%3$s</font> %4$s]]></string> | ||||
<string name="timelineReviewLeftComment">%1$s left a comment: %2$s %3$s</string> | ||||
<string name="timelinePinned">%1$s pinned this %2$s</string> | ||||
| |
Loading…
Add table
Add a link
Reference in a new issue