hide ReleaseCounter Badge on old Gitea instances (#367)
Hide Release Count on old Gitea Instances fix compareVersion Co-authored-by: 6543 <6543@obermui.de> Reviewed-on: https://gitea.com/gitnex/GitNex/pulls/367 Reviewed-by: M M Arif <mmarif@swatian.com>
This commit is contained in:
parent
d46db0475f
commit
da90005e42
@ -37,6 +37,7 @@ import org.mian.gitnex.fragments.PullRequestsFragment;
|
|||||||
import org.mian.gitnex.fragments.ReleasesFragment;
|
import org.mian.gitnex.fragments.ReleasesFragment;
|
||||||
import org.mian.gitnex.fragments.RepoInfoFragment;
|
import org.mian.gitnex.fragments.RepoInfoFragment;
|
||||||
import org.mian.gitnex.helpers.Authorization;
|
import org.mian.gitnex.helpers.Authorization;
|
||||||
|
import org.mian.gitnex.helpers.VersionCheck;
|
||||||
import org.mian.gitnex.models.UserRepositories;
|
import org.mian.gitnex.models.UserRepositories;
|
||||||
import org.mian.gitnex.models.WatchRepository;
|
import org.mian.gitnex.models.WatchRepository;
|
||||||
import org.mian.gitnex.util.AppUtil;
|
import org.mian.gitnex.util.AppUtil;
|
||||||
@ -168,7 +169,8 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
}
|
}
|
||||||
|
|
||||||
// release count
|
// release count
|
||||||
if (textViewBadgeRelease.getText() != "") { // only show if API returned a number
|
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);
|
Objects.requireNonNull(tabLayout.getTabAt(6)).setCustomView(tabHeader6);
|
||||||
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(6);
|
TabLayout.Tab tabOpenRelease = tabLayout.getTabAt(6);
|
||||||
assert tabOpenRelease != null;
|
assert tabOpenRelease != null;
|
||||||
@ -176,6 +178,7 @@ public class RepoDetailActivity extends BaseActivity implements BottomSheetRepoF
|
|||||||
openReleaseTabView.setTextColor(textColor);
|
openReleaseTabView.setTextColor(textColor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
checkRepositoryStarStatus(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
||||||
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
checkRepositoryWatchStatus(instanceUrl, Authorization.returnAuthentication(getApplicationContext(), loginUid, instanceToken), repoOwner, repoName1);
|
||||||
|
@ -102,6 +102,22 @@ public enum VersionCheck {
|
|||||||
* 2 = more
|
* 2 = more
|
||||||
*/
|
*/
|
||||||
public static int compareVersion(String A, String B) {
|
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
|
//throw new IllegalArgumentException
|
||||||
if((!A.matches("[0-9]+(\\.[0-9]+)*")) || (!B.matches("[0-9]+(\\.[0-9]+)*"))) throw new IllegalArgumentException("Invalid version format");
|
if((!A.matches("[0-9]+(\\.[0-9]+)*")) || (!B.matches("[0-9]+(\\.[0-9]+)*"))) throw new IllegalArgumentException("Invalid version format");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user