diff --git a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java index b72013467..f1c283a14 100644 --- a/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java +++ b/app/src/main/java/io/xpipe/app/ext/DataStoreProvider.java @@ -122,8 +122,8 @@ public interface DataStoreProvider { default void storageInit() throws Exception {} - default boolean isShareable() { - return false; + default boolean isShareable(DataStoreEntry entry) { + return true; } default String summaryString(StoreEntryWrapper wrapper) { diff --git a/app/src/main/java/io/xpipe/app/storage/DataStorage.java b/app/src/main/java/io/xpipe/app/storage/DataStorage.java index 6ff55c44f..5db818443 100644 --- a/app/src/main/java/io/xpipe/app/storage/DataStorage.java +++ b/app/src/main/java/io/xpipe/app/storage/DataStorage.java @@ -161,6 +161,38 @@ public abstract class DataStorage { public abstract void save(); public abstract boolean supportsSharing(); + public boolean shouldShare(DataStoreCategory entry) { + if (!entry.canShare()) { + return false; + } + + DataStoreCategory c = entry; + do { + if (!c.shouldShareChildren()) { + return false; + } + } while ((c = DataStorage.get() + .getStoreCategoryIfPresent(c.getParentCategory()) + .orElse(null)) + != null); + return true; + } + + public boolean shouldShare(DataStoreEntry entry) { + if (!shouldShare(DataStorage.get() + .getStoreCategoryIfPresent(entry.getCategoryUuid()) + .orElseThrow())) { + return false; + } + + DataStoreEntry c = entry; + do { + if (!c.getProvider().isShareable(c)) { + return false; + } + } while ((c = DataStorage.get().getDisplayParent(c).orElse(null)) != null); + return true; + } protected void refreshValidities(boolean makeValid) { var changed = new AtomicBoolean(false); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/action/ShareStoreAction.java b/ext/base/src/main/java/io/xpipe/ext/base/action/ShareStoreAction.java index 13a02076d..3a8648ba1 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/action/ShareStoreAction.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/action/ShareStoreAction.java @@ -57,7 +57,7 @@ public class ShareStoreAction implements ActionProvider { @Override public boolean isApplicable(DataStoreEntryRef o) { - return o.get().getProvider().isShareable(); + return o.get().getProvider().isShareable(o.get()); } @Override diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptGroupStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptGroupStoreProvider.java index 801499265..0d9301648 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptGroupStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/ScriptGroupStoreProvider.java @@ -24,10 +24,6 @@ import java.util.List; public class ScriptGroupStoreProvider implements DataStoreProvider { - public boolean isShareable() { - return true; - } - @Override public Comp customEntryComp(StoreSection sec, boolean preferLarge) { ScriptGroupStore s = sec.getWrapper().getEntry().getStore().asNeeded(); diff --git a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java index 490ff497e..bd4af43a3 100644 --- a/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java +++ b/ext/base/src/main/java/io/xpipe/ext/base/script/SimpleScriptStoreProvider.java @@ -89,11 +89,6 @@ public class SimpleScriptStoreProvider implements DataStoreProvider { return true; } - @Override - public boolean isShareable() { - return true; - } - @Override public DataStoreEntry getDisplayParent(DataStoreEntry store) { SimpleScriptStore st = store.getStore().asNeeded();