Fix version check (#1131)

It used a TinyDB value which is empty, of course.

Co-authored-by: qwerty287 <ndev@web.de>
Co-authored-by: M M Arif <mmarif@swatian.com>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1131
Reviewed-by: M M Arif <mmarif@noreply.codeberg.org>
Co-authored-by: qwerty287 <qwerty287@noreply.codeberg.org>
Co-committed-by: qwerty287 <qwerty287@noreply.codeberg.org>
This commit is contained in:
qwerty287 2022-05-15 13:12:36 +02:00 committed by M M Arif
parent 43b1a3907d
commit 884054b772
4 changed files with 42 additions and 42 deletions

View File

@ -419,10 +419,14 @@ public class IssueDetailActivity extends BaseActivity implements LabelsListAdapt
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
if(issue.getIssueType().equalsIgnoreCase("pull")) {
inflater.inflate(R.menu.pr_info_menu, menu);
}
new Handler().postDelayed(() -> {
inflater.inflate(R.menu.generic_nav_dotted_menu, menu);
if(issue.getIssueType() != null) {
if(issue.getIssueType().equalsIgnoreCase("pull")) {
inflater.inflate(R.menu.pr_info_menu, menu);
}
}
}, 800);
return true;
}

View File

@ -15,6 +15,7 @@ import androidx.fragment.app.Fragment;
import com.vdurmont.emoji.EmojiParser;
import org.gitnex.tea4j.v2.models.Commit;
import org.mian.gitnex.R;
import org.mian.gitnex.activities.BaseActivity;
import org.mian.gitnex.activities.ProfileActivity;
import org.mian.gitnex.adapters.DiffFilesAdapter;
import org.mian.gitnex.clients.PicassoService;
@ -82,14 +83,15 @@ public class CommitDetailFragment extends Fragment {
}
private void getDiff() {
Call<String> call = new Version(TinyDB.getInstance(requireContext()).getString("giteaVersion")).higherOrEqual("1.16.0") ?
Call<String> call = ((BaseActivity) requireActivity()).getAccount().requiresVersion("1.16.0") ?
RetrofitClient.getApiInterface(requireContext()).repoDownloadCommitDiffOrPatch(repoOwner, repoName, sha, "diff") :
RetrofitClient.getWebInterface(requireContext()).repoDownloadCommitDiffOrPatch(repoOwner, repoName, sha, "diff");
call.enqueue(new Callback<String>() {
call.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<String> call, @NonNull Response<String> response) {
checkLoading();
assert response.body() != null;
switch(response.code()) {
@ -121,6 +123,7 @@ public class CommitDetailFragment extends Fragment {
@Override
public void onFailure(@NonNull Call<String> call, @NonNull Throwable t) {
checkLoading();
Toasty.error(requireContext(), getString(R.string.genericError));
}
@ -130,10 +133,11 @@ public class CommitDetailFragment extends Fragment {
private void getCommit() {
RetrofitClient.getApiInterface(requireContext()).repoGetSingleCommit(repoOwner, repoName, sha)
.enqueue(new Callback<Commit>() {
.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull Call<Commit> call, @NonNull Response<Commit> response) {
checkLoading();
CustomCommitHeaderBinding binding = CustomCommitHeaderBinding.inflate(getLayoutInflater());
binding.getRoot().setOnClickListener((v) -> {
@ -148,38 +152,34 @@ public class CommitDetailFragment extends Fragment {
binding.commitBody.setVisibility(View.VISIBLE);
binding.commitSubject.setText(EmojiParser.parseToUnicode(commitMessageParts[0].trim()));
binding.commitBody.setText(EmojiParser.parseToUnicode(commitMessageParts[1].trim()));
} else {
}
else {
binding.commitSubject.setText(EmojiParser.parseToUnicode(commitMessageParts[0].trim()));
binding.commitBody.setVisibility(View.GONE);
}
if(!Objects.equals(commitsModel.getCommit().getCommitter().getEmail(), commitsModel.getCommit().getCommitter().getEmail())) {
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(CommitDetailFragment.this
.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
TimeHelper
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
} else {
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(CommitDetailFragment.this
.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
TimeHelper
.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
CommitDetailFragment.this.getString(R.string.commitAuthoredByAndCommittedByWhen, commitsModel.getCommit().getAuthor().getName(), commitsModel.getCommit().getCommitter().getName(),
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
}
else {
binding.commitAuthorAndCommitter.setText(HtmlCompat.fromHtml(
CommitDetailFragment.this.getString(R.string.commitCommittedByWhen, commitsModel.getCommit().getCommitter().getName(),
TimeHelper.formatTime(TimeHelper.parseIso8601(commitsModel.getCommit().getCommitter().getDate()), getResources().getConfiguration().locale, "pretty",
requireContext())), HtmlCompat.FROM_HTML_MODE_COMPACT));
}
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null &&
!commitsModel.getAuthor().getAvatarUrl().isEmpty()) {
if(commitsModel.getAuthor() != null && commitsModel.getAuthor().getAvatarUrl() != null && !commitsModel.getAuthor().getAvatarUrl()
.isEmpty()) {
binding.commitAuthorAvatar.setVisibility(View.VISIBLE);
int imgRadius = AppUtil.getPixelsFromDensity(requireContext(), 3);
PicassoService.getInstance(requireContext()).get()
.load(commitsModel.getAuthor().getAvatarUrl())
.placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120)
.centerCrop().into(binding.commitAuthorAvatar);
PicassoService.getInstance(requireContext()).get().load(commitsModel.getAuthor().getAvatarUrl())
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(binding.commitAuthorAvatar);
binding.commitAuthorAvatar.setOnClickListener((v) -> {
Intent intent = new Intent(requireContext(), ProfileActivity.class);
@ -187,26 +187,21 @@ public class CommitDetailFragment extends Fragment {
startActivity(intent);
});
} else {
}
else {
binding.commitAuthorAvatar.setImageDrawable(null);
binding.commitAuthorAvatar.setVisibility(View.GONE);
}
if(commitsModel.getCommitter() != null &&
(commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin().equals(commitsModel.getCommitter().getLogin())) &&
commitsModel.getCommitter().getAvatarUrl() != null &&
!commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
if(commitsModel.getCommitter() != null && (commitsModel.getAuthor() == null || !commitsModel.getAuthor().getLogin()
.equals(commitsModel.getCommitter().getLogin())) && commitsModel.getCommitter().getAvatarUrl() != null && !commitsModel.getCommitter().getAvatarUrl().isEmpty()) {
binding.commitCommitterAvatar.setVisibility(View.VISIBLE);
int imgRadius = AppUtil.getPixelsFromDensity(requireContext(), 3);
PicassoService.getInstance(requireContext()).get()
.load(commitsModel.getCommitter().getAvatarUrl())
.placeholder(R.drawable.loader_animated)
.transform(new RoundedTransformation(imgRadius, 0))
.resize(120, 120)
.centerCrop().into(binding.commitCommitterAvatar);
PicassoService.getInstance(requireContext()).get().load(commitsModel.getCommitter().getAvatarUrl())
.placeholder(R.drawable.loader_animated).transform(new RoundedTransformation(imgRadius, 0)).resize(120, 120).centerCrop().into(binding.commitCommitterAvatar);
binding.commitCommitterAvatar.setOnClickListener((v) -> {
Intent intent = new Intent(requireContext(), ProfileActivity.class);
@ -214,7 +209,8 @@ public class CommitDetailFragment extends Fragment {
startActivity(intent);
});
} else {
}
else {
binding.commitCommitterAvatar.setImageDrawable(null);
binding.commitCommitterAvatar.setVisibility(View.GONE);
}

View File

@ -8,7 +8,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Author 6543
* @author 6543
*/
public class Version {

View File

@ -654,8 +654,8 @@
<string name="mainNotificationChannelDescription">This is the main notification channel of GitNex.</string>
<string name="notificationExtraInfo" translatable="false">- %s (%s)</string>
<plurals name="youHaveNewNotifications">
<item quantity="one">You have %s new notification.</item>
<item quantity="other">You have %s new notifications.</item>
<item quantity="one">You have %s new notification</item>
<item quantity="other">You have %s new notifications</item>
</plurals>
<string name="isRead">Read</string>