View files in timeline, fix crash on review in timeline and other UI enhancements
This commit is contained in:
parent
562b881583
commit
f19ed8253b
|
@ -57,13 +57,13 @@ dependencies {
|
|||
|
||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||
implementation 'androidx.appcompat:appcompat:1.6.1'
|
||||
implementation 'com.google.android.material:material:1.11.0-beta01'
|
||||
implementation 'androidx.compose.material3:material3:1.2.0-alpha10'
|
||||
implementation 'androidx.compose.material3:material3-window-size-class:1.2.0-alpha10'
|
||||
implementation 'com.google.android.material:material:1.11.0'
|
||||
implementation 'androidx.compose.material3:material3:1.2.0-beta02'
|
||||
implementation 'androidx.compose.material3:material3-window-size-class:1.2.0-beta02'
|
||||
implementation 'androidx.viewpager2:viewpager2:1.1.0-beta02'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
|
||||
implementation "androidx.legacy:legacy-support-v4:1.0.0"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:2.6.2"
|
||||
implementation "androidx.lifecycle:lifecycle-viewmodel:2.7.0"
|
||||
testImplementation 'junit:junit:4.13.2'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
|
||||
|
@ -99,16 +99,16 @@ dependencies {
|
|||
implementation 'ch.acra:acra-mail:5.11.2'
|
||||
implementation 'ch.acra:acra-limiter:5.11.2'
|
||||
implementation 'ch.acra:acra-notification:5.11.2'
|
||||
implementation 'androidx.room:room-runtime:2.6.0'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.6.0'
|
||||
implementation "androidx.work:work-runtime:2.8.1"
|
||||
implementation 'androidx.room:room-runtime:2.6.1'
|
||||
annotationProcessor 'androidx.room:room-compiler:2.6.1'
|
||||
implementation "androidx.work:work-runtime:2.9.0"
|
||||
implementation "io.mikael:urlbuilder:2.0.9"
|
||||
implementation "org.codeberg.gitnex-garage:emoji-java:v5.1.2"
|
||||
//noinspection GradleDependency
|
||||
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
|
||||
implementation 'androidx.biometric:biometric:1.1.0'
|
||||
implementation 'com.github.chrisvest:stormpot:2.4.2'
|
||||
implementation 'androidx.browser:browser:1.6.0'
|
||||
implementation 'androidx.browser:browser:1.7.0'
|
||||
implementation 'com.google.android.flexbox:flexbox:3.0.0'
|
||||
implementation('org.codeberg.gitnex:tea4j-autodeploy:4646f53557') {
|
||||
exclude module: 'org.apache.oltu.oauth2.common'
|
||||
|
|
|
@ -151,7 +151,7 @@ public class IssueDetailActivity extends BaseActivity
|
|||
}
|
||||
});
|
||||
|
||||
ActivityResultLauncher<Intent> downloadAttachmentLauncher =
|
||||
public ActivityResultLauncher<Intent> downloadAttachmentLauncher =
|
||||
registerForActivityResult(
|
||||
new ActivityResultContracts.StartActivityForResult(),
|
||||
result -> {
|
||||
|
@ -326,6 +326,7 @@ public class IssueDetailActivity extends BaseActivity
|
|||
viewBinding.toolbarTitle.setText(repoName);
|
||||
|
||||
getSingleIssue(repoOwner, repoName, issueIndex);
|
||||
getAttachments();
|
||||
fetchDataAsync(repoOwner, repoName, issueIndex);
|
||||
|
||||
if (getIntent().getStringExtra("openPrDiff") != null
|
||||
|
@ -729,8 +730,6 @@ public class IssueDetailActivity extends BaseActivity
|
|||
|
||||
private void getSingleIssue(String repoOwner, String repoName, int issueIndex) {
|
||||
|
||||
getAttachments();
|
||||
|
||||
if (issue.hasIssue()) {
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
getSubscribed();
|
||||
|
@ -761,7 +760,6 @@ public class IssueDetailActivity extends BaseActivity
|
|||
} else if (response.code() == 401) {
|
||||
|
||||
AlertDialogs.authorizationTokenRevokedDialog(ctx);
|
||||
|
||||
} else if (response.code() == 404) {
|
||||
|
||||
Toasty.warning(ctx, getResources().getString(R.string.noDataFound));
|
||||
|
@ -773,7 +771,6 @@ public class IssueDetailActivity extends BaseActivity
|
|||
public void onFailure(@NonNull Call<Issue> call, @NonNull Throwable t) {
|
||||
|
||||
viewBinding.progressBar.setVisibility(View.GONE);
|
||||
Log.e("onFailure", t.toString());
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1243,12 +1240,14 @@ public class IssueDetailActivity extends BaseActivity
|
|||
}
|
||||
|
||||
private void getAttachments() {
|
||||
|
||||
Call<List<Attachment>> call =
|
||||
RetrofitClient.getApiInterface(ctx)
|
||||
.issueListIssueAttachments(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
(long) issueIndex);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
|
|
|
@ -32,11 +32,15 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||
import com.amulyakhare.textdrawable.TextDrawable;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.google.android.material.card.MaterialCardView;
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder;
|
||||
import com.vdurmont.emoji.EmojiParser;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.gitnex.tea4j.v2.models.Attachment;
|
||||
import org.gitnex.tea4j.v2.models.TimelineComment;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
@ -48,6 +52,7 @@ import org.mian.gitnex.activities.IssueDetailActivity;
|
|||
import org.mian.gitnex.activities.ProfileActivity;
|
||||
import org.mian.gitnex.clients.PicassoService;
|
||||
import org.mian.gitnex.clients.RetrofitClient;
|
||||
import org.mian.gitnex.databinding.CustomImageViewDialogBinding;
|
||||
import org.mian.gitnex.fragments.BottomSheetReplyFragment;
|
||||
import org.mian.gitnex.fragments.IssuesFragment;
|
||||
import org.mian.gitnex.helpers.AlertDialogs;
|
||||
|
@ -257,6 +262,15 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
timelineDividerView = view.findViewById(R.id.timeline_divider_view);
|
||||
timelineLine2 = view.findViewById(R.id.timeline_line_2);
|
||||
|
||||
String token = ((BaseActivity) context).getAccount().getAccount().getToken();
|
||||
|
||||
new Handler()
|
||||
.postDelayed(
|
||||
() -> {
|
||||
getAttachments(issueComment.getId(), view, token);
|
||||
},
|
||||
250);
|
||||
|
||||
menu.setOnClickListener(
|
||||
v -> {
|
||||
final String loginUid =
|
||||
|
@ -888,20 +902,42 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
}
|
||||
|
||||
if (issueComment.getType().equalsIgnoreCase("review")) {
|
||||
timelineView.setVisibility(View.GONE);
|
||||
timelineDividerView.setVisibility(View.GONE);
|
||||
if (!issueComment.getBody().equalsIgnoreCase("")) {
|
||||
|
||||
start.setText(
|
||||
context.getString(
|
||||
R.string.timelineReviewLeftComment,
|
||||
issueComment.getUser().getLogin(),
|
||||
issueComment.getBody(),
|
||||
info));
|
||||
timelineIcon.setImageDrawable(
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_comment));
|
||||
} else {
|
||||
timelineView.setVisibility(View.GONE);
|
||||
timelineDividerView.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (issueComment.getType().equalsIgnoreCase("dismiss_review")) {
|
||||
timelineView.setVisibility(View.GONE);
|
||||
timelineDividerView.setVisibility(View.GONE);
|
||||
} else if (issueComment.getType().equalsIgnoreCase("review_request")) {
|
||||
String reviewer;
|
||||
if (issueComment.getAssignee() != null) {
|
||||
reviewer = issueComment.getAssignee().getLogin();
|
||||
} else {
|
||||
if (issueComment.getAssigneeTeam() != null) {
|
||||
reviewer = issueComment.getAssigneeTeam().getName();
|
||||
} else {
|
||||
reviewer = "";
|
||||
}
|
||||
}
|
||||
start.setText(
|
||||
context.getString(
|
||||
R.string.timelineReviewRequest,
|
||||
issueComment.getUser().getLogin(),
|
||||
issueComment.getAssignee().getLogin(),
|
||||
reviewer,
|
||||
info));
|
||||
timelineIcon.setImageDrawable(
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_unwatch));
|
||||
ContextCompat.getDrawable(context, R.drawable.ic_watchers));
|
||||
}
|
||||
start.setTextSize(fontSize);
|
||||
|
||||
|
@ -1286,4 +1322,133 @@ public class IssueCommentsAdapter extends RecyclerView.Adapter<RecyclerView.View
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void getAttachments(Long issueIndex, View view, String token) {
|
||||
|
||||
LinearLayout attachmentFrame = view.findViewById(R.id.attachmentFrame);
|
||||
LinearLayout attachmentsView = view.findViewById(R.id.attachmentsView);
|
||||
|
||||
Call<List<Attachment>> call =
|
||||
RetrofitClient.getApiInterface(context)
|
||||
.issueListIssueCommentAttachments(
|
||||
issue.getRepository().getOwner(),
|
||||
issue.getRepository().getName(),
|
||||
issueIndex);
|
||||
|
||||
call.enqueue(
|
||||
new Callback<>() {
|
||||
|
||||
@Override
|
||||
public void onResponse(
|
||||
@NonNull Call<List<Attachment>> call,
|
||||
@NonNull retrofit2.Response<List<Attachment>> response) {
|
||||
|
||||
List<Attachment> attachment = response.body();
|
||||
|
||||
if (response.code() == 200) {
|
||||
assert attachment != null;
|
||||
|
||||
if (attachment.size() > 0) {
|
||||
|
||||
attachmentFrame.setVisibility(View.VISIBLE);
|
||||
LinearLayout.LayoutParams paramsAttachment =
|
||||
new LinearLayout.LayoutParams(96, 96);
|
||||
paramsAttachment.setMargins(0, 0, 48, 0);
|
||||
|
||||
for (int i = 0; i < attachment.size(); i++) {
|
||||
|
||||
ImageView attachmentView = new ImageView(context);
|
||||
MaterialCardView materialCardView =
|
||||
new MaterialCardView(context);
|
||||
materialCardView.setLayoutParams(paramsAttachment);
|
||||
materialCardView.setStrokeWidth(0);
|
||||
materialCardView.setCardBackgroundColor(Color.TRANSPARENT);
|
||||
|
||||
if (Arrays.asList(
|
||||
"bmp", "gif", "jpg", "jpeg", "png", "webp",
|
||||
"heic", "heif")
|
||||
.contains(
|
||||
FilenameUtils.getExtension(
|
||||
attachment.get(i).getName())
|
||||
.toLowerCase())) {
|
||||
|
||||
PicassoService.getInstance(context)
|
||||
.get()
|
||||
.load(
|
||||
attachment.get(i).getBrowserDownloadUrl()
|
||||
+ "?token="
|
||||
+ token)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.resize(120, 120)
|
||||
.centerCrop()
|
||||
.error(R.drawable.ic_close)
|
||||
.into(attachmentView);
|
||||
|
||||
attachmentsView.addView(materialCardView);
|
||||
attachmentView.setLayoutParams(paramsAttachment);
|
||||
materialCardView.addView(attachmentView);
|
||||
|
||||
int finalI1 = i;
|
||||
materialCardView.setOnClickListener(
|
||||
v1 ->
|
||||
imageViewDialog(
|
||||
attachment
|
||||
.get(finalI1)
|
||||
.getBrowserDownloadUrl(),
|
||||
token));
|
||||
|
||||
} else {
|
||||
|
||||
attachmentView.setImageResource(
|
||||
R.drawable.ic_file_download);
|
||||
attachmentView.setPadding(4, 4, 4, 4);
|
||||
attachmentsView.addView(materialCardView);
|
||||
attachmentView.setLayoutParams(paramsAttachment);
|
||||
materialCardView.addView(attachmentView);
|
||||
|
||||
int finalI = i;
|
||||
materialCardView.setOnClickListener(
|
||||
v1 -> {
|
||||
// filesize = attachment.get(finalI).getSize();
|
||||
// filename = attachment.get(finalI).getName();
|
||||
// filehash = attachment.get(finalI).getUuid();
|
||||
// requestFileDownload();
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
attachmentFrame.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(
|
||||
@NonNull Call<List<Attachment>> call, @NonNull Throwable t) {}
|
||||
});
|
||||
}
|
||||
|
||||
private void imageViewDialog(String url, String token) {
|
||||
|
||||
MaterialAlertDialogBuilder materialAlertDialogBuilder =
|
||||
new MaterialAlertDialogBuilder(
|
||||
context, R.style.ThemeOverlay_Material3_Dialog_Alert);
|
||||
|
||||
CustomImageViewDialogBinding imageViewDialogBinding =
|
||||
CustomImageViewDialogBinding.inflate(LayoutInflater.from(context));
|
||||
View view = imageViewDialogBinding.getRoot();
|
||||
materialAlertDialogBuilder.setView(view);
|
||||
|
||||
materialAlertDialogBuilder.setNeutralButton(context.getString(R.string.close), null);
|
||||
PicassoService.getInstance(context)
|
||||
.get()
|
||||
.load(url + "?token=" + token)
|
||||
.placeholder(R.drawable.loader_animated)
|
||||
.resize(0, 1600)
|
||||
.onlyScaleDown()
|
||||
.centerCrop()
|
||||
.error(R.drawable.ic_close)
|
||||
.into(imageViewDialogBinding.imageView);
|
||||
materialAlertDialogBuilder.create().show();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,25 +134,17 @@
|
|||
android:textColorLink="@color/lightBlue"
|
||||
android:textSize="@dimen/dimen16sp"/>
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<org.mian.gitnex.helpers.languagestatistics.LanguageStatisticsBar
|
||||
android:id="@+id/languages_statistic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="?attr/materialCardViewElevatedStyle"
|
||||
android:backgroundTint="@android:color/transparent"
|
||||
app:cardElevation="@dimen/dimen0dp">
|
||||
|
||||
<org.mian.gitnex.helpers.languagestatistics.LanguageStatisticsBar
|
||||
android:id="@+id/languages_statistic"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:thumbTint="@android:color/transparent"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:enabled="false"
|
||||
android:progressDrawable="@android:color/transparent"
|
||||
android:visibility="gone" />
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
android:layout_height="@dimen/dimen22dp"
|
||||
android:layout_marginTop="@dimen/dimen4dp"
|
||||
android:thumbTint="@android:color/transparent"
|
||||
android:clickable="false"
|
||||
android:focusable="false"
|
||||
android:enabled="false"
|
||||
android:progressDrawable="@android:color/transparent"
|
||||
android:visibility="gone" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -35,8 +35,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:background="?attr/materialCardBackgroundColor"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/dimen12dp">
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/materialCardBackgroundColor"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:padding="@dimen/dimen12dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
|
@ -64,8 +71,8 @@
|
|||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="15dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:layout_marginLeft="@dimen/dimen16dp"
|
||||
android:layout_marginRight="@dimen/dimen16dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="vertical">
|
||||
|
@ -77,7 +84,7 @@
|
|||
android:ellipsize="middle"
|
||||
android:singleLine="true"
|
||||
android:textColor="?attr/primaryTextColor"
|
||||
android:textSize="14sp"
|
||||
android:textSize="@dimen/dimen14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
|
@ -87,7 +94,8 @@
|
|||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="?attr/hintColor"
|
||||
android:textSize="12sp" />
|
||||
android:textSize="@dimen/dimen12sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
|
@ -111,16 +119,43 @@
|
|||
android:textColor="?attr/primaryTextColor"
|
||||
android:textColorLink="@color/lightBlue"
|
||||
android:textIsSelectable="true"
|
||||
android:textSize="14sp" />
|
||||
android:textSize="@dimen/dimen14sp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/commentReactionBadges"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="@dimen/dimen16dp"
|
||||
android:orientation="horizontal"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachmentFrame"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/materialCardBackgroundColor"
|
||||
android:foreground="?android:attr/selectableItemBackground"
|
||||
android:visibility="gone"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dimen4dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/attachmentsView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/dimen12dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
<dimen name="dimen16dp">16dp</dimen>
|
||||
<dimen name="dimen18dp">18dp</dimen>
|
||||
<dimen name="dimen20dp">20dp</dimen>
|
||||
<dimen name="dimen22dp">22dp</dimen>
|
||||
<dimen name="dimen24dp">24dp</dimen>
|
||||
<dimen name="dimen26dp">26dp</dimen>
|
||||
<dimen name="dimen28dp">28dp</dimen>
|
||||
|
|
|
@ -874,6 +874,7 @@
|
|||
<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="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="commitStatuses">Statuses</string>
|
||||
<string name="statusNoUrl">This status has no linked target URL.</string>
|
||||
|
|
Loading…
Reference in New Issue