Add dedicated methods for the EOL version checks

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-05-04 10:09:08 +02:00 committed by Andy Scherzinger
parent 37dc7d1df0
commit 1f8905394e
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
3 changed files with 13 additions and 6 deletions

View file

@ -270,8 +270,7 @@ public class ConversationsListController extends BaseController implements Searc
currentUser = userUtils.getCurrentUser();
if (currentUser != null) {
if (!currentUser.hasSpreedFeatureCapability("no-ping")) {
// Talk 4+
if (currentUser.isServerEOL()) {
new LovelyStandardDialog(getActivity(), LovelyStandardDialog.ButtonLayout.HORIZONTAL)
.setTopColorRes(R.color.nc_darkRed)
.setIcon(DisplayUtils.getTintedDrawable(context.getResources(),

View file

@ -553,12 +553,10 @@ public class SettingsController extends BaseController {
baseUrlTextView.setText(Uri.parse(currentUser.getBaseUrl()).getHost());
if (!currentUser.hasSpreedFeatureCapability("no-ping")) {
// Talk 4+
if (currentUser.isServerEOL()) {
serverAgeTextView.setTextColor(getResources().getColor(R.color.nc_darkRed));
serverAgeTextView.setText(R.string.nc_settings_server_eol);
} else if (!currentUser.hasSpreedFeatureCapability("chat-replies")) {
// Talk 8+
} else if (currentUser.isServerAlmostEOL()) {
serverAgeTextView.setTextColor(getResources().getColor(R.color.nc_darkYellow));
serverAgeTextView.setText(R.string.nc_settings_server_almost_eol);
} else {

View file

@ -92,6 +92,16 @@ public interface User extends Parcelable, Persistable, Serializable {
return false;
}
default boolean isServerEOL() {
// Capability is available since Talk 4 => Nextcloud 14 => Autmn 2018
return !hasSpreedFeatureCapability("no-ping");
}
default boolean isServerAlmostEOL() {
// Capability is available since Talk 8 => Nextcloud 18 => January 2020
return !hasSpreedFeatureCapability("chat-replies");
}
default boolean hasSpreedFeatureCapability(String capabilityName) {
if (getCapabilities() != null) {
try {