diff --git a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java index 20c83d77..29033221 100644 --- a/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java +++ b/app/src/main/java/org/mian/gitnex/activities/RepoDetailActivity.java @@ -37,6 +37,7 @@ import org.mian.gitnex.fragments.PullRequestsFragment; import org.mian.gitnex.fragments.ReleasesFragment; import org.mian.gitnex.fragments.RepoInfoFragment; import org.mian.gitnex.helpers.Authorization; +import org.mian.gitnex.helpers.VersionCheck; import org.mian.gitnex.models.UserRepositories; import org.mian.gitnex.models.WatchRepository; import org.mian.gitnex.util.AppUtil; @@ -168,12 +169,14 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF } // release count - if (textViewBadgeRelease.getText() != "") { // only show if API returned a number - Objects.requireNonNull(tabLayout.getTabAt(6)).setCustomView(tabHeader6); - TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(6); - assert tabOpenRelease != null; - TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText); - openReleaseTabView.setTextColor(textColor); + if (VersionCheck.compareVersion("1.11.5", tinyDb.getString("giteaVersion")) < 1) { + if(textViewBadgeRelease.getText() != "") { // only show if API returned a number + Objects.requireNonNull(tabLayout.getTabAt(6)).setCustomView(tabHeader6); + TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(6); + assert tabOpenRelease != null; + TextView openReleaseTabView = Objects.requireNonNull(tabOpenRelease.getCustomView()).findViewById(R.id.counterBadgeReleaseText); + openReleaseTabView.setTextColor(textColor); + } } } diff --git a/app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java b/app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java index 12a25232..ae69c1e4 100644 --- a/app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java +++ b/app/src/main/java/org/mian/gitnex/helpers/VersionCheck.java @@ -102,6 +102,22 @@ public enum VersionCheck { * 2 = more */ public static int compareVersion(String A, String B) { + final Pattern pattern_stable_release = Pattern.compile("^(\\d)\\.(\\d+)\\.(\\d+)"); + final Pattern pattern_dev_release = Pattern.compile("^(\\d).(\\d+).(\\d+)(\\D)(.+)"); + Matcher match; + match = pattern_dev_release.matcher(A); + if (match.find()) { + match = pattern_stable_release.matcher(A); + match.find(); + A = match.group(); + } + match = pattern_dev_release.matcher(B); + if (match.find()) { + match = pattern_stable_release.matcher(B); + match.find(); + B = match.group(); + } + //throw new IllegalArgumentException if((!A.matches("[0-9]+(\\.[0-9]+)*")) || (!B.matches("[0-9]+(\\.[0-9]+)*"))) throw new IllegalArgumentException("Invalid version format");