From eeb0de4a4e576185cebcfb1b9119dcd71892e5e2 Mon Sep 17 00:00:00 2001 From: crschnick Date: Sat, 23 Dec 2023 12:31:40 +0000 Subject: [PATCH] Rework licensed features to include preview check --- .../java/io/xpipe/app/util/Hyperlinks.java | 1 + .../app/util/LicenseRequiredException.java | 19 +++++++++++-------- .../io/xpipe/app/util/LicensedFeature.java | 8 ++++++++ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/util/Hyperlinks.java b/app/src/main/java/io/xpipe/app/util/Hyperlinks.java index 5515bc22..af73fa75 100644 --- a/app/src/main/java/io/xpipe/app/util/Hyperlinks.java +++ b/app/src/main/java/io/xpipe/app/util/Hyperlinks.java @@ -8,6 +8,7 @@ public class Hyperlinks { public static final String GITHUB = "https://github.com/xpipe-io/xpipe"; public static final String PRIVACY = "https://docs.xpipe.io/privacy-policy"; public static final String EULA = "https://docs.xpipe.io/end-user-license-agreement"; + public static final String PREVIEW = "https://docs.xpipe.io/preview"; public static final String SECURITY = "https://docs.xpipe.io/security"; public static final String DISCORD = "https://discord.gg/8y89vS8cRb"; public static final String SLACK = "https://join.slack.com/t/XPipe/shared_invite/zt-1awjq0t5j-5i4UjNJfNe1VN4b_auu6Cg"; diff --git a/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java b/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java index 00d598d2..abb157e6 100644 --- a/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java +++ b/app/src/main/java/io/xpipe/app/util/LicenseRequiredException.java @@ -1,17 +1,20 @@ package io.xpipe.app.util; -import lombok.AccessLevel; -import lombok.experimental.FieldDefaults; +import lombok.Getter; -@FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) public class LicenseRequiredException extends RuntimeException { - String featureName; - boolean plural; + @Getter + private final LicensedFeature feature; - public LicenseRequiredException(String featureName, boolean plural) { + public LicenseRequiredException(LicensedFeature feature) { + super(feature.getDisplayName() + (feature.isPlural() ? " are" : " is") + " only supported with a professional license"); + this.feature = feature; + } + + + public LicenseRequiredException(String featureName, boolean plural, LicensedFeature feature) { super(featureName + (plural ? " are" : " is") + " only supported with a professional license"); - this.featureName = featureName; - this.plural = plural; + this.feature = feature; } } diff --git a/app/src/main/java/io/xpipe/app/util/LicensedFeature.java b/app/src/main/java/io/xpipe/app/util/LicensedFeature.java index 1d637742..96685eba 100644 --- a/app/src/main/java/io/xpipe/app/util/LicensedFeature.java +++ b/app/src/main/java/io/xpipe/app/util/LicensedFeature.java @@ -4,5 +4,13 @@ public interface LicensedFeature { String getId(); + String getDisplayName(); + + boolean isPlural(); + boolean isSupported(); + + boolean isPreviewSupported(); + + public void throwIfUnsupported() throws LicenseRequiredException; }