Compare commits
53 Commits
beta
...
e3b6196349
| Author | SHA1 | Date | |
|---|---|---|---|
| e3b6196349 | |||
| baed51259e | |||
| ba77d1b787 | |||
| 85aafd8a02 | |||
| 71a2146c4b | |||
| 509ac11749 | |||
| 5ee7f02b42 | |||
| a7f1ff712a | |||
| 2385f1d088 | |||
| c247c2d998 | |||
| 35f45513aa | |||
| a7b0e68197 | |||
| f74e21e7d9 | |||
| cb26cec7bc | |||
| 8249c68266 | |||
| 338a7e4c0e | |||
| d099d878a0 | |||
| 339e413f82 | |||
| e888bbf8a8 | |||
| a5bf6639e8 | |||
| 9dd5c7e627 | |||
| 9a38c6d98f | |||
| 8f1689574c | |||
| 9c1e27d473 | |||
| bd933ca671 | |||
| 70d549f929 | |||
| c674e2c27a | |||
| a3998d6c1d | |||
| 77176a6d4f | |||
| fa25c1bef3 | |||
| 0e21554773 | |||
| 0cbd03da69 | |||
| c06b53ed6b | |||
| 2d043320e0 | |||
| 1e0c9ece0f | |||
| 65d1b64e0b | |||
| ddb58622d6 | |||
| d63b125175 | |||
| b66b653982 | |||
| ccb06960a2 | |||
| ccc9fadef9 | |||
| a3dace36de | |||
| a3d1a139e9 | |||
| 2af18cbf1d | |||
| 044202cb3a | |||
| b3ac787360 | |||
| 60a26ba81d | |||
| edc6415ad5 | |||
| e2a1fafaa9 | |||
| 51b0245cfe | |||
| 605f4b99f7 | |||
| 92b619a407 | |||
| 3a775f47e0 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -1,3 +1,10 @@
|
|||||||
|
# OS / System
|
||||||
.DS_Store
|
.DS_Store
|
||||||
._*
|
._*
|
||||||
thumbs.db
|
thumbs.db
|
||||||
|
|
||||||
|
# Build & Tooling
|
||||||
|
.artifacts/
|
||||||
|
.worktrees/
|
||||||
|
.build/
|
||||||
|
|
||||||
|
|||||||
18
.idea/.gitignore
generated
vendored
Normal file
18
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# User-specific and local IDE state files
|
||||||
|
/workspace.xml
|
||||||
|
/shelf/
|
||||||
|
/caches/
|
||||||
|
/deviceManager.xml
|
||||||
|
/deploymentTargetSelector.xml
|
||||||
|
/appInsightsSettings.xml
|
||||||
|
/planningMode.xml
|
||||||
|
/studiobot.xml
|
||||||
|
/markdown.xml
|
||||||
|
/assetWizardSettings.xml
|
||||||
|
/usage.statistics.xml
|
||||||
|
/tasks.xml
|
||||||
|
|
||||||
|
# IntelliJ module files generated by Gradle
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
/modules.xml
|
||||||
1
.idea/.name
generated
Normal file
1
.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
|||||||
|
MonsterCards
|
||||||
6
.idea/AndroidProjectSystem.xml
generated
Normal file
6
.idea/AndroidProjectSystem.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/compiler.xml
generated
Normal file
6
.idea/compiler.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<bytecodeTargetLevel target="21" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
18
.idea/gradle.xml
generated
Normal file
18
.idea/gradle.xml
generated
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||||
|
<component name="GradleSettings">
|
||||||
|
<option name="linkedExternalProjectsSettings">
|
||||||
|
<GradleProjectSettings>
|
||||||
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
|
<option name="externalProjectPath" value="$PROJECT_DIR$/Android" />
|
||||||
|
<option name="modules">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/Android" />
|
||||||
|
<option value="$PROJECT_DIR$/Android/app" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</GradleProjectSettings>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
60
.idea/misc.xml
generated
Normal file
60
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="NullableNotNullManager">
|
||||||
|
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
||||||
|
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||||
|
<option name="myOrdered" value="true" />
|
||||||
|
<option name="myNullables">
|
||||||
|
<value>
|
||||||
|
<list size="17">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||||
|
<item index="7" class="java.lang.String" itemvalue="org.jspecify.annotations.Nullable" />
|
||||||
|
<item index="8" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||||
|
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
||||||
|
<item index="13" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
|
||||||
|
<item index="15" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
|
<item index="16" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="myNotNulls">
|
||||||
|
<value>
|
||||||
|
<list size="16">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||||
|
<item index="1" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
||||||
|
<item index="2" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
||||||
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
|
<item index="4" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||||
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||||
|
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||||
|
<item index="7" class="java.lang.String" itemvalue="org.jspecify.annotations.NonNull" />
|
||||||
|
<item index="8" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||||
|
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||||
|
<item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||||
|
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||||
|
<item index="13" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
|
||||||
|
<item index="15" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
|
</list>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectType">
|
||||||
|
<option name="id" value="Android" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
17
.idea/runConfigurations.xml
generated
Normal file
17
.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
68
.idea/runConfigurations/app.xml
generated
Normal file
68
.idea/runConfigurations/app.xml
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="app" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false" focusToolWindowBeforeRun="true">
|
||||||
|
<module name="MonsterCards.app" />
|
||||||
|
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
|
||||||
|
<option name="DEPLOY" value="true" />
|
||||||
|
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
|
||||||
|
<option name="DEPLOY_AS_INSTANT" value="false" />
|
||||||
|
<option name="ARTIFACT_NAME" value="" />
|
||||||
|
<option name="PM_INSTALL_OPTIONS" value="" />
|
||||||
|
<option name="ALL_USERS" value="false" />
|
||||||
|
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
|
||||||
|
<option name="ALLOW_ASSUME_VERIFIED" value="false" />
|
||||||
|
<option name="CLEAR_APP_STORAGE" value="false" />
|
||||||
|
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
|
||||||
|
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
|
||||||
|
<option name="MODE" value="default_activity" />
|
||||||
|
<option name="RESTORE_ENABLED" value="false" />
|
||||||
|
<option name="RESTORE_FILE" value="" />
|
||||||
|
<option name="RESTORE_FRESH_INSTALL_ONLY" value="false" />
|
||||||
|
<option name="CLEAR_LOGCAT" value="true" />
|
||||||
|
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
|
||||||
|
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
|
||||||
|
<option name="DEBUGGER_TYPE" value="Auto" />
|
||||||
|
<Auto>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="true" />
|
||||||
|
</Auto>
|
||||||
|
<Hybrid>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Hybrid>
|
||||||
|
<Java>
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Java>
|
||||||
|
<Native>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Native>
|
||||||
|
<Profilers>
|
||||||
|
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="LeakCanary" />
|
||||||
|
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
|
||||||
|
</Profilers>
|
||||||
|
<option name="DEEP_LINK" value="" />
|
||||||
|
<option name="ACTIVITY" value="" />
|
||||||
|
<option name="ACTIVITY_CLASS" value="" />
|
||||||
|
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
|
||||||
|
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
28
Android/.gitignore
vendored
28
Android/.gitignore
vendored
@@ -1,17 +1,15 @@
|
|||||||
|
# Build outputs
|
||||||
|
build/
|
||||||
|
app/build/
|
||||||
|
.externalNativeBuild/
|
||||||
|
.cxx/
|
||||||
|
captures/
|
||||||
|
local.properties
|
||||||
*.iml
|
*.iml
|
||||||
.gradle
|
|
||||||
/local.properties
|
# Android / Gradle caches
|
||||||
/.idea/caches
|
.gradle/
|
||||||
/.idea/libraries
|
.artifacts/
|
||||||
/.idea/modules.xml
|
|
||||||
/.idea/workspace.xml
|
# System
|
||||||
/.idea/navEditor.xml
|
|
||||||
/.idea/assetWizardSettings.xml
|
|
||||||
/.idea/dictionaries
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/build
|
|
||||||
/captures
|
|
||||||
.externalNativeBuild
|
|
||||||
.cxx
|
|
||||||
/app/debug
|
|
||||||
/app/release
|
|
||||||
|
|||||||
18
Android/.idea/.gitignore
generated
vendored
Normal file
18
Android/.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# User-specific and local IDE state files
|
||||||
|
/workspace.xml
|
||||||
|
/shelf/
|
||||||
|
/caches/
|
||||||
|
/deviceManager.xml
|
||||||
|
/deploymentTargetSelector.xml
|
||||||
|
/appInsightsSettings.xml
|
||||||
|
/planningMode.xml
|
||||||
|
/studiobot.xml
|
||||||
|
/markdown.xml
|
||||||
|
/assetWizardSettings.xml
|
||||||
|
/usage.statistics.xml
|
||||||
|
/tasks.xml
|
||||||
|
|
||||||
|
# IntelliJ module files generated by Gradle
|
||||||
|
*.iml
|
||||||
|
*.iws
|
||||||
|
/modules.xml
|
||||||
6
Android/.idea/AndroidProjectSystem.xml
generated
Normal file
6
Android/.idea/AndroidProjectSystem.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AndroidProjectSystem">
|
||||||
|
<option name="providerId" value="com.android.tools.idea.GradleProjectSystem" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
23
Android/.idea/appInsightsSettings.xml
generated
Normal file
23
Android/.idea/appInsightsSettings.xml
generated
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="AppInsightsSettings">
|
||||||
|
<option name="tabSettings">
|
||||||
|
<map>
|
||||||
|
<entry key="Android vitals">
|
||||||
|
<value>
|
||||||
|
<InsightsFilterSettings>
|
||||||
|
<option name="connection">
|
||||||
|
<ConnectionSetting>
|
||||||
|
<option name="appId" value="com.planbgamestudios.downtosize" />
|
||||||
|
</ConnectionSetting>
|
||||||
|
</option>
|
||||||
|
<option name="signal" value="SIGNAL_UNSPECIFIED" />
|
||||||
|
<option name="timeIntervalDays" value="SEVEN_DAYS" />
|
||||||
|
<option name="visibilityType" value="ALL" />
|
||||||
|
</InsightsFilterSettings>
|
||||||
|
</value>
|
||||||
|
</entry>
|
||||||
|
</map>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
2
Android/.idea/compiler.xml
generated
2
Android/.idea/compiler.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="16" />
|
<bytecodeTargetLevel target="21" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
5
Android/.idea/gradle.xml
generated
5
Android/.idea/gradle.xml
generated
@@ -4,17 +4,14 @@
|
|||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="CHOOSE_PER_TEST" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
<option name="gradleJvm" value="Android Studio java home" />
|
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
<option value="$PROJECT_DIR$/app" />
|
<option value="$PROJECT_DIR$/app" />
|
||||||
</set>
|
</set>
|
||||||
</option>
|
</option>
|
||||||
<option name="resolveModulePerSourceSet" value="false" />
|
|
||||||
</GradleProjectSettings>
|
</GradleProjectSettings>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
10
Android/.idea/migrations.xml
generated
Normal file
10
Android/.idea/migrations.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectMigrations">
|
||||||
|
<option name="MigrateToGradleLocalJavaHome">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
65
Android/.idea/misc.xml
generated
65
Android/.idea/misc.xml
generated
@@ -1,50 +1,57 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="NullableNotNullManager">
|
<component name="NullableNotNullManager">
|
||||||
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
<option name="myDefaultNullable" value="androidx.annotation.Nullable" />
|
||||||
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
<option name="myDefaultNotNull" value="androidx.annotation.NonNull" />
|
||||||
|
<option name="myOrdered" value="true" />
|
||||||
<option name="myNullables">
|
<option name="myNullables">
|
||||||
<value>
|
<value>
|
||||||
<list size="14">
|
<list size="17">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
<item index="1" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
<item index="2" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.Nullable" />
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.Nullable" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
<item index="4" class="java.lang.String" itemvalue="android.annotation.Nullable" />
|
||||||
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.Nullable" />
|
||||||
<item index="6" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNullable" />
|
||||||
<item index="7" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
<item index="7" class="java.lang.String" itemvalue="org.jspecify.annotations.Nullable" />
|
||||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
<item index="8" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
|
||||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.Nullable" />
|
||||||
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableDecl" />
|
||||||
<item index="11" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
<item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NullableType" />
|
||||||
<item index="12" class="java.lang.String" itemvalue="io.reactivex.annotations.Nullable" />
|
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.Nullable" />
|
||||||
<item index="13" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.Nullable" />
|
<item index="13" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="jakarta.annotation.Nullable" />
|
||||||
|
<item index="15" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
|
||||||
|
<item index="16" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
<option name="myNotNulls">
|
<option name="myNotNulls">
|
||||||
<value>
|
<value>
|
||||||
<list size="14">
|
<list size="16">
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
<item index="0" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
||||||
<item index="1" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
<item index="1" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
||||||
<item index="2" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
<item index="2" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
||||||
<item index="3" class="java.lang.String" itemvalue="androidx.annotation.NonNull" />
|
<item index="3" class="java.lang.String" itemvalue="android.support.annotation.NonNull" />
|
||||||
<item index="4" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
<item index="4" class="java.lang.String" itemvalue="android.annotation.NonNull" />
|
||||||
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
<item index="5" class="java.lang.String" itemvalue="com.android.annotations.NonNull" />
|
||||||
<item index="6" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
<item index="6" class="java.lang.String" itemvalue="androidx.annotation.RecentlyNonNull" />
|
||||||
<item index="7" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
<item index="7" class="java.lang.String" itemvalue="org.jspecify.annotations.NonNull" />
|
||||||
<item index="8" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
<item index="8" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
|
||||||
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
<item index="9" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.qual.NonNull" />
|
||||||
<item index="10" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
<item index="10" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullDecl" />
|
||||||
<item index="11" class="java.lang.String" itemvalue="io.reactivex.annotations.NonNull" />
|
<item index="11" class="java.lang.String" itemvalue="org.checkerframework.checker.nullness.compatqual.NonNullType" />
|
||||||
<item index="12" class="java.lang.String" itemvalue="io.reactivex.rxjava3.annotations.NonNull" />
|
<item index="12" class="java.lang.String" itemvalue="org.eclipse.jdt.annotation.NonNull" />
|
||||||
<item index="13" class="java.lang.String" itemvalue="lombok.NonNull" />
|
<item index="13" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
|
||||||
|
<item index="14" class="java.lang.String" itemvalue="jakarta.annotation.Nonnull" />
|
||||||
|
<item index="15" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
|
||||||
</list>
|
</list>
|
||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
20
Android/.idea/runConfigurations.xml
generated
Normal file
20
Android/.idea/runConfigurations.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RunConfigurationProducerService">
|
||||||
|
<option name="ignoredProducers">
|
||||||
|
<set>
|
||||||
|
<option value="com.intellij.execution.junit.AbstractAllInDirectoryConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.AllInPackageConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.PatternConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.TestInClassConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.UniqueIdConfigurationProducer" />
|
||||||
|
<option value="com.intellij.execution.junit.testDiscovery.JUnitTestDiscoveryConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinJUnitRunConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.kotlin.idea.junit.KotlinPatternConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
|
||||||
|
<option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
68
Android/.idea/runConfigurations/app.xml
generated
Normal file
68
Android/.idea/runConfigurations/app.xml
generated
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="app" type="AndroidRunConfigurationType" factoryName="Android App" activateToolWindowBeforeRun="false" focusToolWindowBeforeRun="true">
|
||||||
|
<module name="MonsterCards.app" />
|
||||||
|
<option name="ANDROID_RUN_CONFIGURATION_SCHEMA_VERSION" value="1" />
|
||||||
|
<option name="DEPLOY" value="true" />
|
||||||
|
<option name="DEPLOY_APK_FROM_BUNDLE" value="false" />
|
||||||
|
<option name="DEPLOY_AS_INSTANT" value="false" />
|
||||||
|
<option name="ARTIFACT_NAME" value="" />
|
||||||
|
<option name="PM_INSTALL_OPTIONS" value="" />
|
||||||
|
<option name="ALL_USERS" value="false" />
|
||||||
|
<option name="ALWAYS_INSTALL_WITH_PM" value="false" />
|
||||||
|
<option name="ALLOW_ASSUME_VERIFIED" value="false" />
|
||||||
|
<option name="CLEAR_APP_STORAGE" value="false" />
|
||||||
|
<option name="DYNAMIC_FEATURES_DISABLED_LIST" value="" />
|
||||||
|
<option name="ACTIVITY_EXTRA_FLAGS" value="" />
|
||||||
|
<option name="MODE" value="default_activity" />
|
||||||
|
<option name="RESTORE_ENABLED" value="false" />
|
||||||
|
<option name="RESTORE_FILE" value="" />
|
||||||
|
<option name="RESTORE_FRESH_INSTALL_ONLY" value="false" />
|
||||||
|
<option name="CLEAR_LOGCAT" value="true" />
|
||||||
|
<option name="SHOW_LOGCAT_AUTOMATICALLY" value="true" />
|
||||||
|
<option name="TARGET_SELECTION_MODE" value="DEVICE_AND_SNAPSHOT_COMBO_BOX" />
|
||||||
|
<option name="DEBUGGER_TYPE" value="Auto" />
|
||||||
|
<Auto>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="true" />
|
||||||
|
</Auto>
|
||||||
|
<Hybrid>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Hybrid>
|
||||||
|
<Java>
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Java>
|
||||||
|
<Native>
|
||||||
|
<option name="USE_JAVA_AWARE_DEBUGGER" value="false" />
|
||||||
|
<option name="SHOW_STATIC_VARS" value="true" />
|
||||||
|
<option name="WORKING_DIR" value="" />
|
||||||
|
<option name="TARGET_LOGGING_CHANNELS" value="lldb process:gdb-remote packets" />
|
||||||
|
<option name="SHOW_OPTIMIZED_WARNING" value="true" />
|
||||||
|
<option name="ATTACH_ON_WAIT_FOR_DEBUGGER" value="false" />
|
||||||
|
</Native>
|
||||||
|
<Profilers>
|
||||||
|
<option name="ADVANCED_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_CPU_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="STARTUP_CPU_PROFILING_CONFIGURATION_NAME" value="LeakCanary" />
|
||||||
|
<option name="STARTUP_NATIVE_MEMORY_PROFILING_ENABLED" value="false" />
|
||||||
|
<option name="NATIVE_MEMORY_SAMPLE_RATE_BYTES" value="2048" />
|
||||||
|
</Profilers>
|
||||||
|
<option name="DEEP_LINK" value="" />
|
||||||
|
<option name="ACTIVITY" value="" />
|
||||||
|
<option name="ACTIVITY_CLASS" value="" />
|
||||||
|
<option name="SEARCH_ACTIVITY_IN_GLOBAL_SCOPE" value="false" />
|
||||||
|
<option name="SKIP_ACTIVITY_VALIDATION" value="false" />
|
||||||
|
<method v="2">
|
||||||
|
<option name="Android.Gradle.BeforeRunTask" enabled="true" />
|
||||||
|
</method>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
2
Android/.idea/vcs.xml
generated
2
Android/.idea/vcs.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
[](https://appcenter.ms)
|
|
||||||
|
|
||||||
# MonsterCards for Android
|
|
||||||
|
|
||||||
@@ -13,13 +13,14 @@ def appCenterEnvSecret = System.getenv('APPCENTER_SECRET')
|
|||||||
def appCenterSecret = appCenterLocalSecret != null ? appCenterLocalSecret : appCenterEnvSecret != null ? appCenterEnvSecret : ""
|
def appCenterSecret = appCenterLocalSecret != null ? appCenterLocalSecret : appCenterEnvSecret != null ? appCenterEnvSecret : ""
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 31
|
namespace "com.majinnaibu.monstercards"
|
||||||
buildToolsVersion '30.0.3'
|
compileSdk 37
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.majinnaibu.monstercards"
|
applicationId "com.majinnaibu.monstercards"
|
||||||
minSdkVersion 22
|
minSdkVersion 24
|
||||||
targetSdkVersion 31
|
//noinspection OldTargetApi
|
||||||
|
targetSdk 36
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
buildConfigField "String", "APPCENTER_SECRET", "\"${appCenterSecret}\""
|
buildConfigField "String", "APPCENTER_SECRET", "\"${appCenterSecret}\""
|
||||||
@@ -50,14 +51,18 @@ android {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
compileOptions {
|
compileOptions {
|
||||||
sourceCompatibility JavaVersion.VERSION_1_8
|
sourceCompatibility JavaVersion.VERSION_21
|
||||||
targetCompatibility JavaVersion.VERSION_1_8
|
targetCompatibility JavaVersion.VERSION_21
|
||||||
}
|
}
|
||||||
buildFeatures {
|
buildFeatures {
|
||||||
viewBinding true
|
viewBinding true
|
||||||
|
buildConfig true
|
||||||
}
|
}
|
||||||
lintOptions {
|
}
|
||||||
checkDependencies true
|
|
||||||
|
java {
|
||||||
|
toolchain {
|
||||||
|
languageVersion = JavaLanguageVersion.of(21)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,40 +71,35 @@ dependencies {
|
|||||||
implementation fileTree(dir: "libs", include: ["*.jar"])
|
implementation fileTree(dir: "libs", include: ["*.jar"])
|
||||||
|
|
||||||
// Google
|
// Google
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
implementation 'androidx.appcompat:appcompat:1.8.0'
|
||||||
implementation 'com.google.android.material:material:1.4.0'
|
implementation 'com.google.android.material:material:1.14.0'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
implementation 'androidx.constraintlayout:constraintlayout:2.2.2'
|
||||||
implementation "androidx.navigation:navigation-fragment:2.3.5"
|
implementation "androidx.navigation:navigation-fragment:2.10.1"
|
||||||
implementation "androidx.navigation:navigation-ui:2.3.5"
|
implementation "androidx.navigation:navigation-ui:2.10.1"
|
||||||
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||||
implementation 'androidx.recyclerview:recyclerview:1.2.1'
|
implementation 'androidx.recyclerview:recyclerview:1.4.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.11.0'
|
||||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1'
|
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.11.0'
|
||||||
|
|
||||||
// Testing
|
// Testing
|
||||||
testImplementation 'junit:junit:4.13.2'
|
testImplementation 'junit:junit:4.13.2'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
|
||||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
androidTestImplementation 'androidx.test.espresso:espresso-core:3.7.0'
|
||||||
|
|
||||||
// Room DB
|
// Room DB
|
||||||
implementation 'io.reactivex.rxjava3:rxjava:3.1.0'
|
implementation "io.reactivex.rxjava3:rxjava:3.1.12"
|
||||||
implementation "io.reactivex.rxjava3:rxandroid:3.0.0"
|
implementation "io.reactivex.rxjava3:rxandroid:3.0.2"
|
||||||
implementation "androidx.room:room-runtime:2.3.0"
|
implementation "androidx.room:room-runtime:2.8.5"
|
||||||
annotationProcessor "androidx.room:room-compiler:2.3.0"
|
annotationProcessor "androidx.room:room-compiler:2.8.5"
|
||||||
implementation "androidx.room:room-rxjava3:2.3.0"
|
implementation "androidx.room:room-rxjava3:2.8.5"
|
||||||
//testImplementation "androidx.room:room-testing:2.3.0"
|
//testImplementation "androidx.room:room-testing:2.8.5"
|
||||||
|
|
||||||
// AppCenter
|
// AppCenter
|
||||||
debugImplementation 'com.microsoft.appcenter:appcenter-analytics:4.2.0'
|
debugImplementation "com.microsoft.appcenter:appcenter-analytics:5.0.6"
|
||||||
debugImplementation 'com.microsoft.appcenter:appcenter-crashes:4.2.0'
|
debugImplementation "com.microsoft.appcenter:appcenter-crashes:5.0.6"
|
||||||
|
|
||||||
// Flipper
|
|
||||||
debugImplementation 'com.facebook.flipper:flipper:0.102.0'
|
|
||||||
debugImplementation "com.facebook.soloader:soloader:0.10.1"
|
|
||||||
releaseImplementation 'com.facebook.flipper:flipper-noop:0.102.0'
|
|
||||||
|
|
||||||
// Other 3rd Party
|
// Other 3rd Party
|
||||||
implementation 'com.atlassian.commonmark:commonmark:0.17.0'
|
implementation 'com.atlassian.commonmark:commonmark:0.17.0'
|
||||||
implementation 'com.google.code.gson:gson:2.8.7'
|
implementation "com.google.code.gson:gson:2.14.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,554 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 4,
|
||||||
|
"identityHash": "ca0ad042eed557daa5ff0ada5de6596c",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthScore",
|
||||||
|
"columnName": "strength_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowAdvantage",
|
||||||
|
"columnName": "strength_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowProficiency",
|
||||||
|
"columnName": "strength_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexterityScore",
|
||||||
|
"columnName": "dexterity_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowAdvantage",
|
||||||
|
"columnName": "dexterity_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowProficiency",
|
||||||
|
"columnName": "dexterity_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionScore",
|
||||||
|
"columnName": "constitution_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowAdvantage",
|
||||||
|
"columnName": "constitution_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowProficiency",
|
||||||
|
"columnName": "constitution_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceScore",
|
||||||
|
"columnName": "intelligence_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowAdvantage",
|
||||||
|
"columnName": "intelligence_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowProficiency",
|
||||||
|
"columnName": "intelligence_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomScore",
|
||||||
|
"columnName": "wisdom_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowAdvantage",
|
||||||
|
"columnName": "wisdom_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowProficiency",
|
||||||
|
"columnName": "wisdom_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaScore",
|
||||||
|
"columnName": "charisma_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowAdvantage",
|
||||||
|
"columnName": "charisma_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowProficiency",
|
||||||
|
"columnName": "charisma_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "armorType",
|
||||||
|
"columnName": "armor_type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "shieldBonus",
|
||||||
|
"columnName": "shield_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "naturalArmorBonus",
|
||||||
|
"columnName": "natural_armor_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "otherArmorDescription",
|
||||||
|
"columnName": "other_armor_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hitDice",
|
||||||
|
"columnName": "hit_dice",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomHP",
|
||||||
|
"columnName": "has_custom_hit_points",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customHPDescription",
|
||||||
|
"columnName": "custom_hit_points_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "walkSpeed",
|
||||||
|
"columnName": "walk_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "burrowSpeed",
|
||||||
|
"columnName": "burrow_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "climbSpeed",
|
||||||
|
"columnName": "climb_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flySpeed",
|
||||||
|
"columnName": "fly_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "canHover",
|
||||||
|
"columnName": "can_hover",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "swimSpeed",
|
||||||
|
"columnName": "swim_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomSpeed",
|
||||||
|
"columnName": "has_custom_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customSpeedDescription",
|
||||||
|
"columnName": "custom_speed_description",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "challengeRating",
|
||||||
|
"columnName": "challenge_rating",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'1'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customChallengeRatingDescription",
|
||||||
|
"columnName": "custom_challenge_rating_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customProficiencyBonus",
|
||||||
|
"columnName": "custom_proficiency_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "telepathyRange",
|
||||||
|
"columnName": "telepathy_range",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "understandsButDescription",
|
||||||
|
"columnName": "understands_but_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "senses",
|
||||||
|
"columnName": "senses",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skills",
|
||||||
|
"columnName": "skills",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageImmunities",
|
||||||
|
"columnName": "damage_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageResistances",
|
||||||
|
"columnName": "damage_resistances",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageVulnerabilities",
|
||||||
|
"columnName": "damage_vulnerabilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "conditionImmunities",
|
||||||
|
"columnName": "condition_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "languages",
|
||||||
|
"columnName": "languages",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "abilities",
|
||||||
|
"columnName": "abilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "actions",
|
||||||
|
"columnName": "actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "reactions",
|
||||||
|
"columnName": "reactions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActions",
|
||||||
|
"columnName": "lair_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActions",
|
||||||
|
"columnName": "legendary_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActions",
|
||||||
|
"columnName": "regional_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "monsters_fts",
|
||||||
|
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT, `size` TEXT, `type` TEXT, `subtype` TEXT, `alignment` TEXT, content=`monsters`)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": []
|
||||||
|
},
|
||||||
|
"ftsVersion": "FTS4",
|
||||||
|
"ftsOptions": {
|
||||||
|
"tokenizer": "simple",
|
||||||
|
"tokenizerArgs": [],
|
||||||
|
"contentTable": "monsters",
|
||||||
|
"languageIdColumnName": "",
|
||||||
|
"matchInfo": "FTS4",
|
||||||
|
"notIndexedColumns": [],
|
||||||
|
"prefixSizes": [],
|
||||||
|
"preferredOrder": "ASC"
|
||||||
|
},
|
||||||
|
"contentSyncTriggers": [
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_UPDATE BEFORE UPDATE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_DELETE BEFORE DELETE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_UPDATE AFTER UPDATE ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_INSERT AFTER INSERT ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collections",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collection_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "collectionId",
|
||||||
|
"columnName": "collection_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_collection_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `${TABLE_NAME}` (`collection_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "collections",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, 'ca0ad042eed557daa5ff0ada5de6596c')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,609 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 5,
|
||||||
|
"identityHash": "6d497d0f0530c0f46bed1d57492e940e",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthScore",
|
||||||
|
"columnName": "strength_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowAdvantage",
|
||||||
|
"columnName": "strength_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowProficiency",
|
||||||
|
"columnName": "strength_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexterityScore",
|
||||||
|
"columnName": "dexterity_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowAdvantage",
|
||||||
|
"columnName": "dexterity_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowProficiency",
|
||||||
|
"columnName": "dexterity_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionScore",
|
||||||
|
"columnName": "constitution_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowAdvantage",
|
||||||
|
"columnName": "constitution_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowProficiency",
|
||||||
|
"columnName": "constitution_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceScore",
|
||||||
|
"columnName": "intelligence_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowAdvantage",
|
||||||
|
"columnName": "intelligence_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowProficiency",
|
||||||
|
"columnName": "intelligence_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomScore",
|
||||||
|
"columnName": "wisdom_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowAdvantage",
|
||||||
|
"columnName": "wisdom_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowProficiency",
|
||||||
|
"columnName": "wisdom_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaScore",
|
||||||
|
"columnName": "charisma_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowAdvantage",
|
||||||
|
"columnName": "charisma_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowProficiency",
|
||||||
|
"columnName": "charisma_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "armorType",
|
||||||
|
"columnName": "armor_type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "shieldBonus",
|
||||||
|
"columnName": "shield_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "naturalArmorBonus",
|
||||||
|
"columnName": "natural_armor_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "otherArmorDescription",
|
||||||
|
"columnName": "other_armor_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hitDice",
|
||||||
|
"columnName": "hit_dice",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomHP",
|
||||||
|
"columnName": "has_custom_hit_points",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customHPDescription",
|
||||||
|
"columnName": "custom_hit_points_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "walkSpeed",
|
||||||
|
"columnName": "walk_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "burrowSpeed",
|
||||||
|
"columnName": "burrow_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "climbSpeed",
|
||||||
|
"columnName": "climb_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flySpeed",
|
||||||
|
"columnName": "fly_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "canHover",
|
||||||
|
"columnName": "can_hover",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "swimSpeed",
|
||||||
|
"columnName": "swim_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomSpeed",
|
||||||
|
"columnName": "has_custom_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customSpeedDescription",
|
||||||
|
"columnName": "custom_speed_description",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "challengeRating",
|
||||||
|
"columnName": "challenge_rating",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'1'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customChallengeRatingDescription",
|
||||||
|
"columnName": "custom_challenge_rating_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customProficiencyBonus",
|
||||||
|
"columnName": "custom_proficiency_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "telepathyRange",
|
||||||
|
"columnName": "telepathy_range",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "understandsButDescription",
|
||||||
|
"columnName": "understands_but_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "senses",
|
||||||
|
"columnName": "senses",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skills",
|
||||||
|
"columnName": "skills",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageImmunities",
|
||||||
|
"columnName": "damage_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageResistances",
|
||||||
|
"columnName": "damage_resistances",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageVulnerabilities",
|
||||||
|
"columnName": "damage_vulnerabilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "conditionImmunities",
|
||||||
|
"columnName": "condition_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "languages",
|
||||||
|
"columnName": "languages",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "abilities",
|
||||||
|
"columnName": "abilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "actions",
|
||||||
|
"columnName": "actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "reactions",
|
||||||
|
"columnName": "reactions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActions",
|
||||||
|
"columnName": "lair_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActions",
|
||||||
|
"columnName": "legendary_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActions",
|
||||||
|
"columnName": "regional_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "monsters_fts",
|
||||||
|
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT, `size` TEXT, `type` TEXT, `subtype` TEXT, `alignment` TEXT, content=`monsters`)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": []
|
||||||
|
},
|
||||||
|
"ftsVersion": "FTS4",
|
||||||
|
"ftsOptions": {
|
||||||
|
"tokenizer": "simple",
|
||||||
|
"tokenizerArgs": [],
|
||||||
|
"contentTable": "monsters",
|
||||||
|
"languageIdColumnName": "",
|
||||||
|
"matchInfo": "FTS4",
|
||||||
|
"notIndexedColumns": [],
|
||||||
|
"prefixSizes": [],
|
||||||
|
"preferredOrder": "ASC"
|
||||||
|
},
|
||||||
|
"contentSyncTriggers": [
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_UPDATE BEFORE UPDATE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_DELETE BEFORE DELETE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_UPDATE AFTER UPDATE ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_INSERT AFTER INSERT ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collections",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collection_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "collectionId",
|
||||||
|
"columnName": "collection_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_collection_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `${TABLE_NAME}` (`collection_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "collections",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "dashboard_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_dashboard_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_dashboard_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '6d497d0f0530c0f46bed1d57492e940e')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,663 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 6,
|
||||||
|
"identityHash": "0ab331e246de46304f847d7ed2d10124",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', `source_url` TEXT DEFAULT '', `bonus_actions` TEXT DEFAULT '[]', `mythic_actions` TEXT DEFAULT '[]', `legendary_actions_description` TEXT DEFAULT '', `lair_actions_description` TEXT DEFAULT '', `lair_actions_end_note` TEXT DEFAULT '', `regional_actions_description` TEXT DEFAULT '', `regional_actions_end_note` TEXT DEFAULT '', `mythic_actions_description` TEXT DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthScore",
|
||||||
|
"columnName": "strength_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowAdvantage",
|
||||||
|
"columnName": "strength_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowProficiency",
|
||||||
|
"columnName": "strength_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexterityScore",
|
||||||
|
"columnName": "dexterity_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowAdvantage",
|
||||||
|
"columnName": "dexterity_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowProficiency",
|
||||||
|
"columnName": "dexterity_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionScore",
|
||||||
|
"columnName": "constitution_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowAdvantage",
|
||||||
|
"columnName": "constitution_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowProficiency",
|
||||||
|
"columnName": "constitution_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceScore",
|
||||||
|
"columnName": "intelligence_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowAdvantage",
|
||||||
|
"columnName": "intelligence_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowProficiency",
|
||||||
|
"columnName": "intelligence_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomScore",
|
||||||
|
"columnName": "wisdom_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowAdvantage",
|
||||||
|
"columnName": "wisdom_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowProficiency",
|
||||||
|
"columnName": "wisdom_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaScore",
|
||||||
|
"columnName": "charisma_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowAdvantage",
|
||||||
|
"columnName": "charisma_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowProficiency",
|
||||||
|
"columnName": "charisma_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "armorType",
|
||||||
|
"columnName": "armor_type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "shieldBonus",
|
||||||
|
"columnName": "shield_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "naturalArmorBonus",
|
||||||
|
"columnName": "natural_armor_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "otherArmorDescription",
|
||||||
|
"columnName": "other_armor_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hitDice",
|
||||||
|
"columnName": "hit_dice",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomHP",
|
||||||
|
"columnName": "has_custom_hit_points",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customHPDescription",
|
||||||
|
"columnName": "custom_hit_points_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "walkSpeed",
|
||||||
|
"columnName": "walk_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "burrowSpeed",
|
||||||
|
"columnName": "burrow_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "climbSpeed",
|
||||||
|
"columnName": "climb_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flySpeed",
|
||||||
|
"columnName": "fly_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "canHover",
|
||||||
|
"columnName": "can_hover",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "swimSpeed",
|
||||||
|
"columnName": "swim_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomSpeed",
|
||||||
|
"columnName": "has_custom_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customSpeedDescription",
|
||||||
|
"columnName": "custom_speed_description",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "challengeRating",
|
||||||
|
"columnName": "challenge_rating",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'1'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customChallengeRatingDescription",
|
||||||
|
"columnName": "custom_challenge_rating_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customProficiencyBonus",
|
||||||
|
"columnName": "custom_proficiency_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "telepathyRange",
|
||||||
|
"columnName": "telepathy_range",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "understandsButDescription",
|
||||||
|
"columnName": "understands_but_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "senses",
|
||||||
|
"columnName": "senses",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skills",
|
||||||
|
"columnName": "skills",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageImmunities",
|
||||||
|
"columnName": "damage_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageResistances",
|
||||||
|
"columnName": "damage_resistances",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageVulnerabilities",
|
||||||
|
"columnName": "damage_vulnerabilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "conditionImmunities",
|
||||||
|
"columnName": "condition_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "languages",
|
||||||
|
"columnName": "languages",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "abilities",
|
||||||
|
"columnName": "abilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "actions",
|
||||||
|
"columnName": "actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "reactions",
|
||||||
|
"columnName": "reactions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActions",
|
||||||
|
"columnName": "lair_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActions",
|
||||||
|
"columnName": "legendary_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActions",
|
||||||
|
"columnName": "regional_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "sourceUrl",
|
||||||
|
"columnName": "source_url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "bonusActions",
|
||||||
|
"columnName": "bonus_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActions",
|
||||||
|
"columnName": "mythic_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActionsDescription",
|
||||||
|
"columnName": "legendary_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsDescription",
|
||||||
|
"columnName": "lair_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsEndNote",
|
||||||
|
"columnName": "lair_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsDescription",
|
||||||
|
"columnName": "regional_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsEndNote",
|
||||||
|
"columnName": "regional_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActionsDescription",
|
||||||
|
"columnName": "mythic_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "monsters_fts",
|
||||||
|
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT, `size` TEXT, `type` TEXT, `subtype` TEXT, `alignment` TEXT, content=`monsters`)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": []
|
||||||
|
},
|
||||||
|
"ftsVersion": "FTS4",
|
||||||
|
"ftsOptions": {
|
||||||
|
"tokenizer": "simple",
|
||||||
|
"tokenizerArgs": [],
|
||||||
|
"contentTable": "monsters",
|
||||||
|
"languageIdColumnName": "",
|
||||||
|
"matchInfo": "FTS4",
|
||||||
|
"notIndexedColumns": [],
|
||||||
|
"prefixSizes": [],
|
||||||
|
"preferredOrder": "ASC"
|
||||||
|
},
|
||||||
|
"contentSyncTriggers": [
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_UPDATE BEFORE UPDATE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_DELETE BEFORE DELETE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_UPDATE AFTER UPDATE ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_INSERT AFTER INSERT ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collections",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collection_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "collectionId",
|
||||||
|
"columnName": "collection_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_collection_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `${TABLE_NAME}` (`collection_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "collections",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "dashboard_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_dashboard_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_dashboard_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '0ab331e246de46304f847d7ed2d10124')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,768 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 7,
|
||||||
|
"identityHash": "38f6bbd6f1e298b20e17b3a08fbc7f70",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', `source_url` TEXT DEFAULT '', `bonus_actions` TEXT DEFAULT '[]', `mythic_actions` TEXT DEFAULT '[]', `legendary_actions_description` TEXT DEFAULT '', `lair_actions_description` TEXT DEFAULT '', `lair_actions_end_note` TEXT DEFAULT '', `regional_actions_description` TEXT DEFAULT '', `regional_actions_end_note` TEXT DEFAULT '', `mythic_actions_description` TEXT DEFAULT '', `player_name` TEXT NOT NULL DEFAULT '', `background` TEXT NOT NULL DEFAULT '', `personality_traits` TEXT NOT NULL DEFAULT '', `ideals` TEXT NOT NULL DEFAULT '', `bonds` TEXT NOT NULL DEFAULT '', `flaws` TEXT NOT NULL DEFAULT '', `age` TEXT NOT NULL DEFAULT '', `height` TEXT NOT NULL DEFAULT '', `weight` TEXT NOT NULL DEFAULT '', `eyes` TEXT NOT NULL DEFAULT '', `skin` TEXT NOT NULL DEFAULT '', `hair` TEXT NOT NULL DEFAULT '', `appearance` TEXT NOT NULL DEFAULT '', `backstory` TEXT NOT NULL DEFAULT '', `allies_and_organizations` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthScore",
|
||||||
|
"columnName": "strength_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowAdvantage",
|
||||||
|
"columnName": "strength_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowProficiency",
|
||||||
|
"columnName": "strength_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexterityScore",
|
||||||
|
"columnName": "dexterity_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowAdvantage",
|
||||||
|
"columnName": "dexterity_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowProficiency",
|
||||||
|
"columnName": "dexterity_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionScore",
|
||||||
|
"columnName": "constitution_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowAdvantage",
|
||||||
|
"columnName": "constitution_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowProficiency",
|
||||||
|
"columnName": "constitution_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceScore",
|
||||||
|
"columnName": "intelligence_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowAdvantage",
|
||||||
|
"columnName": "intelligence_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowProficiency",
|
||||||
|
"columnName": "intelligence_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomScore",
|
||||||
|
"columnName": "wisdom_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowAdvantage",
|
||||||
|
"columnName": "wisdom_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowProficiency",
|
||||||
|
"columnName": "wisdom_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaScore",
|
||||||
|
"columnName": "charisma_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowAdvantage",
|
||||||
|
"columnName": "charisma_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowProficiency",
|
||||||
|
"columnName": "charisma_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "armorType",
|
||||||
|
"columnName": "armor_type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "shieldBonus",
|
||||||
|
"columnName": "shield_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "naturalArmorBonus",
|
||||||
|
"columnName": "natural_armor_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "otherArmorDescription",
|
||||||
|
"columnName": "other_armor_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hitDice",
|
||||||
|
"columnName": "hit_dice",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomHP",
|
||||||
|
"columnName": "has_custom_hit_points",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customHPDescription",
|
||||||
|
"columnName": "custom_hit_points_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "walkSpeed",
|
||||||
|
"columnName": "walk_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "burrowSpeed",
|
||||||
|
"columnName": "burrow_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "climbSpeed",
|
||||||
|
"columnName": "climb_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flySpeed",
|
||||||
|
"columnName": "fly_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "canHover",
|
||||||
|
"columnName": "can_hover",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "swimSpeed",
|
||||||
|
"columnName": "swim_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomSpeed",
|
||||||
|
"columnName": "has_custom_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customSpeedDescription",
|
||||||
|
"columnName": "custom_speed_description",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "challengeRating",
|
||||||
|
"columnName": "challenge_rating",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'1'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customChallengeRatingDescription",
|
||||||
|
"columnName": "custom_challenge_rating_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customProficiencyBonus",
|
||||||
|
"columnName": "custom_proficiency_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "telepathyRange",
|
||||||
|
"columnName": "telepathy_range",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "understandsButDescription",
|
||||||
|
"columnName": "understands_but_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "senses",
|
||||||
|
"columnName": "senses",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skills",
|
||||||
|
"columnName": "skills",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageImmunities",
|
||||||
|
"columnName": "damage_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageResistances",
|
||||||
|
"columnName": "damage_resistances",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageVulnerabilities",
|
||||||
|
"columnName": "damage_vulnerabilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "conditionImmunities",
|
||||||
|
"columnName": "condition_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "languages",
|
||||||
|
"columnName": "languages",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "abilities",
|
||||||
|
"columnName": "abilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "actions",
|
||||||
|
"columnName": "actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "reactions",
|
||||||
|
"columnName": "reactions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActions",
|
||||||
|
"columnName": "lair_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActions",
|
||||||
|
"columnName": "legendary_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActions",
|
||||||
|
"columnName": "regional_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "sourceUrl",
|
||||||
|
"columnName": "source_url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "bonusActions",
|
||||||
|
"columnName": "bonus_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActions",
|
||||||
|
"columnName": "mythic_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActionsDescription",
|
||||||
|
"columnName": "legendary_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsDescription",
|
||||||
|
"columnName": "lair_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsEndNote",
|
||||||
|
"columnName": "lair_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsDescription",
|
||||||
|
"columnName": "regional_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsEndNote",
|
||||||
|
"columnName": "regional_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActionsDescription",
|
||||||
|
"columnName": "mythic_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "playerName",
|
||||||
|
"columnName": "player_name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "background",
|
||||||
|
"columnName": "background",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "personalityTraits",
|
||||||
|
"columnName": "personality_traits",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ideals",
|
||||||
|
"columnName": "ideals",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "bonds",
|
||||||
|
"columnName": "bonds",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flaws",
|
||||||
|
"columnName": "flaws",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "age",
|
||||||
|
"columnName": "age",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "height",
|
||||||
|
"columnName": "height",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "weight",
|
||||||
|
"columnName": "weight",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "eyes",
|
||||||
|
"columnName": "eyes",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skin",
|
||||||
|
"columnName": "skin",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hair",
|
||||||
|
"columnName": "hair",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "appearance",
|
||||||
|
"columnName": "appearance",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "backstory",
|
||||||
|
"columnName": "backstory",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alliesAndOrganizations",
|
||||||
|
"columnName": "allies_and_organizations",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "monsters_fts",
|
||||||
|
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT, `size` TEXT, `type` TEXT, `subtype` TEXT, `alignment` TEXT, content=`monsters`)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": []
|
||||||
|
},
|
||||||
|
"ftsVersion": "FTS4",
|
||||||
|
"ftsOptions": {
|
||||||
|
"tokenizer": "simple",
|
||||||
|
"tokenizerArgs": [],
|
||||||
|
"contentTable": "monsters",
|
||||||
|
"languageIdColumnName": "",
|
||||||
|
"matchInfo": "FTS4",
|
||||||
|
"notIndexedColumns": [],
|
||||||
|
"prefixSizes": [],
|
||||||
|
"preferredOrder": "ASC"
|
||||||
|
},
|
||||||
|
"contentSyncTriggers": [
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_UPDATE BEFORE UPDATE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_DELETE BEFORE DELETE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_UPDATE AFTER UPDATE ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_INSERT AFTER INSERT ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collections",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collection_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "collectionId",
|
||||||
|
"columnName": "collection_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_collection_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `${TABLE_NAME}` (`collection_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "collections",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "dashboard_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_dashboard_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_dashboard_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '38f6bbd6f1e298b20e17b3a08fbc7f70')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,768 @@
|
|||||||
|
{
|
||||||
|
"formatVersion": 1,
|
||||||
|
"database": {
|
||||||
|
"version": 8,
|
||||||
|
"identityHash": "38f6bbd6f1e298b20e17b3a08fbc7f70",
|
||||||
|
"entities": [
|
||||||
|
{
|
||||||
|
"tableName": "monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', `source_url` TEXT DEFAULT '', `bonus_actions` TEXT DEFAULT '[]', `mythic_actions` TEXT DEFAULT '[]', `legendary_actions_description` TEXT DEFAULT '', `lair_actions_description` TEXT DEFAULT '', `lair_actions_end_note` TEXT DEFAULT '', `regional_actions_description` TEXT DEFAULT '', `regional_actions_end_note` TEXT DEFAULT '', `mythic_actions_description` TEXT DEFAULT '', `player_name` TEXT NOT NULL DEFAULT '', `background` TEXT NOT NULL DEFAULT '', `personality_traits` TEXT NOT NULL DEFAULT '', `ideals` TEXT NOT NULL DEFAULT '', `bonds` TEXT NOT NULL DEFAULT '', `flaws` TEXT NOT NULL DEFAULT '', `age` TEXT NOT NULL DEFAULT '', `height` TEXT NOT NULL DEFAULT '', `weight` TEXT NOT NULL DEFAULT '', `eyes` TEXT NOT NULL DEFAULT '', `skin` TEXT NOT NULL DEFAULT '', `hair` TEXT NOT NULL DEFAULT '', `appearance` TEXT NOT NULL DEFAULT '', `backstory` TEXT NOT NULL DEFAULT '', `allies_and_organizations` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthScore",
|
||||||
|
"columnName": "strength_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowAdvantage",
|
||||||
|
"columnName": "strength_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "strengthSavingThrowProficiency",
|
||||||
|
"columnName": "strength_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexterityScore",
|
||||||
|
"columnName": "dexterity_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowAdvantage",
|
||||||
|
"columnName": "dexterity_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "dexteritySavingThrowProficiency",
|
||||||
|
"columnName": "dexterity_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionScore",
|
||||||
|
"columnName": "constitution_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowAdvantage",
|
||||||
|
"columnName": "constitution_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "constitutionSavingThrowProficiency",
|
||||||
|
"columnName": "constitution_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceScore",
|
||||||
|
"columnName": "intelligence_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowAdvantage",
|
||||||
|
"columnName": "intelligence_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "intelligenceSavingThrowProficiency",
|
||||||
|
"columnName": "intelligence_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomScore",
|
||||||
|
"columnName": "wisdom_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowAdvantage",
|
||||||
|
"columnName": "wisdom_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "wisdomSavingThrowProficiency",
|
||||||
|
"columnName": "wisdom_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaScore",
|
||||||
|
"columnName": "charisma_score",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowAdvantage",
|
||||||
|
"columnName": "charisma_saving_throw_advantage",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "charismaSavingThrowProficiency",
|
||||||
|
"columnName": "charisma_saving_throw_proficiency",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "armorType",
|
||||||
|
"columnName": "armor_type",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'none'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "shieldBonus",
|
||||||
|
"columnName": "shield_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "naturalArmorBonus",
|
||||||
|
"columnName": "natural_armor_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "otherArmorDescription",
|
||||||
|
"columnName": "other_armor_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hitDice",
|
||||||
|
"columnName": "hit_dice",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "1"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomHP",
|
||||||
|
"columnName": "has_custom_hit_points",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customHPDescription",
|
||||||
|
"columnName": "custom_hit_points_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "walkSpeed",
|
||||||
|
"columnName": "walk_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "burrowSpeed",
|
||||||
|
"columnName": "burrow_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "climbSpeed",
|
||||||
|
"columnName": "climb_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flySpeed",
|
||||||
|
"columnName": "fly_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "canHover",
|
||||||
|
"columnName": "can_hover",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "swimSpeed",
|
||||||
|
"columnName": "swim_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hasCustomSpeed",
|
||||||
|
"columnName": "has_custom_speed",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "false"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customSpeedDescription",
|
||||||
|
"columnName": "custom_speed_description",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "challengeRating",
|
||||||
|
"columnName": "challenge_rating",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'1'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customChallengeRatingDescription",
|
||||||
|
"columnName": "custom_challenge_rating_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "customProficiencyBonus",
|
||||||
|
"columnName": "custom_proficiency_bonus",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "telepathyRange",
|
||||||
|
"columnName": "telepathy_range",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "understandsButDescription",
|
||||||
|
"columnName": "understands_but_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "senses",
|
||||||
|
"columnName": "senses",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skills",
|
||||||
|
"columnName": "skills",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageImmunities",
|
||||||
|
"columnName": "damage_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageResistances",
|
||||||
|
"columnName": "damage_resistances",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "damageVulnerabilities",
|
||||||
|
"columnName": "damage_vulnerabilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "conditionImmunities",
|
||||||
|
"columnName": "condition_immunities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "languages",
|
||||||
|
"columnName": "languages",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "abilities",
|
||||||
|
"columnName": "abilities",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "actions",
|
||||||
|
"columnName": "actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "reactions",
|
||||||
|
"columnName": "reactions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActions",
|
||||||
|
"columnName": "lair_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActions",
|
||||||
|
"columnName": "legendary_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActions",
|
||||||
|
"columnName": "regional_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "sourceUrl",
|
||||||
|
"columnName": "source_url",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "bonusActions",
|
||||||
|
"columnName": "bonus_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActions",
|
||||||
|
"columnName": "mythic_actions",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "'[]'"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "legendaryActionsDescription",
|
||||||
|
"columnName": "legendary_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsDescription",
|
||||||
|
"columnName": "lair_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "lairActionsEndNote",
|
||||||
|
"columnName": "lair_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsDescription",
|
||||||
|
"columnName": "regional_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "regionalActionsEndNote",
|
||||||
|
"columnName": "regional_actions_end_note",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "mythicActionsDescription",
|
||||||
|
"columnName": "mythic_actions_description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "playerName",
|
||||||
|
"columnName": "player_name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "background",
|
||||||
|
"columnName": "background",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "personalityTraits",
|
||||||
|
"columnName": "personality_traits",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ideals",
|
||||||
|
"columnName": "ideals",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "bonds",
|
||||||
|
"columnName": "bonds",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "flaws",
|
||||||
|
"columnName": "flaws",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "age",
|
||||||
|
"columnName": "age",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "height",
|
||||||
|
"columnName": "height",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "weight",
|
||||||
|
"columnName": "weight",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "eyes",
|
||||||
|
"columnName": "eyes",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "skin",
|
||||||
|
"columnName": "skin",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "hair",
|
||||||
|
"columnName": "hair",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "appearance",
|
||||||
|
"columnName": "appearance",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "backstory",
|
||||||
|
"columnName": "backstory",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alliesAndOrganizations",
|
||||||
|
"columnName": "allies_and_organizations",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "monsters_fts",
|
||||||
|
"createSql": "CREATE VIRTUAL TABLE IF NOT EXISTS `${TABLE_NAME}` USING FTS4(`name` TEXT, `size` TEXT, `type` TEXT, `subtype` TEXT, `alignment` TEXT, content=`monsters`)",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "size",
|
||||||
|
"columnName": "size",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "type",
|
||||||
|
"columnName": "type",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "subtype",
|
||||||
|
"columnName": "subtype",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "alignment",
|
||||||
|
"columnName": "alignment",
|
||||||
|
"affinity": "TEXT"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": []
|
||||||
|
},
|
||||||
|
"ftsVersion": "FTS4",
|
||||||
|
"ftsOptions": {
|
||||||
|
"tokenizer": "simple",
|
||||||
|
"tokenizerArgs": [],
|
||||||
|
"contentTable": "monsters",
|
||||||
|
"languageIdColumnName": "",
|
||||||
|
"matchInfo": "FTS4",
|
||||||
|
"notIndexedColumns": [],
|
||||||
|
"prefixSizes": [],
|
||||||
|
"preferredOrder": "ASC"
|
||||||
|
},
|
||||||
|
"contentSyncTriggers": [
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_UPDATE BEFORE UPDATE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_BEFORE_DELETE BEFORE DELETE ON `monsters` BEGIN DELETE FROM `monsters_fts` WHERE `docid`=OLD.`rowid`; END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_UPDATE AFTER UPDATE ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END",
|
||||||
|
"CREATE TRIGGER IF NOT EXISTS room_fts_content_sync_monsters_fts_AFTER_INSERT AFTER INSERT ON `monsters` BEGIN INSERT INTO `monsters_fts`(`docid`, `name`, `size`, `type`, `subtype`, `alignment`) VALUES (NEW.`rowid`, NEW.`name`, NEW.`size`, NEW.`type`, NEW.`subtype`, NEW.`alignment`); END"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collections",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "name",
|
||||||
|
"columnName": "name",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "description",
|
||||||
|
"columnName": "description",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "''"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": false,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "collection_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE , FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "collectionId",
|
||||||
|
"columnName": "collection_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_collection_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `${TABLE_NAME}` (`collection_id`)"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "index_collection_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "collections",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"collection_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tableName": "dashboard_monsters",
|
||||||
|
"createSql": "CREATE TABLE IF NOT EXISTS `${TABLE_NAME}` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE )",
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldPath": "id",
|
||||||
|
"columnName": "id",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "monsterId",
|
||||||
|
"columnName": "monster_id",
|
||||||
|
"affinity": "TEXT",
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldPath": "ordinal",
|
||||||
|
"columnName": "ordinal",
|
||||||
|
"affinity": "INTEGER",
|
||||||
|
"notNull": true,
|
||||||
|
"defaultValue": "0"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"primaryKey": {
|
||||||
|
"autoGenerate": true,
|
||||||
|
"columnNames": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"indices": [
|
||||||
|
{
|
||||||
|
"name": "index_dashboard_monsters_monster_id",
|
||||||
|
"unique": false,
|
||||||
|
"columnNames": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"orders": [],
|
||||||
|
"createSql": "CREATE INDEX IF NOT EXISTS `index_dashboard_monsters_monster_id` ON `${TABLE_NAME}` (`monster_id`)"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"foreignKeys": [
|
||||||
|
{
|
||||||
|
"table": "monsters",
|
||||||
|
"onDelete": "CASCADE",
|
||||||
|
"onUpdate": "NO ACTION",
|
||||||
|
"columns": [
|
||||||
|
"monster_id"
|
||||||
|
],
|
||||||
|
"referencedColumns": [
|
||||||
|
"id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"setupQueries": [
|
||||||
|
"CREATE TABLE IF NOT EXISTS room_master_table (id INTEGER PRIMARY KEY,identity_hash TEXT)",
|
||||||
|
"INSERT OR REPLACE INTO room_master_table (id,identity_hash) VALUES(42, '38f6bbd6f1e298b20e17b3a08fbc7f70')"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
package com.majinnaibu.monstercards.init;
|
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
import androidx.navigation.NavController;
|
|
||||||
import androidx.navigation.NavDestination;
|
|
||||||
|
|
||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
|
||||||
import com.facebook.flipper.android.utils.FlipperUtils;
|
|
||||||
import com.facebook.flipper.core.FlipperClient;
|
|
||||||
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
|
|
||||||
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.navigation.NavigationFlipperPlugin;
|
|
||||||
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
|
|
||||||
import com.facebook.soloader.SoLoader;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.majinnaibu.monstercards.BuildConfig;
|
|
||||||
|
|
||||||
public class FlipperInitializer {
|
|
||||||
|
|
||||||
public static void init(Context ctx) {
|
|
||||||
SoLoader.init(ctx, false);
|
|
||||||
|
|
||||||
if (BuildConfig.DEBUG && FlipperUtils.shouldEnableFlipper(ctx)) {
|
|
||||||
final FlipperClient client = AndroidFlipperClient.getInstance(ctx);
|
|
||||||
client.addPlugin(new InspectorFlipperPlugin(ctx, DescriptorMapping.withDefaults()));
|
|
||||||
client.addPlugin(new DatabasesFlipperPlugin(ctx));
|
|
||||||
client.addPlugin(new SharedPreferencesFlipperPlugin(ctx));
|
|
||||||
client.addPlugin(NavigationFlipperPlugin.getInstance());
|
|
||||||
client.start();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendNavigationEvent(NavController controller, NavDestination destination, Bundle arguments) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String json = gson.toJson(arguments != null ? arguments : new Bundle());
|
|
||||||
NavigationFlipperPlugin.getInstance().sendNavigationEvent(String.format("%s:%s", destination.getLabel(), json), null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +1,99 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
package="com.majinnaibu.monstercards">
|
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".MonsterCardsApplication"
|
android:name=".MonsterCardsApplication"
|
||||||
android:allowBackup="true"
|
android:allowBackup="true"
|
||||||
android:fullBackupOnly="true"
|
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
android:label="@string/app_name"
|
android:label="@string/app_name"
|
||||||
android:roundIcon="@mipmap/ic_launcher_round"
|
android:roundIcon="@mipmap/ic_launcher_round"
|
||||||
android:supportsRtl="true"
|
android:supportsRtl="true"
|
||||||
|
android:intentMatchingFlags="enforceIntentFilter"
|
||||||
android:theme="@style/AppTheme">
|
android:theme="@style/AppTheme">
|
||||||
<activity
|
<activity
|
||||||
android:name=".MainActivity"
|
android:name=".SplashActivity"
|
||||||
android:exported="true"
|
android:theme="@style/Theme.App.Starting"
|
||||||
android:label="@string/app_name"
|
android:exported="true">
|
||||||
android:launchMode="singleTask">
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:label="@string/app_name"
|
||||||
|
android:launchMode="singleTask"
|
||||||
|
android:windowSoftInputMode="adjustResize"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
|
<!-- Intent filter for viewing/opening content:// URIs with binary/octet-stream MIME type (.monster) -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<action android:name="android.intent.action.EDIT" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:scheme="content" />
|
||||||
|
<data android:mimeType="application/octet-stream" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Intent filter for file:// URIs ending in .monster, .monster.txt, .card, or .card.txt -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<action android:name="android.intent.action.EDIT" />
|
||||||
|
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
|
<data android:scheme="file" android:host="*" />
|
||||||
|
<data android:pathPattern=".*\\.monster" />
|
||||||
|
<data android:pathPattern=".*\\.monster\\.txt" />
|
||||||
|
<data android:pathPattern=".*\\.card" />
|
||||||
|
<data android:pathPattern=".*\\.card\\.txt" />
|
||||||
|
<data android:pathPattern=".*\\.binder" />
|
||||||
|
<data android:pathPattern=".*\\.binder\\.txt" />
|
||||||
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Intent filter for explicitly sharing files/text to Monster Cards -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.SEND" />
|
<action android:name="android.intent.action.SEND" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
|
||||||
<data android:mimeType="text/plain" />
|
<data android:mimeType="text/plain" />
|
||||||
|
<data android:mimeType="application/octet-stream" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<!-- Intent filter for viewing dndbeyond.com character URLs directly in Monster Cards -->
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<action android:name="android.intent.action.EDIT" />
|
|
||||||
<action android:name="android.intent.action.PICK" />
|
|
||||||
<action android:name="android.intent.action.INSERT" />
|
|
||||||
<action android:name="android.intent.action.INSERT_OR_EDIT" />
|
|
||||||
|
|
||||||
<category android:name="android.intent.category.ALTERNATIVE" />
|
|
||||||
<category android:name="android.intent.category.SELECTED_ALTERNATIVE" />
|
|
||||||
<category android:name="android.intent.category.DEFAULT" />
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
|
||||||
<data
|
<data android:scheme="http" />
|
||||||
android:mimeType="text/plain"
|
<data android:scheme="https" />
|
||||||
android:scheme="content" />
|
<data android:host="www.dndbeyond.com" />
|
||||||
<data
|
<data android:host="dndbeyond.com" />
|
||||||
android:mimeType="application/octet-stream"
|
<data android:pathPrefix="/characters/" />
|
||||||
android:scheme="content" />
|
|
||||||
<data
|
|
||||||
android:mimeType="text/plain"
|
|
||||||
android:scheme="file" />
|
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<nav-graph android:value="@navigation/mobile_navigation" />
|
<nav-graph android:value="@navigation/mobile_navigation" />
|
||||||
</activity>
|
</activity>
|
||||||
<activity
|
|
||||||
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"
|
<provider
|
||||||
android:exported="true" />
|
android:name="androidx.core.content.FileProvider"
|
||||||
|
android:authorities="com.majinnaibu.monstercards.fileprovider"
|
||||||
|
android:exported="false"
|
||||||
|
android:grantUriPermissions="true">
|
||||||
|
<meta-data
|
||||||
|
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||||
|
android:resource="@xml/file_paths" />
|
||||||
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import androidx.room.Database;
|
|||||||
import androidx.room.RoomDatabase;
|
import androidx.room.RoomDatabase;
|
||||||
import androidx.room.TypeConverters;
|
import androidx.room.TypeConverters;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.data.CollectionDAO;
|
||||||
|
import com.majinnaibu.monstercards.data.DashboardDAO;
|
||||||
import com.majinnaibu.monstercards.data.MonsterDAO;
|
import com.majinnaibu.monstercards.data.MonsterDAO;
|
||||||
import com.majinnaibu.monstercards.data.converters.ArmorTypeConverter;
|
import com.majinnaibu.monstercards.data.converters.ArmorTypeConverter;
|
||||||
import com.majinnaibu.monstercards.data.converters.ChallengeRatingConverter;
|
import com.majinnaibu.monstercards.data.converters.ChallengeRatingConverter;
|
||||||
@@ -12,10 +14,13 @@ import com.majinnaibu.monstercards.data.converters.SetOfLanguageConverter;
|
|||||||
import com.majinnaibu.monstercards.data.converters.SetOfSkillConverter;
|
import com.majinnaibu.monstercards.data.converters.SetOfSkillConverter;
|
||||||
import com.majinnaibu.monstercards.data.converters.SetOfStringConverter;
|
import com.majinnaibu.monstercards.data.converters.SetOfStringConverter;
|
||||||
import com.majinnaibu.monstercards.data.converters.UUIDConverter;
|
import com.majinnaibu.monstercards.data.converters.UUIDConverter;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonster;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.models.MonsterFTS;
|
import com.majinnaibu.monstercards.models.MonsterFTS;
|
||||||
|
|
||||||
@Database(entities = {Monster.class, MonsterFTS.class}, version = 3)
|
@Database(entities = {Monster.class, MonsterFTS.class, Collection.class, CollectionMonster.class, DashboardMonster.class}, version = 8)
|
||||||
@TypeConverters({
|
@TypeConverters({
|
||||||
ArmorTypeConverter.class,
|
ArmorTypeConverter.class,
|
||||||
ChallengeRatingConverter.class,
|
ChallengeRatingConverter.class,
|
||||||
@@ -27,4 +32,6 @@ import com.majinnaibu.monstercards.models.MonsterFTS;
|
|||||||
})
|
})
|
||||||
public abstract class AppDatabase extends RoomDatabase {
|
public abstract class AppDatabase extends RoomDatabase {
|
||||||
public abstract MonsterDAO monsterDAO();
|
public abstract MonsterDAO monsterDAO();
|
||||||
|
public abstract CollectionDAO collectionDAO();
|
||||||
|
public abstract DashboardDAO dashboardDAO();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,37 +1,66 @@
|
|||||||
package com.majinnaibu.monstercards;
|
package com.majinnaibu.monstercards;
|
||||||
|
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.provider.DocumentsContract;
|
import android.provider.OpenableColumns;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
import androidx.core.graphics.Insets;
|
||||||
|
import androidx.core.view.ViewCompat;
|
||||||
|
import androidx.core.view.WindowCompat;
|
||||||
|
import androidx.core.view.WindowInsetsCompat;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.fragment.NavHostFragment;
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
import androidx.navigation.ui.AppBarConfiguration;
|
import androidx.navigation.ui.AppBarConfiguration;
|
||||||
import androidx.navigation.ui.NavigationUI;
|
import androidx.navigation.ui.NavigationUI;
|
||||||
|
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.majinnaibu.monstercards.helpers.MonsterImportHelper;
|
||||||
import com.majinnaibu.monstercards.helpers.StringHelper;
|
import com.majinnaibu.monstercards.helpers.StringHelper;
|
||||||
|
import com.majinnaibu.monstercards.importers.BinderImporter;
|
||||||
|
import com.majinnaibu.monstercards.importers.DnDBeyondImporter;
|
||||||
|
import com.majinnaibu.monstercards.importers.GitRepoImporterService;
|
||||||
|
import com.majinnaibu.monstercards.importers.Open5eApiWrapper;
|
||||||
import com.majinnaibu.monstercards.init.AppCenterInitializer;
|
import com.majinnaibu.monstercards.init.AppCenterInitializer;
|
||||||
import com.majinnaibu.monstercards.init.FlipperInitializer;
|
import com.majinnaibu.monstercards.models.BinderExport;
|
||||||
|
import com.majinnaibu.monstercards.models.ImportSource;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
import com.majinnaibu.monstercards.utils.ToastHelper;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.core.Single;
|
||||||
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private Disposable mImportDisposable;
|
||||||
|
private ImportSource mCurrentImportSource;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
if (item.getItemId() == android.R.id.home) {
|
if (item.getItemId() == android.R.id.home) {
|
||||||
@@ -45,10 +74,33 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
@SuppressWarnings("ConstantConditions")
|
@SuppressWarnings("ConstantConditions")
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setTheme(R.style.AppTheme);
|
||||||
|
WindowCompat.setDecorFitsSystemWindows(getWindow(), false);
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
AppCenterInitializer.init(getApplication());
|
AppCenterInitializer.init(getApplication());
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
MaterialToolbar toolbar = findViewById(R.id.toolbar);
|
||||||
|
if (toolbar != null) {
|
||||||
|
setSupportActionBar(toolbar);
|
||||||
|
}
|
||||||
|
|
||||||
|
View appBarLayout = findViewById(R.id.app_bar_layout);
|
||||||
BottomNavigationView navView = findViewById(R.id.nav_view);
|
BottomNavigationView navView = findViewById(R.id.nav_view);
|
||||||
|
|
||||||
|
View container = findViewById(R.id.container);
|
||||||
|
if (container != null) {
|
||||||
|
ViewCompat.setOnApplyWindowInsetsListener(container, (v, windowInsets) -> {
|
||||||
|
Insets systemBars = windowInsets.getInsets(WindowInsetsCompat.Type.systemBars());
|
||||||
|
if (appBarLayout != null) {
|
||||||
|
appBarLayout.setPadding(0, systemBars.top, 0, 0);
|
||||||
|
}
|
||||||
|
if (navView != null) {
|
||||||
|
navView.setPadding(0, 0, 0, systemBars.bottom);
|
||||||
|
}
|
||||||
|
return windowInsets;
|
||||||
|
});
|
||||||
|
}
|
||||||
// Passing each menu ID as a set of Ids because each
|
// Passing each menu ID as a set of Ids because each
|
||||||
// menu should be considered as top level destinations.
|
// menu should be considered as top level destinations.
|
||||||
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
|
||||||
@@ -59,7 +111,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.build();
|
.build();
|
||||||
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
|
NavHostFragment navHostFragment = (NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
|
||||||
NavController navController = navHostFragment.getNavController();
|
NavController navController = navHostFragment.getNavController();
|
||||||
navController.addOnDestinationChangedListener(FlipperInitializer::sendNavigationEvent);
|
|
||||||
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
|
||||||
NavigationUI.setupWithNavController(navView, navController);
|
NavigationUI.setupWithNavController(navView, navController);
|
||||||
onNewIntent(getIntent());
|
onNewIntent(getIntent());
|
||||||
@@ -69,12 +120,273 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
|
||||||
|
if (intent == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String action = intent.getAction();
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
|
||||||
|
if ("android.intent.action.SEND".equals(action) && extras != null) {
|
||||||
|
CharSequence sharedText = extras.getCharSequence(Intent.EXTRA_TEXT);
|
||||||
|
if (sharedText != null) {
|
||||||
|
String textStr = sharedText.toString().trim();
|
||||||
|
DnDBeyondImporter dndImporter = new DnDBeyondImporter();
|
||||||
|
if (dndImporter.canImport(textStr)) {
|
||||||
|
importMonsterFromInputAndNavigate(textStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ("android.intent.action.VIEW".equals(action)) {
|
||||||
|
Uri dataUri = intent.getData();
|
||||||
|
if (dataUri != null) {
|
||||||
|
String dataStr = dataUri.toString().trim();
|
||||||
|
DnDBeyondImporter dndImporter = new DnDBeyondImporter();
|
||||||
|
if (dndImporter.canImport(dataStr)) {
|
||||||
|
importMonsterFromInputAndNavigate(dataStr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Uri intentUri = getUriFromIntent(intent);
|
||||||
|
String fileName = intentUri != null ? getFileNameFromUri(intentUri) : null;
|
||||||
String json = readMonsterJSONFromIntent(intent);
|
String json = readMonsterJSONFromIntent(intent);
|
||||||
if (!StringHelper.isNullOrEmpty(json)) {
|
if (!StringHelper.isNullOrEmpty(json)) {
|
||||||
NavHostFragment navHostFragment = Objects.requireNonNull((NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment));
|
importMonsterFromInputAndNavigate(json, fileName);
|
||||||
NavController navController = navHostFragment.getNavController();
|
}
|
||||||
NavDirections action = MobileNavigationDirections.actionGlobalMonsterImportFragment(json);
|
}
|
||||||
navController.navigate(action);
|
|
||||||
|
@Nullable
|
||||||
|
private Uri getUriFromIntent(@NonNull Intent intent) {
|
||||||
|
String action = intent.getAction();
|
||||||
|
Bundle extras = intent.getExtras();
|
||||||
|
if ("android.intent.action.SEND".equals(action)) {
|
||||||
|
if (extras != null) {
|
||||||
|
return extras.getParcelable(Intent.EXTRA_STREAM);
|
||||||
|
}
|
||||||
|
} else if ("android.intent.action.VIEW".equals(action) || "android.intent.action.EDIT".equals(action)) {
|
||||||
|
return intent.getData();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importMonsterFromInputAndNavigate(@NonNull String input) {
|
||||||
|
importMonsterFromInputAndNavigate(input, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importMonsterFromInputAndNavigate(@NonNull String input, @Nullable String fileName) {
|
||||||
|
try {
|
||||||
|
BinderImporter binderImporter = new BinderImporter();
|
||||||
|
if (binderImporter.canImport(input)) {
|
||||||
|
ToastHelper.showShort(this, R.string.toast_importing_url);
|
||||||
|
Single.fromCallable(() -> binderImporter.parse(input))
|
||||||
|
.flatMapCompletable(binder -> ((MonsterCardsApplication) getApplication()).getMonsterRepository().importBinder(binder))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
ToastHelper.showLong(this, R.string.snackbar_import_binder_success);
|
||||||
|
NavHostFragment navHostFragment = Objects.requireNonNull((NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment));
|
||||||
|
NavController navController = navHostFragment.getNavController();
|
||||||
|
navController.navigate(R.id.navigation_library);
|
||||||
|
}, throwable -> {
|
||||||
|
Logger.logError("Failed to import binder from input: " + fileName, throwable);
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToastHelper.showShort(this, R.string.toast_importing_url);
|
||||||
|
Single.fromCallable(() -> MonsterImportHelper.fromJSON(input, fileName))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monster -> {
|
||||||
|
String serializedJson = new Gson().toJson(monster);
|
||||||
|
NavHostFragment navHostFragment = Objects.requireNonNull((NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment));
|
||||||
|
NavController navController = navHostFragment.getNavController();
|
||||||
|
NavDirections navAction = MobileNavigationDirections.actionGlobalMonsterImportFragment(serializedJson);
|
||||||
|
navController.navigate(navAction);
|
||||||
|
}, throwable -> {
|
||||||
|
Logger.logError("Failed to import monster from input: " + fileName, throwable);
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to process import input: " + fileName, e);
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startImportFromSource(ImportSource source) {
|
||||||
|
if (mImportDisposable != null && !mImportDisposable.isDisposed()) {
|
||||||
|
new AlertDialog.Builder(this)
|
||||||
|
.setTitle(R.string.dialog_import_already_running_title)
|
||||||
|
.setMessage(getString(R.string.dialog_import_already_running_message, mCurrentImportSource != null ? mCurrentImportSource.projectName : ""))
|
||||||
|
.setPositiveButton(R.string.action_cancel_current, (dialog, which) -> {
|
||||||
|
mImportDisposable.dispose();
|
||||||
|
executeImportFromSource(source);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
executeImportFromSource(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void executeImportFromSource(ImportSource source) {
|
||||||
|
mCurrentImportSource = source;
|
||||||
|
View rootView = findViewById(android.R.id.content);
|
||||||
|
Snackbar snackbar = SnackbarHelper.makeIndefinite(rootView, getString(R.string.snackbar_importing_source, source.projectName));
|
||||||
|
snackbar.setAction(R.string.action_cancel, v -> {
|
||||||
|
if (mImportDisposable != null && !mImportDisposable.isDisposed()) {
|
||||||
|
mImportDisposable.dispose();
|
||||||
|
SnackbarHelper.showLong(rootView, getString(R.string.snackbar_import_source_cancelled, source.projectName));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
snackbar.show();
|
||||||
|
|
||||||
|
Callable<Integer> importTask;
|
||||||
|
if (source.importType == ImportSource.ImportType.OPEN5E_API) {
|
||||||
|
importTask = () -> {
|
||||||
|
int totalImported = 0;
|
||||||
|
String nextUrl = null;
|
||||||
|
do {
|
||||||
|
if (mImportDisposable != null && mImportDisposable.isDisposed()) {
|
||||||
|
throw new InterruptedException("Open5e import was cancelled");
|
||||||
|
}
|
||||||
|
Open5eApiWrapper.Open5ePageResult page = Open5eApiWrapper.fetchPage(nextUrl, () -> mImportDisposable != null && mImportDisposable.isDisposed());
|
||||||
|
for (Monster monster : page.monsters) {
|
||||||
|
if (mImportDisposable != null && mImportDisposable.isDisposed()) {
|
||||||
|
throw new InterruptedException("Open5e import was cancelled");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
((MonsterCardsApplication) getApplication()).getMonsterRepository()
|
||||||
|
.saveMonster(monster)
|
||||||
|
.blockingAwait();
|
||||||
|
totalImported++;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to save monster to database", e);
|
||||||
|
runOnUiThread(() -> ToastHelper.showShort(MainActivity.this, "An error occurred while saving a monster."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nextUrl = page.nextUrl;
|
||||||
|
} while (nextUrl != null && !nextUrl.isEmpty());
|
||||||
|
return totalImported;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
importTask = () -> {
|
||||||
|
try {
|
||||||
|
return GitRepoImporterService.importFromGitRepository(getApplicationContext(), source, () -> mImportDisposable != null && mImportDisposable.isDisposed());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Logger.logError("Import task was interrupted", e);
|
||||||
|
return 0; // Return gracefully on interruption
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
mImportDisposable = Single.fromCallable(importTask)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(resultCount -> {
|
||||||
|
snackbar.dismiss();
|
||||||
|
SnackbarHelper.showLong(rootView, getString(R.string.snackbar_import_source_complete, resultCount, source.projectName));
|
||||||
|
}, throwable -> {
|
||||||
|
snackbar.dismiss();
|
||||||
|
if (throwable instanceof InterruptedException) {
|
||||||
|
Logger.logError("Import task was cancelled: " + source.projectName, throwable);
|
||||||
|
// The user cancelled via UI, message handled in the snackbar action.
|
||||||
|
} else {
|
||||||
|
Logger.logError("Failed to import from source: " + source.projectName, throwable);
|
||||||
|
SnackbarHelper.showLong(rootView, getString(R.string.snackbar_import_source_failed, source.projectName));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importMultipleFilesFromUris(@NonNull List<Uri> uris) {
|
||||||
|
if (uris.isEmpty()) return;
|
||||||
|
if (uris.size() == 1) {
|
||||||
|
Uri singleUri = uris.get(0);
|
||||||
|
String fileName = getFileNameFromUri(singleUri);
|
||||||
|
String content = readContentsOfUri(singleUri);
|
||||||
|
if (content != null && !content.trim().isEmpty()) {
|
||||||
|
importMonsterFromInputAndNavigate(content, fileName);
|
||||||
|
} else {
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ToastHelper.showShort(this, R.string.toast_importing_url);
|
||||||
|
Single.fromCallable(() -> {
|
||||||
|
int monstersImported = 0;
|
||||||
|
int bindersImported = 0;
|
||||||
|
|
||||||
|
for (Uri uri : uris) {
|
||||||
|
try {
|
||||||
|
String fileName = getFileNameFromUri(uri);
|
||||||
|
String content = readContentsOfUri(uri);
|
||||||
|
if (content == null || content.trim().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
BinderImporter binderImporter = new BinderImporter();
|
||||||
|
if (binderImporter.canImport(content)) {
|
||||||
|
BinderExport binder = binderImporter.parse(content);
|
||||||
|
((MonsterCardsApplication) getApplication()).getMonsterRepository()
|
||||||
|
.importBinder(binder)
|
||||||
|
.blockingAwait();
|
||||||
|
bindersImported++;
|
||||||
|
} else {
|
||||||
|
Monster monster = MonsterImportHelper.fromJSON(content, fileName);
|
||||||
|
((MonsterCardsApplication) getApplication()).getMonsterRepository()
|
||||||
|
.saveMonster(monster)
|
||||||
|
.blockingAwait();
|
||||||
|
monstersImported++;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to import file URI: " + uri, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new BatchImportResult(monstersImported, bindersImported);
|
||||||
|
})
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(result -> {
|
||||||
|
if (result.bindersImported > 0 || result.monstersImported > 0) {
|
||||||
|
String message = buildImportSummaryMessage(result.monstersImported, result.bindersImported);
|
||||||
|
ToastHelper.showLong(this, message);
|
||||||
|
NavHostFragment navHostFragment = Objects.requireNonNull((NavHostFragment) getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment));
|
||||||
|
NavController navController = navHostFragment.getNavController();
|
||||||
|
navController.navigate(R.id.navigation_library);
|
||||||
|
} else {
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
}
|
||||||
|
}, throwable -> {
|
||||||
|
Logger.logError("Failed to execute batch file import", throwable);
|
||||||
|
ToastHelper.showLong(this, R.string.failed_to_import_url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildImportSummaryMessage(int monstersCount, int bindersCount) {
|
||||||
|
StringBuilder sb = new StringBuilder("Successfully imported ");
|
||||||
|
if (bindersCount > 0 && monstersCount > 0) {
|
||||||
|
sb.append(bindersCount).append(bindersCount == 1 ? " collection" : " collections")
|
||||||
|
.append(" and ")
|
||||||
|
.append(monstersCount).append(monstersCount == 1 ? " monster" : " monsters");
|
||||||
|
} else if (bindersCount > 0) {
|
||||||
|
sb.append(bindersCount).append(bindersCount == 1 ? " collection" : " collections");
|
||||||
|
} else {
|
||||||
|
sb.append(monstersCount).append(monstersCount == 1 ? " monster" : " monsters");
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BatchImportResult {
|
||||||
|
final int monstersImported;
|
||||||
|
final int bindersImported;
|
||||||
|
|
||||||
|
BatchImportResult(int monstersImported, int bindersImported) {
|
||||||
|
this.monstersImported = monstersImported;
|
||||||
|
this.bindersImported = bindersImported;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,75 +394,87 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
private String readMonsterJSONFromIntent(@NonNull Intent intent) {
|
private String readMonsterJSONFromIntent(@NonNull Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
String type = intent.getType();
|
|
||||||
String json;
|
|
||||||
Uri uri = null;
|
Uri uri = null;
|
||||||
if ("android.intent.action.MAIN".equals(action)) {
|
if ("android.intent.action.SEND".equals(action)) {
|
||||||
return null;
|
if (extras != null) {
|
||||||
} else if ("android.intent.action.SEND".equals(action) && "text/plain".equals(type)) {
|
uri = extras.getParcelable(Intent.EXTRA_STREAM);
|
||||||
uri = extras.getParcelable("android.intent.extra.STREAM");
|
}
|
||||||
} else if ("android.intent.action.VIEW".equals(action) && ("text/plain".equals(type) || "application/octet-stream".equals(type))) {
|
} else if ("android.intent.action.VIEW".equals(action) || "android.intent.action.EDIT".equals(action)) {
|
||||||
uri = intent.getData();
|
uri = intent.getData();
|
||||||
} else {
|
} else {
|
||||||
Logger.logError(String.format("unexpected launch configuration action: %s, type: %s", action, type));
|
Logger.logError(String.format("unexpected launch configuration action: %s", action));
|
||||||
}
|
}
|
||||||
if (uri == null) {
|
|
||||||
|
if (uri == null || !isMonsterFile(uri)) {
|
||||||
|
if (uri != null) {
|
||||||
|
Logger.logError("Ignored file because extension is not supported (.monster, .card, .binder): " + uri);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
json = readContentsOfUri(uri);
|
|
||||||
|
String json = readContentsOfUri(uri);
|
||||||
if (StringHelper.isNullOrEmpty(json)) {
|
if (StringHelper.isNullOrEmpty(json)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isMonsterFile(@NonNull Uri uri) {
|
||||||
|
String fileName = getFileNameFromUri(uri);
|
||||||
|
if (fileName == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String lowerName = fileName.toLowerCase(Locale.ROOT);
|
||||||
|
return lowerName.endsWith(".monster") || lowerName.endsWith(".monster.txt")
|
||||||
|
|| lowerName.endsWith(".card") || lowerName.endsWith(".card.txt")
|
||||||
|
|| lowerName.endsWith(".binder") || lowerName.endsWith(".binder.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private String getFileNameFromUri(@NonNull Uri uri) {
|
||||||
|
String displayName = null;
|
||||||
|
if ("content".equals(uri.getScheme())) {
|
||||||
|
try (Cursor cursor = getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||||
|
if (nameIndex != -1) {
|
||||||
|
displayName = cursor.getString(nameIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Error querying display name from content URI", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (displayName == null) {
|
||||||
|
displayName = uri.getPath();
|
||||||
|
}
|
||||||
|
return displayName;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String readContentsOfUri(Uri uri) {
|
private String readContentsOfUri(Uri uri) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
try (
|
try (InputStream inputStream =
|
||||||
InputStream inputStream = openInputStream(uri);
|
getContentResolver().openInputStream(uri);
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream)))
|
BufferedReader reader = new BufferedReader(
|
||||||
) {
|
new InputStreamReader(Objects.requireNonNull(inputStream)))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
builder.append(line);
|
builder.append(line);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.logError("error reading file", e);
|
Logger.logError("error reading file", e);
|
||||||
|
ToastHelper.showLong(this, "An error occurred while reading the file.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isVirtualFile(Uri uri) {
|
@Override
|
||||||
if (!DocumentsContract.isDocumentUri(this, uri)) {
|
protected void onDestroy() {
|
||||||
return false;
|
super.onDestroy();
|
||||||
}
|
if (mImportDisposable != null && !mImportDisposable.isDisposed()) {
|
||||||
|
mImportDisposable.dispose();
|
||||||
Cursor cursor = getContentResolver().query(
|
|
||||||
uri,
|
|
||||||
new String[]{DocumentsContract.Document.COLUMN_FLAGS},
|
|
||||||
null, null, null);
|
|
||||||
|
|
||||||
int flags = 0;
|
|
||||||
if (cursor.moveToFirst()) {
|
|
||||||
flags = cursor.getInt(0);
|
|
||||||
}
|
|
||||||
cursor.close();
|
|
||||||
|
|
||||||
return (flags & DocumentsContract.Document.FLAG_VIRTUAL_DOCUMENT) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private InputStream openInputStream(Uri uri) throws IOException {
|
|
||||||
ContentResolver resolver = getContentResolver();
|
|
||||||
if (isVirtualFile(uri)) {
|
|
||||||
String[] openableMimeTypes = resolver.getStreamTypes(uri, "*/*");
|
|
||||||
if (openableMimeTypes == null || openableMimeTypes.length <= 0) {
|
|
||||||
throw new FileNotFoundException();
|
|
||||||
}
|
|
||||||
return resolver.openTypedAssetFileDescriptor(uri, openableMimeTypes[0], null).createInputStream();
|
|
||||||
} else {
|
|
||||||
return resolver.openInputStream(uri);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,12 @@ import androidx.room.migration.Migration;
|
|||||||
import androidx.sqlite.db.SupportSQLiteDatabase;
|
import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||||
|
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
import com.majinnaibu.monstercards.init.FlipperInitializer;
|
|
||||||
|
import io.reactivex.rxjava3.exceptions.UndeliverableException;
|
||||||
|
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
|
|
||||||
public class MonsterCardsApplication extends Application {
|
public class MonsterCardsApplication extends Application {
|
||||||
|
|
||||||
@@ -36,6 +41,66 @@ public class MonsterCardsApplication extends Application {
|
|||||||
database.execSQL("ALTER TABLE new_monsters RENAME TO monsters");
|
database.execSQL("ALTER TABLE new_monsters RENAME TO monsters");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
private static final Migration MIGRATION_3_4 = new Migration(3, 4) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("CREATE TABLE IF NOT EXISTS `collections` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `description` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))");
|
||||||
|
database.execSQL("CREATE TABLE IF NOT EXISTS `collection_monsters` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `collection_id` TEXT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`collection_id`) REFERENCES `collections`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE)");
|
||||||
|
database.execSQL("CREATE INDEX IF NOT EXISTS `index_collection_monsters_collection_id` ON `collection_monsters` (`collection_id`)");
|
||||||
|
database.execSQL("CREATE INDEX IF NOT EXISTS `index_collection_monsters_monster_id` ON `collection_monsters` (`monster_id`)");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static final Migration MIGRATION_4_5 = new Migration(4, 5) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("CREATE TABLE IF NOT EXISTS `dashboard_monsters` (`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `monster_id` TEXT NOT NULL, `ordinal` INTEGER NOT NULL DEFAULT 0, FOREIGN KEY(`monster_id`) REFERENCES `monsters`(`id`) ON UPDATE NO ACTION ON DELETE CASCADE)");
|
||||||
|
database.execSQL("CREATE INDEX IF NOT EXISTS `index_dashboard_monsters_monster_id` ON `dashboard_monsters` (`monster_id`)");
|
||||||
|
database.execSQL("INSERT INTO dashboard_monsters(monster_id, ordinal) SELECT id, 0 FROM monsters");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static final Migration MIGRATION_5_6 = new Migration(5, 6) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `source_url` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `bonus_actions` TEXT DEFAULT '[]'");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `mythic_actions` TEXT DEFAULT '[]'");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `legendary_actions_description` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `lair_actions_description` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `lair_actions_end_note` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `regional_actions_description` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `regional_actions_end_note` TEXT DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `mythic_actions_description` TEXT DEFAULT ''");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static final Migration MIGRATION_6_7 = new Migration(6, 7) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `player_name` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `background` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `personality_traits` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `ideals` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `bonds` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `flaws` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `age` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `height` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `weight` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `eyes` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `skin` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `hair` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `appearance` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `backstory` TEXT NOT NULL DEFAULT ''");
|
||||||
|
database.execSQL("ALTER TABLE monsters ADD COLUMN `allies_and_organizations` TEXT NOT NULL DEFAULT ''");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private static final Migration MIGRATION_7_8 = new Migration(7, 8) {
|
||||||
|
@Override
|
||||||
|
public void migrate(@NonNull SupportSQLiteDatabase database) {
|
||||||
|
database.execSQL("CREATE TABLE IF NOT EXISTS `new_monsters` (`id` TEXT NOT NULL, `name` TEXT NOT NULL DEFAULT '', `size` TEXT NOT NULL DEFAULT '', `type` TEXT NOT NULL DEFAULT '', `subtype` TEXT NOT NULL DEFAULT '', `alignment` TEXT NOT NULL DEFAULT '', `strength_score` INTEGER NOT NULL DEFAULT 10, `strength_saving_throw_advantage` TEXT DEFAULT 'none', `strength_saving_throw_proficiency` TEXT DEFAULT 'none', `dexterity_score` INTEGER NOT NULL DEFAULT 10, `dexterity_saving_throw_advantage` TEXT DEFAULT 'none', `dexterity_saving_throw_proficiency` TEXT DEFAULT 'none', `constitution_score` INTEGER NOT NULL DEFAULT 10, `constitution_saving_throw_advantage` TEXT DEFAULT 'none', `constitution_saving_throw_proficiency` TEXT DEFAULT 'none', `intelligence_score` INTEGER NOT NULL DEFAULT 10, `intelligence_saving_throw_advantage` TEXT DEFAULT 'none', `intelligence_saving_throw_proficiency` TEXT DEFAULT 'none', `wisdom_score` INTEGER NOT NULL DEFAULT 10, `wisdom_saving_throw_advantage` TEXT DEFAULT 'none', `wisdom_saving_throw_proficiency` TEXT DEFAULT 'none', `charisma_score` INTEGER NOT NULL DEFAULT 10, `charisma_saving_throw_advantage` TEXT DEFAULT 'none', `charisma_saving_throw_proficiency` TEXT DEFAULT 'none', `armor_type` TEXT DEFAULT 'none', `shield_bonus` INTEGER NOT NULL DEFAULT 0, `natural_armor_bonus` INTEGER NOT NULL DEFAULT 0, `other_armor_description` TEXT DEFAULT '', `hit_dice` INTEGER NOT NULL DEFAULT 1, `has_custom_hit_points` INTEGER NOT NULL, `custom_hit_points_description` TEXT DEFAULT '', `walk_speed` INTEGER NOT NULL DEFAULT 0, `burrow_speed` INTEGER NOT NULL DEFAULT 0, `climb_speed` INTEGER NOT NULL DEFAULT 0, `fly_speed` INTEGER NOT NULL DEFAULT 0, `can_hover` INTEGER NOT NULL DEFAULT false, `swim_speed` INTEGER NOT NULL DEFAULT 0, `has_custom_speed` INTEGER NOT NULL DEFAULT false, `custom_speed_description` TEXT, `challenge_rating` TEXT DEFAULT '1', `custom_challenge_rating_description` TEXT DEFAULT '', `custom_proficiency_bonus` INTEGER NOT NULL DEFAULT 0, `telepathy_range` INTEGER NOT NULL DEFAULT 0, `understands_but_description` TEXT DEFAULT '', `senses` TEXT DEFAULT '[]', `skills` TEXT DEFAULT '[]', `damage_immunities` TEXT DEFAULT '[]', `damage_resistances` TEXT DEFAULT '[]', `damage_vulnerabilities` TEXT DEFAULT '[]', `condition_immunities` TEXT DEFAULT '[]', `languages` TEXT DEFAULT '[]', `abilities` TEXT DEFAULT '[]', `actions` TEXT DEFAULT '[]', `reactions` TEXT DEFAULT '[]', `lair_actions` TEXT DEFAULT '[]', `legendary_actions` TEXT DEFAULT '[]', `regional_actions` TEXT DEFAULT '[]', `source_url` TEXT DEFAULT '', `bonus_actions` TEXT DEFAULT '[]', `mythic_actions` TEXT DEFAULT '[]', `legendary_actions_description` TEXT DEFAULT '', `lair_actions_description` TEXT DEFAULT '', `lair_actions_end_note` TEXT DEFAULT '', `regional_actions_description` TEXT DEFAULT '', `regional_actions_end_note` TEXT DEFAULT '', `mythic_actions_description` TEXT DEFAULT '', `player_name` TEXT NOT NULL DEFAULT '', `background` TEXT NOT NULL DEFAULT '', `personality_traits` TEXT NOT NULL DEFAULT '', `ideals` TEXT NOT NULL DEFAULT '', `bonds` TEXT NOT NULL DEFAULT '', `flaws` TEXT NOT NULL DEFAULT '', `age` TEXT NOT NULL DEFAULT '', `height` TEXT NOT NULL DEFAULT '', `weight` TEXT NOT NULL DEFAULT '', `eyes` TEXT NOT NULL DEFAULT '', `skin` TEXT NOT NULL DEFAULT '', `hair` TEXT NOT NULL DEFAULT '', `appearance` TEXT NOT NULL DEFAULT '', `backstory` TEXT NOT NULL DEFAULT '', `allies_and_organizations` TEXT NOT NULL DEFAULT '', PRIMARY KEY(`id`))");
|
||||||
|
database.execSQL("INSERT INTO `new_monsters` SELECT id, name, size, type, subtype, alignment, strength_score, strength_saving_throw_advantage, strength_saving_throw_proficiency, dexterity_score, dexterity_saving_throw_advantage, dexterity_saving_throw_proficiency, constitution_score, constitution_saving_throw_advantage, constitution_saving_throw_proficiency, intelligence_score, intelligence_saving_throw_advantage, intelligence_saving_throw_proficiency, wisdom_score, wisdom_saving_throw_advantage, wisdom_saving_throw_proficiency, charisma_score, charisma_saving_throw_advantage, charisma_saving_throw_proficiency, armor_type, shield_bonus, natural_armor_bonus, other_armor_description, hit_dice, has_custom_hit_points, custom_hit_points_description, walk_speed, burrow_speed, climb_speed, fly_speed, can_hover, swim_speed, has_custom_speed, custom_speed_description, challenge_rating, custom_challenge_rating_description, custom_proficiency_bonus, telepathy_range, understands_but_description, senses, skills, damage_immunities, damage_resistances, damage_vulnerabilities, condition_immunities, languages, abilities, actions, reactions, lair_actions, legendary_actions, regional_actions, source_url, bonus_actions, mythic_actions, legendary_actions_description, lair_actions_description, lair_actions_end_note, regional_actions_description, regional_actions_end_note, mythic_actions_description, COALESCE(player_name, ''), COALESCE(background, ''), COALESCE(personality_traits, ''), COALESCE(ideals, ''), COALESCE(bonds, ''), COALESCE(flaws, ''), COALESCE(age, ''), COALESCE(height, ''), COALESCE(weight, ''), COALESCE(eyes, ''), COALESCE(skin, ''), COALESCE(hair, ''), COALESCE(appearance, ''), COALESCE(backstory, ''), COALESCE(allies_and_organizations, '') FROM `monsters`");
|
||||||
|
database.execSQL("DROP TABLE `monsters`");
|
||||||
|
database.execSQL("ALTER TABLE `new_monsters` RENAME TO `monsters`");
|
||||||
|
}
|
||||||
|
};
|
||||||
private MonsterRepository m_monsterLibraryRepository;
|
private MonsterRepository m_monsterLibraryRepository;
|
||||||
|
|
||||||
|
|
||||||
@@ -51,14 +116,30 @@ public class MonsterCardsApplication extends Application {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
|
|
||||||
|
RxJavaPlugins.setErrorHandler(e -> {
|
||||||
|
if (e instanceof UndeliverableException) {
|
||||||
|
e = e.getCause();
|
||||||
|
}
|
||||||
|
if (e instanceof InterruptedException || e instanceof InterruptedIOException) {
|
||||||
|
// Expected when a blocking task is cancelled; swallow silently.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.logError("Undeliverable exception received by RxJava global handler", e);
|
||||||
|
});
|
||||||
|
|
||||||
// Required initialization logic here!
|
// Required initialization logic here!
|
||||||
|
|
||||||
FlipperInitializer.init(this);
|
|
||||||
|
|
||||||
// .fallbackToDestructiveMigration()
|
// .fallbackToDestructiveMigration()
|
||||||
AppDatabase m_db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "monsters")
|
AppDatabase m_db = Room.databaseBuilder(getApplicationContext(), AppDatabase.class, "monsters")
|
||||||
.addMigrations(MIGRATION_1_2)
|
.addMigrations(MIGRATION_1_2)
|
||||||
.addMigrations(MIGRATION_2_3)
|
.addMigrations(MIGRATION_2_3)
|
||||||
|
.addMigrations(MIGRATION_3_4)
|
||||||
|
.addMigrations(MIGRATION_4_5)
|
||||||
|
.addMigrations(MIGRATION_5_6)
|
||||||
|
.addMigrations(MIGRATION_6_7)
|
||||||
|
.addMigrations(MIGRATION_7_8)
|
||||||
.fallbackToDestructiveMigrationOnDowngrade()
|
.fallbackToDestructiveMigrationOnDowngrade()
|
||||||
// .fallbackToDestructiveMigration()
|
// .fallbackToDestructiveMigration()
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.majinnaibu.monstercards;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
|
|
||||||
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
|
|
||||||
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setTheme(R.style.AppTheme);
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_splash);
|
||||||
|
|
||||||
|
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||||
|
Intent intent = new Intent(SplashActivity.this, MainActivity.class);
|
||||||
|
if (getIntent() != null) {
|
||||||
|
if (getIntent().getExtras() != null) {
|
||||||
|
intent.putExtras(getIntent().getExtras());
|
||||||
|
}
|
||||||
|
if (getIntent().getAction() != null) {
|
||||||
|
intent.setAction(getIntent().getAction());
|
||||||
|
}
|
||||||
|
if (getIntent().getData() != null) {
|
||||||
|
intent.setData(getIntent().getData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
|
||||||
|
}, 1200);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package com.majinnaibu.monstercards.data;
|
||||||
|
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Delete;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.OnConflictStrategy;
|
||||||
|
import androidx.room.Query;
|
||||||
|
import androidx.room.Update;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionWithCount;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Completable;
|
||||||
|
import io.reactivex.rxjava3.core.Flowable;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface CollectionDAO {
|
||||||
|
|
||||||
|
@Query("SELECT * FROM collections")
|
||||||
|
Flowable<List<Collection>> getAll();
|
||||||
|
|
||||||
|
@Query("SELECT collections.*, COUNT(collection_monsters.id) as monsterCount FROM collections LEFT JOIN collection_monsters ON collections.id = collection_monsters.collection_id GROUP BY collections.id")
|
||||||
|
Flowable<List<CollectionWithCount>> getCollectionsWithCount();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM collections WHERE id = :id LIMIT 1")
|
||||||
|
Flowable<Collection> getById(String id);
|
||||||
|
|
||||||
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
|
Completable save(Collection... collections);
|
||||||
|
|
||||||
|
@Delete
|
||||||
|
Completable delete(Collection collection);
|
||||||
|
|
||||||
|
@Query("SELECT monsters.* FROM monsters INNER JOIN collection_monsters ON monsters.id = collection_monsters.monster_id WHERE collection_monsters.collection_id = :collectionId ORDER BY collection_monsters.ordinal ASC, collection_monsters.id ASC")
|
||||||
|
Flowable<List<Monster>> getMonstersForCollection(String collectionId);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM collection_monsters WHERE collection_id = :collectionId ORDER BY ordinal ASC, id ASC")
|
||||||
|
Flowable<List<CollectionMonster>> getCollectionMonstersForCollection(String collectionId);
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
Completable addMonsterToCollection(CollectionMonster... collectionMonsters);
|
||||||
|
|
||||||
|
@Query("DELETE FROM collection_monsters WHERE collection_id = :collectionId AND monster_id = :monsterId")
|
||||||
|
Completable removeMonsterFromCollection(String collectionId, String monsterId);
|
||||||
|
|
||||||
|
@Query("DELETE FROM collection_monsters WHERE collection_id = :collectionId")
|
||||||
|
Completable removeAllMonstersFromCollection(String collectionId);
|
||||||
|
|
||||||
|
@Query("DELETE FROM collection_monsters WHERE id = :id")
|
||||||
|
Completable removeCollectionMonsterById(long id);
|
||||||
|
|
||||||
|
@Query("DELETE FROM collection_monsters")
|
||||||
|
Completable deleteAllCollectionMonsters();
|
||||||
|
|
||||||
|
@Query("DELETE FROM collections")
|
||||||
|
Completable deleteAllCollections();
|
||||||
|
|
||||||
|
@Update
|
||||||
|
Completable updateCollectionMonsters(List<CollectionMonster> collectionMonsters);
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.majinnaibu.monstercards.data;
|
||||||
|
|
||||||
|
import androidx.room.Dao;
|
||||||
|
import androidx.room.Insert;
|
||||||
|
import androidx.room.Query;
|
||||||
|
import androidx.room.Transaction;
|
||||||
|
import androidx.room.Update;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonsterWithMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.core.Completable;
|
||||||
|
import io.reactivex.rxjava3.core.Flowable;
|
||||||
|
|
||||||
|
@Dao
|
||||||
|
public interface DashboardDAO {
|
||||||
|
|
||||||
|
@Query("SELECT monsters.* FROM monsters INNER JOIN dashboard_monsters ON monsters.id = dashboard_monsters.monster_id ORDER BY dashboard_monsters.ordinal ASC, dashboard_monsters.id ASC")
|
||||||
|
Flowable<List<Monster>> getDashboardMonsters();
|
||||||
|
|
||||||
|
@Transaction
|
||||||
|
@Query("SELECT * FROM dashboard_monsters ORDER BY ordinal ASC, id ASC")
|
||||||
|
Flowable<List<DashboardMonsterWithMonster>> getDashboardMonstersWithMonster();
|
||||||
|
|
||||||
|
@Query("SELECT * FROM dashboard_monsters ORDER BY ordinal ASC, id ASC")
|
||||||
|
Flowable<List<DashboardMonster>> getDashboardMonsterEntries();
|
||||||
|
|
||||||
|
@Insert
|
||||||
|
Completable addMonsterToDashboard(DashboardMonster... dashboardMonsters);
|
||||||
|
|
||||||
|
@Query("DELETE FROM dashboard_monsters WHERE id = :id")
|
||||||
|
Completable removeDashboardMonsterById(long id);
|
||||||
|
|
||||||
|
@Query("DELETE FROM dashboard_monsters WHERE id = (SELECT id FROM dashboard_monsters WHERE monster_id = :monsterId LIMIT 1)")
|
||||||
|
Completable removeMonsterFromDashboard(String monsterId);
|
||||||
|
|
||||||
|
@Query("DELETE FROM dashboard_monsters WHERE monster_id = :monsterId")
|
||||||
|
Completable removeAllMonstersFromDashboard(String monsterId);
|
||||||
|
|
||||||
|
@Query("DELETE FROM dashboard_monsters")
|
||||||
|
Completable clearDashboard();
|
||||||
|
|
||||||
|
@Update
|
||||||
|
Completable updateDashboardMonsters(List<DashboardMonster> dashboardMonsters);
|
||||||
|
}
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.majinnaibu.monstercards.data;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.models.ImportSource;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ImportConfig {
|
||||||
|
public static final List<ImportSource> SOURCES = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
SOURCES.add(new ImportSource(
|
||||||
|
"open5e",
|
||||||
|
"Open5e.com System Reference Document",
|
||||||
|
"Open5e",
|
||||||
|
"https://open5e.com",
|
||||||
|
ImportSource.ImportType.OPEN5E_API,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null,
|
||||||
|
null
|
||||||
|
));
|
||||||
|
|
||||||
|
SOURCES.add(new ImportSource(
|
||||||
|
"pf2e_foundry",
|
||||||
|
"Pathfinder 2e Foundry VTT",
|
||||||
|
"foundryvtt",
|
||||||
|
"https://github.com/foundryvtt/pf2e",
|
||||||
|
ImportSource.ImportType.GIT_ARCHIVE,
|
||||||
|
"https://github.com/foundryvtt/pf2e/archive/refs/heads/v14-dev.zip",
|
||||||
|
"com.majinnaibu.monstercards.importers.Pf2eImporter",
|
||||||
|
".json",
|
||||||
|
"pf2e-14-dev/packs/pf2e"
|
||||||
|
));
|
||||||
|
|
||||||
|
SOURCES.add(new ImportSource(
|
||||||
|
"sf2e_foundry",
|
||||||
|
"Starfinder 2e Foundry VTT",
|
||||||
|
"foundryvtt",
|
||||||
|
"https://github.com/foundryvtt/pf2e",
|
||||||
|
ImportSource.ImportType.GIT_ARCHIVE,
|
||||||
|
"https://github.com/foundryvtt/pf2e/archive/refs/heads/v14-dev.zip",
|
||||||
|
"com.majinnaibu.monstercards.importers.Pf2eImporter",
|
||||||
|
".json",
|
||||||
|
"pf2e-14-dev/packs/sf2e"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -36,4 +36,7 @@ public interface MonsterDAO {
|
|||||||
|
|
||||||
@Delete
|
@Delete
|
||||||
Completable delete(Monster monster);
|
Completable delete(Monster monster);
|
||||||
|
|
||||||
|
@Query("DELETE FROM monsters")
|
||||||
|
Completable deleteAllMonsters();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,15 +4,27 @@ import androidx.annotation.NonNull;
|
|||||||
|
|
||||||
import com.majinnaibu.monstercards.AppDatabase;
|
import com.majinnaibu.monstercards.AppDatabase;
|
||||||
import com.majinnaibu.monstercards.helpers.StringHelper;
|
import com.majinnaibu.monstercards.helpers.StringHelper;
|
||||||
|
import com.majinnaibu.monstercards.models.BinderExport;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionWithCount;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonsterWithMonster;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.SearchResultItem;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.rxjava3.core.Completable;
|
import io.reactivex.rxjava3.core.Completable;
|
||||||
import io.reactivex.rxjava3.core.Flowable;
|
import io.reactivex.rxjava3.core.Flowable;
|
||||||
|
import io.reactivex.rxjava3.core.Single;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
@SuppressWarnings("ResultOfMethodCallIgnored")
|
@SuppressWarnings("ResultOfMethodCallIgnored")
|
||||||
@@ -47,6 +59,43 @@ public class MonsterRepository {
|
|||||||
.observeOn(AndroidSchedulers.mainThread());
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Flowable<List<SearchResultItem>> searchAll(String searchText) {
|
||||||
|
Flowable<List<Monster>> monstersFlowable = m_db.monsterDAO()
|
||||||
|
.getAll()
|
||||||
|
.map(monsters -> {
|
||||||
|
ArrayList<Monster> filteredMonsters = new ArrayList<>();
|
||||||
|
for (Monster monster : monsters) {
|
||||||
|
if (Helpers.monsterMatchesSearch(monster, searchText)) {
|
||||||
|
filteredMonsters.add(monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (List<Monster>) filteredMonsters;
|
||||||
|
});
|
||||||
|
|
||||||
|
Flowable<List<Collection>> collectionsFlowable = m_db.collectionDAO()
|
||||||
|
.getAll()
|
||||||
|
.map(collections -> {
|
||||||
|
ArrayList<Collection> filteredCollections = new ArrayList<>();
|
||||||
|
for (Collection collection : collections) {
|
||||||
|
if (StringHelper.isNullOrEmpty(searchText) || StringHelper.containsCaseInsensitive(collection.name, searchText)) {
|
||||||
|
filteredCollections.add(collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (List<Collection>) filteredCollections;
|
||||||
|
});
|
||||||
|
|
||||||
|
return Flowable.combineLatest(monstersFlowable, collectionsFlowable, (monsters, collections) -> {
|
||||||
|
ArrayList<SearchResultItem> results = new ArrayList<>();
|
||||||
|
for (Monster monster : monsters) {
|
||||||
|
results.add(new SearchResultItem(monster));
|
||||||
|
}
|
||||||
|
for (Collection collection : collections) {
|
||||||
|
results.add(new SearchResultItem(collection));
|
||||||
|
}
|
||||||
|
return (List<SearchResultItem>) results;
|
||||||
|
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
public Flowable<Monster> getMonster(@NonNull UUID monsterId) {
|
public Flowable<Monster> getMonster(@NonNull UUID monsterId) {
|
||||||
return m_db.monsterDAO()
|
return m_db.monsterDAO()
|
||||||
.loadAllByIds(new String[]{monsterId.toString()})
|
.loadAllByIds(new String[]{monsterId.toString()})
|
||||||
@@ -80,6 +129,396 @@ public class MonsterRepository {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Flowable<List<Collection>> getCollections() {
|
||||||
|
return m_db.collectionDAO()
|
||||||
|
.getAll()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<CollectionWithCount>> getCollectionsWithCount() {
|
||||||
|
return m_db.collectionDAO()
|
||||||
|
.getCollectionsWithCount()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<Collection> getCollection(@NonNull UUID collectionId) {
|
||||||
|
return m_db.collectionDAO()
|
||||||
|
.getById(collectionId.toString())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable saveCollection(Collection collection) {
|
||||||
|
Completable result = m_db.collectionDAO().save(collection);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable deleteCollection(Collection collection) {
|
||||||
|
Completable result = m_db.collectionDAO().delete(collection);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<Monster>> getMonstersForCollection(@NonNull UUID collectionId) {
|
||||||
|
return m_db.collectionDAO()
|
||||||
|
.getMonstersForCollection(collectionId.toString())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<CollectionMonster>> getCollectionMonstersForCollection(@NonNull UUID collectionId) {
|
||||||
|
return m_db.collectionDAO()
|
||||||
|
.getCollectionMonstersForCollection(collectionId.toString())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable addMonsterToCollection(@NonNull UUID collectionId, @NonNull UUID monsterId) {
|
||||||
|
return addMonsterToCollection(collectionId, monsterId, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable addMonsterToCollection(@NonNull UUID collectionId, @NonNull UUID monsterId, int ordinal) {
|
||||||
|
CollectionMonster collectionMonster = new CollectionMonster(collectionId, monsterId, ordinal);
|
||||||
|
Completable result = m_db.collectionDAO().addMonsterToCollection(collectionMonster);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeMonsterFromCollection(@NonNull UUID collectionId, @NonNull UUID monsterId) {
|
||||||
|
Completable result = m_db.collectionDAO().removeMonsterFromCollection(collectionId.toString(), monsterId.toString());
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeCollectionMonsterById(long junctionId) {
|
||||||
|
Completable result = m_db.collectionDAO().removeCollectionMonsterById(junctionId);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable updateCollectionMonsters(List<CollectionMonster> collectionMonsters) {
|
||||||
|
Completable result = m_db.collectionDAO().updateCollectionMonsters(collectionMonsters);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<Monster>> getDashboardMonsters() {
|
||||||
|
return m_db.dashboardDAO()
|
||||||
|
.getDashboardMonsters()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<com.majinnaibu.monstercards.models.DashboardMonsterWithMonster>> getDashboardMonstersWithMonster() {
|
||||||
|
return m_db.dashboardDAO()
|
||||||
|
.getDashboardMonstersWithMonster()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Flowable<List<DashboardMonster>> getDashboardMonsterEntries() {
|
||||||
|
return m_db.dashboardDAO()
|
||||||
|
.getDashboardMonsterEntries()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable addMonsterToDashboard(@NonNull UUID monsterId) {
|
||||||
|
DashboardMonster entry = new DashboardMonster(monsterId, 0);
|
||||||
|
Completable result = m_db.dashboardDAO().addMonsterToDashboard(entry);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable addCollectionToDashboard(@NonNull UUID collectionId) {
|
||||||
|
return m_db.collectionDAO().getMonstersForCollection(collectionId.toString())
|
||||||
|
.firstOrError()
|
||||||
|
.flatMapCompletable(monsters -> {
|
||||||
|
if (monsters.isEmpty()) {
|
||||||
|
return Completable.complete();
|
||||||
|
}
|
||||||
|
DashboardMonster[] entries = new DashboardMonster[monsters.size()];
|
||||||
|
for (int i = 0; i < monsters.size(); i++) {
|
||||||
|
entries[i] = new DashboardMonster(monsters.get(i).id, i);
|
||||||
|
}
|
||||||
|
return m_db.dashboardDAO().addMonsterToDashboard(entries);
|
||||||
|
})
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeMonsterFromDashboard(@NonNull UUID monsterId) {
|
||||||
|
Completable result = m_db.dashboardDAO().removeMonsterFromDashboard(monsterId.toString());
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeDashboardMonsterById(long id) {
|
||||||
|
Completable result = m_db.dashboardDAO().removeDashboardMonsterById(id);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable clearDashboard() {
|
||||||
|
Completable result = m_db.dashboardDAO().clearDashboard();
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable clearAllData() {
|
||||||
|
return Completable.fromAction(() -> {
|
||||||
|
m_db.dashboardDAO().clearDashboard().blockingAwait();
|
||||||
|
m_db.collectionDAO().deleteAllCollectionMonsters().blockingAwait();
|
||||||
|
m_db.collectionDAO().deleteAllCollections().blockingAwait();
|
||||||
|
m_db.monsterDAO().deleteAllMonsters().blockingAwait();
|
||||||
|
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeAllCollections() {
|
||||||
|
return Completable.fromAction(() -> {
|
||||||
|
m_db.collectionDAO().deleteAllCollectionMonsters().blockingAwait();
|
||||||
|
m_db.collectionDAO().deleteAllCollections().blockingAwait();
|
||||||
|
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable removeAllMonstersFromCollection(@NonNull UUID collectionId) {
|
||||||
|
Completable result = m_db.collectionDAO().removeAllMonstersFromCollection(collectionId.toString());
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Single<String> exportCollections() {
|
||||||
|
return m_db.collectionDAO().getAll().first(new ArrayList<>())
|
||||||
|
.map(collections -> {
|
||||||
|
List<BinderExport.CollectionExport> colExports = new ArrayList<>();
|
||||||
|
for (Collection col : collections) {
|
||||||
|
List<Monster> colMonsters = m_db.collectionDAO().getMonstersForCollection(col.id.toString())
|
||||||
|
.first(new ArrayList<>()).blockingGet();
|
||||||
|
colExports.add(new BinderExport.CollectionExport(
|
||||||
|
col.id.toString(),
|
||||||
|
col.name,
|
||||||
|
col.description,
|
||||||
|
colMonsters
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return new com.majinnaibu.monstercards.exporters.BinderExporter().exportFullBackup(colExports, null);
|
||||||
|
})
|
||||||
|
.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Single<String> exportEverything() {
|
||||||
|
return Single.zip(
|
||||||
|
m_db.collectionDAO().getAll().first(new ArrayList<>()),
|
||||||
|
m_db.monsterDAO().getAll().first(new ArrayList<>()),
|
||||||
|
m_db.dashboardDAO().getDashboardMonsters().first(new ArrayList<>()),
|
||||||
|
(collections, allMonsters, dashboardMonsters) -> {
|
||||||
|
List<BinderExport.CollectionExport> colExports = new ArrayList<>();
|
||||||
|
Set<UUID> monstersInCollections = new HashSet<>();
|
||||||
|
|
||||||
|
for (Collection col : collections) {
|
||||||
|
List<Monster> colMonsters = m_db.collectionDAO().getMonstersForCollection(col.id.toString())
|
||||||
|
.first(new ArrayList<>()).blockingGet();
|
||||||
|
for (Monster m : colMonsters) {
|
||||||
|
monstersInCollections.add(m.id);
|
||||||
|
}
|
||||||
|
colExports.add(new BinderExport.CollectionExport(
|
||||||
|
col.id.toString(),
|
||||||
|
col.name,
|
||||||
|
col.description,
|
||||||
|
colMonsters
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Monster> uncategorized = new ArrayList<>();
|
||||||
|
for (Monster m : allMonsters) {
|
||||||
|
if (!monstersInCollections.contains(m.id)) {
|
||||||
|
uncategorized.add(m);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uncategorized.isEmpty() || colExports.isEmpty()) {
|
||||||
|
colExports.add(new BinderExport.CollectionExport(
|
||||||
|
UUID.randomUUID().toString(),
|
||||||
|
colExports.isEmpty() ? "All Monsters" : "Uncategorized",
|
||||||
|
"",
|
||||||
|
colExports.isEmpty() ? allMonsters : uncategorized
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return new com.majinnaibu.monstercards.exporters.BinderExporter().exportFullBackup(colExports, dashboardMonsters);
|
||||||
|
}
|
||||||
|
).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable updateDashboardMonsters(List<DashboardMonster> items) {
|
||||||
|
Completable result = m_db.dashboardDAO().updateDashboardMonsters(items);
|
||||||
|
result.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Completable importBinder(@NonNull BinderExport binder) {
|
||||||
|
return Completable.fromAction(() -> {
|
||||||
|
// 1. Process Collections & Cards in Binder
|
||||||
|
if (binder.collections != null && !binder.collections.isEmpty()) {
|
||||||
|
List<Collection> existingCols = m_db.collectionDAO().getAll().first(new ArrayList<>()).blockingGet();
|
||||||
|
|
||||||
|
for (BinderExport.CollectionExport colExport : binder.collections) {
|
||||||
|
if (colExport == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
String colName = colExport.name != null ? colExport.name.trim() : "";
|
||||||
|
String colDesc = colExport.description != null ? colExport.description.trim() : "";
|
||||||
|
|
||||||
|
UUID colExportId = null;
|
||||||
|
if (colExport.id != null && !colExport.id.trim().isEmpty()) {
|
||||||
|
try {
|
||||||
|
colExportId = UUID.fromString(colExport.id.trim());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collection targetCollection = null;
|
||||||
|
if (colExportId != null) {
|
||||||
|
for (Collection existing : existingCols) {
|
||||||
|
if (existing.id.equals(colExportId)) {
|
||||||
|
targetCollection = existing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (targetCollection == null && !colName.isEmpty()) {
|
||||||
|
for (Collection existing : existingCols) {
|
||||||
|
if (existing.name != null && existing.name.equalsIgnoreCase(colName)) {
|
||||||
|
targetCollection = existing;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID targetCollectionId;
|
||||||
|
if (targetCollection != null) {
|
||||||
|
targetCollectionId = targetCollection.id;
|
||||||
|
if (!colDesc.isEmpty() && (targetCollection.description == null || targetCollection.description.isEmpty())) {
|
||||||
|
targetCollection.description = colDesc;
|
||||||
|
m_db.collectionDAO().save(targetCollection).blockingAwait();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Collection newCol = new Collection();
|
||||||
|
newCol.id = colExportId != null ? colExportId : UUID.randomUUID();
|
||||||
|
newCol.name = !colName.isEmpty() ? colName : "Imported Collection";
|
||||||
|
newCol.description = colDesc;
|
||||||
|
m_db.collectionDAO().save(newCol).blockingAwait();
|
||||||
|
targetCollectionId = newCol.id;
|
||||||
|
existingCols.add(newCol);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (colExport.cards != null && !colExport.cards.isEmpty()) {
|
||||||
|
List<Monster> monstersToSave = new ArrayList<>();
|
||||||
|
Map<UUID, Integer> importedCardCounts = new HashMap<>();
|
||||||
|
|
||||||
|
for (Monster card : colExport.cards) {
|
||||||
|
if (card != null) {
|
||||||
|
if (card.id == null) {
|
||||||
|
card.id = UUID.randomUUID();
|
||||||
|
}
|
||||||
|
monstersToSave.add(card);
|
||||||
|
importedCardCounts.put(card.id, getCount(importedCardCounts, card.id) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!monstersToSave.isEmpty()) {
|
||||||
|
m_db.monsterDAO().save(monstersToSave.toArray(new Monster[0])).blockingAwait();
|
||||||
|
|
||||||
|
List<Monster> existingColMonsters = m_db.collectionDAO().getMonstersForCollection(targetCollectionId.toString())
|
||||||
|
.first(new ArrayList<>()).blockingGet();
|
||||||
|
Map<UUID, Integer> existingCardCounts = new HashMap<>();
|
||||||
|
for (Monster m : existingColMonsters) {
|
||||||
|
existingCardCounts.put(m.id, getCount(existingCardCounts, m.id) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ordinal = existingColMonsters.size();
|
||||||
|
for (Map.Entry<UUID, Integer> entry : importedCardCounts.entrySet()) {
|
||||||
|
UUID monsterId = entry.getKey();
|
||||||
|
int importedCount = entry.getValue();
|
||||||
|
int existingCount = getCount(existingCardCounts, monsterId);
|
||||||
|
|
||||||
|
if (importedCount > existingCount) {
|
||||||
|
int extraCopiesNeeded = importedCount - existingCount;
|
||||||
|
for (int k = 0; k < extraCopiesNeeded; k++) {
|
||||||
|
m_db.collectionDAO().addMonsterToCollection(new CollectionMonster(targetCollectionId, monsterId, ordinal++)).blockingAwait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Process Dashboard entries in Binder if present
|
||||||
|
if (binder.dashboard != null && !binder.dashboard.isEmpty()) {
|
||||||
|
List<Monster> dashboardMonstersToSave = new ArrayList<>();
|
||||||
|
Map<UUID, Integer> importedDashboardCounts = new HashMap<>();
|
||||||
|
|
||||||
|
for (Monster card : binder.dashboard) {
|
||||||
|
if (card != null) {
|
||||||
|
if (card.id == null) {
|
||||||
|
card.id = UUID.randomUUID();
|
||||||
|
}
|
||||||
|
dashboardMonstersToSave.add(card);
|
||||||
|
importedDashboardCounts.put(card.id, getCount(importedDashboardCounts, card.id) + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!dashboardMonstersToSave.isEmpty()) {
|
||||||
|
m_db.monsterDAO().save(dashboardMonstersToSave.toArray(new Monster[0])).blockingAwait();
|
||||||
|
|
||||||
|
List<DashboardMonsterWithMonster> existingDashboard = m_db.dashboardDAO().getDashboardMonstersWithMonster()
|
||||||
|
.first(new ArrayList<>()).blockingGet();
|
||||||
|
Map<UUID, Integer> existingDashboardCounts = new HashMap<>();
|
||||||
|
int currentMaxOrdinal = 0;
|
||||||
|
for (DashboardMonsterWithMonster entry : existingDashboard) {
|
||||||
|
if (entry.monster != null) {
|
||||||
|
existingDashboardCounts.put(entry.monster.id, getCount(existingDashboardCounts, entry.monster.id) + 1);
|
||||||
|
}
|
||||||
|
if (entry.dashboardEntry != null && entry.dashboardEntry.ordinal > currentMaxOrdinal) {
|
||||||
|
currentMaxOrdinal = entry.dashboardEntry.ordinal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ordinal = currentMaxOrdinal + 1;
|
||||||
|
List<DashboardMonster> extraEntriesToAdd = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<UUID, Integer> entry : importedDashboardCounts.entrySet()) {
|
||||||
|
UUID monsterId = entry.getKey();
|
||||||
|
int importedCount = entry.getValue();
|
||||||
|
int existingCount = getCount(existingDashboardCounts, monsterId);
|
||||||
|
|
||||||
|
if (importedCount > existingCount) {
|
||||||
|
int extraNeeded = importedCount - existingCount;
|
||||||
|
for (int k = 0; k < extraNeeded; k++) {
|
||||||
|
extraEntriesToAdd.add(new DashboardMonster(monsterId, ordinal++));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!extraEntriesToAdd.isEmpty()) {
|
||||||
|
m_db.dashboardDAO().addMonsterToDashboard(extraEntriesToAdd.toArray(new DashboardMonster[0])).blockingAwait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getCount(Map<UUID, Integer> map, UUID key) {
|
||||||
|
if (map == null || key == null) return 0;
|
||||||
|
Integer val = map.get(key);
|
||||||
|
return val != null ? val : 0;
|
||||||
|
}
|
||||||
|
|
||||||
private static class Helpers {
|
private static class Helpers {
|
||||||
static boolean monsterMatchesSearch(Monster monster, String searchText) {
|
static boolean monsterMatchesSearch(Monster monster, String searchText) {
|
||||||
if (StringHelper.isNullOrEmpty(searchText)) {
|
if (StringHelper.isNullOrEmpty(searchText)) {
|
||||||
|
|||||||
@@ -21,11 +21,23 @@ public enum AbilityScore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AbilityScore valueOfString(String string) {
|
public static AbilityScore valueOfString(String string) {
|
||||||
|
if (string == null) {
|
||||||
|
return AbilityScore.STRENGTH;
|
||||||
|
}
|
||||||
|
String lower = string.trim().toLowerCase(java.util.Locale.ROOT);
|
||||||
for (AbilityScore abilityScore : values()) {
|
for (AbilityScore abilityScore : values()) {
|
||||||
if (abilityScore.stringValue.equals(string)) {
|
if (abilityScore.stringValue.equalsIgnoreCase(lower)
|
||||||
|
|| abilityScore.shortDisplayName.equalsIgnoreCase(lower)
|
||||||
|
|| abilityScore.name().equalsIgnoreCase(lower)) {
|
||||||
return abilityScore;
|
return abilityScore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (lower.startsWith("str")) return STRENGTH;
|
||||||
|
if (lower.startsWith("dex")) return DEXTERITY;
|
||||||
|
if (lower.startsWith("con")) return CONSTITUTION;
|
||||||
|
if (lower.startsWith("int")) return INTELLIGENCE;
|
||||||
|
if (lower.startsWith("wis")) return WISDOM;
|
||||||
|
if (lower.startsWith("cha")) return CHARISMA;
|
||||||
return AbilityScore.STRENGTH;
|
return AbilityScore.STRENGTH;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package com.majinnaibu.monstercards.exporters;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.majinnaibu.monstercards.models.BinderExport;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BinderExporter {
|
||||||
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportBinder(String collectionName, List<Monster> monsters) {
|
||||||
|
return exportBinder(new Collection(collectionName != null ? collectionName : "", ""), monsters, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportBinder(@Nullable Collection collection, List<Monster> monsters) {
|
||||||
|
return exportBinder(collection, monsters, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportBinder(@Nullable Collection collection, @Nullable List<Monster> monsters, @Nullable List<Monster> dashboardMonsters) {
|
||||||
|
BinderExport export = new BinderExport();
|
||||||
|
export.schema = "https://majinnaibu.com/schemas/binder.schema.json";
|
||||||
|
export.schemaVersion = 1;
|
||||||
|
|
||||||
|
if (monsters != null) {
|
||||||
|
for (Monster monster : monsters) {
|
||||||
|
monster.schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
monster.schemaVersion = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dashboardMonsters != null && !dashboardMonsters.isEmpty()) {
|
||||||
|
for (Monster monster : dashboardMonsters) {
|
||||||
|
monster.schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
monster.schemaVersion = 1;
|
||||||
|
}
|
||||||
|
export.dashboard = dashboardMonsters;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (collection != null) {
|
||||||
|
String colId = collection.id.toString();
|
||||||
|
String colName = collection.name;
|
||||||
|
String colDesc = collection.description;
|
||||||
|
|
||||||
|
BinderExport.CollectionExport col = new BinderExport.CollectionExport(
|
||||||
|
colId,
|
||||||
|
colName,
|
||||||
|
colDesc,
|
||||||
|
monsters
|
||||||
|
);
|
||||||
|
export.collections = Collections.singletonList(col);
|
||||||
|
}
|
||||||
|
return GSON.toJson(export);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportFullBackup(@Nullable List<BinderExport.CollectionExport> collections, @Nullable List<Monster> dashboardMonsters) {
|
||||||
|
BinderExport export = new BinderExport();
|
||||||
|
export.schema = "https://majinnaibu.com/schemas/binder.schema.json";
|
||||||
|
export.schemaVersion = 1;
|
||||||
|
|
||||||
|
if (collections != null) {
|
||||||
|
for (BinderExport.CollectionExport col : collections) {
|
||||||
|
if (col.cards != null) {
|
||||||
|
for (Monster m : col.cards) {
|
||||||
|
m.schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
m.schemaVersion = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export.collections = collections;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dashboardMonsters != null && !dashboardMonsters.isEmpty()) {
|
||||||
|
for (Monster m : dashboardMonsters) {
|
||||||
|
m.schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
m.schemaVersion = 1;
|
||||||
|
}
|
||||||
|
export.dashboard = dashboardMonsters;
|
||||||
|
}
|
||||||
|
|
||||||
|
return GSON.toJson(export);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.majinnaibu.monstercards.exporters;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
public class MonsterCardExporter {
|
||||||
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportCard(@NonNull Monster monster) {
|
||||||
|
monster.schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
monster.schemaVersion = 1;
|
||||||
|
return GSON.toJson(monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,287 @@
|
|||||||
|
package com.majinnaibu.monstercards.exporters;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonNull;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.Skill;
|
||||||
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Open5eExporter {
|
||||||
|
|
||||||
|
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public String exportMonster(@NonNull Monster monster) {
|
||||||
|
JsonObject root = new JsonObject();
|
||||||
|
root.addProperty("$schema", "../../../schema/entity.json");
|
||||||
|
root.addProperty("uuid", monster.id != null ? monster.id.toString() : UUID.randomUUID().toString());
|
||||||
|
root.addProperty("ruleset_id", "open5e");
|
||||||
|
root.addProperty("entity_type", "character");
|
||||||
|
root.addProperty("display_name", monster.name != null && !monster.name.isEmpty() ? monster.name : "Unnamed Entity");
|
||||||
|
root.addProperty("description", buildDescription(monster));
|
||||||
|
root.addProperty("version", "1.0.0");
|
||||||
|
root.addProperty("template_id", "stat_block");
|
||||||
|
|
||||||
|
JsonObject props = new JsonObject();
|
||||||
|
props.addProperty("name", monster.name != null ? monster.name : "");
|
||||||
|
props.addProperty("size", monster.size != null ? monster.size : "");
|
||||||
|
props.addProperty("type", monster.type != null ? monster.type : "");
|
||||||
|
props.addProperty("subtype", monster.subtype != null ? monster.subtype : "");
|
||||||
|
props.addProperty("alignment", monster.alignment != null ? monster.alignment : "");
|
||||||
|
props.addProperty("armor_class", monster.getArmorClassValue());
|
||||||
|
props.addProperty("armor_description", monster.getArmorClass());
|
||||||
|
|
||||||
|
if (monster.armorType != null && !monster.armorType.equals(ArmorType.NONE)) {
|
||||||
|
JsonObject armorObj = new JsonObject();
|
||||||
|
armorObj.addProperty("id", monster.armorType.stringValue);
|
||||||
|
armorObj.addProperty("name", monster.armorType.displayName);
|
||||||
|
armorObj.addProperty("armor_category", getArmorCategory(monster.armorType));
|
||||||
|
armorObj.addProperty("ac_base", monster.armorType.baseArmorClass);
|
||||||
|
|
||||||
|
Integer dexCap = getDexCap(monster.armorType);
|
||||||
|
if (dexCap != null) {
|
||||||
|
armorObj.addProperty("dex_cap", dexCap);
|
||||||
|
} else {
|
||||||
|
armorObj.add("dex_cap", JsonNull.INSTANCE);
|
||||||
|
}
|
||||||
|
armorObj.addProperty("stealth_disadvantage", isStealthDisadvantage(monster.armorType));
|
||||||
|
props.add("equipped_armor", armorObj);
|
||||||
|
} else {
|
||||||
|
props.add("equipped_armor", JsonNull.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monster.shieldBonus > 0) {
|
||||||
|
JsonObject shieldObj = new JsonObject();
|
||||||
|
shieldObj.addProperty("id", "shield");
|
||||||
|
shieldObj.addProperty("name", "Shield");
|
||||||
|
shieldObj.addProperty("ac_bonus", monster.shieldBonus);
|
||||||
|
props.add("equipped_shield", shieldObj);
|
||||||
|
} else {
|
||||||
|
props.add("equipped_shield", JsonNull.INSTANCE);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject hpObj = new JsonObject();
|
||||||
|
hpObj.addProperty("max", monster.getHitPointsValue());
|
||||||
|
hpObj.addProperty("current", monster.getHitPointsValue());
|
||||||
|
hpObj.addProperty("formula", monster.hasCustomHP && !monster.customHPDescription.isEmpty() ? monster.customHPDescription : monster.getHitPoints());
|
||||||
|
hpObj.addProperty("hit_dice", monster.hitDice + "d8");
|
||||||
|
props.add("hit_points", hpObj);
|
||||||
|
|
||||||
|
props.addProperty("speed", monster.walkSpeed);
|
||||||
|
props.addProperty("speed_desc", monster.getSpeedText());
|
||||||
|
props.addProperty("challenge_rating", monster.getChallengeRatingDescription());
|
||||||
|
props.addProperty("cr", monster.challengeRating != null ? monster.challengeRating.stringValue : "1");
|
||||||
|
|
||||||
|
JsonObject abilitiesObj = new JsonObject();
|
||||||
|
abilitiesObj.addProperty("strength", monster.strengthScore);
|
||||||
|
abilitiesObj.addProperty("dexterity", monster.dexterityScore);
|
||||||
|
abilitiesObj.addProperty("constitution", monster.constitutionScore);
|
||||||
|
abilitiesObj.addProperty("intelligence", monster.intelligenceScore);
|
||||||
|
abilitiesObj.addProperty("wisdom", monster.wisdomScore);
|
||||||
|
abilitiesObj.addProperty("charisma", monster.charismaScore);
|
||||||
|
props.add("abilities", abilitiesObj);
|
||||||
|
|
||||||
|
if (monster.playerName != null && !monster.playerName.isEmpty()) props.addProperty("player_name", monster.playerName);
|
||||||
|
if (monster.background != null && !monster.background.isEmpty()) props.addProperty("background", monster.background);
|
||||||
|
if (monster.personalityTraits != null && !monster.personalityTraits.isEmpty()) props.addProperty("personality_traits", monster.personalityTraits);
|
||||||
|
if (monster.ideals != null && !monster.ideals.isEmpty()) props.addProperty("ideals", monster.ideals);
|
||||||
|
if (monster.bonds != null && !monster.bonds.isEmpty()) props.addProperty("bonds", monster.bonds);
|
||||||
|
if (monster.flaws != null && !monster.flaws.isEmpty()) props.addProperty("flaws", monster.flaws);
|
||||||
|
|
||||||
|
if (hasDetails(monster)) {
|
||||||
|
JsonObject detailsObj = new JsonObject();
|
||||||
|
if (monster.age != null && !monster.age.isEmpty()) detailsObj.addProperty("age", monster.age);
|
||||||
|
if (monster.height != null && !monster.height.isEmpty()) detailsObj.addProperty("height", monster.height);
|
||||||
|
if (monster.weight != null && !monster.weight.isEmpty()) detailsObj.addProperty("weight", monster.weight);
|
||||||
|
if (monster.eyes != null && !monster.eyes.isEmpty()) detailsObj.addProperty("eyes", monster.eyes);
|
||||||
|
if (monster.skin != null && !monster.skin.isEmpty()) detailsObj.addProperty("skin", monster.skin);
|
||||||
|
if (monster.hair != null && !monster.hair.isEmpty()) detailsObj.addProperty("hair", monster.hair);
|
||||||
|
if (monster.appearance != null && !monster.appearance.isEmpty()) detailsObj.addProperty("appearance", monster.appearance);
|
||||||
|
if (monster.backstory != null && !monster.backstory.isEmpty()) detailsObj.addProperty("backstory", monster.backstory);
|
||||||
|
if (monster.alliesAndOrganizations != null && !monster.alliesAndOrganizations.isEmpty()) detailsObj.addProperty("allies_and_organizations", monster.alliesAndOrganizations);
|
||||||
|
props.add("character_details", detailsObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonArray savesArr = buildSavingThrowsArray(monster);
|
||||||
|
if (savesArr.size() > 0) props.add("saving_throws", savesArr);
|
||||||
|
|
||||||
|
JsonArray skillsArr = buildSkillsArray(monster);
|
||||||
|
if (skillsArr.size() > 0) props.add("skills", skillsArr);
|
||||||
|
|
||||||
|
if (monster.damageImmunities != null && !monster.damageImmunities.isEmpty()) props.add("damage_immunities", toJsonArray(monster.damageImmunities));
|
||||||
|
if (monster.damageResistances != null && !monster.damageResistances.isEmpty()) props.add("damage_resistances", toJsonArray(monster.damageResistances));
|
||||||
|
if (monster.damageVulnerabilities != null && !monster.damageVulnerabilities.isEmpty()) props.add("damage_vulnerabilities", toJsonArray(monster.damageVulnerabilities));
|
||||||
|
if (monster.conditionImmunities != null && !monster.conditionImmunities.isEmpty()) props.add("condition_immunities", toJsonArray(monster.conditionImmunities));
|
||||||
|
|
||||||
|
props.addProperty("senses", monster.getSensesDescription());
|
||||||
|
|
||||||
|
if (monster.languages != null && !monster.languages.isEmpty()) {
|
||||||
|
JsonArray langArr = new JsonArray();
|
||||||
|
for (Language l : monster.languages) {
|
||||||
|
if (l != null && l.getName() != null && !l.getName().isEmpty()) {
|
||||||
|
langArr.add(l.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
props.add("languages", langArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monster.abilities != null && !monster.abilities.isEmpty()) props.add("traits", traitsToJsonArray(monster.abilities));
|
||||||
|
if (monster.actions != null && !monster.actions.isEmpty()) props.add("actions", traitsToJsonArray(monster.actions));
|
||||||
|
if (monster.bonusActions != null && !monster.bonusActions.isEmpty()) props.add("bonus_actions", traitsToJsonArray(monster.bonusActions));
|
||||||
|
if (monster.reactions != null && !monster.reactions.isEmpty()) props.add("reactions", traitsToJsonArray(monster.reactions));
|
||||||
|
if (monster.legendaryActions != null && !monster.legendaryActions.isEmpty()) props.add("legendary_actions", traitsToJsonArray(monster.legendaryActions));
|
||||||
|
if (monster.legendaryActionsDescription != null && !monster.legendaryActionsDescription.isEmpty()) props.addProperty("legendary_desc", monster.legendaryActionsDescription);
|
||||||
|
if (monster.lairActions != null && !monster.lairActions.isEmpty()) props.add("lair_actions", traitsToJsonArray(monster.lairActions));
|
||||||
|
if (monster.lairActionsDescription != null && !monster.lairActionsDescription.isEmpty()) props.addProperty("lair_desc", monster.lairActionsDescription);
|
||||||
|
if (monster.regionalActions != null && !monster.regionalActions.isEmpty()) props.add("regional_effects", traitsToJsonArray(monster.regionalActions));
|
||||||
|
if (monster.regionalActionsDescription != null && !monster.regionalActionsDescription.isEmpty()) props.addProperty("regional_desc", monster.regionalActionsDescription);
|
||||||
|
if (monster.mythicActions != null && !monster.mythicActions.isEmpty()) props.add("mythic_actions", traitsToJsonArray(monster.mythicActions));
|
||||||
|
if (monster.mythicActionsDescription != null && !monster.mythicActionsDescription.isEmpty()) props.addProperty("mythic_desc", monster.mythicActionsDescription);
|
||||||
|
|
||||||
|
if (monster.sourceUrl != null && !monster.sourceUrl.isEmpty()) props.addProperty("source_url", monster.sourceUrl);
|
||||||
|
|
||||||
|
root.add("properties", props);
|
||||||
|
return GSON.toJson(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getArmorCategory(ArmorType armorType) {
|
||||||
|
switch (armorType) {
|
||||||
|
case PADDED:
|
||||||
|
case LEATHER:
|
||||||
|
case STUDDED_LEATHER:
|
||||||
|
return "light";
|
||||||
|
case HIDE:
|
||||||
|
case CHAIN_SHIRT:
|
||||||
|
case SCALE_MAIL:
|
||||||
|
case BREASTPLATE:
|
||||||
|
case HALF_PLATE:
|
||||||
|
return "medium";
|
||||||
|
case RING_MAIL:
|
||||||
|
case CHAIN_MAIL:
|
||||||
|
case SPLINT_MAIL:
|
||||||
|
case PLATE_MAIL:
|
||||||
|
return "heavy";
|
||||||
|
default:
|
||||||
|
return "natural";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer getDexCap(ArmorType armorType) {
|
||||||
|
switch (armorType) {
|
||||||
|
case HIDE:
|
||||||
|
case CHAIN_SHIRT:
|
||||||
|
case SCALE_MAIL:
|
||||||
|
case BREASTPLATE:
|
||||||
|
case HALF_PLATE:
|
||||||
|
return 2;
|
||||||
|
case RING_MAIL:
|
||||||
|
case CHAIN_MAIL:
|
||||||
|
case SPLINT_MAIL:
|
||||||
|
case PLATE_MAIL:
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isStealthDisadvantage(ArmorType armorType) {
|
||||||
|
switch (armorType) {
|
||||||
|
case PADDED:
|
||||||
|
case SCALE_MAIL:
|
||||||
|
case HALF_PLATE:
|
||||||
|
case RING_MAIL:
|
||||||
|
case CHAIN_MAIL:
|
||||||
|
case SPLINT_MAIL:
|
||||||
|
case PLATE_MAIL:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean hasDetails(Monster monster) {
|
||||||
|
return (monster.age != null && !monster.age.isEmpty()) ||
|
||||||
|
(monster.height != null && !monster.height.isEmpty()) ||
|
||||||
|
(monster.weight != null && !monster.weight.isEmpty()) ||
|
||||||
|
(monster.eyes != null && !monster.eyes.isEmpty()) ||
|
||||||
|
(monster.skin != null && !monster.skin.isEmpty()) ||
|
||||||
|
(monster.hair != null && !monster.hair.isEmpty()) ||
|
||||||
|
(monster.appearance != null && !monster.appearance.isEmpty()) ||
|
||||||
|
(monster.backstory != null && !monster.backstory.isEmpty()) ||
|
||||||
|
(monster.alliesAndOrganizations != null && !monster.alliesAndOrganizations.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String buildDescription(Monster monster) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (monster.size != null && !monster.size.isEmpty()) sb.append(monster.size).append(" ");
|
||||||
|
if (monster.type != null && !monster.type.isEmpty()) sb.append(monster.type);
|
||||||
|
if (monster.subtype != null && !monster.subtype.isEmpty()) sb.append(" (").append(monster.subtype).append(")");
|
||||||
|
if (monster.alignment != null && !monster.alignment.isEmpty()) sb.append(", ").append(monster.alignment);
|
||||||
|
return sb.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonArray buildSavingThrowsArray(Monster monster) {
|
||||||
|
JsonArray arr = new JsonArray();
|
||||||
|
checkSave(arr, "Strength", monster.getSavingThrowProficiencyType(AbilityScore.STRENGTH), monster.getAbilityModifier(AbilityScore.STRENGTH) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.STRENGTH)));
|
||||||
|
checkSave(arr, "Dexterity", monster.getSavingThrowProficiencyType(AbilityScore.DEXTERITY), monster.getAbilityModifier(AbilityScore.DEXTERITY) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.DEXTERITY)));
|
||||||
|
checkSave(arr, "Constitution", monster.getSavingThrowProficiencyType(AbilityScore.CONSTITUTION), monster.getAbilityModifier(AbilityScore.CONSTITUTION) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.CONSTITUTION)));
|
||||||
|
checkSave(arr, "Intelligence", monster.getSavingThrowProficiencyType(AbilityScore.INTELLIGENCE), monster.getAbilityModifier(AbilityScore.INTELLIGENCE) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.INTELLIGENCE)));
|
||||||
|
checkSave(arr, "Wisdom", monster.getSavingThrowProficiencyType(AbilityScore.WISDOM), monster.getAbilityModifier(AbilityScore.WISDOM) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.WISDOM)));
|
||||||
|
checkSave(arr, "Charisma", monster.getSavingThrowProficiencyType(AbilityScore.CHARISMA), monster.getAbilityModifier(AbilityScore.CHARISMA) + monster.getProficiencyBonus(monster.getSavingThrowProficiencyType(AbilityScore.CHARISMA)));
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSave(JsonArray arr, String statName, ProficiencyType prof, int bonus) {
|
||||||
|
if (prof != null && !prof.equals(ProficiencyType.NONE)) {
|
||||||
|
arr.add(String.format(Locale.ROOT, "%s %+d", statName, bonus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonArray buildSkillsArray(Monster monster) {
|
||||||
|
JsonArray arr = new JsonArray();
|
||||||
|
if (monster.skills != null) {
|
||||||
|
for (Skill s : monster.skills) {
|
||||||
|
if (s != null && s.proficiencyType != null && !s.proficiencyType.equals(ProficiencyType.NONE)) {
|
||||||
|
int bonus = s.getSkillBonus(monster);
|
||||||
|
arr.add(String.format(Locale.ROOT, "%s %+d", s.name.toLowerCase(Locale.ROOT), bonus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonArray toJsonArray(Collection<String> items) {
|
||||||
|
JsonArray arr = new JsonArray();
|
||||||
|
for (String s : items) {
|
||||||
|
if (s != null && !s.isEmpty()) arr.add(s);
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JsonArray traitsToJsonArray(List<Trait> traits) {
|
||||||
|
JsonArray arr = new JsonArray();
|
||||||
|
for (Trait t : traits) {
|
||||||
|
if (t != null && t.name != null && !t.name.isEmpty()) {
|
||||||
|
JsonObject obj = new JsonObject();
|
||||||
|
obj.addProperty("name", t.name);
|
||||||
|
obj.addProperty("desc", t.description != null ? t.description : "");
|
||||||
|
arr.add(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,311 +1,86 @@
|
|||||||
package com.majinnaibu.monstercards.helpers;
|
package com.majinnaibu.monstercards.helpers;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.JsonPrimitive;
|
import com.majinnaibu.monstercards.importers.DnDBeyondImporter;
|
||||||
import com.majinnaibu.monstercards.data.converters.ArmorTypeConverter;
|
import com.majinnaibu.monstercards.importers.EntityImporter;
|
||||||
import com.majinnaibu.monstercards.data.converters.ChallengeRatingConverter;
|
import com.majinnaibu.monstercards.importers.MonsterJsonImporter;
|
||||||
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
import com.majinnaibu.monstercards.importers.Open5eImporter;
|
||||||
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
import com.majinnaibu.monstercards.importers.TetraCubeMonsterImporter;
|
||||||
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
|
||||||
import com.majinnaibu.monstercards.models.Language;
|
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.models.Skill;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
import com.majinnaibu.monstercards.models.Trait;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class MonsterImportHelper {
|
public class MonsterImportHelper {
|
||||||
|
private static final List<EntityImporter<Monster>> IMPORTERS = new ArrayList<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
IMPORTERS.add(new TetraCubeMonsterImporter());
|
||||||
|
IMPORTERS.add(new MonsterJsonImporter());
|
||||||
|
IMPORTERS.add(new Open5eImporter());
|
||||||
|
IMPORTERS.add(new DnDBeyondImporter());
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
public static Monster fromJSON(String json) {
|
public static Monster fromJSON(String json) {
|
||||||
JsonObject rootDict = JsonParser.parseString(json).getAsJsonObject();
|
return fromJSON(json, null);
|
||||||
|
|
||||||
Monster monster = new Monster();
|
|
||||||
monster.name = Helpers.getString(rootDict, "name");
|
|
||||||
monster.size = Helpers.getString(rootDict, "size");
|
|
||||||
monster.type = Helpers.getString(rootDict, "type");
|
|
||||||
monster.subtype = Helpers.getString(rootDict, "tag");
|
|
||||||
monster.alignment = Helpers.getString(rootDict, "alignment");
|
|
||||||
monster.hitDice = Helpers.getInt(rootDict, "hitDice");
|
|
||||||
monster.armorType = ArmorTypeConverter.armorTypeFromStringValue(Helpers.getString(rootDict, "armorName"));
|
|
||||||
monster.shieldBonus = Helpers.getInt(rootDict, "shieldBonus");
|
|
||||||
monster.naturalArmorBonus = Helpers.getInt(rootDict, "natArmorBonus");
|
|
||||||
monster.otherArmorDescription = Helpers.getString(rootDict, "otherArmorDesc");
|
|
||||||
monster.walkSpeed = Helpers.getInt(rootDict, "speed");
|
|
||||||
monster.burrowSpeed = Helpers.getInt(rootDict, "burrowSpeed");
|
|
||||||
monster.climbSpeed = Helpers.getInt(rootDict, "climbSpeed");
|
|
||||||
monster.flySpeed = Helpers.getInt(rootDict, "flySpeed");
|
|
||||||
monster.canHover = Helpers.getBool(rootDict, "hover");
|
|
||||||
monster.swimSpeed = Helpers.getInt(rootDict, "swimSpeed");
|
|
||||||
monster.hasCustomHP = Helpers.getBool(rootDict, "customHP");
|
|
||||||
monster.hasCustomSpeed = Helpers.getBool(rootDict, "customSpeed");
|
|
||||||
monster.customHPDescription = Helpers.getString(rootDict, "hpText");
|
|
||||||
monster.customSpeedDescription = Helpers.getString(rootDict, "speedDesc");
|
|
||||||
monster.strengthScore = Helpers.getInt(rootDict, "strPoints");
|
|
||||||
monster.dexterityScore = Helpers.getInt(rootDict, "dexPoints");
|
|
||||||
monster.constitutionScore = Helpers.getInt(rootDict, "conPoints");
|
|
||||||
monster.intelligenceScore = Helpers.getInt(rootDict, "intPoints");
|
|
||||||
monster.wisdomScore = Helpers.getInt(rootDict, "wisPoints");
|
|
||||||
monster.charismaScore = Helpers.getInt(rootDict, "chaPoints");
|
|
||||||
Helpers.addSense(monster, rootDict, "blindsight");
|
|
||||||
// Helpers.getBool(rootDict, "blind");
|
|
||||||
Helpers.addSense(monster, rootDict, "darkvision");
|
|
||||||
Helpers.addSense(monster, rootDict, "tremorsense");
|
|
||||||
Helpers.addSense(monster, rootDict, "truesight");
|
|
||||||
monster.telepathyRange = Helpers.getInt(rootDict, "telepathy");
|
|
||||||
monster.challengeRating = ChallengeRatingConverter.challengeRatingFromStringValue(Helpers.getString(rootDict, "cr"));
|
|
||||||
monster.customChallengeRatingDescription = Helpers.getString(rootDict, "customCr");
|
|
||||||
monster.customProficiencyBonus = Helpers.getInt(rootDict, "customProf");
|
|
||||||
// Helpers.getBool(rootDict, "isLegendary");
|
|
||||||
// Helpers.getString(rootDict, "legendariesDescription");
|
|
||||||
// Helpers.getBool(rootDict, "isLair");
|
|
||||||
// Helpers.getString(rootDict, "lairDescription");
|
|
||||||
// Helpers.getString(rootDict, "lairDescriptionEnd");
|
|
||||||
// Helpers.getBool(rootDict, "isRegional");
|
|
||||||
// Helpers.getString(rootDict, "regionalDescription");
|
|
||||||
// Helpers.getString(rootDict, "regionalDescriptionEnd");
|
|
||||||
// properties: []
|
|
||||||
monster.abilities = Helpers.getListOfTraits(rootDict, "abilities");
|
|
||||||
monster.actions = Helpers.getListOfTraits(rootDict, "actions");
|
|
||||||
monster.reactions = Helpers.getListOfTraits(rootDict, "reactions");
|
|
||||||
monster.legendaryActions = Helpers.getListOfTraits(rootDict, "legendaries");
|
|
||||||
monster.lairActions = Helpers.getListOfTraits(rootDict, "lairs");
|
|
||||||
monster.regionalActions = Helpers.getListOfTraits(rootDict, "regionals");
|
|
||||||
Helpers.addSavingThrows(monster, rootDict);
|
|
||||||
// skills: []
|
|
||||||
monster.skills = Helpers.getSetOfSkills(rootDict);
|
|
||||||
// damagetypes: []
|
|
||||||
// specialdamage: []
|
|
||||||
monster.damageImmunities = Helpers.getSetOfDamageTypes(rootDict, "damageTypes", "i");
|
|
||||||
monster.damageImmunities.addAll(Helpers.getSetOfDamageTypes(rootDict, "specialdamage", "i"));
|
|
||||||
monster.damageResistances = Helpers.getSetOfDamageTypes(rootDict, "damageTypes", "r");
|
|
||||||
monster.damageResistances.addAll(Helpers.getSetOfDamageTypes(rootDict, "specialdamage", "r"));
|
|
||||||
monster.damageVulnerabilities = Helpers.getSetOfDamageTypes(rootDict, "damageTypes", "v");
|
|
||||||
monster.damageVulnerabilities.addAll(Helpers.getSetOfDamageTypes(rootDict, "specialdamage", "v"));
|
|
||||||
// conditions: []
|
|
||||||
monster.conditionImmunities = Helpers.getSetOfDamageTypes(rootDict, "conditions");
|
|
||||||
// languages: []
|
|
||||||
monster.languages = Helpers.getSetOfLanguages(rootDict, "languages");
|
|
||||||
// understandsBut: ""
|
|
||||||
monster.understandsButDescription = Helpers.getString(rootDict, "understandsBut");
|
|
||||||
// shortName: ""
|
|
||||||
// doubleColumns: true
|
|
||||||
// separationPoint: -1
|
|
||||||
// damage: []
|
|
||||||
// pluralName: ""
|
|
||||||
|
|
||||||
return monster;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static class Helpers {
|
public static Monster fromJSON(String json, @Nullable String fileName) {
|
||||||
public static String getString(JsonObject dict, String name) {
|
if (json == null || json.trim().isEmpty()) {
|
||||||
return getString(dict, name, "");
|
throw new IllegalArgumentException("JSON payload is null or empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getString(@NonNull JsonObject dict, String name, String defaultValue) {
|
// 1. Check for explicit $schema reference matching monster-card or tetracube schema
|
||||||
if (dict.has(name)) {
|
try {
|
||||||
return dict.get(name).getAsString();
|
JsonElement el = JsonParser.parseString(json);
|
||||||
}
|
if (el.isJsonObject()) {
|
||||||
|
JsonObject obj = el.getAsJsonObject();
|
||||||
return defaultValue;
|
if (obj.has("$schema")) {
|
||||||
}
|
String schemaVal = obj.get("$schema").getAsString();
|
||||||
|
if (schemaVal.contains("monster-card.schema.json")) {
|
||||||
public static int getInt(JsonObject dict, String name) {
|
return new MonsterJsonImporter().parse(json);
|
||||||
return getInt(dict, name, 0);
|
} else if (schemaVal.contains("tetracube-monster.schema.json")) {
|
||||||
}
|
return new TetraCubeMonsterImporter().parse(json);
|
||||||
|
|
||||||
public static int getInt(@NonNull JsonObject dict, String name, int defaultValue) {
|
|
||||||
if (dict.has(name)) {
|
|
||||||
JsonElement element = dict.get(name);
|
|
||||||
if (element.isJsonPrimitive()) {
|
|
||||||
JsonPrimitive rawValue = element.getAsJsonPrimitive();
|
|
||||||
if (rawValue.isNumber()) {
|
|
||||||
return rawValue.getAsInt();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return rawValue.getAsInt();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return defaultValue;
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Error checking $schema reference tag", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean getBool(JsonObject dict, String name) {
|
// 2. If filename ends in .monster, try TetraCube importer first
|
||||||
return getBool(dict, name, false);
|
String lowerFileName = fileName != null ? fileName.toLowerCase(Locale.ROOT) : "";
|
||||||
}
|
boolean isMonsterFile = lowerFileName.endsWith(".monster") || lowerFileName.endsWith(".monster.txt");
|
||||||
|
if (isMonsterFile) {
|
||||||
public static boolean getBool(@NonNull JsonObject dict, String name, boolean defaultValue) {
|
TetraCubeMonsterImporter tetraImporter = new TetraCubeMonsterImporter();
|
||||||
if (dict.has(name)) {
|
if (tetraImporter.canImport(json)) {
|
||||||
JsonElement element = dict.get(name);
|
try {
|
||||||
if (element.isJsonPrimitive()) {
|
return tetraImporter.parse(json);
|
||||||
JsonPrimitive rawValue = element.getAsJsonPrimitive();
|
} catch (Exception e) {
|
||||||
if (rawValue.isBoolean()) {
|
Logger.logError("TetraCube importer failed for .monster file: " + fileName, e);
|
||||||
return rawValue.getAsBoolean();
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
return rawValue.getAsBoolean();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static String formatDistance(String name, int distance) {
|
|
||||||
// TODO: consider moving this to a string resource so it can be localized
|
|
||||||
return String.format(Locale.getDefault(), "%s %d ft.", name, distance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addSense(Monster monster, JsonObject root, String name) {
|
|
||||||
int distance = Helpers.getInt(root, name);
|
|
||||||
if (distance > 0) {
|
|
||||||
monster.senses.add(Helpers.formatDistance(name, distance));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static List<Trait> getListOfTraits(@NonNull JsonObject dict, String name) {
|
|
||||||
ArrayList<Trait> traits = new ArrayList<>();
|
|
||||||
if (dict.has(name)) {
|
|
||||||
JsonElement arrayElement = dict.get(name);
|
|
||||||
if (arrayElement.isJsonArray()) {
|
|
||||||
JsonArray array = arrayElement.getAsJsonArray();
|
|
||||||
int size = array.size();
|
|
||||||
for (int index = 0; index < size; index++) {
|
|
||||||
JsonElement jsonElement = array.get(index);
|
|
||||||
if (jsonElement.isJsonObject()) {
|
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
||||||
String traitName = Helpers.getString(jsonObject, "name");
|
|
||||||
String description = Helpers.getString(jsonObject, "desc");
|
|
||||||
Trait trait = new Trait(traitName, description);
|
|
||||||
traits.add(trait);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return traits;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addSavingThrows(Monster monster, @NonNull JsonObject root) {
|
|
||||||
if (root.has("sthrows")) {
|
|
||||||
JsonElement arrayElement = root.get("sthrows");
|
|
||||||
if (arrayElement.isJsonArray()) {
|
|
||||||
JsonArray array = arrayElement.getAsJsonArray();
|
|
||||||
int size = array.size();
|
|
||||||
for (int index = 0; index < size; index++) {
|
|
||||||
JsonElement jsonElement = array.get(index);
|
|
||||||
if (jsonElement.isJsonObject()) {
|
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
||||||
String name = Helpers.getString(jsonObject, "name");
|
|
||||||
if ("str".equals(name)) {
|
|
||||||
monster.strengthSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
} else if ("dex".equals(name)) {
|
|
||||||
monster.dexteritySavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
} else if ("con".equals(name)) {
|
|
||||||
monster.constitutionSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
} else if ("int".equals(name)) {
|
|
||||||
monster.intelligenceSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
} else if ("wis".equals(name)) {
|
|
||||||
monster.wisdomSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
} else if ("cha".equals(name)) {
|
|
||||||
monster.charismaSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
// 3. Fallback to current importer detection chain
|
||||||
public static Set<Skill> getSetOfSkills(@NonNull JsonObject root) {
|
for (EntityImporter<Monster> importer : IMPORTERS) {
|
||||||
HashSet<Skill> skills = new HashSet<>();
|
if (importer.canImport(json)) {
|
||||||
if (root.has("skills")) {
|
try {
|
||||||
JsonElement arrayElement = root.get("skills");
|
return importer.parse(json);
|
||||||
if (arrayElement.isJsonArray()) {
|
} catch (Exception e) {
|
||||||
JsonArray array = arrayElement.getAsJsonArray();
|
Logger.logError("Importer " + importer.getClass().getSimpleName() + " failed", e);
|
||||||
int size = array.size();
|
|
||||||
for (int index = 0; index < size; index++) {
|
|
||||||
JsonElement jsonElement = array.get(index);
|
|
||||||
if (jsonElement.isJsonObject()) {
|
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
||||||
String name = Helpers.getString(jsonObject, "name");
|
|
||||||
String stat = Helpers.getString(jsonObject, "stat");
|
|
||||||
String note = Helpers.getString(jsonObject, "note");
|
|
||||||
|
|
||||||
Skill skill = new Skill(name, AbilityScore.valueOfString(stat), AdvantageType.NONE, " (ex)".equals(note) ? ProficiencyType.EXPERTISE : ProficiencyType.PROFICIENT);
|
|
||||||
skills.add(skill);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return skills;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static Set<String> getSetOfDamageTypes(JsonObject rootDict, String name) {
|
|
||||||
return getSetOfDamageTypes(rootDict, name, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static Set<String> getSetOfDamageTypes(@NonNull JsonObject root, String name, String type) {
|
|
||||||
HashSet<String> damageTypes = new HashSet<>();
|
|
||||||
if (root.has(name)) {
|
|
||||||
JsonElement arrayElement = root.get(name);
|
|
||||||
if (arrayElement.isJsonArray()) {
|
|
||||||
JsonArray array = arrayElement.getAsJsonArray();
|
|
||||||
int size = array.size();
|
|
||||||
for (int index = 0; index < size; index++) {
|
|
||||||
JsonElement jsonElement = array.get(index);
|
|
||||||
if (jsonElement.isJsonObject()) {
|
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
||||||
String dtName = Helpers.getString(jsonObject, "name");
|
|
||||||
String dtType = Helpers.getString(jsonObject, "type");
|
|
||||||
if (type == null || type.equals(dtType)) {
|
|
||||||
damageTypes.add(dtName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return damageTypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
public static Set<Language> getSetOfLanguages(@NonNull JsonObject root, String name) {
|
|
||||||
HashSet<Language> languages = new HashSet<>();
|
|
||||||
if (root.has(name)) {
|
|
||||||
JsonElement arrayElement = root.get(name);
|
|
||||||
if (arrayElement.isJsonArray()) {
|
|
||||||
JsonArray array = arrayElement.getAsJsonArray();
|
|
||||||
int size = array.size();
|
|
||||||
for (int index = 0; index < size; index++) {
|
|
||||||
JsonElement jsonElement = array.get(index);
|
|
||||||
if (jsonElement.isJsonObject()) {
|
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
|
||||||
String languageName = Helpers.getString(jsonObject, "name");
|
|
||||||
boolean canSpeak = Helpers.getBool(jsonObject, "speaks");
|
|
||||||
Language language = new Language(languageName, canSpeak);
|
|
||||||
languages.add(language);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return languages;
|
|
||||||
}
|
}
|
||||||
|
throw new IllegalArgumentException("No importer found capable of parsing the given JSON payload.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.models.BinderExport;
|
||||||
|
|
||||||
|
public class BinderImporter implements EntityImporter<BinderExport> {
|
||||||
|
|
||||||
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
try {
|
||||||
|
JsonElement el = JsonParser.parseString(input);
|
||||||
|
if (el.isJsonObject()) {
|
||||||
|
JsonObject obj = el.getAsJsonObject();
|
||||||
|
if (obj.has("$schema")) {
|
||||||
|
String schemaVal = obj.get("$schema").getAsString();
|
||||||
|
if (schemaVal.contains("binder.schema.json")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj.has("collections") && obj.get("collections").isJsonArray();
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public BinderExport parse(@NonNull String input) throws Exception {
|
||||||
|
BinderExport binder = GSON.fromJson(input, BinderExport.class);
|
||||||
|
if (binder == null || binder.collections == null) {
|
||||||
|
throw new IllegalArgumentException("Failed to deserialize Binder JSON");
|
||||||
|
}
|
||||||
|
return binder;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,418 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.Skill;
|
||||||
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
|
||||||
|
public class DnDBeyondImporter implements EntityImporter<Monster> {
|
||||||
|
|
||||||
|
private static final Pattern DNDBEYOND_URL_PATTERN = Pattern.compile("https?://(?:www\\.)?dndbeyond\\.com/characters/(\\d+)(?:/([a-zA-Z0-9]+))?", Pattern.CASE_INSENSITIVE);
|
||||||
|
private static final Pattern CHARACTER_ID_PATTERN = Pattern.compile("^\\d+$");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
String trimmed = input.trim();
|
||||||
|
if (trimmed.isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (DNDBEYOND_URL_PATTERN.matcher(trimmed).find() || CHARACTER_ID_PATTERN.matcher(trimmed).matches()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JsonElement element = JsonParser.parseString(trimmed);
|
||||||
|
if (element.isJsonObject()) {
|
||||||
|
JsonObject root = element.getAsJsonObject();
|
||||||
|
if (root.has("data") && root.getAsJsonObject("data").has("baseHitPoints")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Monster parse(@NonNull String input) throws Exception {
|
||||||
|
String trimmed = input.trim();
|
||||||
|
JsonObject characterData;
|
||||||
|
String sourceUrl = "";
|
||||||
|
|
||||||
|
if (trimmed.startsWith("{")) {
|
||||||
|
JsonObject root = JsonParser.parseString(trimmed).getAsJsonObject();
|
||||||
|
characterData = root.has("data") ? root.getAsJsonObject("data") : root;
|
||||||
|
} else {
|
||||||
|
String characterId = extractCharacterId(trimmed);
|
||||||
|
if (characterId == null) {
|
||||||
|
throw new IllegalArgumentException("Could not extract D&D Beyond character ID from input: " + input);
|
||||||
|
}
|
||||||
|
sourceUrl = trimmed.startsWith("http") ? trimmed : "https://www.dndbeyond.com/characters/" + characterId;
|
||||||
|
String jsonPayload = fetchCharacterJson(characterId);
|
||||||
|
JsonObject root = JsonParser.parseString(jsonPayload).getAsJsonObject();
|
||||||
|
if (!root.has("data") || root.get("data").isJsonNull()) {
|
||||||
|
throw new IllegalArgumentException("D&D Beyond response did not contain character data.");
|
||||||
|
}
|
||||||
|
characterData = root.getAsJsonObject("data");
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildMonsterFromCharacterData(characterData, sourceUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static String extractCharacterId(@NonNull String input) {
|
||||||
|
String trimmed = input.trim();
|
||||||
|
Matcher urlMatcher = DNDBEYOND_URL_PATTERN.matcher(trimmed);
|
||||||
|
if (urlMatcher.find()) {
|
||||||
|
return urlMatcher.group(1);
|
||||||
|
}
|
||||||
|
if (CHARACTER_ID_PATTERN.matcher(trimmed).matches()) {
|
||||||
|
return trimmed;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private String fetchCharacterJson(@NonNull String characterId) throws Exception {
|
||||||
|
String serviceUrl = "https://character-service.dndbeyond.com/character/v5/character/" + characterId + "?includeCustomItems=true";
|
||||||
|
URL url = new URL(serviceUrl);
|
||||||
|
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Android; Mobile)");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setConnectTimeout(10000);
|
||||||
|
conn.setReadTimeout(10000);
|
||||||
|
|
||||||
|
int code = conn.getResponseCode();
|
||||||
|
if (code != 200) {
|
||||||
|
throw new IllegalStateException("D&D Beyond service returned HTTP " + code);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try (InputStream in = conn.getInputStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private Monster buildMonsterFromCharacterData(@NonNull JsonObject data, @NonNull String sourceUrl) {
|
||||||
|
Monster monster = new Monster();
|
||||||
|
monster.sourceUrl = sourceUrl;
|
||||||
|
|
||||||
|
String rawName = getString(data, "name");
|
||||||
|
if (rawName.startsWith("\"") && rawName.endsWith("\"") && rawName.length() > 1) {
|
||||||
|
rawName = rawName.substring(1, rawName.length() - 1);
|
||||||
|
}
|
||||||
|
monster.name = rawName.isEmpty() ? "D&D Beyond Character" : rawName;
|
||||||
|
|
||||||
|
monster.size = "Medium";
|
||||||
|
monster.type = "Humanoid";
|
||||||
|
|
||||||
|
parseClassesAndLevel(data, monster);
|
||||||
|
parseStats(data, monster);
|
||||||
|
parseHitPoints(data, monster);
|
||||||
|
parseSpeedAndSenses(data, monster);
|
||||||
|
parseModifiers(data, monster);
|
||||||
|
parseTraitsAndFeatures(data, monster);
|
||||||
|
parseActionsAndAttacks(data, monster);
|
||||||
|
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseClassesAndLevel(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
StringBuilder classSummary = new StringBuilder();
|
||||||
|
int totalLevel = 0;
|
||||||
|
if (data.has("classes") && data.get("classes").isJsonArray()) {
|
||||||
|
JsonArray classes = data.getAsJsonArray("classes");
|
||||||
|
for (int i = 0; i < classes.size(); i++) {
|
||||||
|
JsonObject cls = classes.get(i).getAsJsonObject();
|
||||||
|
int level = getInt(cls, "level", 1);
|
||||||
|
totalLevel += level;
|
||||||
|
String className = "";
|
||||||
|
if (cls.has("definition") && cls.get("definition").isJsonObject()) {
|
||||||
|
className = getString(cls.getAsJsonObject("definition"), "name");
|
||||||
|
}
|
||||||
|
String subclassName = "";
|
||||||
|
if (cls.has("subclassDefinition") && cls.get("subclassDefinition").isJsonObject()) {
|
||||||
|
subclassName = getString(cls.getAsJsonObject("subclassDefinition"), "name");
|
||||||
|
}
|
||||||
|
if (classSummary.length() > 0) {
|
||||||
|
classSummary.append(" / ");
|
||||||
|
}
|
||||||
|
classSummary.append(className);
|
||||||
|
if (!subclassName.isEmpty()) {
|
||||||
|
classSummary.append(" (").append(subclassName).append(")");
|
||||||
|
}
|
||||||
|
classSummary.append(" ").append(level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monster.hitDice = totalLevel > 0 ? totalLevel : 1;
|
||||||
|
String raceName = "";
|
||||||
|
if (data.has("race") && data.get("race").isJsonObject()) {
|
||||||
|
JsonObject race = data.getAsJsonObject("race");
|
||||||
|
raceName = getString(race, "fullName");
|
||||||
|
if (raceName.isEmpty()) {
|
||||||
|
raceName = getString(race, "baseRaceName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder subtypeSb = new StringBuilder();
|
||||||
|
if (totalLevel > 0) {
|
||||||
|
subtypeSb.append("Level ").append(totalLevel);
|
||||||
|
}
|
||||||
|
if (!raceName.isEmpty()) {
|
||||||
|
if (subtypeSb.length() > 0) subtypeSb.append(" ");
|
||||||
|
subtypeSb.append(raceName);
|
||||||
|
}
|
||||||
|
if (classSummary.length() > 0) {
|
||||||
|
if (subtypeSb.length() > 0) subtypeSb.append(" ");
|
||||||
|
subtypeSb.append(classSummary);
|
||||||
|
}
|
||||||
|
monster.subtype = subtypeSb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseStats(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
if (data.has("stats") && data.get("stats").isJsonArray()) {
|
||||||
|
JsonArray stats = data.getAsJsonArray("stats");
|
||||||
|
for (int i = 0; i < stats.size(); i++) {
|
||||||
|
JsonObject stat = stats.get(i).getAsJsonObject();
|
||||||
|
int id = getInt(stat, "id");
|
||||||
|
int val = getInt(stat, "value", 10);
|
||||||
|
switch (id) {
|
||||||
|
case 1: monster.strengthScore = val; break;
|
||||||
|
case 2: monster.dexterityScore = val; break;
|
||||||
|
case 3: monster.constitutionScore = val; break;
|
||||||
|
case 4: monster.intelligenceScore = val; break;
|
||||||
|
case 5: monster.wisdomScore = val; break;
|
||||||
|
case 6: monster.charismaScore = val; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseHitPoints(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
int baseHp = getInt(data, "baseHitPoints");
|
||||||
|
int overrideHp = getInt(data, "overrideHitPoints");
|
||||||
|
int maxHp = overrideHp > 0 ? overrideHp : baseHp;
|
||||||
|
if (maxHp > 0) {
|
||||||
|
monster.hasCustomHP = true;
|
||||||
|
monster.customHPDescription = String.format(Locale.ROOT, "%d (%dd%d)", maxHp, monster.hitDice, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSpeedAndSenses(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
if (data.has("race") && data.get("race").isJsonObject()) {
|
||||||
|
JsonObject race = data.getAsJsonObject("race");
|
||||||
|
if (race.has("weightSpeeds") && race.get("weightSpeeds").isJsonObject()) {
|
||||||
|
JsonObject weightSpeeds = race.getAsJsonObject("weightSpeeds");
|
||||||
|
if (weightSpeeds.has("normal") && weightSpeeds.get("normal").isJsonObject()) {
|
||||||
|
JsonObject normal = weightSpeeds.getAsJsonObject("normal");
|
||||||
|
monster.walkSpeed = getInt(normal, "walk", 30);
|
||||||
|
monster.flySpeed = getInt(normal, "fly", 0);
|
||||||
|
monster.burrowSpeed = getInt(normal, "burrow", 0);
|
||||||
|
monster.swimSpeed = getInt(normal, "swim", 0);
|
||||||
|
monster.climbSpeed = getInt(normal, "climb", 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (monster.walkSpeed == 0) {
|
||||||
|
monster.walkSpeed = 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseModifiers(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
if (!data.has("modifiers") || !data.get("modifiers").isJsonObject()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JsonObject modifiersObj = data.getAsJsonObject("modifiers");
|
||||||
|
String[] categories = new String[]{"race", "class", "background", "item", "feat"};
|
||||||
|
|
||||||
|
for (String cat : categories) {
|
||||||
|
if (modifiersObj.has(cat) && modifiersObj.get(cat).isJsonArray()) {
|
||||||
|
JsonArray mods = modifiersObj.getAsJsonArray(cat);
|
||||||
|
for (int i = 0; i < mods.size(); i++) {
|
||||||
|
JsonObject mod = mods.get(i).getAsJsonObject();
|
||||||
|
String type = getString(mod, "type");
|
||||||
|
String subType = getString(mod, "subType");
|
||||||
|
int fixedVal = getInt(mod, "fixedValue");
|
||||||
|
|
||||||
|
if ("set-base".equals(type) && "darkvision".equals(subType)) {
|
||||||
|
int dist = fixedVal > 0 ? fixedVal : 60;
|
||||||
|
monster.senses.add("darkvision " + dist + " ft.");
|
||||||
|
} else if ("language".equals(type)) {
|
||||||
|
String langName = capitalize(subType.replace("-", " "));
|
||||||
|
monster.languages.add(new Language(langName, true));
|
||||||
|
} else if ("proficiency".equals(type)) {
|
||||||
|
if (subType.endsWith("-saving-throws")) {
|
||||||
|
String stat = subType.replace("-saving-throws", "");
|
||||||
|
applySavingThrowProficiency(monster, stat);
|
||||||
|
} else {
|
||||||
|
applySkillProficiency(monster, subType, ProficiencyType.PROFICIENT);
|
||||||
|
}
|
||||||
|
} else if ("expertise".equals(type)) {
|
||||||
|
applySkillProficiency(monster, subType, ProficiencyType.EXPERTISE);
|
||||||
|
} else if ("immunity".equals(type)) {
|
||||||
|
monster.damageImmunities.add(capitalize(subType.replace("-", " ")));
|
||||||
|
} else if ("resistance".equals(type)) {
|
||||||
|
monster.damageResistances.add(capitalize(subType.replace("-", " ")));
|
||||||
|
} else if ("vulnerability".equals(type)) {
|
||||||
|
monster.damageVulnerabilities.add(capitalize(subType.replace("-", " ")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applySavingThrowProficiency(@NonNull Monster monster, String stat) {
|
||||||
|
if ("strength".equals(stat) || "str".equals(stat)) monster.strengthSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if ("dexterity".equals(stat) || "dex".equals(stat)) monster.dexteritySavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if ("constitution".equals(stat) || "con".equals(stat)) monster.constitutionSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if ("intelligence".equals(stat) || "int".equals(stat)) monster.intelligenceSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if ("wisdom".equals(stat) || "wis".equals(stat)) monster.wisdomSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if ("charisma".equals(stat) || "cha".equals(stat)) monster.charismaSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applySkillProficiency(@NonNull Monster monster, String subType, ProficiencyType profType) {
|
||||||
|
String skillName = capitalize(subType.replace("-", " "));
|
||||||
|
AbilityScore abilityScore = AbilityScore.STRENGTH;
|
||||||
|
if ("Acrobatics".equalsIgnoreCase(skillName) || "Sleight Of Hand".equalsIgnoreCase(skillName) || "Stealth".equalsIgnoreCase(skillName)) {
|
||||||
|
abilityScore = AbilityScore.DEXTERITY;
|
||||||
|
} else if ("Arcana".equalsIgnoreCase(skillName) || "History".equalsIgnoreCase(skillName) || "Investigation".equalsIgnoreCase(skillName) || "Nature".equalsIgnoreCase(skillName) || "Religion".equalsIgnoreCase(skillName)) {
|
||||||
|
abilityScore = AbilityScore.INTELLIGENCE;
|
||||||
|
} else if ("Animal Handling".equalsIgnoreCase(skillName) || "Insight".equalsIgnoreCase(skillName) || "Medicine".equalsIgnoreCase(skillName) || "Perception".equalsIgnoreCase(skillName) || "Survival".equalsIgnoreCase(skillName)) {
|
||||||
|
abilityScore = AbilityScore.WISDOM;
|
||||||
|
} else if ("Deception".equalsIgnoreCase(skillName) || "Intimidation".equalsIgnoreCase(skillName) || "Performance".equalsIgnoreCase(skillName) || "Persuasion".equalsIgnoreCase(skillName)) {
|
||||||
|
abilityScore = AbilityScore.CHARISMA;
|
||||||
|
} else if ("Athletics".equalsIgnoreCase(skillName)) {
|
||||||
|
abilityScore = AbilityScore.STRENGTH;
|
||||||
|
}
|
||||||
|
monster.skills.add(new Skill(skillName, abilityScore, AdvantageType.NONE, profType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseTraitsAndFeatures(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
if (data.has("race") && data.get("race").isJsonObject()) {
|
||||||
|
JsonObject race = data.getAsJsonObject("race");
|
||||||
|
if (race.has("racialTraits") && race.get("racialTraits").isJsonArray()) {
|
||||||
|
JsonArray traits = race.getAsJsonArray("racialTraits");
|
||||||
|
for (int i = 0; i < traits.size(); i++) {
|
||||||
|
JsonObject tr = traits.get(i).getAsJsonObject();
|
||||||
|
if (tr.has("definition") && tr.get("definition").isJsonObject()) {
|
||||||
|
JsonObject def = tr.getAsJsonObject("definition");
|
||||||
|
String name = getString(def, "name");
|
||||||
|
String desc = stripHtml(getString(def, "snippet"));
|
||||||
|
if (desc.isEmpty()) {
|
||||||
|
desc = stripHtml(getString(def, "description"));
|
||||||
|
}
|
||||||
|
if (!name.isEmpty() && !desc.isEmpty()) {
|
||||||
|
monster.abilities.add(new Trait(name, desc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseActionsAndAttacks(@NonNull JsonObject data, @NonNull Monster monster) {
|
||||||
|
if (data.has("actions") && data.get("actions").isJsonObject()) {
|
||||||
|
JsonObject actionsObj = data.getAsJsonObject("actions");
|
||||||
|
String[] categories = new String[]{"class", "race", "background", "item", "feat"};
|
||||||
|
for (String cat : categories) {
|
||||||
|
if (actionsObj.has(cat) && actionsObj.get(cat).isJsonArray()) {
|
||||||
|
JsonArray acts = actionsObj.getAsJsonArray(cat);
|
||||||
|
for (int i = 0; i < acts.size(); i++) {
|
||||||
|
JsonObject act = acts.get(i).getAsJsonObject();
|
||||||
|
String name = getString(act, "name");
|
||||||
|
String desc = stripHtml(getString(act, "snippet"));
|
||||||
|
if (desc.isEmpty()) {
|
||||||
|
desc = stripHtml(getString(act, "description"));
|
||||||
|
}
|
||||||
|
int actType = 1;
|
||||||
|
if (act.has("activation") && act.get("activation").isJsonObject()) {
|
||||||
|
actType = getInt(act.getAsJsonObject("activation"), "activationType", 1);
|
||||||
|
}
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
Trait trait = new Trait(name, desc);
|
||||||
|
if (actType == 3) {
|
||||||
|
monster.bonusActions.add(trait);
|
||||||
|
} else if (actType == 4) {
|
||||||
|
monster.reactions.add(trait);
|
||||||
|
} else {
|
||||||
|
monster.actions.add(trait);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(@NonNull JsonObject obj, String key) {
|
||||||
|
return getString(obj, key, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(@NonNull JsonObject obj, String key, String defaultVal) {
|
||||||
|
if (obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
return obj.get(key).getAsString();
|
||||||
|
}
|
||||||
|
return defaultVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(@NonNull JsonObject obj, String key) {
|
||||||
|
return getInt(obj, key, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(@NonNull JsonObject obj, String key, int defaultVal) {
|
||||||
|
if (obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
try {
|
||||||
|
return obj.get(key).getAsInt();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String stripHtml(String html) {
|
||||||
|
if (html == null) return "";
|
||||||
|
return html.replaceAll("<[^>]*>", "").replaceAll(" ", " ").trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String capitalize(String str) {
|
||||||
|
if (str == null || str.isEmpty()) return str;
|
||||||
|
String[] words = str.split("\\s+");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String w : words) {
|
||||||
|
if (!w.isEmpty()) {
|
||||||
|
if (sb.length() > 0) sb.append(" ");
|
||||||
|
sb.append(Character.toUpperCase(w.charAt(0))).append(w.substring(1).toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
public interface EntityImporter<T> {
|
||||||
|
/**
|
||||||
|
* Determines whether the given input string or payload can be handled by this importer.
|
||||||
|
*/
|
||||||
|
boolean canImport(@NonNull String input);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the raw input string into internal domain memory objects (e.g., Monster).
|
||||||
|
*/
|
||||||
|
@NonNull
|
||||||
|
T parse(@NonNull String input) throws Exception;
|
||||||
|
}
|
||||||
@@ -0,0 +1,230 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Environment;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.MonsterCardsApplication;
|
||||||
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.models.ImportSource;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipInputStream;
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
public class GitRepoImporterService {
|
||||||
|
|
||||||
|
public static int importFromGitRepository(Context context, ImportSource source, BooleanSupplier isCancelled) throws Exception {
|
||||||
|
int totalImported = 0;
|
||||||
|
|
||||||
|
File downloadsDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS);
|
||||||
|
if (!downloadsDir.exists()) {
|
||||||
|
downloadsDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
File tempZip = null;
|
||||||
|
File[] existingZips = downloadsDir.listFiles((dir, name) -> name.startsWith(source.id + "_download") && name.endsWith(".zip"));
|
||||||
|
if (existingZips != null && existingZips.length > 0) {
|
||||||
|
tempZip = existingZips[0];
|
||||||
|
} else {
|
||||||
|
tempZip = new File(downloadsDir, source.id + "_download_" + System.currentTimeMillis() + ".zip");
|
||||||
|
downloadZip(source.downloadUrl, tempZip, isCancelled);
|
||||||
|
}
|
||||||
|
|
||||||
|
File extractDir = new File(context.getCacheDir(), "repo_extracted_" + System.currentTimeMillis());
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (isCancelled.getAsBoolean()) return 0;
|
||||||
|
|
||||||
|
if (!extractDir.exists()) {
|
||||||
|
extractDir.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
int extractedFiles = unzipAndFilter(tempZip, extractDir, source.fileExtension, source.subfolder, isCancelled);
|
||||||
|
Logger.logWTF("Extracted " + extractedFiles + " files to " + extractDir.getAbsolutePath());
|
||||||
|
|
||||||
|
if (isCancelled.getAsBoolean()) return 0;
|
||||||
|
|
||||||
|
// Instantiate Importer dynamically
|
||||||
|
Class<?> clazz = Class.forName(source.importerClassName);
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
EntityImporter<Monster> importer = (EntityImporter<Monster>) clazz.newInstance();
|
||||||
|
|
||||||
|
MonsterRepository repository = ((MonsterCardsApplication) context.getApplicationContext()).getMonsterRepository();
|
||||||
|
|
||||||
|
// Process files
|
||||||
|
totalImported = processDirectory(extractDir, importer, repository, isCancelled);
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
// We no longer delete tempZip since the user wants to keep the downloaded zip
|
||||||
|
// deleteFileOrDir(tempZip);
|
||||||
|
// DO NOT DELETE EXTRACT DIR FOR NOW
|
||||||
|
// deleteFileOrDir(extractDir);
|
||||||
|
Logger.logWTF("Skipping deletion of extract directory: " + extractDir.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
|
return totalImported;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void downloadZip(String urlStr, File dest, BooleanSupplier isCancelled) throws IOException, InterruptedException {
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
conn.setReadTimeout(30000);
|
||||||
|
|
||||||
|
int code = conn.getResponseCode();
|
||||||
|
// GitHub might redirect archive links, so handle redirect
|
||||||
|
if (code == HttpURLConnection.HTTP_MOVED_TEMP || code == HttpURLConnection.HTTP_MOVED_PERM || code == HttpURLConnection.HTTP_SEE_OTHER) {
|
||||||
|
String newUrl = conn.getHeaderField("Location");
|
||||||
|
conn = (HttpURLConnection) new URL(newUrl).openConnection();
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
conn.setReadTimeout(30000);
|
||||||
|
code = conn.getResponseCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (code != 200) {
|
||||||
|
throw new IllegalStateException("Git repo download failed with HTTP " + code);
|
||||||
|
}
|
||||||
|
|
||||||
|
try (InputStream in = new BufferedInputStream(conn.getInputStream());
|
||||||
|
FileOutputStream out = new FileOutputStream(dest)) {
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int count;
|
||||||
|
while ((count = in.read(buffer)) != -1) {
|
||||||
|
if (isCancelled.getAsBoolean()) {
|
||||||
|
throw new InterruptedException("Git download was cancelled.");
|
||||||
|
}
|
||||||
|
out.write(buffer, 0, count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int unzipAndFilter(File zipFile, File extractDir, String filterExtension, String subfolder, BooleanSupplier isCancelled) throws InterruptedException {
|
||||||
|
int extractedCount = 0;
|
||||||
|
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) {
|
||||||
|
ZipEntry entry;
|
||||||
|
while ((entry = zis.getNextEntry()) != null) {
|
||||||
|
if (isCancelled.getAsBoolean()) {
|
||||||
|
try {
|
||||||
|
zis.closeEntry();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to close zip entry upon cancellation", e);
|
||||||
|
}
|
||||||
|
throw new InterruptedException("Git extraction was cancelled.");
|
||||||
|
}
|
||||||
|
if (!entry.isDirectory()) {
|
||||||
|
String name = entry.getName();
|
||||||
|
boolean inSubfolder = subfolder == null || subfolder.isEmpty() || name.contains("/" + subfolder + "/") || name.startsWith(subfolder + "/");
|
||||||
|
if (inSubfolder && (filterExtension == null || name.endsWith(filterExtension))) {
|
||||||
|
File outFile = new File(extractDir, new File(name).getName());
|
||||||
|
if (outFile.exists()) {
|
||||||
|
outFile = new File(extractDir, System.currentTimeMillis() + "_" + new File(name).getName());
|
||||||
|
}
|
||||||
|
try (FileOutputStream fos = new FileOutputStream(outFile)) {
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
|
int count;
|
||||||
|
while ((count = zis.read(buffer)) != -1) {
|
||||||
|
if (isCancelled.getAsBoolean()) {
|
||||||
|
throw new InterruptedException("Git extraction was cancelled during file read.");
|
||||||
|
}
|
||||||
|
fos.write(buffer, 0, count);
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to write extracted file to disk: " + name, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
zis.closeEntry();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to close zip entry", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed during unzip stream processing", e);
|
||||||
|
}
|
||||||
|
return extractedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int processDirectory(File dir, EntityImporter<Monster> importer, MonsterRepository repository, BooleanSupplier isCancelled) throws InterruptedException {
|
||||||
|
int importedCount = 0;
|
||||||
|
File[] files = dir.listFiles();
|
||||||
|
if (files == null) {
|
||||||
|
Logger.logWTF("processDirectory: files array is null for " + dir.getAbsolutePath());
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.logWTF("Attempting to process " + files.length + " JSON files.");
|
||||||
|
|
||||||
|
for (File file : files) {
|
||||||
|
if (isCancelled.getAsBoolean()) {
|
||||||
|
throw new InterruptedException("Git import processing was cancelled.");
|
||||||
|
}
|
||||||
|
if (file.isFile()) {
|
||||||
|
String content = readFileContent(file);
|
||||||
|
if (content != null) {
|
||||||
|
if (importer.canImport(content)) {
|
||||||
|
try {
|
||||||
|
Monster monster = importer.parse(content);
|
||||||
|
repository.saveMonster(monster).blockingAwait();
|
||||||
|
importedCount++;
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to parse/save monster from file: " + file.getName(), e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.logWTF("Importer rejected file: " + file.getName());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logger.logError("Failed to read content from file: " + file.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return importedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readFileContent(File file) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try (InputStream in = new FileInputStream(file);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
sb.append(line).append("\n");
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
Logger.logError("Error reading extracted file", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deleteFileOrDir(File fileOrDir) {
|
||||||
|
if (fileOrDir.isDirectory()) {
|
||||||
|
File[] children = fileOrDir.listFiles();
|
||||||
|
if (children != null) {
|
||||||
|
for (File child : children) {
|
||||||
|
deleteFileOrDir(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fileOrDir.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
public class MonsterJsonImporter implements EntityImporter<Monster> {
|
||||||
|
|
||||||
|
private static final Gson GSON = new Gson();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
try {
|
||||||
|
JsonElement el = JsonParser.parseString(input);
|
||||||
|
if (el.isJsonObject()) {
|
||||||
|
JsonObject obj = el.getAsJsonObject();
|
||||||
|
if (obj.has("$schema")) {
|
||||||
|
String schemaVal = obj.get("$schema").getAsString();
|
||||||
|
if (schemaVal.contains("monster-card.schema.json")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return obj.has("name") && (obj.has("strengthScore") || obj.has("strengthSavingThrowProficiency"));
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Monster parse(@NonNull String input) throws Exception {
|
||||||
|
Monster monster = GSON.fromJson(input, Monster.class);
|
||||||
|
if (monster == null) {
|
||||||
|
throw new IllegalArgumentException("Failed to deserialize Monster JSON");
|
||||||
|
}
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.InterruptedIOException;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.BooleanSupplier;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
|
||||||
|
public class Open5eApiWrapper {
|
||||||
|
private static final String BASE_URL = "https://api.open5e.com/v2/creatures/";
|
||||||
|
|
||||||
|
public static class Open5ePageResult {
|
||||||
|
public List<Monster> monsters = new ArrayList<>();
|
||||||
|
@Nullable public String nextUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static Open5ePageResult fetchPage(@Nullable String urlStr, BooleanSupplier isCancelled) throws Exception {
|
||||||
|
if (urlStr == null || urlStr.isEmpty()) {
|
||||||
|
urlStr = BASE_URL;
|
||||||
|
}
|
||||||
|
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Android; Mobile)");
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
conn.setReadTimeout(15000);
|
||||||
|
|
||||||
|
int code = conn.getResponseCode();
|
||||||
|
if (code != 200) {
|
||||||
|
throw new IllegalStateException("Open5e API returned HTTP " + code);
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
try (InputStream in = conn.getInputStream();
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8))) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
if (isCancelled.getAsBoolean()) {
|
||||||
|
throw new InterruptedException("Open5e network read was cancelled.");
|
||||||
|
}
|
||||||
|
sb.append(line);
|
||||||
|
}
|
||||||
|
} catch (InterruptedIOException e) {
|
||||||
|
throw new InterruptedException("Open5e network read was cancelled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
String jsonPayload = sb.toString();
|
||||||
|
JsonObject root = JsonParser.parseString(jsonPayload).getAsJsonObject();
|
||||||
|
|
||||||
|
Open5ePageResult result = new Open5ePageResult();
|
||||||
|
if (root.has("next") && !root.get("next").isJsonNull()) {
|
||||||
|
result.nextUrl = root.get("next").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.has("results") && root.get("results").isJsonArray()) {
|
||||||
|
JsonArray results = root.getAsJsonArray("results");
|
||||||
|
Open5eImporter importer = new Open5eImporter();
|
||||||
|
for (int i = 0; i < results.size(); i++) {
|
||||||
|
JsonElement el = results.get(i);
|
||||||
|
if (el.isJsonObject()) {
|
||||||
|
try {
|
||||||
|
Monster monster = importer.parse(el.toString());
|
||||||
|
result.monsters.add(monster);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to parse Open5e monster", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,450 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ChallengeRating;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.Skill;
|
||||||
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class Open5eImporter implements EntityImporter<Monster> {
|
||||||
|
|
||||||
|
private static final Pattern HIT_DICE_PATTERN = Pattern.compile("(\\d+)d(\\d+)");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
String trimmed = input.trim();
|
||||||
|
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JsonElement element = JsonParser.parseString(trimmed);
|
||||||
|
if (!element.isJsonObject()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonObject root = element.getAsJsonObject();
|
||||||
|
if (root.has("ruleset_id") && root.get("ruleset_id").getAsString().equals("open5e")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (root.has("properties") && root.getAsJsonObject("properties").has("abilities")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Monster parse(@NonNull String input) throws Exception {
|
||||||
|
JsonObject root = JsonParser.parseString(input.trim()).getAsJsonObject();
|
||||||
|
|
||||||
|
Monster monster = new Monster();
|
||||||
|
|
||||||
|
if (root.has("uuid") && !root.get("uuid").isJsonNull()) {
|
||||||
|
try {
|
||||||
|
monster.id = UUID.fromString(root.get("uuid").getAsString());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (root.has("display_name") && !root.get("display_name").isJsonNull()) {
|
||||||
|
monster.name = root.get("display_name").getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject props = root.has("properties") ? root.getAsJsonObject("properties") : root;
|
||||||
|
|
||||||
|
if (monster.name == null || monster.name.isEmpty()) {
|
||||||
|
monster.name = getString(props, "name", "Unnamed Entity");
|
||||||
|
}
|
||||||
|
|
||||||
|
monster.size = getString(props, "size");
|
||||||
|
monster.type = getString(props, "type");
|
||||||
|
monster.subtype = getString(props, "subtype");
|
||||||
|
monster.alignment = getString(props, "alignment");
|
||||||
|
|
||||||
|
parseArmorClass(props, monster);
|
||||||
|
parseHitPoints(props, monster);
|
||||||
|
|
||||||
|
if (props.has("speed") && props.get("speed").isJsonObject()) {
|
||||||
|
JsonObject speedObj = props.getAsJsonObject("speed");
|
||||||
|
monster.walkSpeed = getInt(speedObj, "walk", 30);
|
||||||
|
monster.flySpeed = getInt(speedObj, "fly", 0);
|
||||||
|
monster.swimSpeed = getInt(speedObj, "swim", 0);
|
||||||
|
monster.burrowSpeed = getInt(speedObj, "burrow", 0);
|
||||||
|
monster.climbSpeed = getInt(speedObj, "climb", 0);
|
||||||
|
} else {
|
||||||
|
monster.walkSpeed = getInt(props, "speed", 30);
|
||||||
|
}
|
||||||
|
if (props.has("speed_desc")) {
|
||||||
|
String speedDesc = getString(props, "speed_desc");
|
||||||
|
if (!speedDesc.isEmpty()) {
|
||||||
|
monster.hasCustomSpeed = true;
|
||||||
|
monster.customSpeedDescription = speedDesc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parseChallengeRating(props, monster);
|
||||||
|
parseAbilities(props, monster);
|
||||||
|
parseIdentityFields(props, monster);
|
||||||
|
|
||||||
|
parseSavingThrows(props, monster);
|
||||||
|
parseSkills(props, monster);
|
||||||
|
parseSenses(props, monster);
|
||||||
|
parseLanguages(props, monster);
|
||||||
|
parseDamageAndConditions(props, monster);
|
||||||
|
|
||||||
|
parseTraitsAndActions(props, monster);
|
||||||
|
|
||||||
|
if (props.has("source_url")) {
|
||||||
|
monster.sourceUrl = getString(props, "source_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseArmorClass(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("equipped_armor") && props.get("equipped_armor").isJsonObject()) {
|
||||||
|
JsonObject armorObj = props.getAsJsonObject("equipped_armor");
|
||||||
|
String armorId = getString(armorObj, "id");
|
||||||
|
ArmorType armorType = ArmorType.valueOfString(armorId);
|
||||||
|
if (armorType != ArmorType.NONE) {
|
||||||
|
monster.armorType = armorType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.has("equipped_shield") && props.get("equipped_shield").isJsonObject()) {
|
||||||
|
JsonObject shieldObj = props.getAsJsonObject("equipped_shield");
|
||||||
|
monster.shieldBonus = getInt(shieldObj, "ac_bonus", 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (monster.armorType == ArmorType.NONE && props.has("armor_description")) {
|
||||||
|
String armorDesc = getString(props, "armor_description");
|
||||||
|
if (!armorDesc.isEmpty()) {
|
||||||
|
monster.otherArmorDescription = armorDesc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseHitPoints(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("hit_points") && props.get("hit_points").isJsonObject()) {
|
||||||
|
JsonObject hpObj = props.getAsJsonObject("hit_points");
|
||||||
|
int maxHp = getInt(hpObj, "max", getInt(hpObj, "current", 10));
|
||||||
|
if (hpObj.has("hit_dice") && !hpObj.get("hit_dice").isJsonNull()) {
|
||||||
|
String hitDiceStr = hpObj.get("hit_dice").getAsString();
|
||||||
|
Matcher m = HIT_DICE_PATTERN.matcher(hitDiceStr);
|
||||||
|
if (m.find()) {
|
||||||
|
monster.hitDice = Integer.parseInt(m.group(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hpObj.has("formula") && !hpObj.get("formula").isJsonNull()) {
|
||||||
|
monster.hasCustomHP = true;
|
||||||
|
monster.customHPDescription = String.format(Locale.ROOT, "%d (%s)", maxHp, hpObj.get("formula").getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseChallengeRating(JsonObject props, Monster monster) {
|
||||||
|
String crStr = "";
|
||||||
|
if (props.has("cr") && !props.get("cr").isJsonNull()) {
|
||||||
|
crStr = props.get("cr").getAsString();
|
||||||
|
} else if (props.has("challenge_rating") && !props.get("challenge_rating").isJsonNull()) {
|
||||||
|
crStr = props.get("challenge_rating").getAsString();
|
||||||
|
}
|
||||||
|
if (!crStr.isEmpty()) {
|
||||||
|
crStr = crStr.replace(".0", "");
|
||||||
|
if (crStr.equals("0.125")) crStr = "1/8";
|
||||||
|
else if (crStr.equals("0.25")) crStr = "1/4";
|
||||||
|
else if (crStr.equals("0.5")) crStr = "1/2";
|
||||||
|
monster.challengeRating = ChallengeRating.valueOfString(crStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseAbilities(JsonObject props, Monster monster) {
|
||||||
|
if (!props.has("abilities") || !props.get("abilities").isJsonObject()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
JsonObject abs = props.getAsJsonObject("abilities");
|
||||||
|
monster.strengthScore = extractAbilityScore(abs, "strength");
|
||||||
|
monster.dexterityScore = extractAbilityScore(abs, "dexterity");
|
||||||
|
monster.constitutionScore = extractAbilityScore(abs, "constitution");
|
||||||
|
monster.intelligenceScore = extractAbilityScore(abs, "intelligence");
|
||||||
|
monster.wisdomScore = extractAbilityScore(abs, "wisdom");
|
||||||
|
monster.charismaScore = extractAbilityScore(abs, "charisma");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int extractAbilityScore(JsonObject abs, String key) {
|
||||||
|
if (!abs.has(key) || abs.get(key).isJsonNull()) {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
JsonElement el = abs.get(key);
|
||||||
|
if (el.isJsonPrimitive()) {
|
||||||
|
return el.getAsInt();
|
||||||
|
} else if (el.isJsonObject() && el.getAsJsonObject().has("value")) {
|
||||||
|
return el.getAsJsonObject().get("value").getAsInt();
|
||||||
|
}
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseIdentityFields(JsonObject props, Monster monster) {
|
||||||
|
monster.playerName = getString(props, "player_name");
|
||||||
|
monster.background = getString(props, "background");
|
||||||
|
monster.personalityTraits = getString(props, "personality_traits");
|
||||||
|
monster.ideals = getString(props, "ideals");
|
||||||
|
monster.bonds = getString(props, "bonds");
|
||||||
|
monster.flaws = getString(props, "flaws");
|
||||||
|
|
||||||
|
if (props.has("character_details") && props.get("character_details").isJsonObject()) {
|
||||||
|
JsonObject details = props.getAsJsonObject("character_details");
|
||||||
|
monster.age = getString(details, "age");
|
||||||
|
monster.height = getString(details, "height");
|
||||||
|
monster.weight = getString(details, "weight");
|
||||||
|
monster.eyes = getString(details, "eyes");
|
||||||
|
monster.skin = getString(details, "skin");
|
||||||
|
monster.hair = getString(details, "hair");
|
||||||
|
monster.appearance = getString(details, "appearance");
|
||||||
|
monster.backstory = getString(details, "backstory");
|
||||||
|
monster.alliesAndOrganizations = getString(details, "allies_and_organizations");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSavingThrows(JsonObject props, Monster monster) {
|
||||||
|
if (!props.has("saving_throws")) return;
|
||||||
|
JsonElement savesEl = props.get("saving_throws");
|
||||||
|
if (savesEl.isJsonObject()) {
|
||||||
|
JsonObject savesObj = savesEl.getAsJsonObject();
|
||||||
|
for (String key : savesObj.keySet()) {
|
||||||
|
applySaveProficiency(monster, key.toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
} else if (savesEl.isJsonArray()) {
|
||||||
|
JsonArray arr = savesEl.getAsJsonArray();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
String saveStr = arr.get(i).getAsString().toLowerCase(Locale.ROOT);
|
||||||
|
applySaveProficiency(monster, saveStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applySaveProficiency(Monster monster, String saveStr) {
|
||||||
|
if (saveStr.contains("str")) monster.strengthSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if (saveStr.contains("dex")) monster.dexteritySavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if (saveStr.contains("con")) monster.constitutionSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if (saveStr.contains("int")) monster.intelligenceSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if (saveStr.contains("wis")) monster.wisdomSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
else if (saveStr.contains("cha")) monster.charismaSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSkills(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("skill_bonuses") && props.get("skill_bonuses").isJsonObject()) {
|
||||||
|
JsonObject skillsObj = props.getAsJsonObject("skill_bonuses");
|
||||||
|
for (String key : skillsObj.keySet()) {
|
||||||
|
AbilityScore stat = getAbilityForSkill(key);
|
||||||
|
monster.skills.add(new Skill(capitalize(key.replace("_", " ")), stat, AdvantageType.NONE, ProficiencyType.PROFICIENT));
|
||||||
|
}
|
||||||
|
} else if (props.has("skills")) {
|
||||||
|
JsonElement skillsEl = props.get("skills");
|
||||||
|
if (skillsEl.isJsonArray()) {
|
||||||
|
JsonArray arr = skillsEl.getAsJsonArray();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
String skillStr = arr.get(i).getAsString();
|
||||||
|
String skillName = skillStr.replaceAll("[+-]\\d+", "").trim();
|
||||||
|
if (!skillName.isEmpty()) {
|
||||||
|
AbilityScore stat = getAbilityForSkill(skillName);
|
||||||
|
monster.skills.add(new Skill(capitalize(skillName), stat, AdvantageType.NONE, ProficiencyType.PROFICIENT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AbilityScore getAbilityForSkill(String skillName) {
|
||||||
|
String lower = skillName.toLowerCase(Locale.ROOT);
|
||||||
|
if (lower.contains("acro") || lower.contains("sleight") || lower.contains("stealth")) return AbilityScore.DEXTERITY;
|
||||||
|
if (lower.contains("arca") || lower.contains("hist") || lower.contains("inve") || lower.contains("natu") || lower.contains("reli")) return AbilityScore.INTELLIGENCE;
|
||||||
|
if (lower.contains("anim") || lower.contains("insi") || lower.contains("medi") || lower.contains("perc") || lower.contains("surv")) return AbilityScore.WISDOM;
|
||||||
|
if (lower.contains("dece") || lower.contains("inti") || lower.contains("perf") || lower.contains("pers")) return AbilityScore.CHARISMA;
|
||||||
|
return AbilityScore.STRENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseSenses(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("senses")) {
|
||||||
|
String sensesStr = getString(props, "senses");
|
||||||
|
if (!sensesStr.isEmpty()) {
|
||||||
|
String[] parts = sensesStr.split(",");
|
||||||
|
for (String p : parts) {
|
||||||
|
if (!p.trim().isEmpty()) {
|
||||||
|
monster.senses.add(p.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseLanguages(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("languages")) {
|
||||||
|
JsonElement langEl = props.get("languages");
|
||||||
|
if (langEl.isJsonObject()) {
|
||||||
|
if (langEl.getAsJsonObject().has("data") && langEl.getAsJsonObject().get("data").isJsonArray()) {
|
||||||
|
JsonArray arr = langEl.getAsJsonObject().getAsJsonArray("data");
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
if (arr.get(i).isJsonObject()) {
|
||||||
|
String langName = getString(arr.get(i).getAsJsonObject(), "name");
|
||||||
|
if (!langName.isEmpty()) {
|
||||||
|
monster.languages.add(new Language(langName, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (langEl.getAsJsonObject().has("as_string")) {
|
||||||
|
String langStr = langEl.getAsJsonObject().get("as_string").getAsString();
|
||||||
|
for (String l : langStr.split(",")) {
|
||||||
|
if (!l.trim().isEmpty()) {
|
||||||
|
monster.languages.add(new Language(l.trim(), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (langEl.isJsonArray()) {
|
||||||
|
JsonArray arr = langEl.getAsJsonArray();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
String langName = arr.get(i).getAsString();
|
||||||
|
if (!langName.isEmpty()) {
|
||||||
|
monster.languages.add(new Language(langName, true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (langEl.isJsonPrimitive()) {
|
||||||
|
String langStr = langEl.getAsString();
|
||||||
|
for (String l : langStr.split(",")) {
|
||||||
|
if (!l.trim().isEmpty()) {
|
||||||
|
monster.languages.add(new Language(l.trim(), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseDamageAndConditions(JsonObject props, Monster monster) {
|
||||||
|
if (props.has("resistances_and_immunities") && props.get("resistances_and_immunities").isJsonObject()) {
|
||||||
|
JsonObject resObj = props.getAsJsonObject("resistances_and_immunities");
|
||||||
|
parseStringSet(resObj, "damage_immunities", monster.damageImmunities);
|
||||||
|
parseStringSet(resObj, "damage_resistances", monster.damageResistances);
|
||||||
|
parseStringSet(resObj, "damage_vulnerabilities", monster.damageVulnerabilities);
|
||||||
|
parseStringSet(resObj, "condition_immunities", monster.conditionImmunities);
|
||||||
|
} else {
|
||||||
|
parseStringSet(props, "damage_immunities", monster.damageImmunities);
|
||||||
|
parseStringSet(props, "damage_resistances", monster.damageResistances);
|
||||||
|
parseStringSet(props, "damage_vulnerabilities", monster.damageVulnerabilities);
|
||||||
|
parseStringSet(props, "condition_immunities", monster.conditionImmunities);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseStringSet(JsonObject props, String key, java.util.Set<String> set) {
|
||||||
|
if (!props.has(key)) return;
|
||||||
|
JsonElement el = props.get(key);
|
||||||
|
if (el.isJsonArray()) {
|
||||||
|
JsonArray arr = el.getAsJsonArray();
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
JsonElement item = arr.get(i);
|
||||||
|
if (item.isJsonObject() && item.getAsJsonObject().has("name")) {
|
||||||
|
String val = item.getAsJsonObject().get("name").getAsString();
|
||||||
|
if (!val.isEmpty()) set.add(capitalize(val));
|
||||||
|
} else if (item.isJsonPrimitive()) {
|
||||||
|
String val = item.getAsString();
|
||||||
|
if (!val.isEmpty()) set.add(capitalize(val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (el.isJsonPrimitive()) {
|
||||||
|
for (String val : el.getAsString().split(",")) {
|
||||||
|
if (!val.trim().isEmpty()) set.add(capitalize(val.trim()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseTraitsAndActions(JsonObject props, Monster monster) {
|
||||||
|
parseTraitList(props, "traits", monster.abilities);
|
||||||
|
parseTraitList(props, "actions", monster.actions);
|
||||||
|
parseTraitList(props, "bonus_actions", monster.bonusActions);
|
||||||
|
parseTraitList(props, "reactions", monster.reactions);
|
||||||
|
parseTraitList(props, "legendary_actions", monster.legendaryActions);
|
||||||
|
parseTraitList(props, "lair_actions", monster.lairActions);
|
||||||
|
parseTraitList(props, "regional_effects", monster.regionalActions);
|
||||||
|
parseTraitList(props, "mythic_actions", monster.mythicActions);
|
||||||
|
|
||||||
|
if (props.has("legendary_desc")) monster.legendaryActionsDescription = getString(props, "legendary_desc");
|
||||||
|
if (props.has("lair_desc")) monster.lairActionsDescription = getString(props, "lair_desc");
|
||||||
|
if (props.has("lair_end_note")) monster.lairActionsEndNote = getString(props, "lair_end_note");
|
||||||
|
if (props.has("regional_desc")) monster.regionalActionsDescription = getString(props, "regional_desc");
|
||||||
|
if (props.has("regional_end_note")) monster.regionalActionsEndNote = getString(props, "regional_end_note");
|
||||||
|
if (props.has("mythic_desc")) monster.mythicActionsDescription = getString(props, "mythic_desc");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseTraitList(JsonObject props, String key, List<Trait> list) {
|
||||||
|
if (!props.has(key) || !props.get(key).isJsonArray()) return;
|
||||||
|
JsonArray arr = props.getAsJsonArray(key);
|
||||||
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
|
JsonElement el = arr.get(i);
|
||||||
|
if (el.isJsonObject()) {
|
||||||
|
JsonObject obj = el.getAsJsonObject();
|
||||||
|
String name = getString(obj, "name");
|
||||||
|
String desc = getString(obj, "desc");
|
||||||
|
if (desc.isEmpty()) desc = getString(obj, "description");
|
||||||
|
if (!name.isEmpty()) {
|
||||||
|
list.add(new Trait(name, desc));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(JsonObject obj, String key) {
|
||||||
|
return getString(obj, key, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(JsonObject obj, String key, String defaultVal) {
|
||||||
|
if (obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
JsonElement el = obj.get(key);
|
||||||
|
if (el.isJsonPrimitive()) {
|
||||||
|
return el.getAsString();
|
||||||
|
} else if (el.isJsonObject() && el.getAsJsonObject().has("name")) {
|
||||||
|
return el.getAsJsonObject().get("name").getAsString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(JsonObject obj, String key, int defaultVal) {
|
||||||
|
if (obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
try {
|
||||||
|
return obj.get(key).getAsInt();
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String capitalize(String str) {
|
||||||
|
if (str == null || str.isEmpty()) return str;
|
||||||
|
String[] words = str.split("\\s+");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String w : words) {
|
||||||
|
if (!w.isEmpty()) {
|
||||||
|
if (sb.length() > 0) sb.append(" ");
|
||||||
|
sb.append(Character.toUpperCase(w.charAt(0))).append(w.substring(1).toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ChallengeRating;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.Skill;
|
||||||
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Pf2eImporter implements EntityImporter<Monster> {
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
String trimmed = input.trim();
|
||||||
|
if (!trimmed.startsWith("{") || !trimmed.endsWith("}")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JsonObject root = JsonParser.parseString(trimmed).getAsJsonObject();
|
||||||
|
if (root.has("type") && "npc".equals(root.get("type").getAsString())) {
|
||||||
|
if (root.has("system") && root.getAsJsonObject("system").has("attributes")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Monster parse(@NonNull String input) throws Exception {
|
||||||
|
JsonObject root = JsonParser.parseString(input.trim()).getAsJsonObject();
|
||||||
|
JsonObject system = root.has("system") ? root.getAsJsonObject("system") : new JsonObject();
|
||||||
|
|
||||||
|
Monster monster = new Monster();
|
||||||
|
monster.id = UUID.randomUUID();
|
||||||
|
|
||||||
|
// Name
|
||||||
|
if (root.has("name") && !root.get("name").isJsonNull()) {
|
||||||
|
monster.name = root.get("name").getAsString();
|
||||||
|
} else {
|
||||||
|
monster.name = "Unknown PF2e Monster";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Type / Size / Alignment
|
||||||
|
if (system.has("traits") && system.get("traits").isJsonObject()) {
|
||||||
|
JsonObject traits = system.getAsJsonObject("traits");
|
||||||
|
if (traits.has("size") && traits.get("size").isJsonObject()) {
|
||||||
|
monster.size = mapPf2eSize(getString(traits.getAsJsonObject("size"), "value"));
|
||||||
|
}
|
||||||
|
if (traits.has("value") && traits.get("value").isJsonArray()) {
|
||||||
|
// PF2e holds type/alignment tags in traits array
|
||||||
|
StringBuilder typeSb = new StringBuilder();
|
||||||
|
for (JsonElement el : traits.getAsJsonArray("value")) {
|
||||||
|
String trait = el.getAsString();
|
||||||
|
if (typeSb.length() > 0) typeSb.append(", ");
|
||||||
|
typeSb.append(capitalize(trait));
|
||||||
|
}
|
||||||
|
monster.type = typeSb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ability Scores
|
||||||
|
if (system.has("abilities") && system.get("abilities").isJsonObject()) {
|
||||||
|
JsonObject abilities = system.getAsJsonObject("abilities");
|
||||||
|
monster.strengthScore = 10 + (getInt(abilities.getAsJsonObject("str"), "mod") * 2);
|
||||||
|
monster.dexterityScore = 10 + (getInt(abilities.getAsJsonObject("dex"), "mod") * 2);
|
||||||
|
monster.constitutionScore = 10 + (getInt(abilities.getAsJsonObject("con"), "mod") * 2);
|
||||||
|
monster.intelligenceScore = 10 + (getInt(abilities.getAsJsonObject("int"), "mod") * 2);
|
||||||
|
monster.wisdomScore = 10 + (getInt(abilities.getAsJsonObject("wis"), "mod") * 2);
|
||||||
|
monster.charismaScore = 10 + (getInt(abilities.getAsJsonObject("cha"), "mod") * 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Attributes (HP, AC, Speed, Level)
|
||||||
|
if (system.has("attributes") && system.get("attributes").isJsonObject()) {
|
||||||
|
JsonObject attributes = system.getAsJsonObject("attributes");
|
||||||
|
|
||||||
|
if (attributes.has("ac") && attributes.get("ac").isJsonObject()) {
|
||||||
|
monster.armorType = ArmorType.NONE;
|
||||||
|
monster.otherArmorDescription = String.valueOf(getInt(attributes.getAsJsonObject("ac"), "value"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributes.has("hp") && attributes.get("hp").isJsonObject()) {
|
||||||
|
monster.hasCustomHP = true;
|
||||||
|
monster.customHPDescription = String.valueOf(getInt(attributes.getAsJsonObject("hp"), "max"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (attributes.has("speed") && attributes.get("speed").isJsonObject()) {
|
||||||
|
monster.walkSpeed = getInt(attributes.getAsJsonObject("speed"), "value");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Level (Mapped to CR)
|
||||||
|
if (system.has("details") && system.get("details").isJsonObject()) {
|
||||||
|
JsonObject details = system.getAsJsonObject("details");
|
||||||
|
if (details.has("level") && details.get("level").isJsonObject()) {
|
||||||
|
int level = getInt(details.getAsJsonObject("level"), "value");
|
||||||
|
monster.challengeRating = mapLevelToCr(level);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (details.has("languages") && details.get("languages").isJsonObject()) {
|
||||||
|
JsonObject langObj = details.getAsJsonObject("languages");
|
||||||
|
if (langObj.has("value") && langObj.get("value").isJsonArray()) {
|
||||||
|
for (JsonElement el : langObj.getAsJsonArray("value")) {
|
||||||
|
monster.languages.add(new Language(capitalize(el.getAsString()), true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (details.has("publicNotes") && !details.get("publicNotes").isJsonNull()) {
|
||||||
|
String notes = details.get("publicNotes").getAsString().replaceAll("<[^>]*>", "").trim();
|
||||||
|
monster.backstory = notes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String mapPf2eSize(String pf2eSize) {
|
||||||
|
if (pf2eSize == null) return "Medium";
|
||||||
|
switch (pf2eSize.toLowerCase(Locale.ROOT)) {
|
||||||
|
case "tiny": return "Tiny";
|
||||||
|
case "sm": return "Small";
|
||||||
|
case "med": return "Medium";
|
||||||
|
case "lg": return "Large";
|
||||||
|
case "huge": return "Huge";
|
||||||
|
case "grg": return "Gargantuan";
|
||||||
|
default: return "Medium";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private ChallengeRating mapLevelToCr(int level) {
|
||||||
|
if (level <= 0) return ChallengeRating.ZERO;
|
||||||
|
if (level > 30) return ChallengeRating.THIRTY;
|
||||||
|
return ChallengeRating.valueOfString(String.valueOf(level));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(JsonObject obj, String key) {
|
||||||
|
if (obj != null && obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
return obj.get(key).getAsString();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(JsonObject obj, String key) {
|
||||||
|
if (obj != null && obj.has(key) && !obj.get(key).isJsonNull()) {
|
||||||
|
try {
|
||||||
|
return obj.get(key).getAsInt();
|
||||||
|
} catch (Exception ignored) {}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String capitalize(String str) {
|
||||||
|
if (str == null || str.isEmpty()) return str;
|
||||||
|
return str.substring(0, 1).toUpperCase(Locale.ROOT) + str.substring(1).toLowerCase(Locale.ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,364 @@
|
|||||||
|
package com.majinnaibu.monstercards.importers;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.google.gson.JsonArray;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.google.gson.JsonPrimitive;
|
||||||
|
import com.majinnaibu.monstercards.data.converters.ArmorTypeConverter;
|
||||||
|
import com.majinnaibu.monstercards.data.converters.ChallengeRatingConverter;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||||
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
|
import com.majinnaibu.monstercards.models.Language;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.Skill;
|
||||||
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class TetraCubeMonsterImporter implements EntityImporter<Monster> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canImport(@NonNull String input) {
|
||||||
|
if (input.trim().isEmpty()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
JsonElement element = JsonParser.parseString(input);
|
||||||
|
if (!element.isJsonObject()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
JsonObject rootDict = element.getAsJsonObject();
|
||||||
|
if (rootDict.has("$schema")) {
|
||||||
|
String schemaVal = rootDict.get("$schema").getAsString();
|
||||||
|
if (schemaVal.contains("tetracube-monster.schema.json")) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rootDict.has("armorName") || rootDict.has("strPoints")
|
||||||
|
|| rootDict.has("isLegendary") || rootDict.has("isMythic")
|
||||||
|
|| rootDict.has("legendariesDescription");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Monster parse(@NonNull String input) throws Exception {
|
||||||
|
JsonObject rootDict = JsonParser.parseString(input).getAsJsonObject();
|
||||||
|
|
||||||
|
Monster monster = new Monster();
|
||||||
|
monster.name = getString(rootDict, "name");
|
||||||
|
monster.size = getString(rootDict, "size");
|
||||||
|
monster.type = getString(rootDict, "type");
|
||||||
|
monster.subtype = getString(rootDict, "tag");
|
||||||
|
monster.alignment = getString(rootDict, "alignment");
|
||||||
|
monster.hitDice = getInt(rootDict, "hitDice");
|
||||||
|
monster.armorType = ArmorTypeConverter.armorTypeFromStringValue(getString(rootDict, "armorName"));
|
||||||
|
monster.shieldBonus = getInt(rootDict, "shieldBonus");
|
||||||
|
monster.naturalArmorBonus = getInt(rootDict, "natArmorBonus");
|
||||||
|
monster.otherArmorDescription = getString(rootDict, "otherArmorDesc");
|
||||||
|
monster.walkSpeed = getInt(rootDict, "speed");
|
||||||
|
monster.burrowSpeed = getInt(rootDict, "burrowSpeed");
|
||||||
|
monster.climbSpeed = getInt(rootDict, "climbSpeed");
|
||||||
|
monster.flySpeed = getInt(rootDict, "flySpeed");
|
||||||
|
monster.canHover = getBool(rootDict, "hover");
|
||||||
|
monster.swimSpeed = getInt(rootDict, "swimSpeed");
|
||||||
|
monster.hasCustomHP = getBool(rootDict, "customHP");
|
||||||
|
monster.hasCustomSpeed = getBool(rootDict, "customSpeed");
|
||||||
|
monster.customHPDescription = getString(rootDict, "hpText");
|
||||||
|
monster.customSpeedDescription = getString(rootDict, "speedDesc");
|
||||||
|
monster.strengthScore = getInt(rootDict, "strPoints");
|
||||||
|
monster.dexterityScore = getInt(rootDict, "dexPoints");
|
||||||
|
monster.constitutionScore = getInt(rootDict, "conPoints");
|
||||||
|
monster.intelligenceScore = getInt(rootDict, "intPoints");
|
||||||
|
monster.wisdomScore = getInt(rootDict, "wisPoints");
|
||||||
|
monster.charismaScore = getInt(rootDict, "chaPoints");
|
||||||
|
addSense(monster, rootDict, "blindsight");
|
||||||
|
addSense(monster, rootDict, "darkvision");
|
||||||
|
addSense(monster, rootDict, "tremorsense");
|
||||||
|
addSense(monster, rootDict, "truesight");
|
||||||
|
monster.telepathyRange = getInt(rootDict, "telepathy");
|
||||||
|
monster.challengeRating = ChallengeRatingConverter.challengeRatingFromStringValue(getString(rootDict, "cr"));
|
||||||
|
monster.customChallengeRatingDescription = getString(rootDict, "customCr");
|
||||||
|
monster.customProficiencyBonus = getInt(rootDict, "customProf");
|
||||||
|
|
||||||
|
monster.abilities = getListOfTraits(rootDict, "abilities");
|
||||||
|
monster.actions = getListOfTraits(rootDict, "actions");
|
||||||
|
monster.bonusActions = getListOfTraits(rootDict, "bonusActions");
|
||||||
|
monster.reactions = getListOfTraits(rootDict, "reactions");
|
||||||
|
monster.legendaryActions = getListOfTraits(rootDict, "legendaries");
|
||||||
|
monster.mythicActions = getListOfTraits(rootDict, "mythics");
|
||||||
|
monster.lairActions = getListOfTraits(rootDict, "lairs");
|
||||||
|
monster.regionalActions = getListOfTraits(rootDict, "regionals");
|
||||||
|
|
||||||
|
monster.legendaryActionsDescription = getString(rootDict, "legendariesDescription");
|
||||||
|
if (!monster.legendaryActionsDescription.isEmpty()) {
|
||||||
|
monster.legendaryActions.add(0, new Trait("Legendary Actions", monster.legendaryActionsDescription));
|
||||||
|
}
|
||||||
|
|
||||||
|
monster.mythicActionsDescription = getString(rootDict, "mythicDescription");
|
||||||
|
if (!monster.mythicActionsDescription.isEmpty() || !monster.mythicActions.isEmpty()) {
|
||||||
|
if (!monster.mythicActionsDescription.isEmpty()) {
|
||||||
|
monster.legendaryActions.add(new Trait("Mythic Actions", monster.mythicActionsDescription));
|
||||||
|
}
|
||||||
|
for (Trait mythic : monster.mythicActions) {
|
||||||
|
String traitName = mythic.name;
|
||||||
|
if (!traitName.toLowerCase(Locale.ROOT).startsWith("mythic action")) {
|
||||||
|
traitName = "Mythic Action: " + traitName;
|
||||||
|
}
|
||||||
|
monster.legendaryActions.add(new Trait(traitName, mythic.description));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
monster.lairActionsDescription = getString(rootDict, "lairDescription");
|
||||||
|
monster.lairActionsEndNote = getString(rootDict, "lairDescriptionEnd");
|
||||||
|
String fullLairDesc = combineDescriptions(monster.lairActionsDescription, monster.lairActionsEndNote);
|
||||||
|
if (!fullLairDesc.isEmpty()) {
|
||||||
|
monster.lairActions.add(0, new Trait("Lair Actions", fullLairDesc));
|
||||||
|
}
|
||||||
|
|
||||||
|
monster.regionalActionsDescription = getString(rootDict, "regionalDescription");
|
||||||
|
monster.regionalActionsEndNote = getString(rootDict, "regionalDescriptionEnd");
|
||||||
|
String fullRegionalDesc = combineDescriptions(monster.regionalActionsDescription, monster.regionalActionsEndNote);
|
||||||
|
if (!fullRegionalDesc.isEmpty()) {
|
||||||
|
monster.regionalActions.add(0, new Trait("Regional Effects", fullRegionalDesc));
|
||||||
|
}
|
||||||
|
|
||||||
|
addSavingThrows(monster, rootDict);
|
||||||
|
monster.skills = getSetOfSkills(rootDict);
|
||||||
|
monster.damageImmunities = getSetOfDamageTypes(rootDict, "damageTypes", "i");
|
||||||
|
monster.damageImmunities.addAll(getSetOfDamageTypes(rootDict, "specialdamage", "i"));
|
||||||
|
monster.damageResistances = getSetOfDamageTypes(rootDict, "damageTypes", "r");
|
||||||
|
monster.damageResistances.addAll(getSetOfDamageTypes(rootDict, "specialdamage", "r"));
|
||||||
|
monster.damageVulnerabilities = getSetOfDamageTypes(rootDict, "damageTypes", "v");
|
||||||
|
monster.damageVulnerabilities.addAll(getSetOfDamageTypes(rootDict, "specialdamage", "v"));
|
||||||
|
monster.conditionImmunities = getSetOfDamageTypes(rootDict, "conditions");
|
||||||
|
monster.languages = getSetOfLanguages(rootDict, "languages");
|
||||||
|
monster.understandsButDescription = getString(rootDict, "understandsBut");
|
||||||
|
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static String combineDescriptions(String desc1, String desc2) {
|
||||||
|
if (!desc1.isEmpty() && !desc2.isEmpty()) {
|
||||||
|
return desc1 + "\n\n" + desc2;
|
||||||
|
} else if (!desc1.isEmpty()) {
|
||||||
|
return desc1;
|
||||||
|
} else {
|
||||||
|
return desc2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(JsonObject dict, String name) {
|
||||||
|
return getString(dict, name, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getString(@NonNull JsonObject dict, String name, String defaultValue) {
|
||||||
|
if (dict.has(name)) {
|
||||||
|
return dict.get(name).getAsString();
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(JsonObject dict, String name) {
|
||||||
|
return getInt(dict, name, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int getInt(@NonNull JsonObject dict, String name, int defaultValue) {
|
||||||
|
if (dict.has(name)) {
|
||||||
|
JsonElement element = dict.get(name);
|
||||||
|
if (element.isJsonPrimitive()) {
|
||||||
|
JsonPrimitive rawValue = element.getAsJsonPrimitive();
|
||||||
|
if (rawValue.isNumber()) {
|
||||||
|
return rawValue.getAsInt();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return rawValue.getAsInt();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getBool(JsonObject dict, String name) {
|
||||||
|
return getBool(dict, name, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean getBool(@NonNull JsonObject dict, String name, boolean defaultValue) {
|
||||||
|
if (dict.has(name)) {
|
||||||
|
JsonElement element = dict.get(name);
|
||||||
|
if (element.isJsonPrimitive()) {
|
||||||
|
JsonPrimitive rawValue = element.getAsJsonPrimitive();
|
||||||
|
if (rawValue.isBoolean()) {
|
||||||
|
return rawValue.getAsBoolean();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return rawValue.getAsBoolean();
|
||||||
|
} catch (Exception ex) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static String formatDistance(String name, int distance) {
|
||||||
|
return String.format(Locale.getDefault(), "%s %d ft.", name, distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addSense(Monster monster, JsonObject root, String name) {
|
||||||
|
int distance = getInt(root, name);
|
||||||
|
if (distance > 0) {
|
||||||
|
String senseStr = formatDistance(name, distance);
|
||||||
|
if ("blindsight".equals(name) && getBool(root, "blind")) {
|
||||||
|
senseStr += " (blind beyond this radius)";
|
||||||
|
}
|
||||||
|
monster.senses.add(senseStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static List<Trait> getListOfTraits(@NonNull JsonObject dict, String name) {
|
||||||
|
ArrayList<Trait> traits = new ArrayList<>();
|
||||||
|
if (dict.has(name)) {
|
||||||
|
JsonElement arrayElement = dict.get(name);
|
||||||
|
if (arrayElement.isJsonArray()) {
|
||||||
|
JsonArray array = arrayElement.getAsJsonArray();
|
||||||
|
int size = array.size();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
JsonElement jsonElement = array.get(index);
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
String traitName = getString(jsonObject, "name");
|
||||||
|
String description = getString(jsonObject, "desc");
|
||||||
|
Trait trait = new Trait(traitName, description);
|
||||||
|
traits.add(trait);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return traits;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addSavingThrows(Monster monster, @NonNull JsonObject root) {
|
||||||
|
if (root.has("sthrows")) {
|
||||||
|
JsonElement arrayElement = root.get("sthrows");
|
||||||
|
if (arrayElement.isJsonArray()) {
|
||||||
|
JsonArray array = arrayElement.getAsJsonArray();
|
||||||
|
int size = array.size();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
JsonElement jsonElement = array.get(index);
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
String name = getString(jsonObject, "name");
|
||||||
|
if ("str".equals(name)) {
|
||||||
|
monster.strengthSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
} else if ("dex".equals(name)) {
|
||||||
|
monster.dexteritySavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
} else if ("con".equals(name)) {
|
||||||
|
monster.constitutionSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
} else if ("int".equals(name)) {
|
||||||
|
monster.intelligenceSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
} else if ("wis".equals(name)) {
|
||||||
|
monster.wisdomSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
} else if ("cha".equals(name)) {
|
||||||
|
monster.charismaSavingThrowProficiency = ProficiencyType.PROFICIENT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static Set<Skill> getSetOfSkills(@NonNull JsonObject root) {
|
||||||
|
HashSet<Skill> skills = new HashSet<>();
|
||||||
|
if (root.has("skills")) {
|
||||||
|
JsonElement arrayElement = root.get("skills");
|
||||||
|
if (arrayElement.isJsonArray()) {
|
||||||
|
JsonArray array = arrayElement.getAsJsonArray();
|
||||||
|
int size = array.size();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
JsonElement jsonElement = array.get(index);
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
String name = getString(jsonObject, "name");
|
||||||
|
String stat = getString(jsonObject, "stat");
|
||||||
|
String note = getString(jsonObject, "note");
|
||||||
|
|
||||||
|
Skill skill = new Skill(name, AbilityScore.valueOfString(stat), AdvantageType.NONE, " (ex)".equals(note) ? ProficiencyType.EXPERTISE : ProficiencyType.PROFICIENT);
|
||||||
|
skills.add(skill);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return skills;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static Set<String> getSetOfDamageTypes(JsonObject rootDict, String name) {
|
||||||
|
return getSetOfDamageTypes(rootDict, name, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static Set<String> getSetOfDamageTypes(JsonObject rootDict, String name, String type) {
|
||||||
|
HashSet<String> damageTypes = new HashSet<>();
|
||||||
|
if (rootDict.has(name)) {
|
||||||
|
JsonElement arrayElement = rootDict.get(name);
|
||||||
|
if (arrayElement.isJsonArray()) {
|
||||||
|
JsonArray array = arrayElement.getAsJsonArray();
|
||||||
|
int size = array.size();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
JsonElement jsonElement = array.get(index);
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
String dtName = getString(jsonObject, "name");
|
||||||
|
String dtType = getString(jsonObject, "type");
|
||||||
|
if (type == null || type.equals(dtType)) {
|
||||||
|
damageTypes.add(dtName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return damageTypes;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
private static Set<Language> getSetOfLanguages(@NonNull JsonObject root, String name) {
|
||||||
|
HashSet<Language> languages = new HashSet<>();
|
||||||
|
if (root.has(name)) {
|
||||||
|
JsonElement arrayElement = root.get(name);
|
||||||
|
if (arrayElement.isJsonArray()) {
|
||||||
|
JsonArray array = arrayElement.getAsJsonArray();
|
||||||
|
int size = array.size();
|
||||||
|
for (int index = 0; index < size; index++) {
|
||||||
|
JsonElement jsonElement = array.get(index);
|
||||||
|
if (jsonElement.isJsonObject()) {
|
||||||
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
|
String languageName = getString(jsonObject, "name");
|
||||||
|
boolean canSpeak = getBool(jsonObject, "speaks");
|
||||||
|
Language language = new Language(languageName, canSpeak);
|
||||||
|
languages.add(language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return languages;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BinderExport {
|
||||||
|
@SerializedName("$schema")
|
||||||
|
public String schema = "https://majinnaibu.com/schemas/binder.schema.json";
|
||||||
|
|
||||||
|
@SerializedName("schemaVersion")
|
||||||
|
public int schemaVersion = 1;
|
||||||
|
|
||||||
|
@SerializedName("collections")
|
||||||
|
public List<CollectionExport> collections = new ArrayList<>();
|
||||||
|
|
||||||
|
@SerializedName("dashboard")
|
||||||
|
public List<Monster> dashboard = new ArrayList<>();
|
||||||
|
|
||||||
|
public static class CollectionExport {
|
||||||
|
@SerializedName("id")
|
||||||
|
public String id;
|
||||||
|
|
||||||
|
@SerializedName("name")
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
@SerializedName("description")
|
||||||
|
public String description;
|
||||||
|
|
||||||
|
@SerializedName("cards")
|
||||||
|
public List<Monster> cards = new ArrayList<>();
|
||||||
|
|
||||||
|
public CollectionExport() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionExport(String id, String name, String description, List<Monster> cards) {
|
||||||
|
this.id = id != null ? id : UUID.randomUUID().toString();
|
||||||
|
this.name = name != null ? name : "";
|
||||||
|
this.description = description != null ? description : "";
|
||||||
|
this.cards = cards != null ? cards : new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CollectionExport(String name, List<Monster> cards) {
|
||||||
|
this(UUID.randomUUID().toString(), name, "", cards);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity(tableName = "collections")
|
||||||
|
public class Collection {
|
||||||
|
|
||||||
|
@PrimaryKey
|
||||||
|
@NonNull
|
||||||
|
public UUID id;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(defaultValue = "")
|
||||||
|
public String name;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(defaultValue = "")
|
||||||
|
public String description;
|
||||||
|
|
||||||
|
public Collection() {
|
||||||
|
this.id = UUID.randomUUID();
|
||||||
|
this.name = "";
|
||||||
|
this.description = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public Collection(@NonNull String name, @NonNull String description) {
|
||||||
|
this.id = UUID.randomUUID();
|
||||||
|
this.name = name;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(@Nullable Object obj) {
|
||||||
|
if (this == obj) return true;
|
||||||
|
if (obj == null || getClass() != obj.getClass()) return false;
|
||||||
|
Collection that = (Collection) obj;
|
||||||
|
return Objects.equals(id, that.id) &&
|
||||||
|
Objects.equals(name, that.name) &&
|
||||||
|
Objects.equals(description, that.description);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id, name, description);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.ForeignKey;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
import androidx.room.Index;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
tableName = "collection_monsters",
|
||||||
|
foreignKeys = {
|
||||||
|
@ForeignKey(
|
||||||
|
entity = Collection.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "collection_id",
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
),
|
||||||
|
@ForeignKey(
|
||||||
|
entity = Monster.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "monster_id",
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
)
|
||||||
|
},
|
||||||
|
indices = {
|
||||||
|
@Index(value = {"collection_id"}),
|
||||||
|
@Index(value = {"monster_id"})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
public class CollectionMonster {
|
||||||
|
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
public long id;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "collection_id")
|
||||||
|
public UUID collectionId;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "monster_id")
|
||||||
|
public UUID monsterId;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "ordinal", defaultValue = "0")
|
||||||
|
public int ordinal;
|
||||||
|
|
||||||
|
public CollectionMonster() {
|
||||||
|
this.collectionId = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||||
|
this.monsterId = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||||
|
this.ordinal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public CollectionMonster(@NonNull UUID collectionId, @NonNull UUID monsterId, int ordinal) {
|
||||||
|
this.collectionId = collectionId;
|
||||||
|
this.monsterId = monsterId;
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.room.Embedded;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
|
||||||
|
public class CollectionWithCount {
|
||||||
|
@Embedded
|
||||||
|
public Collection collection;
|
||||||
|
|
||||||
|
public int monsterCount;
|
||||||
|
|
||||||
|
public CollectionWithCount() {
|
||||||
|
this.collection = new Collection();
|
||||||
|
this.monsterCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public CollectionWithCount(Collection collection, int monsterCount) {
|
||||||
|
this.collection = collection;
|
||||||
|
this.monsterCount = monsterCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.room.ColumnInfo;
|
||||||
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.ForeignKey;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
import androidx.room.Index;
|
||||||
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@Entity(
|
||||||
|
tableName = "dashboard_monsters",
|
||||||
|
foreignKeys = @ForeignKey(
|
||||||
|
entity = Monster.class,
|
||||||
|
parentColumns = "id",
|
||||||
|
childColumns = "monster_id",
|
||||||
|
onDelete = ForeignKey.CASCADE
|
||||||
|
),
|
||||||
|
indices = @Index(value = {"monster_id"})
|
||||||
|
)
|
||||||
|
public class DashboardMonster {
|
||||||
|
|
||||||
|
@PrimaryKey(autoGenerate = true)
|
||||||
|
public long id;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "monster_id")
|
||||||
|
public UUID monsterId;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "ordinal", defaultValue = "0")
|
||||||
|
public int ordinal;
|
||||||
|
|
||||||
|
public DashboardMonster() {
|
||||||
|
this.monsterId = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||||
|
this.ordinal = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public DashboardMonster(@NonNull UUID monsterId, int ordinal) {
|
||||||
|
this.monsterId = monsterId;
|
||||||
|
this.ordinal = ordinal;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.room.Embedded;
|
||||||
|
import androidx.room.Ignore;
|
||||||
|
import androidx.room.Relation;
|
||||||
|
|
||||||
|
public class DashboardMonsterWithMonster {
|
||||||
|
@Embedded
|
||||||
|
public DashboardMonster dashboardEntry;
|
||||||
|
|
||||||
|
@Relation(
|
||||||
|
parentColumn = "monster_id",
|
||||||
|
entityColumn = "id"
|
||||||
|
)
|
||||||
|
public Monster monster;
|
||||||
|
|
||||||
|
public DashboardMonsterWithMonster() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public DashboardMonsterWithMonster(DashboardMonster dashboardEntry, Monster monster) {
|
||||||
|
this.dashboardEntry = dashboardEntry;
|
||||||
|
this.monster = monster;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
public class ImportSource {
|
||||||
|
public enum ImportType {
|
||||||
|
GIT_ARCHIVE,
|
||||||
|
OPEN5E_API
|
||||||
|
}
|
||||||
|
|
||||||
|
public String id;
|
||||||
|
public String projectName;
|
||||||
|
public String creatorName;
|
||||||
|
public String creatorPageLink;
|
||||||
|
public ImportType importType;
|
||||||
|
|
||||||
|
// Optional attributes specific to Git archive
|
||||||
|
public String downloadUrl;
|
||||||
|
public String importerClassName;
|
||||||
|
public String fileExtension;
|
||||||
|
public String subfolder;
|
||||||
|
|
||||||
|
public ImportSource(String id, String projectName, String creatorName, String creatorPageLink, ImportType importType, String downloadUrl, String importerClassName, String fileExtension, String subfolder) {
|
||||||
|
this.id = id;
|
||||||
|
this.projectName = projectName;
|
||||||
|
this.creatorName = creatorName;
|
||||||
|
this.creatorPageLink = creatorPageLink;
|
||||||
|
this.importType = importType;
|
||||||
|
this.downloadUrl = downloadUrl;
|
||||||
|
this.importerClassName = importerClassName;
|
||||||
|
this.fileExtension = fileExtension;
|
||||||
|
this.subfolder = subfolder;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,8 +6,10 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.room.ColumnInfo;
|
import androidx.room.ColumnInfo;
|
||||||
import androidx.room.Entity;
|
import androidx.room.Entity;
|
||||||
|
import androidx.room.Ignore;
|
||||||
import androidx.room.PrimaryKey;
|
import androidx.room.PrimaryKey;
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName;
|
||||||
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
import com.majinnaibu.monstercards.data.enums.AbilityScore;
|
||||||
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
import com.majinnaibu.monstercards.data.enums.AdvantageType;
|
||||||
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
import com.majinnaibu.monstercards.data.enums.ArmorType;
|
||||||
@@ -29,8 +31,16 @@ import java.util.UUID;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class Monster {
|
public class Monster {
|
||||||
|
|
||||||
|
@SerializedName("$schema")
|
||||||
|
@Ignore
|
||||||
|
public String schema = "https://majinnaibu.com/schemas/monster-card.schema.json";
|
||||||
|
|
||||||
|
@Ignore
|
||||||
|
public int schemaVersion = 1;
|
||||||
|
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@SerializedName("id")
|
||||||
public UUID id;
|
public UUID id;
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -206,6 +216,93 @@ public class Monster {
|
|||||||
@ColumnInfo(name = "regional_actions", defaultValue = "[]")
|
@ColumnInfo(name = "regional_actions", defaultValue = "[]")
|
||||||
public List<Trait> regionalActions;
|
public List<Trait> regionalActions;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "source_url", defaultValue = "")
|
||||||
|
public String sourceUrl;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "bonus_actions", defaultValue = "[]")
|
||||||
|
public List<Trait> bonusActions;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "mythic_actions", defaultValue = "[]")
|
||||||
|
public List<Trait> mythicActions;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "legendary_actions_description", defaultValue = "")
|
||||||
|
public String legendaryActionsDescription;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "lair_actions_description", defaultValue = "")
|
||||||
|
public String lairActionsDescription;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "lair_actions_end_note", defaultValue = "")
|
||||||
|
public String lairActionsEndNote;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "regional_actions_description", defaultValue = "")
|
||||||
|
public String regionalActionsDescription;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "regional_actions_end_note", defaultValue = "")
|
||||||
|
public String regionalActionsEndNote;
|
||||||
|
|
||||||
|
@ColumnInfo(name = "mythic_actions_description", defaultValue = "")
|
||||||
|
public String mythicActionsDescription;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "player_name", defaultValue = "")
|
||||||
|
public String playerName;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "background", defaultValue = "")
|
||||||
|
public String background;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "personality_traits", defaultValue = "")
|
||||||
|
public String personalityTraits;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "ideals", defaultValue = "")
|
||||||
|
public String ideals;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "bonds", defaultValue = "")
|
||||||
|
public String bonds;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "flaws", defaultValue = "")
|
||||||
|
public String flaws;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "age", defaultValue = "")
|
||||||
|
public String age;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "height", defaultValue = "")
|
||||||
|
public String height;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "weight", defaultValue = "")
|
||||||
|
public String weight;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "eyes", defaultValue = "")
|
||||||
|
public String eyes;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "skin", defaultValue = "")
|
||||||
|
public String skin;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "hair", defaultValue = "")
|
||||||
|
public String hair;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "appearance", defaultValue = "")
|
||||||
|
public String appearance;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "backstory", defaultValue = "")
|
||||||
|
public String backstory;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@ColumnInfo(name = "allies_and_organizations", defaultValue = "")
|
||||||
|
public String alliesAndOrganizations;
|
||||||
|
|
||||||
public Monster() {
|
public Monster() {
|
||||||
id = UUID.randomUUID();
|
id = UUID.randomUUID();
|
||||||
name = "";
|
name = "";
|
||||||
@@ -251,6 +348,21 @@ public class Monster {
|
|||||||
wisdomSavingThrowProficiency = ProficiencyType.NONE;
|
wisdomSavingThrowProficiency = ProficiencyType.NONE;
|
||||||
charismaSavingThrowAdvantage = AdvantageType.NONE;
|
charismaSavingThrowAdvantage = AdvantageType.NONE;
|
||||||
charismaSavingThrowProficiency = ProficiencyType.NONE;
|
charismaSavingThrowProficiency = ProficiencyType.NONE;
|
||||||
|
playerName = "";
|
||||||
|
background = "";
|
||||||
|
personalityTraits = "";
|
||||||
|
ideals = "";
|
||||||
|
bonds = "";
|
||||||
|
flaws = "";
|
||||||
|
age = "";
|
||||||
|
height = "";
|
||||||
|
weight = "";
|
||||||
|
eyes = "";
|
||||||
|
skin = "";
|
||||||
|
hair = "";
|
||||||
|
appearance = "";
|
||||||
|
backstory = "";
|
||||||
|
alliesAndOrganizations = "";
|
||||||
|
|
||||||
|
|
||||||
skills = new HashSet<>();
|
skills = new HashSet<>();
|
||||||
@@ -266,6 +378,15 @@ public class Monster {
|
|||||||
lairActions = new ArrayList<>();
|
lairActions = new ArrayList<>();
|
||||||
legendaryActions = new ArrayList<>();
|
legendaryActions = new ArrayList<>();
|
||||||
regionalActions = new ArrayList<>();
|
regionalActions = new ArrayList<>();
|
||||||
|
bonusActions = new ArrayList<>();
|
||||||
|
mythicActions = new ArrayList<>();
|
||||||
|
sourceUrl = "";
|
||||||
|
legendaryActionsDescription = "";
|
||||||
|
lairActionsDescription = "";
|
||||||
|
lairActionsEndNote = "";
|
||||||
|
regionalActionsDescription = "";
|
||||||
|
regionalActionsEndNote = "";
|
||||||
|
mythicActionsDescription = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getMeta() {
|
public String getMeta() {
|
||||||
@@ -323,7 +444,10 @@ public class Monster {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAbilityModifier(@NonNull AbilityScore abilityScore) {
|
public int getAbilityModifier(@Nullable AbilityScore abilityScore) {
|
||||||
|
if (abilityScore == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
switch (abilityScore) {
|
switch (abilityScore) {
|
||||||
case STRENGTH:
|
case STRENGTH:
|
||||||
return getStrengthModifier();
|
return getStrengthModifier();
|
||||||
@@ -783,6 +907,22 @@ public class Monster {
|
|||||||
return actionDescriptions;
|
return actionDescriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getBonusActionDescriptions() {
|
||||||
|
ArrayList<String> actionDescriptions = new ArrayList<>();
|
||||||
|
for (Trait action : bonusActions) {
|
||||||
|
actionDescriptions.add(getPlaceholderReplacedText(String.format("__%s__ %s", action.name, action.description)));
|
||||||
|
}
|
||||||
|
return actionDescriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getMythicActionDescriptions() {
|
||||||
|
ArrayList<String> actionDescriptions = new ArrayList<>();
|
||||||
|
for (Trait action : mythicActions) {
|
||||||
|
actionDescriptions.add(getPlaceholderReplacedText(String.format("__%s__ %s", action.name, action.description)));
|
||||||
|
}
|
||||||
|
return actionDescriptions;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> getReactionDescriptions() {
|
public List<String> getReactionDescriptions() {
|
||||||
ArrayList<String> actionDescriptions = new ArrayList<>();
|
ArrayList<String> actionDescriptions = new ArrayList<>();
|
||||||
for (Trait action : reactions) {
|
for (Trait action : reactions) {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.majinnaibu.monstercards.models;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
|
public class SearchResultItem {
|
||||||
|
public enum Type {
|
||||||
|
MONSTER,
|
||||||
|
COLLECTION
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public final Type type;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public final Monster monster;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public final Collection collection;
|
||||||
|
|
||||||
|
public SearchResultItem(@NonNull Monster monster) {
|
||||||
|
this.type = Type.MONSTER;
|
||||||
|
this.monster = monster;
|
||||||
|
this.collection = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SearchResultItem(@NonNull Collection collection) {
|
||||||
|
this.type = Type.COLLECTION;
|
||||||
|
this.monster = null;
|
||||||
|
this.collection = collection;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,13 +34,25 @@ public class Skill implements Comparator<Skill>, Comparable<Skill> {
|
|||||||
this.proficiencyType = proficiencyType;
|
this.proficiencyType = proficiencyType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AbilityScore getAbilityScore() {
|
||||||
|
if (abilityScore != null) {
|
||||||
|
return abilityScore;
|
||||||
|
}
|
||||||
|
if (name != null) {
|
||||||
|
return AbilityScore.valueOfString(name);
|
||||||
|
}
|
||||||
|
return AbilityScore.STRENGTH;
|
||||||
|
}
|
||||||
|
|
||||||
public int getSkillBonus(Monster monster) {
|
public int getSkillBonus(Monster monster) {
|
||||||
int modifier = monster.getAbilityModifier(abilityScore);
|
AbilityScore score = getAbilityScore();
|
||||||
switch (proficiencyType) {
|
int modifier = monster != null ? monster.getAbilityModifier(score) : 0;
|
||||||
|
ProficiencyType prof = proficiencyType != null ? proficiencyType : ProficiencyType.PROFICIENT;
|
||||||
|
switch (prof) {
|
||||||
case PROFICIENT:
|
case PROFICIENT:
|
||||||
return modifier + monster.getProficiencyBonus();
|
return modifier + (monster != null ? monster.getProficiencyBonus() : 0);
|
||||||
case EXPERTISE:
|
case EXPERTISE:
|
||||||
return modifier + monster.getProficiencyBonus() * 2;
|
return modifier + (monster != null ? monster.getProficiencyBonus() * 2 : 0);
|
||||||
case NONE:
|
case NONE:
|
||||||
default:
|
default:
|
||||||
return modifier;
|
return modifier;
|
||||||
|
|||||||
@@ -0,0 +1,282 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.collections;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
|
import androidx.navigation.NavDirections;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.majinnaibu.monstercards.R;
|
||||||
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonsterWithMonster;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.ui.dashboard.DashboardRecyclerViewAdapter;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
|
public class CollectionDetailFragment extends MCFragment {
|
||||||
|
|
||||||
|
private CollectionDetailViewModel mViewModel;
|
||||||
|
private UUID mCollectionId;
|
||||||
|
private DashboardRecyclerViewAdapter mAdapter;
|
||||||
|
private final CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
|
View root = inflater.inflate(R.layout.fragment_collection_detail, container, false);
|
||||||
|
|
||||||
|
Bundle arguments = getArguments();
|
||||||
|
assert arguments != null;
|
||||||
|
mCollectionId = UUID.fromString(CollectionDetailFragmentArgs.fromBundle(arguments).getCollectionId());
|
||||||
|
|
||||||
|
mViewModel = new ViewModelProvider(this).get(CollectionDetailViewModel.class);
|
||||||
|
|
||||||
|
TextView nameView = root.findViewById(R.id.detail_collection_name);
|
||||||
|
TextView descriptionView = root.findViewById(R.id.detail_collection_description);
|
||||||
|
RecyclerView recyclerView = root.findViewById(R.id.collection_monster_list);
|
||||||
|
FloatingActionButton fab = root.findViewById(R.id.fab_add_monster_to_collection);
|
||||||
|
|
||||||
|
if (fab != null) {
|
||||||
|
fab.setOnClickListener(v -> showCollectionDetailFabOptionsDialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
mViewModel.getCollection().observe(getViewLifecycleOwner(), collection -> {
|
||||||
|
if (collection != null) {
|
||||||
|
nameView.setText(collection.name);
|
||||||
|
setTitle(collection.name);
|
||||||
|
if (!TextUtils.isEmpty(collection.description)) {
|
||||||
|
descriptionView.setVisibility(View.VISIBLE);
|
||||||
|
descriptionView.setText(collection.description);
|
||||||
|
} else {
|
||||||
|
descriptionView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
mViewModel.getMonsters().observe(getViewLifecycleOwner(), monsters -> {
|
||||||
|
if (mAdapter != null) {
|
||||||
|
List<DashboardMonsterWithMonster> items = new ArrayList<>();
|
||||||
|
if (monsters != null) {
|
||||||
|
for (int i = 0; i < monsters.size(); i++) {
|
||||||
|
DashboardMonster dm = new DashboardMonster(monsters.get(i).id, i);
|
||||||
|
dm.id = i + 1;
|
||||||
|
items.add(new DashboardMonsterWithMonster(dm, monsters.get(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mAdapter.submitList(items);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
setupRecyclerView(recyclerView);
|
||||||
|
loadCollectionData();
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCollectionData() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getCollection(mCollectionId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(collection -> {
|
||||||
|
if (collection != null) {
|
||||||
|
mViewModel.setCollection(collection);
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
|
||||||
|
mDisposables.add(repository.getMonstersForCollection(mCollectionId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> mViewModel.setMonsters(monsters), Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
|
int columnCount = Math.max(1, getResources().getConfiguration().screenWidthDp / 396);
|
||||||
|
Context context = requireContext();
|
||||||
|
GridLayoutManager layoutManager = new GridLayoutManager(context, columnCount);
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
mAdapter = new DashboardRecyclerViewAdapter(item -> {
|
||||||
|
if (item != null && item.monster != null) {
|
||||||
|
navigateToMonsterDetail(item.monster.id);
|
||||||
|
} else {
|
||||||
|
Logger.logError("Can't navigate to MonsterDetailFragment with a null monster");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showCollectionDetailFabOptionsDialog() {
|
||||||
|
String[] options = new String[]{
|
||||||
|
getString(R.string.action_add_monster),
|
||||||
|
getString(R.string.action_create_monster),
|
||||||
|
getString(R.string.action_import)
|
||||||
|
};
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.title_collection_actions)
|
||||||
|
.setItems(options, (dialog, which) -> {
|
||||||
|
if (which == 0) {
|
||||||
|
showAddMonsterDialog();
|
||||||
|
} else if (which == 1) {
|
||||||
|
createNewMonster();
|
||||||
|
} else if (which == 2) {
|
||||||
|
showImportDialog();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddMonsterDialog() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getMonsters()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
if (monsters.isEmpty()) {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_failed_to_create_monster));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] monsterNames = new String[monsters.size()];
|
||||||
|
for (int i = 0; i < monsters.size(); i++) {
|
||||||
|
monsterNames[i] = monsters.get(i).name;
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.action_add_monster)
|
||||||
|
.setItems(monsterNames, (dialog, which) -> {
|
||||||
|
Monster selectedMonster = monsters.get(which);
|
||||||
|
addMonsterToCollection(selectedMonster);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMonsterToCollection(Monster monster) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.addMonsterToCollection(mCollectionId, monster.id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
Collection collection = mViewModel.getCollection().getValue();
|
||||||
|
String collectionName = collection != null ? collection.name : "";
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_monster_added_to_collection, monster.name, collectionName));
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToMonsterDetail(@NonNull UUID monsterId) {
|
||||||
|
NavDirections action = CollectionDetailFragmentDirections.actionCollectionDetailFragmentToNavigationMonster(monsterId.toString());
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.collection_detail_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_action_add_collection_to_dashboard) {
|
||||||
|
addCollectionToDashboard();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_export_collection) {
|
||||||
|
exportCollection();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_remove_all_monsters_from_collection) {
|
||||||
|
showRemoveAllMonstersConfirmationDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showRemoveAllMonstersConfirmationDialog() {
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.dialog_remove_all_from_collection_title)
|
||||||
|
.setMessage(R.string.dialog_remove_all_from_collection_message)
|
||||||
|
.setPositiveButton(R.string.action_remove_all, (dialog, which) -> {
|
||||||
|
mDisposables.add(getMonsterRepository().removeAllMonstersFromCollection(mCollectionId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.snackbar_collection_cleared);
|
||||||
|
}
|
||||||
|
}, throwable -> Logger.logError("Failed to remove all monsters from collection", throwable)));
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportCollection() {
|
||||||
|
Collection collection = mViewModel.getCollection().getValue();
|
||||||
|
List<Monster> monsters = mViewModel.getMonsters().getValue();
|
||||||
|
if (collection != null) {
|
||||||
|
String json = new com.majinnaibu.monstercards.exporters.BinderExporter().exportBinder(
|
||||||
|
collection.name,
|
||||||
|
monsters != null ? monsters : new java.util.ArrayList<>()
|
||||||
|
);
|
||||||
|
String collectionName = (collection.name != null && !collection.name.trim().isEmpty())
|
||||||
|
? collection.name.trim()
|
||||||
|
: "collection";
|
||||||
|
exportToFile(collectionName + ".binder", json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCollectionToDashboard() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.addCollectionToDashboard(mCollectionId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
Collection collection = mViewModel.getCollection().getValue();
|
||||||
|
String collectionName = collection != null ? collection.name : "";
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_collection_added_to_dashboard, collectionName));
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
mDisposables.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.collections;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.lifecycle.LiveData;
|
||||||
|
import androidx.lifecycle.MutableLiveData;
|
||||||
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CollectionDetailViewModel extends ViewModel {
|
||||||
|
private final MutableLiveData<Collection> mCollection = new MutableLiveData<>();
|
||||||
|
private final MutableLiveData<List<Monster>> mMonsters = new MutableLiveData<>(new ArrayList<>());
|
||||||
|
|
||||||
|
public CollectionDetailViewModel() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<Collection> getCollection() {
|
||||||
|
return mCollection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCollection(Collection collection) {
|
||||||
|
mCollection.setValue(collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Monster>> getMonsters() {
|
||||||
|
return mMonsters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMonsters(List<Monster> monsters) {
|
||||||
|
mMonsters.setValue(monsters);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,247 @@
|
|||||||
package com.majinnaibu.monstercards.ui.collections;
|
package com.majinnaibu.monstercards.ui.collections;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.EditText;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.navigation.NavDirections;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
|
import com.majinnaibu.monstercards.ui.shared.SwipeToDeleteCallback;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
|
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class CollectionsFragment extends MCFragment {
|
public class CollectionsFragment extends MCFragment {
|
||||||
|
private final CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
private CollectionsViewModel collectionsViewModel;
|
@Nullable
|
||||||
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
@Nullable ViewGroup container,
|
||||||
collectionsViewModel = new ViewModelProvider(this).get(CollectionsViewModel.class);
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
View root = inflater.inflate(R.layout.fragment_collections, container, false);
|
View root = inflater.inflate(R.layout.fragment_collections, container, false);
|
||||||
final TextView textView = root.findViewById(R.id.text_collections);
|
|
||||||
collectionsViewModel.getText().observe(getViewLifecycleOwner(), textView::setText);
|
FloatingActionButton fab = root.findViewById(R.id.fab_add_collection);
|
||||||
|
if (fab != null) {
|
||||||
|
fab.setOnClickListener(v -> showCollectionFabOptionsDialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
View emptyState = root.findViewById(R.id.empty_state);
|
||||||
|
View emptyStateButton = root.findViewById(R.id.empty_state_button);
|
||||||
|
if (emptyStateButton != null) {
|
||||||
|
emptyStateButton.setOnClickListener(v -> showCollectionFabOptionsDialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
RecyclerView recyclerView = root.findViewById(R.id.collection_list);
|
||||||
|
if (recyclerView != null) {
|
||||||
|
setupRecyclerView(recyclerView, emptyState);
|
||||||
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupRecyclerView(@NonNull RecyclerView recyclerView, @Nullable View emptyState) {
|
||||||
|
Context context = requireContext();
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
|
||||||
|
mDisposables.add(repository.getCollectionsWithCount()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(collections -> {
|
||||||
|
boolean isEmpty = (collections == null || collections.isEmpty());
|
||||||
|
if (emptyState != null) {
|
||||||
|
emptyState.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
recyclerView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
|
||||||
|
}, Logger::logError));
|
||||||
|
|
||||||
|
CollectionsRecyclerViewAdapter adapter = new CollectionsRecyclerViewAdapter(
|
||||||
|
context,
|
||||||
|
repository.getCollectionsWithCount(),
|
||||||
|
collection -> navigateToCollectionDetail(collection.id),
|
||||||
|
collection -> repository.deleteCollection(collection)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new DisposableCompletableObserver() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
Logger.logError(e);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
recyclerView.setAdapter(adapter);
|
||||||
|
LinearLayoutManager layoutManager = new LinearLayoutManager(context);
|
||||||
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
|
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, layoutManager.getOrientation());
|
||||||
|
recyclerView.addItemDecoration(dividerItemDecoration);
|
||||||
|
|
||||||
|
ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new SwipeToDeleteCallback(context, (position, direction) -> adapter.deleteItem(position), null));
|
||||||
|
itemTouchHelper.attachToRecyclerView(recyclerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showCollectionFabOptionsDialog() {
|
||||||
|
String[] options = new String[]{
|
||||||
|
getString(R.string.title_new_collection),
|
||||||
|
getString(R.string.action_import_collection)
|
||||||
|
};
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.title_collection_actions)
|
||||||
|
.setItems(options, (dialog, which) -> {
|
||||||
|
if (which == 0) {
|
||||||
|
showCreateCollectionDialog();
|
||||||
|
} else if (which == 1) {
|
||||||
|
importCollectionFromFile();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showCreateCollectionDialog() {
|
||||||
|
Context context = requireContext();
|
||||||
|
LinearLayout layout = new LinearLayout(context);
|
||||||
|
layout.setOrientation(LinearLayout.VERTICAL);
|
||||||
|
int padding = (int) (16 * getResources().getDisplayMetrics().density);
|
||||||
|
layout.setPadding(padding, padding, padding, padding);
|
||||||
|
|
||||||
|
final EditText nameInput = new EditText(context);
|
||||||
|
nameInput.setHint(R.string.label_collection_name);
|
||||||
|
layout.addView(nameInput);
|
||||||
|
|
||||||
|
final EditText descInput = new EditText(context);
|
||||||
|
descInput.setHint(R.string.label_collection_description);
|
||||||
|
layout.addView(descInput);
|
||||||
|
|
||||||
|
new AlertDialog.Builder(context)
|
||||||
|
.setTitle(R.string.title_new_collection)
|
||||||
|
.setView(layout)
|
||||||
|
.setPositiveButton(R.string.dialog_create, (dialog, which) -> {
|
||||||
|
String name = nameInput.getText().toString().trim();
|
||||||
|
String description = descInput.getText().toString().trim();
|
||||||
|
if (TextUtils.isEmpty(name)) {
|
||||||
|
name = getString(R.string.title_new_collection);
|
||||||
|
}
|
||||||
|
createCollection(name, description);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createCollection(@NonNull String name, @NonNull String description) {
|
||||||
|
Collection collection = new Collection(name, description);
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
repository.saveCollection(collection)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new DisposableCompletableObserver() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.makeLong(view, getString(R.string.snackbar_collection_created, collection.name))
|
||||||
|
.setAction("View", v -> navigateToCollectionDetail(collection.id))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
Logger.logError("Error creating collection", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_failed_to_create_collection));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void navigateToCollectionDetail(@NonNull UUID collectionId) {
|
||||||
|
NavDirections action = CollectionsFragmentDirections.actionNavigationCollectionsToCollectionDetailFragment(collectionId.toString());
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.collections_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_action_export_collections) {
|
||||||
|
exportCollections();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_remove_all_collections) {
|
||||||
|
showRemoveAllCollectionsConfirmationDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportCollections() {
|
||||||
|
mDisposables.add(getMonsterRepository().exportCollections()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(json -> exportToFile("collections.binder", json),
|
||||||
|
throwable -> Logger.logError("Failed to export collections", throwable)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showRemoveAllCollectionsConfirmationDialog() {
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.dialog_remove_all_collections_title)
|
||||||
|
.setMessage(R.string.dialog_remove_all_collections_message)
|
||||||
|
.setPositiveButton(R.string.action_remove_all, (dialog, which) -> {
|
||||||
|
mDisposables.add(getMonsterRepository().removeAllCollections()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.snackbar_all_collections_removed);
|
||||||
|
}
|
||||||
|
}, throwable -> Logger.logError("Failed to remove all collections", throwable)));
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
mDisposables.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,137 @@
|
|||||||
|
package com.majinnaibu.monstercards.ui.collections;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.R;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionWithCount;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.core.Flowable;
|
||||||
|
import io.reactivex.rxjava3.disposables.Disposable;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
|
public class CollectionsRecyclerViewAdapter extends RecyclerView.Adapter<CollectionsRecyclerViewAdapter.ViewHolder> {
|
||||||
|
private final Context mContext;
|
||||||
|
private final CollectionCallback mOnClick;
|
||||||
|
private final CollectionCallback mOnDelete;
|
||||||
|
private final Flowable<List<CollectionWithCount>> mItemsObservable;
|
||||||
|
private List<CollectionWithCount> mValues;
|
||||||
|
private Disposable mDisposable;
|
||||||
|
|
||||||
|
private final View.OnClickListener mOnClickListener = new View.OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(@NonNull View view) {
|
||||||
|
Collection collection = (Collection) view.getTag();
|
||||||
|
if (mOnClick != null) {
|
||||||
|
mOnClick.onCallback(collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public CollectionsRecyclerViewAdapter(Context context,
|
||||||
|
Flowable<List<CollectionWithCount>> itemsObservable,
|
||||||
|
CollectionCallback onClick,
|
||||||
|
CollectionCallback onDelete) {
|
||||||
|
mContext = context;
|
||||||
|
mItemsObservable = itemsObservable;
|
||||||
|
mOnClick = onClick;
|
||||||
|
mOnDelete = onDelete;
|
||||||
|
mValues = new ArrayList<>();
|
||||||
|
mDisposable = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
|
.inflate(R.layout.collection_list_item, parent, false);
|
||||||
|
return new ViewHolder(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
|
CollectionWithCount item = mValues.get(position);
|
||||||
|
Collection collection = item.collection;
|
||||||
|
holder.mNameView.setText(collection.name);
|
||||||
|
|
||||||
|
String countText;
|
||||||
|
if (item.monsterCount == 1) {
|
||||||
|
countText = mContext.getString(R.string.format_monster_count_one);
|
||||||
|
} else {
|
||||||
|
countText = mContext.getString(R.string.format_monster_count_other, item.monsterCount);
|
||||||
|
}
|
||||||
|
holder.mCountView.setText(countText);
|
||||||
|
holder.mCountView.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(collection.description)) {
|
||||||
|
holder.mDescriptionView.setVisibility(View.VISIBLE);
|
||||||
|
holder.mDescriptionView.setText(collection.description);
|
||||||
|
} else {
|
||||||
|
holder.mDescriptionView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.itemView.setTag(collection);
|
||||||
|
holder.itemView.setOnClickListener(mOnClickListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getItemCount() {
|
||||||
|
return mValues.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
|
super.onAttachedToRecyclerView(recyclerView);
|
||||||
|
mDisposable = mItemsObservable
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(collections -> {
|
||||||
|
mValues = collections;
|
||||||
|
notifyDataSetChanged();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
|
super.onDetachedFromRecyclerView(recyclerView);
|
||||||
|
if (mDisposable != null) {
|
||||||
|
mDisposable.dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteItem(int position) {
|
||||||
|
if (mOnDelete != null && position >= 0 && position < mValues.size()) {
|
||||||
|
Collection collection = mValues.get(position).collection;
|
||||||
|
mOnDelete.onCallback(collection);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface CollectionCallback {
|
||||||
|
void onCallback(Collection collection);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
final TextView mNameView;
|
||||||
|
final TextView mDescriptionView;
|
||||||
|
final TextView mCountView;
|
||||||
|
|
||||||
|
ViewHolder(View view) {
|
||||||
|
super(view);
|
||||||
|
mNameView = view.findViewById(R.id.collection_name);
|
||||||
|
mDescriptionView = view.findViewById(R.id.collection_description);
|
||||||
|
mCountView = view.findViewById(R.id.collection_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,68 +3,349 @@ package com.majinnaibu.monstercards.ui.dashboard;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.lifecycle.LiveData;
|
import androidx.lifecycle.LiveData;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.ItemTouchHelper;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
|
import com.majinnaibu.monstercards.models.CollectionWithCount;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class DashboardFragment extends MCFragment {
|
public class DashboardFragment extends MCFragment {
|
||||||
private DashboardViewModel mViewModel;
|
private DashboardViewModel mViewModel;
|
||||||
private ViewHolder mHolder;
|
private ViewHolder mHolder;
|
||||||
private DashboardRecyclerViewAdapter mAdapter;
|
private DashboardRecyclerViewAdapter mAdapter;
|
||||||
|
private final CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
@Nullable ViewGroup container,
|
||||||
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
mViewModel = new ViewModelProvider(this).get(DashboardViewModel.class);
|
mViewModel = new ViewModelProvider(this).get(DashboardViewModel.class);
|
||||||
View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
|
View root = inflater.inflate(R.layout.fragment_dashboard, container, false);
|
||||||
mHolder = new ViewHolder(root);
|
mHolder = new ViewHolder(root);
|
||||||
|
|
||||||
setupRecyclerView(mHolder.list);
|
FloatingActionButton fab = root.findViewById(R.id.fab_add_to_dashboard);
|
||||||
|
if (fab != null) {
|
||||||
|
fab.setOnClickListener(v -> showAddToDashboardOptionsDialog());
|
||||||
|
}
|
||||||
|
if (mHolder.emptyStateButton != null) {
|
||||||
|
mHolder.emptyStateButton.setOnClickListener(v -> showAddToDashboardOptionsDialog());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: subscribe better
|
setupRecyclerView(mHolder.list);
|
||||||
getMonsterRepository()
|
loadDashboardMonsters();
|
||||||
.getMonsters()
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(monsters -> mViewModel.setMonsters(monsters));
|
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void loadDashboardMonsters() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getDashboardMonstersWithMonster()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> mViewModel.setMonsters(monsters), Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||||
int columnCount = Math.max(1, getResources().getConfiguration().screenWidthDp / 396);
|
int columnCount = Math.max(1, getResources().getConfiguration().screenWidthDp / 360);
|
||||||
|
Logger.logWTF(String.format(Locale.US, "Setting column count to %d", columnCount));
|
||||||
Context context = requireContext();
|
Context context = requireContext();
|
||||||
GridLayoutManager layoutManager = new GridLayoutManager(context, columnCount);
|
GridLayoutManager layoutManager = new GridLayoutManager(context, columnCount);
|
||||||
recyclerView.setLayoutManager(layoutManager);
|
recyclerView.setLayoutManager(layoutManager);
|
||||||
|
|
||||||
LiveData<List<Monster>> monsterData = mViewModel.getMonsters();
|
LiveData<List<com.majinnaibu.monstercards.models.DashboardMonsterWithMonster>> monsterData = mViewModel.getMonsters();
|
||||||
mAdapter = new DashboardRecyclerViewAdapter(monster -> {
|
mAdapter = new DashboardRecyclerViewAdapter(
|
||||||
if (monster != null) {
|
item -> {
|
||||||
navigateToMonsterDetail(monster);
|
if (item != null && item.monster != null) {
|
||||||
} else {
|
navigateToMonsterDetail(item.monster);
|
||||||
Logger.logError("Can't navigate to MonsterDetailFragment with a null monster");
|
} else {
|
||||||
}
|
Logger.logError("Can't navigate to MonsterDetailFragment with a null monster");
|
||||||
});
|
}
|
||||||
|
},
|
||||||
|
item -> {
|
||||||
|
if (item != null) {
|
||||||
|
showCardOptionsMenu(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
if (monsterData != null) {
|
if (monsterData != null) {
|
||||||
monsterData.observe(getViewLifecycleOwner(), monsters -> mAdapter.submitList(monsters));
|
monsterData.observe(getViewLifecycleOwner(), monsters -> {
|
||||||
|
mAdapter.submitList(monsters);
|
||||||
|
boolean isEmpty = (monsters == null || monsters.isEmpty());
|
||||||
|
if (mHolder.emptyState != null) {
|
||||||
|
mHolder.emptyState.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
if (mHolder.list != null) {
|
||||||
|
mHolder.list.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
recyclerView.setAdapter(mAdapter);
|
recyclerView.setAdapter(mAdapter);
|
||||||
|
|
||||||
|
ItemTouchHelper.SimpleCallback touchHelperCallback = new ItemTouchHelper.SimpleCallback(
|
||||||
|
ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT,
|
||||||
|
ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT
|
||||||
|
) {
|
||||||
|
@Override
|
||||||
|
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||||
|
int fromPos = viewHolder.getAdapterPosition();
|
||||||
|
int toPos = target.getAdapterPosition();
|
||||||
|
if (fromPos != RecyclerView.NO_POSITION && toPos != RecyclerView.NO_POSITION) {
|
||||||
|
List<com.majinnaibu.monstercards.models.DashboardMonsterWithMonster> currentList = new ArrayList<>(mAdapter.getCurrentList());
|
||||||
|
if (fromPos < currentList.size() && toPos < currentList.size()) {
|
||||||
|
com.majinnaibu.monstercards.models.DashboardMonsterWithMonster moved = currentList.remove(fromPos);
|
||||||
|
currentList.add(toPos, moved);
|
||||||
|
mAdapter.submitList(currentList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int direction) {
|
||||||
|
int position = viewHolder.getAdapterPosition();
|
||||||
|
if (position != RecyclerView.NO_POSITION) {
|
||||||
|
List<com.majinnaibu.monstercards.models.DashboardMonsterWithMonster> currentList = mAdapter.getCurrentList();
|
||||||
|
if (position < currentList.size()) {
|
||||||
|
com.majinnaibu.monstercards.models.DashboardMonsterWithMonster item = currentList.get(position);
|
||||||
|
removeDashboardMonsterEntry(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
new ItemTouchHelper(touchHelperCallback).attachToRecyclerView(recyclerView);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddToDashboardOptionsDialog() {
|
||||||
|
String[] options = new String[]{
|
||||||
|
getString(R.string.action_add_single_monster),
|
||||||
|
getString(R.string.action_add_collection_option),
|
||||||
|
getString(R.string.action_create_monster),
|
||||||
|
getString(R.string.action_import)
|
||||||
|
};
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.title_dashboard_actions)
|
||||||
|
.setItems(options, (dialog, which) -> {
|
||||||
|
if (which == 0) {
|
||||||
|
showAddMonsterPicker();
|
||||||
|
} else if (which == 1) {
|
||||||
|
showAddCollectionPicker();
|
||||||
|
} else if (which == 2) {
|
||||||
|
createNewMonster();
|
||||||
|
} else if (which == 3) {
|
||||||
|
showImportDialog();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showRemoveMonsterPicker() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getDashboardMonsters()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
if (monsters.isEmpty()) {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_dashboard_already_empty));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] names = new String[monsters.size()];
|
||||||
|
for (int i = 0; i < monsters.size(); i++) {
|
||||||
|
names[i] = monsters.get(i).name;
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.action_remove_single_monster)
|
||||||
|
.setItems(names, (dialog, which) -> {
|
||||||
|
Monster selected = monsters.get(which);
|
||||||
|
removeMonsterFromDashboard(selected);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showCardOptionsMenu(@NonNull com.majinnaibu.monstercards.models.DashboardMonsterWithMonster item) {
|
||||||
|
String[] options = new String[]{
|
||||||
|
getString(R.string.action_view_details),
|
||||||
|
getString(R.string.action_remove_from_dashboard)
|
||||||
|
};
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(item.monster.name)
|
||||||
|
.setItems(options, (dialog, which) -> {
|
||||||
|
if (which == 0) {
|
||||||
|
navigateToMonsterDetail(item.monster);
|
||||||
|
} else if (which == 1) {
|
||||||
|
removeDashboardMonsterEntry(item);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeDashboardMonsterEntry(@NonNull com.majinnaibu.monstercards.models.DashboardMonsterWithMonster item) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.removeDashboardMonsterById(item.dashboardEntry.id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.makeLong(view, getString(R.string.snackbar_removed_from_dashboard, item.monster.name))
|
||||||
|
.setAction(R.string.action_undo, v -> addMonsterToDashboard(item.monster))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddMonsterPicker() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getMonsters()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
if (monsters.isEmpty()) {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.no_monsters_available));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] names = new String[monsters.size()];
|
||||||
|
for (int i = 0; i < monsters.size(); i++) {
|
||||||
|
names[i] = monsters.get(i).name;
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.action_add_single_monster)
|
||||||
|
.setItems(names, (dialog, which) -> {
|
||||||
|
Monster selected = monsters.get(which);
|
||||||
|
addMonsterToDashboard(selected);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddCollectionPicker() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.getCollectionsWithCount()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(collections -> {
|
||||||
|
if (collections.isEmpty()) {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.no_collections_available));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] names = new String[collections.size()];
|
||||||
|
for (int i = 0; i < collections.size(); i++) {
|
||||||
|
CollectionWithCount item = collections.get(i);
|
||||||
|
int count = item.monsterCount;
|
||||||
|
String countText = count == 1 ? "1 monster" : count + " monsters";
|
||||||
|
String colName = item.collection != null && item.collection.name != null ? item.collection.name : "";
|
||||||
|
names[i] = colName + " (" + countText + ")";
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.action_add_collection_option)
|
||||||
|
.setItems(names, (dialog, which) -> {
|
||||||
|
Collection selected = collections.get(which).collection;
|
||||||
|
addCollectionToDashboard(selected);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMonsterToDashboard(@NonNull Monster monster) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.addMonsterToDashboard(monster.id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_added_to_dashboard, monster.name));
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCollectionToDashboard(@NonNull Collection collection) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.addCollectionToDashboard(collection.id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_collection_added_to_dashboard, collection.name));
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeMonsterFromDashboard(@NonNull Monster monster) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.removeMonsterFromDashboard(monster.id)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.makeLong(view, getString(R.string.snackbar_removed_from_dashboard, monster.name))
|
||||||
|
.setAction(R.string.action_undo, v -> addMonsterToDashboard(monster))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void clearDashboard() {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
mDisposables.add(repository.clearDashboard()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_dashboard_cleared));
|
||||||
|
}
|
||||||
|
}, Logger::logError));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToMonsterDetail(Monster monster) {
|
private void navigateToMonsterDetail(Monster monster) {
|
||||||
@@ -72,12 +353,57 @@ public class DashboardFragment extends MCFragment {
|
|||||||
Navigation.findNavController(requireView()).navigate(action);
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.dashboard_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_action_add_single_monster) {
|
||||||
|
showAddMonsterPicker();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_add_collection_option) {
|
||||||
|
showAddCollectionPicker();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_clear_dashboard) {
|
||||||
|
clearDashboard();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_export_dashboard) {
|
||||||
|
exportDashboard();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportDashboard() {
|
||||||
|
mDisposables.add(getMonsterRepository().getDashboardMonsters()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
String json = new com.majinnaibu.monstercards.exporters.BinderExporter().exportBinder("", monsters);
|
||||||
|
String fileName = getString(R.string.default_filename_dashboard) + ".binder";
|
||||||
|
exportToFile(fileName, json);
|
||||||
|
}, Logger::logError));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
mDisposables.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
final RecyclerView list;
|
final RecyclerView list;
|
||||||
|
final View emptyState;
|
||||||
|
final View emptyStateButton;
|
||||||
|
|
||||||
ViewHolder(View root) {
|
ViewHolder(View root) {
|
||||||
list = root.findViewById(R.id.list);
|
list = root.findViewById(R.id.list);
|
||||||
|
emptyState = root.findViewById(R.id.empty_state);
|
||||||
|
emptyStateButton = root.findViewById(R.id.empty_state_button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,29 +18,44 @@ import com.majinnaibu.monstercards.data.enums.ChallengeRating;
|
|||||||
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
import com.majinnaibu.monstercards.data.enums.ProficiencyType;
|
||||||
import com.majinnaibu.monstercards.databinding.CardMonsterBinding;
|
import com.majinnaibu.monstercards.databinding.CardMonsterBinding;
|
||||||
import com.majinnaibu.monstercards.helpers.CommonMarkHelper;
|
import com.majinnaibu.monstercards.helpers.CommonMarkHelper;
|
||||||
|
import com.majinnaibu.monstercards.models.DashboardMonsterWithMonster;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.models.Trait;
|
import com.majinnaibu.monstercards.models.Trait;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class DashboardRecyclerViewAdapter extends ListAdapter<Monster, DashboardRecyclerViewAdapter.ViewHolder> {
|
public class DashboardRecyclerViewAdapter extends ListAdapter<DashboardMonsterWithMonster, DashboardRecyclerViewAdapter.ViewHolder> {
|
||||||
private static final DiffUtil.ItemCallback<Monster> DIFF_CALLBACK = new DiffUtil.ItemCallback<Monster>() {
|
private static final DiffUtil.ItemCallback<DashboardMonsterWithMonster> DIFF_CALLBACK = new DiffUtil.ItemCallback<DashboardMonsterWithMonster>() {
|
||||||
@Override
|
@Override
|
||||||
public boolean areItemsTheSame(@NonNull Monster oldItem, @NonNull Monster newItem) {
|
public boolean areItemsTheSame(@NonNull DashboardMonsterWithMonster oldItem, @NonNull DashboardMonsterWithMonster newItem) {
|
||||||
return oldItem.id.equals(newItem.id);
|
if (oldItem.dashboardEntry != null && newItem.dashboardEntry != null) {
|
||||||
|
return oldItem.dashboardEntry.id == newItem.dashboardEntry.id;
|
||||||
|
}
|
||||||
|
return oldItem.monster.id.equals(newItem.monster.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean areContentsTheSame(@NonNull Monster oldItem, @NonNull Monster newItem) {
|
public boolean areContentsTheSame(@NonNull DashboardMonsterWithMonster oldItem, @NonNull DashboardMonsterWithMonster newItem) {
|
||||||
return oldItem.equals(newItem);
|
if (oldItem.dashboardEntry != null && newItem.dashboardEntry != null) {
|
||||||
|
return oldItem.dashboardEntry.id == newItem.dashboardEntry.id
|
||||||
|
&& oldItem.dashboardEntry.ordinal == newItem.dashboardEntry.ordinal
|
||||||
|
&& (oldItem.monster != null && oldItem.monster.equals(newItem.monster));
|
||||||
|
}
|
||||||
|
return (oldItem.monster != null && oldItem.monster.equals(newItem.monster));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private final ItemCallback mOnClick;
|
private final ItemCallback mOnClick;
|
||||||
|
private final ItemCallback mOnLongClick;
|
||||||
|
|
||||||
protected DashboardRecyclerViewAdapter(ItemCallback onClick) {
|
public DashboardRecyclerViewAdapter(ItemCallback onClick, ItemCallback onLongClick) {
|
||||||
super(DIFF_CALLBACK);
|
super(DIFF_CALLBACK);
|
||||||
mOnClick = onClick;
|
mOnClick = onClick;
|
||||||
|
mOnLongClick = onLongClick;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DashboardRecyclerViewAdapter(ItemCallback onClick) {
|
||||||
|
this(onClick, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
@@ -52,7 +67,9 @@ public class DashboardRecyclerViewAdapter extends ListAdapter<Monster, Dashboard
|
|||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||||
Logger.logUnimplementedMethod();
|
Logger.logUnimplementedMethod();
|
||||||
Monster monster = getItem(position);
|
DashboardMonsterWithMonster item = getItem(position);
|
||||||
|
Monster monster = item.monster;
|
||||||
|
holder.item = item;
|
||||||
holder.monster = monster;
|
holder.monster = monster;
|
||||||
holder.name.setText(monster.name);
|
holder.name.setText(monster.name);
|
||||||
holder.meta.setText(monster.getMeta());
|
holder.meta.setText(monster.getMeta());
|
||||||
@@ -120,16 +137,25 @@ public class DashboardRecyclerViewAdapter extends ListAdapter<Monster, Dashboard
|
|||||||
|
|
||||||
holder.itemView.setOnClickListener(v -> {
|
holder.itemView.setOnClickListener(v -> {
|
||||||
if (mOnClick != null) {
|
if (mOnClick != null) {
|
||||||
mOnClick.onItemCallback(holder.monster);
|
mOnClick.onItemCallback(holder.item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
holder.itemView.setOnLongClickListener(v -> {
|
||||||
|
if (mOnLongClick != null) {
|
||||||
|
mOnLongClick.onItemCallback(holder.item);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ItemCallback {
|
public interface ItemCallback {
|
||||||
void onItemCallback(Monster monster);
|
void onItemCallback(DashboardMonsterWithMonster item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
|
public DashboardMonsterWithMonster item;
|
||||||
public final TextView name;
|
public final TextView name;
|
||||||
public final TextView meta;
|
public final TextView meta;
|
||||||
public final View action1Group;
|
public final View action1Group;
|
||||||
|
|||||||
@@ -4,23 +4,23 @@ import androidx.lifecycle.LiveData;
|
|||||||
import androidx.lifecycle.MutableLiveData;
|
import androidx.lifecycle.MutableLiveData;
|
||||||
import androidx.lifecycle.ViewModel;
|
import androidx.lifecycle.ViewModel;
|
||||||
|
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.DashboardMonsterWithMonster;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DashboardViewModel extends ViewModel {
|
public class DashboardViewModel extends ViewModel {
|
||||||
private final MutableLiveData<List<Monster>> mMonsters;
|
private final MutableLiveData<List<DashboardMonsterWithMonster>> mMonsters;
|
||||||
|
|
||||||
public DashboardViewModel() {
|
public DashboardViewModel() {
|
||||||
mMonsters = new MutableLiveData<>(new ArrayList<>());
|
mMonsters = new MutableLiveData<>(new ArrayList<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LiveData<List<Monster>> getMonsters() {
|
public LiveData<List<DashboardMonsterWithMonster>> getMonsters() {
|
||||||
return mMonsters;
|
return mMonsters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMonsters(List<Monster> monsters) {
|
public void setMonsters(List<DashboardMonsterWithMonster> monsters) {
|
||||||
mMonsters.setValue(monsters);
|
mMonsters.setValue(monsters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.majinnaibu.monstercards.ui.editmonster;
|
package com.majinnaibu.monstercards.ui.editmonster;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.activity.OnBackPressedCallback;
|
import androidx.activity.OnBackPressedCallback;
|
||||||
@@ -14,18 +16,19 @@ import androidx.lifecycle.ViewModelProvider;
|
|||||||
import androidx.navigation.NavBackStackEntry;
|
import androidx.navigation.NavBackStackEntry;
|
||||||
import androidx.navigation.NavController;
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.fragment.NavHostFragment;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
import com.majinnaibu.monstercards.data.enums.StringType;
|
import com.majinnaibu.monstercards.data.enums.StringType;
|
||||||
import com.majinnaibu.monstercards.data.enums.TraitType;
|
import com.majinnaibu.monstercards.data.enums.TraitType;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.ui.monster.MonsterDetailFragmentArgs;
|
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -43,21 +46,34 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
|
||||||
@Nullable Bundle savedInstanceState) {
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
MonsterRepository repository = getMonsterRepository();
|
|
||||||
Bundle arguments = getArguments();
|
|
||||||
assert arguments != null;
|
|
||||||
UUID monsterId = UUID.fromString(MonsterDetailFragmentArgs.fromBundle(arguments).getMonsterId());
|
|
||||||
|
|
||||||
NavController navController = Navigation.findNavController(requireActivity(), R.id.nav_host_fragment);
|
|
||||||
NavBackStackEntry backStackEntry = navController.getBackStackEntry(R.id.edit_monster_navigation);
|
|
||||||
mViewModel = new ViewModelProvider(backStackEntry).get(EditMonsterViewModel.class);
|
|
||||||
|
|
||||||
View root = inflater.inflate(R.layout.fragment_edit_monster, container, false);
|
View root = inflater.inflate(R.layout.fragment_edit_monster, container, false);
|
||||||
mHolder = new ViewHolder(root);
|
mHolder = new ViewHolder(root);
|
||||||
|
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
Bundle arguments = getArguments();
|
||||||
|
if (arguments == null) {
|
||||||
|
Logger.logError("Arguments bundle is null in EditMonsterFragment");
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
String monsterIdStr = EditMonsterFragmentArgs.fromBundle(arguments).getMonsterId();
|
||||||
|
if (monsterIdStr == null || monsterIdStr.isEmpty()) {
|
||||||
|
Logger.logError("monsterId is null or empty in EditMonsterFragment");
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID monsterId = UUID.fromString(monsterIdStr);
|
||||||
|
|
||||||
|
try {
|
||||||
|
NavController navController = NavHostFragment.findNavController(this);
|
||||||
|
NavBackStackEntry backStackEntry = navController.getBackStackEntry(R.id.edit_monster_navigation);
|
||||||
|
mViewModel = new ViewModelProvider(backStackEntry).get(EditMonsterViewModel.class);
|
||||||
|
} catch (Exception e) {
|
||||||
|
mViewModel = new ViewModelProvider(this).get(EditMonsterViewModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
setTitle(getString(R.string.title_editMonster_fmt, getString(R.string.default_monster_name)));
|
setTitle(getString(R.string.title_editMonster_fmt, getString(R.string.default_monster_name)));
|
||||||
|
|
||||||
// TODO: Show a loading spinner until we have the monster loaded.
|
|
||||||
if (mViewModel.hasError() || !mViewModel.hasLoaded() || !Objects.equals(mViewModel.getMonsterId().getValue(), monsterId)) {
|
if (mViewModel.hasError() || !mViewModel.hasLoaded() || !Objects.equals(mViewModel.getMonsterId().getValue(), monsterId)) {
|
||||||
repository.getMonster(monsterId).toObservable()
|
repository.getMonster(monsterId).toObservable()
|
||||||
.firstOrError()
|
.firstOrError()
|
||||||
@@ -73,7 +89,6 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
// TODO: Show an error state.
|
|
||||||
Logger.logError(e);
|
Logger.logError(e);
|
||||||
mViewModel.setHasError(true);
|
mViewModel.setHasError(true);
|
||||||
mViewModel.setErrorMessage(e.toString());
|
mViewModel.setErrorMessage(e.toString());
|
||||||
@@ -82,101 +97,9 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
mHolder.basicInfoButton.setOnClickListener(v -> {
|
setupAccordions();
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditBasicInfoFragment();
|
setupSummaries();
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
setupSubClickListeners();
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.armorButton.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditArmorFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.speedButton.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSpeedFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.abilityScoresButton.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditAbilityScoresFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.savingThrows.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSavingThrowsFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.challengeRating.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditChallengeRatingFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.skills.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSkillsFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.senses.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.SENSE);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.conditionImmunities.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.CONDITION_IMMUNITY);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.damageImmunities.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_IMMUNITY);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.damageResistances.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_RESISTANCE);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.damageVulnerabilities.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_VULNERABILITY);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.languages.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditLanguagesFragment();
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.abilities.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.ABILITY);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.actions.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.ACTION);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.lairActions.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.LAIR_ACTION);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.legendaryActions.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.LEGENDARY_ACTION);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.reactions.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.REACTIONS);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
mHolder.regionalActions.setOnClickListener(v -> {
|
|
||||||
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.REGIONAL_ACTION);
|
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
requireActivity().getOnBackPressedDispatcher().addCallback(getViewLifecycleOwner(), new OnBackPressedCallback(true) {
|
||||||
@Override
|
@Override
|
||||||
@@ -187,7 +110,6 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
alertDialog.setTitle("Unsaved Changes");
|
alertDialog.setTitle("Unsaved Changes");
|
||||||
alertDialog.setMessage("Do you want to save your changes?");
|
alertDialog.setMessage("Do you want to save your changes?");
|
||||||
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Save", (dialog, id) -> {
|
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Save", (dialog, id) -> {
|
||||||
// Save the monster. Navigate up if the save is successful. Show a SnackBar if there was an error.
|
|
||||||
getMonsterRepository().saveMonster(mViewModel.buildMonster())
|
getMonsterRepository().saveMonster(mViewModel.buildMonster())
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
@@ -195,29 +117,22 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
new DisposableCompletableObserver() {
|
new DisposableCompletableObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Navigation.findNavController(requireView()).navigateUp();
|
NavHostFragment.findNavController(EditMonsterFragment.this).navigateUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
Logger.logError("Error creating monster", e);
|
Logger.logError("Error saving monster", e);
|
||||||
assert view != null;
|
assert view != null;
|
||||||
Snackbar.make(view, getString(R.string.snackbar_failed_to_create_monster), Snackbar.LENGTH_LONG)
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_failed_to_create_monster));
|
||||||
.setAction("Action", null).show();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Discard", (dialog, id) -> {
|
alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Discard", (dialog, id) -> NavHostFragment.findNavController(EditMonsterFragment.this).navigateUp());
|
||||||
// Navigate up ignoring unsaved changes.
|
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Cancel", (dialog, id) -> {});
|
||||||
Navigation.findNavController(requireView()).navigateUp();
|
|
||||||
});
|
|
||||||
alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, "Cancel", (dialog, id) -> {
|
|
||||||
// Do nothing.
|
|
||||||
});
|
|
||||||
alertDialog.show();
|
alertDialog.show();
|
||||||
} else {
|
} else {
|
||||||
// No changes so we can safely leave.
|
NavHostFragment.findNavController(EditMonsterFragment.this).navigateUp();
|
||||||
Navigation.findNavController(requireView()).navigateUp();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -225,42 +140,344 @@ public class EditMonsterFragment extends MCFragment {
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private void setupAccordions() {
|
||||||
|
if (mHolder.headerBasicInfo != null && mHolder.bodyBasicInfo != null && mHolder.chevronBasicInfo != null) {
|
||||||
|
setupAccordion(mHolder.headerBasicInfo, mHolder.bodyBasicInfo, mHolder.chevronBasicInfo);
|
||||||
|
}
|
||||||
|
if (mHolder.headerCombatAbilities != null && mHolder.bodyCombatAbilities != null && mHolder.chevronCombatAbilities != null) {
|
||||||
|
setupAccordion(mHolder.headerCombatAbilities, mHolder.bodyCombatAbilities, mHolder.chevronCombatAbilities);
|
||||||
|
}
|
||||||
|
if (mHolder.headerSavesSkillsLanguages != null && mHolder.bodySavesSkillsLanguages != null && mHolder.chevronSavesSkillsLanguages != null) {
|
||||||
|
setupAccordion(mHolder.headerSavesSkillsLanguages, mHolder.bodySavesSkillsLanguages, mHolder.chevronSavesSkillsLanguages);
|
||||||
|
}
|
||||||
|
if (mHolder.headerDefenses != null && mHolder.bodyDefenses != null && mHolder.chevronDefenses != null) {
|
||||||
|
setupAccordion(mHolder.headerDefenses, mHolder.bodyDefenses, mHolder.chevronDefenses);
|
||||||
|
}
|
||||||
|
if (mHolder.headerTraitsActions != null && mHolder.bodyTraitsActions != null && mHolder.chevronTraitsActions != null) {
|
||||||
|
setupAccordion(mHolder.headerTraitsActions, mHolder.bodyTraitsActions, mHolder.chevronTraitsActions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextView basicInfoButton;
|
private void setupAccordion(View header, View body, ImageView chevron) {
|
||||||
TextView armorButton;
|
header.setOnClickListener(v -> {
|
||||||
TextView speedButton;
|
boolean isExpanded = body.getVisibility() == View.VISIBLE;
|
||||||
TextView abilityScoresButton;
|
body.setVisibility(isExpanded ? View.GONE : View.VISIBLE);
|
||||||
TextView savingThrows;
|
chevron.setImageResource(isExpanded ? R.drawable.ic_expand_more_24 : R.drawable.ic_expand_less_24);
|
||||||
TextView skills;
|
});
|
||||||
TextView conditionImmunities;
|
}
|
||||||
TextView damageImmunities;
|
|
||||||
TextView damageResistances;
|
private void setupSummaries() {
|
||||||
TextView damageVulnerabilities;
|
mViewModel.getName().observe(getViewLifecycleOwner(), v -> updateBasicInfoSummary());
|
||||||
TextView senses;
|
mViewModel.getSize().observe(getViewLifecycleOwner(), v -> updateBasicInfoSummary());
|
||||||
TextView languages;
|
mViewModel.getType().observe(getViewLifecycleOwner(), v -> updateBasicInfoSummary());
|
||||||
TextView challengeRating;
|
mViewModel.getChallengeRating().observe(getViewLifecycleOwner(), v -> updateBasicInfoSummary());
|
||||||
TextView abilities;
|
|
||||||
TextView actions;
|
mViewModel.getStrength().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
TextView reactions;
|
mViewModel.getDexterity().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
TextView legendaryActions;
|
mViewModel.getConstitution().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
TextView lairActions;
|
mViewModel.getIntelligence().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
TextView regionalActions;
|
mViewModel.getWisdom().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
|
mViewModel.getCharisma().observe(getViewLifecycleOwner(), v -> updateCombatAbilitiesSummary());
|
||||||
|
|
||||||
|
mViewModel.getSkills().observe(getViewLifecycleOwner(), v -> updateSavesSkillsSummary());
|
||||||
|
mViewModel.getLanguages().observe(getViewLifecycleOwner(), v -> updateSavesSkillsSummary());
|
||||||
|
|
||||||
|
mViewModel.getConditionImmunities().observe(getViewLifecycleOwner(), v -> updateDefensesSummary());
|
||||||
|
mViewModel.getDamageImmunities().observe(getViewLifecycleOwner(), v -> updateDefensesSummary());
|
||||||
|
mViewModel.getDamageResistances().observe(getViewLifecycleOwner(), v -> updateDefensesSummary());
|
||||||
|
mViewModel.getDamageVulnerabilities().observe(getViewLifecycleOwner(), v -> updateDefensesSummary());
|
||||||
|
|
||||||
|
mViewModel.getAbilities().observe(getViewLifecycleOwner(), v -> updateTraitsActionsSummary());
|
||||||
|
mViewModel.getActions().observe(getViewLifecycleOwner(), v -> updateTraitsActionsSummary());
|
||||||
|
mViewModel.getReactions().observe(getViewLifecycleOwner(), v -> updateTraitsActionsSummary());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateBasicInfoSummary() {
|
||||||
|
if (mHolder.summaryBasicInfo == null) return;
|
||||||
|
String name = mViewModel.getName().getValue();
|
||||||
|
String size = mViewModel.getSize().getValue();
|
||||||
|
String type = mViewModel.getType().getValue();
|
||||||
|
|
||||||
|
List<String> parts = new ArrayList<>();
|
||||||
|
if (!TextUtils.isEmpty(name)) parts.add(name);
|
||||||
|
if (!TextUtils.isEmpty(size)) parts.add(size);
|
||||||
|
if (!TextUtils.isEmpty(type)) parts.add(type);
|
||||||
|
|
||||||
|
mHolder.summaryBasicInfo.setText(parts.isEmpty() ? "Tap to edit basic info" : TextUtils.join(", ", parts));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCombatAbilitiesSummary() {
|
||||||
|
if (mHolder.summaryCombatAbilities == null) return;
|
||||||
|
Integer str = mViewModel.getStrength().getValue();
|
||||||
|
Integer dex = mViewModel.getDexterity().getValue();
|
||||||
|
Integer con = mViewModel.getConstitution().getValue();
|
||||||
|
Integer intel = mViewModel.getIntelligence().getValue();
|
||||||
|
Integer wis = mViewModel.getWisdom().getValue();
|
||||||
|
Integer cha = mViewModel.getCharisma().getValue();
|
||||||
|
|
||||||
|
String summary = String.format("STR %d | DEX %d | CON %d | INT %d | WIS %d | CHA %d",
|
||||||
|
str != null ? str : 10,
|
||||||
|
dex != null ? dex : 10,
|
||||||
|
con != null ? con : 10,
|
||||||
|
intel != null ? intel : 10,
|
||||||
|
wis != null ? wis : 10,
|
||||||
|
cha != null ? cha : 10);
|
||||||
|
mHolder.summaryCombatAbilities.setText(summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateSavesSkillsSummary() {
|
||||||
|
if (mHolder.summarySavesSkillsLanguages == null) return;
|
||||||
|
int skillsCount = mViewModel.getSkills().getValue() != null ? mViewModel.getSkills().getValue().size() : 0;
|
||||||
|
int languagesCount = mViewModel.getLanguages().getValue() != null ? mViewModel.getLanguages().getValue().size() : 0;
|
||||||
|
|
||||||
|
mHolder.summarySavesSkillsLanguages.setText(String.format("%d Skills, %d Languages", skillsCount, languagesCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDefensesSummary() {
|
||||||
|
if (mHolder.summaryDefenses == null) return;
|
||||||
|
List<String> defenses = new ArrayList<>();
|
||||||
|
if (mViewModel.getConditionImmunities().getValue() != null && !mViewModel.getConditionImmunities().getValue().isEmpty()) {
|
||||||
|
defenses.add(mViewModel.getConditionImmunities().getValue().size() + " Condition Immunities");
|
||||||
|
}
|
||||||
|
if (mViewModel.getDamageImmunities().getValue() != null && !mViewModel.getDamageImmunities().getValue().isEmpty()) {
|
||||||
|
defenses.add(mViewModel.getDamageImmunities().getValue().size() + " Damage Immunities");
|
||||||
|
}
|
||||||
|
if (mViewModel.getDamageResistances().getValue() != null && !mViewModel.getDamageResistances().getValue().isEmpty()) {
|
||||||
|
defenses.add(mViewModel.getDamageResistances().getValue().size() + " Resistances");
|
||||||
|
}
|
||||||
|
|
||||||
|
mHolder.summaryDefenses.setText(defenses.isEmpty() ? "None" : TextUtils.join(", ", defenses));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateTraitsActionsSummary() {
|
||||||
|
if (mHolder.summaryTraitsActions == null) return;
|
||||||
|
int abilitiesCount = mViewModel.getAbilities().getValue() != null ? mViewModel.getAbilities().getValue().size() : 0;
|
||||||
|
int actionsCount = mViewModel.getActions().getValue() != null ? mViewModel.getActions().getValue().size() : 0;
|
||||||
|
int reactionsCount = mViewModel.getReactions().getValue() != null ? mViewModel.getReactions().getValue().size() : 0;
|
||||||
|
|
||||||
|
mHolder.summaryTraitsActions.setText(String.format("%d Abilities, %d Actions, %d Reactions", abilitiesCount, actionsCount, reactionsCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupSubClickListeners() {
|
||||||
|
if (mHolder.basicInfoButton != null) {
|
||||||
|
mHolder.basicInfoButton.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditBasicInfoFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.challengeRating != null) {
|
||||||
|
mHolder.challengeRating.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditChallengeRatingFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.armorButton != null) {
|
||||||
|
mHolder.armorButton.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditArmorFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.speedButton != null) {
|
||||||
|
mHolder.speedButton.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSpeedFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.abilityScoresButton != null) {
|
||||||
|
mHolder.abilityScoresButton.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditAbilityScoresFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.savingThrows != null) {
|
||||||
|
mHolder.savingThrows.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSavingThrowsFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.skills != null) {
|
||||||
|
mHolder.skills.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditSkillsFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.senses != null) {
|
||||||
|
mHolder.senses.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.SENSE);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.languages != null) {
|
||||||
|
mHolder.languages.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditLanguagesFragment();
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.conditionImmunities != null) {
|
||||||
|
mHolder.conditionImmunities.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.CONDITION_IMMUNITY);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.damageImmunities != null) {
|
||||||
|
mHolder.damageImmunities.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_IMMUNITY);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.damageResistances != null) {
|
||||||
|
mHolder.damageResistances.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_RESISTANCE);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.damageVulnerabilities != null) {
|
||||||
|
mHolder.damageVulnerabilities.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditStringsFragment(StringType.DAMAGE_VULNERABILITY);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.abilities != null) {
|
||||||
|
mHolder.abilities.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.ABILITY);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.actions != null) {
|
||||||
|
mHolder.actions.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.ACTION);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.reactions != null) {
|
||||||
|
mHolder.reactions.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.REACTIONS);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.legendaryActions != null) {
|
||||||
|
mHolder.legendaryActions.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.LEGENDARY_ACTION);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.lairActions != null) {
|
||||||
|
mHolder.lairActions.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.LAIR_ACTION);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mHolder.regionalActions != null) {
|
||||||
|
mHolder.regionalActions.setOnClickListener(v -> {
|
||||||
|
NavDirections action = EditMonsterFragmentDirections.actionEditMonsterFragmentToEditTraitListFragment(TraitType.REGIONAL_ACTION);
|
||||||
|
NavHostFragment.findNavController(this).navigate(action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class ViewHolder {
|
||||||
|
final View headerBasicInfo;
|
||||||
|
final View bodyBasicInfo;
|
||||||
|
final ImageView chevronBasicInfo;
|
||||||
|
final TextView summaryBasicInfo;
|
||||||
|
|
||||||
|
final View headerCombatAbilities;
|
||||||
|
final View bodyCombatAbilities;
|
||||||
|
final ImageView chevronCombatAbilities;
|
||||||
|
final TextView summaryCombatAbilities;
|
||||||
|
|
||||||
|
final View headerSavesSkillsLanguages;
|
||||||
|
final View bodySavesSkillsLanguages;
|
||||||
|
final ImageView chevronSavesSkillsLanguages;
|
||||||
|
final TextView summarySavesSkillsLanguages;
|
||||||
|
|
||||||
|
final View headerDefenses;
|
||||||
|
final View bodyDefenses;
|
||||||
|
final ImageView chevronDefenses;
|
||||||
|
final TextView summaryDefenses;
|
||||||
|
|
||||||
|
final View headerTraitsActions;
|
||||||
|
final View bodyTraitsActions;
|
||||||
|
final ImageView chevronTraitsActions;
|
||||||
|
final TextView summaryTraitsActions;
|
||||||
|
|
||||||
|
final TextView basicInfoButton;
|
||||||
|
final TextView challengeRating;
|
||||||
|
final TextView armorButton;
|
||||||
|
final TextView speedButton;
|
||||||
|
final TextView abilityScoresButton;
|
||||||
|
final TextView savingThrows;
|
||||||
|
final TextView skills;
|
||||||
|
final TextView senses;
|
||||||
|
final TextView languages;
|
||||||
|
final TextView conditionImmunities;
|
||||||
|
final TextView damageImmunities;
|
||||||
|
final TextView damageResistances;
|
||||||
|
final TextView damageVulnerabilities;
|
||||||
|
final TextView abilities;
|
||||||
|
final TextView actions;
|
||||||
|
final TextView reactions;
|
||||||
|
final TextView legendaryActions;
|
||||||
|
final TextView lairActions;
|
||||||
|
final TextView regionalActions;
|
||||||
|
|
||||||
ViewHolder(@NonNull View root) {
|
ViewHolder(@NonNull View root) {
|
||||||
|
headerBasicInfo = root.findViewById(R.id.headerBasicInfo);
|
||||||
|
bodyBasicInfo = root.findViewById(R.id.bodyBasicInfo);
|
||||||
|
chevronBasicInfo = root.findViewById(R.id.chevronBasicInfo);
|
||||||
|
summaryBasicInfo = root.findViewById(R.id.summaryBasicInfo);
|
||||||
|
|
||||||
|
headerCombatAbilities = root.findViewById(R.id.headerCombatAbilities);
|
||||||
|
bodyCombatAbilities = root.findViewById(R.id.bodyCombatAbilities);
|
||||||
|
chevronCombatAbilities = root.findViewById(R.id.chevronCombatAbilities);
|
||||||
|
summaryCombatAbilities = root.findViewById(R.id.summaryCombatAbilities);
|
||||||
|
|
||||||
|
headerSavesSkillsLanguages = root.findViewById(R.id.headerSavesSkillsLanguages);
|
||||||
|
bodySavesSkillsLanguages = root.findViewById(R.id.bodySavesSkillsLanguages);
|
||||||
|
chevronSavesSkillsLanguages = root.findViewById(R.id.chevronSavesSkillsLanguages);
|
||||||
|
summarySavesSkillsLanguages = root.findViewById(R.id.summarySavesSkillsLanguages);
|
||||||
|
|
||||||
|
headerDefenses = root.findViewById(R.id.headerDefenses);
|
||||||
|
bodyDefenses = root.findViewById(R.id.bodyDefenses);
|
||||||
|
chevronDefenses = root.findViewById(R.id.chevronDefenses);
|
||||||
|
summaryDefenses = root.findViewById(R.id.summaryDefenses);
|
||||||
|
|
||||||
|
headerTraitsActions = root.findViewById(R.id.headerTraitsActions);
|
||||||
|
bodyTraitsActions = root.findViewById(R.id.bodyTraitsActions);
|
||||||
|
chevronTraitsActions = root.findViewById(R.id.chevronTraitsActions);
|
||||||
|
summaryTraitsActions = root.findViewById(R.id.summaryTraitsActions);
|
||||||
|
|
||||||
basicInfoButton = root.findViewById(R.id.basicInfo);
|
basicInfoButton = root.findViewById(R.id.basicInfo);
|
||||||
|
challengeRating = root.findViewById(R.id.challengeRating);
|
||||||
armorButton = root.findViewById(R.id.armor);
|
armorButton = root.findViewById(R.id.armor);
|
||||||
speedButton = root.findViewById(R.id.speed);
|
speedButton = root.findViewById(R.id.speed);
|
||||||
abilityScoresButton = root.findViewById(R.id.abilityScores);
|
abilityScoresButton = root.findViewById(R.id.abilityScores);
|
||||||
savingThrows = root.findViewById(R.id.savingThrows);
|
savingThrows = root.findViewById(R.id.savingThrows);
|
||||||
skills = root.findViewById(R.id.skills);
|
skills = root.findViewById(R.id.skills);
|
||||||
|
senses = root.findViewById(R.id.senses);
|
||||||
|
languages = root.findViewById(R.id.languages);
|
||||||
conditionImmunities = root.findViewById(R.id.conditionImmunities);
|
conditionImmunities = root.findViewById(R.id.conditionImmunities);
|
||||||
damageImmunities = root.findViewById(R.id.damageImmunities);
|
damageImmunities = root.findViewById(R.id.damageImmunities);
|
||||||
damageResistances = root.findViewById(R.id.damageResistances);
|
damageResistances = root.findViewById(R.id.damageResistances);
|
||||||
damageVulnerabilities = root.findViewById(R.id.damageVulnerabilities);
|
damageVulnerabilities = root.findViewById(R.id.damageVulnerabilities);
|
||||||
senses = root.findViewById(R.id.senses);
|
|
||||||
languages = root.findViewById(R.id.languages);
|
|
||||||
challengeRating = root.findViewById(R.id.challengeRating);
|
|
||||||
abilities = root.findViewById(R.id.abilities);
|
abilities = root.findViewById(R.id.abilities);
|
||||||
actions = root.findViewById(R.id.actions);
|
actions = root.findViewById(R.id.actions);
|
||||||
reactions = root.findViewById(R.id.reactions);
|
reactions = root.findViewById(R.id.reactions);
|
||||||
|
|||||||
@@ -702,6 +702,38 @@ public class EditMonsterViewModel extends ChangeTrackedViewModel {
|
|||||||
return mDamageResistances;
|
return mDamageResistances;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LiveData<List<String>> getDamageVulnerabilities() {
|
||||||
|
return mDamageVulnerabilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<String>> getConditionImmunities() {
|
||||||
|
return mConditionImmunities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getAbilities() {
|
||||||
|
return mAbilities;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getActions() {
|
||||||
|
return mActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getReactions() {
|
||||||
|
return mReactions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getLairActions() {
|
||||||
|
return mLairActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getLegendaryActions() {
|
||||||
|
return mLegendaryActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiveData<List<Trait>> getRegionalActions() {
|
||||||
|
return mRegionalActions;
|
||||||
|
}
|
||||||
|
|
||||||
public LiveData<List<Language>> getLanguages() {
|
public LiveData<List<Language>> getLanguages() {
|
||||||
return mLanguages;
|
return mLanguages;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,21 @@
|
|||||||
package com.majinnaibu.monstercards.ui.library;
|
package com.majinnaibu.monstercards.ui.library;
|
||||||
|
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.navigation.NavController;
|
||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
import androidx.recyclerview.widget.DividerItemDecoration;
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
@@ -15,41 +24,130 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import com.majinnaibu.monstercards.MainActivity;
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.importers.DnDBeyondImporter;
|
||||||
|
import com.majinnaibu.monstercards.importers.Open5eImporter;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.ui.monster.MonsterDetailFragmentDirections;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
import com.majinnaibu.monstercards.ui.shared.SwipeToDeleteCallback;
|
import com.majinnaibu.monstercards.ui.shared.SwipeToDeleteCallback;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.disposables.CompositeDisposable;
|
||||||
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
|
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
|
||||||
import io.reactivex.rxjava3.schedulers.Schedulers;
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class LibraryFragment extends MCFragment {
|
public class LibraryFragment extends MCFragment {
|
||||||
|
private final CompositeDisposable mDisposables = new CompositeDisposable();
|
||||||
|
|
||||||
public View onCreateView(@NonNull LayoutInflater inflater,
|
public View onCreateView(@NonNull LayoutInflater inflater,
|
||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
|
setHasOptionsMenu(true);
|
||||||
View root = inflater.inflate(R.layout.fragment_library, container, false);
|
View root = inflater.inflate(R.layout.fragment_library, container, false);
|
||||||
|
|
||||||
FloatingActionButton fab = root.findViewById(R.id.fab);
|
FloatingActionButton fab = root.findViewById(R.id.fab);
|
||||||
assert fab != null;
|
assert fab != null;
|
||||||
setupAddMonsterButton(fab);
|
setupAddMonsterButton(fab);
|
||||||
|
|
||||||
|
View emptyState = root.findViewById(R.id.empty_state);
|
||||||
|
View emptyStateButton = root.findViewById(R.id.empty_state_button);
|
||||||
|
if (emptyStateButton != null) {
|
||||||
|
emptyStateButton.setOnClickListener(v -> createNewMonster());
|
||||||
|
}
|
||||||
|
|
||||||
final RecyclerView recyclerView = root.findViewById(R.id.monster_list);
|
final RecyclerView recyclerView = root.findViewById(R.id.monster_list);
|
||||||
assert recyclerView != null;
|
assert recyclerView != null;
|
||||||
setupRecyclerView(recyclerView);
|
setupRecyclerView(recyclerView, emptyState);
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupRecyclerView(@NonNull RecyclerView recyclerView) {
|
@Override
|
||||||
|
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||||
|
inflater.inflate(R.menu.library_menu, menu);
|
||||||
|
super.onCreateOptionsMenu(menu, inflater);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||||
|
if (item.getItemId() == R.id.menu_action_import) {
|
||||||
|
showImportDialog();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_export_library) {
|
||||||
|
exportLibrary();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_export_everything) {
|
||||||
|
exportEverything();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_clear_all_data) {
|
||||||
|
showClearAllDataConfirmationDialog();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showClearAllDataConfirmationDialog() {
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.dialog_clear_all_data_title)
|
||||||
|
.setMessage(R.string.dialog_clear_all_data_message)
|
||||||
|
.setPositiveButton(R.string.action_clear, (dialog, which) -> {
|
||||||
|
mDisposables.add(getMonsterRepository().clearAllData()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.snackbar_all_data_cleared);
|
||||||
|
}
|
||||||
|
}, throwable -> Logger.logError("Failed to clear all data", throwable)));
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportLibrary() {
|
||||||
|
getMonsterRepository().getMonsters()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
String json = new com.majinnaibu.monstercards.exporters.BinderExporter().exportBinder("", monsters);
|
||||||
|
String fileName = getString(R.string.default_filename_library) + ".binder";
|
||||||
|
exportToFile(fileName, json);
|
||||||
|
}, Logger::logError);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void exportEverything() {
|
||||||
|
mDisposables.add(getMonsterRepository().exportEverything()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(json -> {
|
||||||
|
String fileName = getString(R.string.default_filename_export_everything) + ".binder";
|
||||||
|
exportToFile(fileName, json);
|
||||||
|
}, throwable -> Logger.logError("Failed to export everything", throwable)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupRecyclerView(@NonNull RecyclerView recyclerView, @Nullable View emptyState) {
|
||||||
Context context = requireContext();
|
Context context = requireContext();
|
||||||
MonsterRepository repository = this.getMonsterRepository();
|
MonsterRepository repository = this.getMonsterRepository();
|
||||||
|
|
||||||
|
mDisposables.add(repository.getMonsters()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(monsters -> {
|
||||||
|
boolean isEmpty = (monsters == null || monsters.isEmpty());
|
||||||
|
if (emptyState != null) {
|
||||||
|
emptyState.setVisibility(isEmpty ? View.VISIBLE : View.GONE);
|
||||||
|
}
|
||||||
|
recyclerView.setVisibility(isEmpty ? View.GONE : View.VISIBLE);
|
||||||
|
}, Logger::logError));
|
||||||
|
|
||||||
LibraryRecyclerViewAdapter adapter = new LibraryRecyclerViewAdapter(
|
LibraryRecyclerViewAdapter adapter = new LibraryRecyclerViewAdapter(
|
||||||
context,
|
context,
|
||||||
repository.getMonsters(),
|
repository.getMonsters(),
|
||||||
@@ -81,41 +179,43 @@ public class LibraryFragment extends MCFragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setupAddMonsterButton(@NonNull FloatingActionButton fab) {
|
private void setupAddMonsterButton(@NonNull FloatingActionButton fab) {
|
||||||
fab.setOnClickListener(view -> {
|
fab.setOnClickListener(view -> showLibraryFabOptionsDialog());
|
||||||
Monster monster = new Monster();
|
}
|
||||||
monster.name = getString(R.string.default_monster_name);
|
|
||||||
MonsterRepository repository = this.getMonsterRepository();
|
|
||||||
repository.addMonster(monster)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(
|
|
||||||
new DisposableCompletableObserver() {
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
View view = getView();
|
|
||||||
assert view != null;
|
|
||||||
Snackbar.make(
|
|
||||||
view,
|
|
||||||
getString(R.string.snackbar_monster_created, monster.name),
|
|
||||||
Snackbar.LENGTH_LONG)
|
|
||||||
.setAction("Action", (_view) -> navigateToMonsterDetail(monster.id))
|
|
||||||
.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
private void showLibraryFabOptionsDialog() {
|
||||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
String[] options = new String[]{
|
||||||
Logger.logError("Error creating monster", e);
|
getString(R.string.action_create_monster),
|
||||||
View view = getView();
|
getString(R.string.action_import)
|
||||||
assert view != null;
|
};
|
||||||
Snackbar.make(view, getString(R.string.snackbar_failed_to_create_monster), Snackbar.LENGTH_LONG)
|
new AlertDialog.Builder(requireContext())
|
||||||
.setAction("Action", null).show();
|
.setTitle(R.string.title_library_actions)
|
||||||
}
|
.setItems(options, (dialog, which) -> {
|
||||||
});
|
if (which == 0) {
|
||||||
});
|
createNewMonster();
|
||||||
|
} else if (which == 1) {
|
||||||
|
showImportDialog();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void navigateToMonsterDetail(@NonNull UUID monsterId) {
|
protected void navigateToMonsterDetail(@NonNull UUID monsterId) {
|
||||||
NavDirections action = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monsterId.toString());
|
NavDirections action = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monsterId.toString());
|
||||||
Navigation.findNavController(requireView()).navigate(action);
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void navigateToEditMonster(@NonNull UUID monsterId) {
|
||||||
|
NavController navController = Navigation.findNavController(requireView());
|
||||||
|
NavDirections action = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monsterId.toString());
|
||||||
|
navController.navigate(action);
|
||||||
|
action = MonsterDetailFragmentDirections.actionNavigationMonsterToEditMonsterFragment(monsterId.toString());
|
||||||
|
navController.navigate(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDestroyView() {
|
||||||
|
super.onDestroyView();
|
||||||
|
mDisposables.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,16 @@
|
|||||||
package com.majinnaibu.monstercards.ui.monster;
|
package com.majinnaibu.monstercards.ui.monster;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import androidx.core.content.FileProvider;
|
||||||
|
import com.majinnaibu.monstercards.exporters.Open5eExporter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
@@ -18,6 +26,7 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.lifecycle.ViewModelProvider;
|
import androidx.lifecycle.ViewModelProvider;
|
||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
@@ -26,14 +35,19 @@ import com.majinnaibu.monstercards.R;
|
|||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
import com.majinnaibu.monstercards.helpers.CommonMarkHelper;
|
import com.majinnaibu.monstercards.helpers.CommonMarkHelper;
|
||||||
import com.majinnaibu.monstercards.helpers.StringHelper;
|
import com.majinnaibu.monstercards.helpers.StringHelper;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
|
||||||
import io.reactivex.rxjava3.observers.DisposableSingleObserver;
|
import io.reactivex.rxjava3.observers.DisposableSingleObserver;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class MonsterDetailFragment extends MCFragment {
|
public class MonsterDetailFragment extends MCFragment {
|
||||||
private ViewHolder mHolder;
|
private ViewHolder mHolder;
|
||||||
@@ -172,10 +186,161 @@ public class MonsterDetailFragment extends MCFragment {
|
|||||||
Logger.logWTF("monsterId cannot be null.");
|
Logger.logWTF("monsterId cannot be null.");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_add_to_collection) {
|
||||||
|
showAddToCollectionDialog();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_add_to_dashboard) {
|
||||||
|
addCurrentMonsterToDashboard();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_share_monster) {
|
||||||
|
shareCurrentMonster();
|
||||||
|
return true;
|
||||||
|
} else if (item.getItemId() == R.id.menu_action_export_card) {
|
||||||
|
exportCurrentMonsterCard();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void exportCurrentMonsterCard() {
|
||||||
|
Monster monster = mViewModel.getMonster();
|
||||||
|
if (monster == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String jsonCard = new com.majinnaibu.monstercards.exporters.MonsterCardExporter().exportCard(monster);
|
||||||
|
String safeName = (monster.name != null && !monster.name.trim().isEmpty())
|
||||||
|
? monster.name.trim()
|
||||||
|
: "monster";
|
||||||
|
exportToFile(safeName + ".card", jsonCard);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void shareCurrentMonster() {
|
||||||
|
Monster monster = mViewModel.getMonster();
|
||||||
|
if (monster == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Open5eExporter exporter = new Open5eExporter();
|
||||||
|
String jsonCard = exporter.exportMonster(monster);
|
||||||
|
|
||||||
|
Context context = requireContext();
|
||||||
|
String safeName = (monster.name != null && !monster.name.trim().isEmpty())
|
||||||
|
? monster.name.replaceAll("[^a-zA-Z0-9._-]", "_")
|
||||||
|
: "monster";
|
||||||
|
File file = new File(context.getCacheDir(), safeName + ".card");
|
||||||
|
|
||||||
|
try (FileOutputStream out = new FileOutputStream(file)) {
|
||||||
|
out.write(jsonCard.getBytes(StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
Uri uri = FileProvider.getUriForFile(
|
||||||
|
context,
|
||||||
|
context.getPackageName() + ".fileprovider",
|
||||||
|
file
|
||||||
|
);
|
||||||
|
|
||||||
|
Intent shareIntent = new Intent(Intent.ACTION_SEND);
|
||||||
|
shareIntent.setType("application/octet-stream");
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_TEXT, jsonCard);
|
||||||
|
shareIntent.putExtra(Intent.EXTRA_SUBJECT, monster.name);
|
||||||
|
shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
|
||||||
|
startActivity(Intent.createChooser(shareIntent, getString(R.string.action_share_monster)));
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to share monster", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.failed_to_share_monster);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addCurrentMonsterToDashboard() {
|
||||||
|
UUID monsterId = mViewModel.getId().getValue();
|
||||||
|
if (monsterId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
repository.addMonsterToDashboard(monsterId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(() -> {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
String monsterName = mViewModel.getName().getValue();
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_added_to_dashboard, monsterName));
|
||||||
|
}
|
||||||
|
}, Logger::logError);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showAddToCollectionDialog() {
|
||||||
|
UUID monsterId = mViewModel.getId().getValue();
|
||||||
|
if (monsterId == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
repository.getCollections()
|
||||||
|
.firstOrError()
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new DisposableSingleObserver<List<Collection>>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(@io.reactivex.rxjava3.annotations.NonNull List<Collection> collections) {
|
||||||
|
if (collections.isEmpty()) {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.no_collections_available));
|
||||||
|
}
|
||||||
|
dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String[] collectionNames = new String[collections.size()];
|
||||||
|
for (int i = 0; i < collections.size(); i++) {
|
||||||
|
collectionNames[i] = collections.get(i).name;
|
||||||
|
}
|
||||||
|
new AlertDialog.Builder(requireContext())
|
||||||
|
.setTitle(R.string.title_select_collection)
|
||||||
|
.setItems(collectionNames, (dialog, which) -> {
|
||||||
|
Collection selectedCollection = collections.get(which);
|
||||||
|
addMonsterToCollection(selectedCollection, monsterId);
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
Logger.logError(e);
|
||||||
|
dispose();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addMonsterToCollection(@NonNull Collection collection, @NonNull UUID monsterId) {
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
repository.addMonsterToCollection(collection.id, monsterId)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new DisposableCompletableObserver() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
String monsterName = mViewModel.getName().getValue();
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_monster_added_to_collection, monsterName, collection.name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
Logger.logError(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
final TextView name;
|
final TextView name;
|
||||||
final TextView meta;
|
final TextView meta;
|
||||||
|
|||||||
@@ -181,6 +181,10 @@ public class MonsterDetailViewModel extends ViewModel {
|
|||||||
return mMonsterId;
|
return mMonsterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Monster getMonster() {
|
||||||
|
return mMonster;
|
||||||
|
}
|
||||||
|
|
||||||
public void setMonster(@NonNull Monster monster) {
|
public void setMonster(@NonNull Monster monster) {
|
||||||
mMonster = monster;
|
mMonster = monster;
|
||||||
mAbilities.setValue(mMonster.getAbilityDescriptions());
|
mAbilities.setValue(mMonster.getAbilityDescriptions());
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ import androidx.navigation.NavController;
|
|||||||
import androidx.navigation.NavDirections;
|
import androidx.navigation.NavDirections;
|
||||||
import androidx.navigation.Navigation;
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
|
||||||
import com.majinnaibu.monstercards.MonsterCardsApplication;
|
import com.majinnaibu.monstercards.MonsterCardsApplication;
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
@@ -34,6 +33,7 @@ import com.majinnaibu.monstercards.models.Monster;
|
|||||||
import com.majinnaibu.monstercards.ui.library.LibraryFragmentDirections;
|
import com.majinnaibu.monstercards.ui.library.LibraryFragmentDirections;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -162,18 +162,19 @@ public class MonsterImportFragment extends MCFragment {
|
|||||||
repository.addMonster(monster).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableCompletableObserver() {
|
repository.addMonster(monster).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new DisposableCompletableObserver() {
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
Snackbar.make(
|
if (getView() != null) {
|
||||||
mHolder.root,
|
NavController navController = Navigation.findNavController(requireView());
|
||||||
getString(R.string.snackbar_monster_created, monster.name),
|
NavDirections toLibraryAction = MonsterImportFragmentDirections.actionMonsterImportFragmentToNavigationLibrary();
|
||||||
Snackbar.LENGTH_LONG)
|
navController.navigate(toLibraryAction);
|
||||||
.setAction("Action", (_view) -> navigateToEditMonster(monster.id))
|
NavDirections toMonsterDetailAction = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monster.id.toString());
|
||||||
.show();
|
navController.navigate(toMonsterDetailAction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
Logger.logError("Error creating monster", e);
|
Logger.logError("Error creating monster", e);
|
||||||
Snackbar.make(mHolder.root, getString(R.string.snackbar_failed_to_create_monster), Snackbar.LENGTH_LONG).show();
|
SnackbarHelper.showLong(mHolder.root, getString(R.string.snackbar_failed_to_create_monster));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@@ -184,17 +185,6 @@ public class MonsterImportFragment extends MCFragment {
|
|||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void navigateToEditMonster(@NonNull UUID monsterId) {
|
|
||||||
NavController navController = Navigation.findNavController(requireView());
|
|
||||||
NavDirections action;
|
|
||||||
action = MonsterImportFragmentDirections.actionMonsterImportFragmentToNavigationLibrary();
|
|
||||||
navController.navigate(action);
|
|
||||||
action = LibraryFragmentDirections.actionNavigationLibraryToNavigationMonster(monsterId.toString());
|
|
||||||
navController.navigate(action);
|
|
||||||
action = MonsterDetailFragmentDirections.actionNavigationMonsterToEditMonsterFragment(monsterId.toString());
|
|
||||||
navController.navigate(action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class ViewHolder {
|
private static class ViewHolder {
|
||||||
final View root;
|
final View root;
|
||||||
final TextView name;
|
final TextView name;
|
||||||
|
|||||||
@@ -9,11 +9,14 @@ import android.view.ViewGroup;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.navigation.NavDirections;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.models.SearchResultItem;
|
||||||
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
import com.majinnaibu.monstercards.ui.shared.MCFragment;
|
||||||
|
|
||||||
public class SearchFragment extends MCFragment {
|
public class SearchFragment extends MCFragment {
|
||||||
@@ -22,7 +25,17 @@ public class SearchFragment extends MCFragment {
|
|||||||
ViewGroup container, Bundle savedInstanceState) {
|
ViewGroup container, Bundle savedInstanceState) {
|
||||||
View root = inflater.inflate(R.layout.fragment_search, container, false);
|
View root = inflater.inflate(R.layout.fragment_search, container, false);
|
||||||
MonsterRepository repository = this.getMonsterRepository();
|
MonsterRepository repository = this.getMonsterRepository();
|
||||||
SearchResultsRecyclerViewAdapter adapter = new SearchResultsRecyclerViewAdapter(repository, null);
|
SearchResultsRecyclerViewAdapter adapter = new SearchResultsRecyclerViewAdapter(repository, item -> {
|
||||||
|
if (item != null) {
|
||||||
|
if (item.type == SearchResultItem.Type.MONSTER && item.monster != null) {
|
||||||
|
NavDirections action = SearchFragmentDirections.actionNavigationSearchToNavigationMonster(item.monster.id.toString());
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
} else if (item.type == SearchResultItem.Type.COLLECTION && item.collection != null) {
|
||||||
|
NavDirections action = SearchFragmentDirections.actionNavigationSearchToCollectionDetailFragment(item.collection.id.toString());
|
||||||
|
Navigation.findNavController(requireView()).navigate(action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
final RecyclerView recyclerView = root.findViewById(R.id.monster_list);
|
final RecyclerView recyclerView = root.findViewById(R.id.monster_list);
|
||||||
assert recyclerView != null;
|
assert recyclerView != null;
|
||||||
setupRecyclerView(recyclerView, adapter);
|
setupRecyclerView(recyclerView, adapter);
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.majinnaibu.monstercards.ui.search;
|
|||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
@@ -10,7 +11,10 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.majinnaibu.monstercards.R;
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.helpers.StringHelper;
|
||||||
|
import com.majinnaibu.monstercards.models.Collection;
|
||||||
import com.majinnaibu.monstercards.models.Monster;
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.models.SearchResultItem;
|
||||||
import com.majinnaibu.monstercards.utils.Logger;
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -23,7 +27,7 @@ public class SearchResultsRecyclerViewAdapter extends RecyclerView.Adapter<Searc
|
|||||||
private final MonsterRepository mRepository;
|
private final MonsterRepository mRepository;
|
||||||
private final ItemCallback mOnClickHandler;
|
private final ItemCallback mOnClickHandler;
|
||||||
private String mSearchText;
|
private String mSearchText;
|
||||||
private List<Monster> mValues;
|
private List<SearchResultItem> mValues;
|
||||||
private Disposable mSubscriptionHandler;
|
private Disposable mSubscriptionHandler;
|
||||||
|
|
||||||
public SearchResultsRecyclerViewAdapter(MonsterRepository repository,
|
public SearchResultsRecyclerViewAdapter(MonsterRepository repository,
|
||||||
@@ -42,9 +46,9 @@ public class SearchResultsRecyclerViewAdapter extends RecyclerView.Adapter<Searc
|
|||||||
mSubscriptionHandler.dispose();
|
mSubscriptionHandler.dispose();
|
||||||
}
|
}
|
||||||
mSearchText = searchText;
|
mSearchText = searchText;
|
||||||
Flowable<List<Monster>> foundMonsters = mRepository.searchMonsters(mSearchText);
|
Flowable<List<SearchResultItem>> resultsFlowable = mRepository.searchAll(mSearchText);
|
||||||
mSubscriptionHandler = foundMonsters.subscribe(monsters -> {
|
mSubscriptionHandler = resultsFlowable.subscribe(results -> {
|
||||||
mValues = monsters;
|
mValues = results;
|
||||||
notifyDataSetChanged();
|
notifyDataSetChanged();
|
||||||
},
|
},
|
||||||
throwable -> Logger.logError("Error performing search", throwable));
|
throwable -> Logger.logError("Error performing search", throwable));
|
||||||
@@ -54,18 +58,52 @@ public class SearchResultsRecyclerViewAdapter extends RecyclerView.Adapter<Searc
|
|||||||
@Override
|
@Override
|
||||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||||
View view = LayoutInflater.from(parent.getContext())
|
View view = LayoutInflater.from(parent.getContext())
|
||||||
.inflate(R.layout.monster_list_content, parent, false);
|
.inflate(R.layout.search_result_list_item, parent, false);
|
||||||
return new ViewHolder(view);
|
return new ViewHolder(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
|
public void onBindViewHolder(@NonNull final ViewHolder holder, int position) {
|
||||||
Monster monster = mValues.get(position);
|
SearchResultItem item = mValues.get(position);
|
||||||
holder.mContentView.setText(monster.name);
|
if (item.type == SearchResultItem.Type.MONSTER && item.monster != null) {
|
||||||
holder.itemView.setTag(monster);
|
Monster monster = item.monster;
|
||||||
|
holder.mTitleView.setText(monster.name);
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (!StringHelper.isNullOrEmpty(monster.alignment)) {
|
||||||
|
sb.append(monster.alignment);
|
||||||
|
}
|
||||||
|
String cr = monster.getChallengeRatingDescription();
|
||||||
|
if (!StringHelper.isNullOrEmpty(cr)) {
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
sb.append(", ");
|
||||||
|
}
|
||||||
|
sb.append("CR ").append(cr);
|
||||||
|
}
|
||||||
|
if (sb.length() > 0) {
|
||||||
|
holder.mSubtitleView.setText(sb.toString());
|
||||||
|
holder.mSubtitleView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.mSubtitleView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
holder.mIconView.setVisibility(View.GONE);
|
||||||
|
} else if (item.type == SearchResultItem.Type.COLLECTION && item.collection != null) {
|
||||||
|
Collection collection = item.collection;
|
||||||
|
holder.mTitleView.setText(collection.name);
|
||||||
|
|
||||||
|
if (!StringHelper.isNullOrEmpty(collection.description)) {
|
||||||
|
holder.mSubtitleView.setText(collection.description);
|
||||||
|
holder.mSubtitleView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
holder.mSubtitleView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
holder.mIconView.setVisibility(View.VISIBLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
holder.itemView.setTag(item);
|
||||||
holder.itemView.setOnClickListener(view -> {
|
holder.itemView.setOnClickListener(view -> {
|
||||||
if (mOnClickHandler != null) {
|
if (mOnClickHandler != null) {
|
||||||
mOnClickHandler.onItem(monster);
|
mOnClickHandler.onItem(item);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -76,15 +114,19 @@ public class SearchResultsRecyclerViewAdapter extends RecyclerView.Adapter<Searc
|
|||||||
}
|
}
|
||||||
|
|
||||||
public interface ItemCallback {
|
public interface ItemCallback {
|
||||||
void onItem(Monster monster);
|
void onItem(SearchResultItem item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ViewHolder extends RecyclerView.ViewHolder {
|
public static class ViewHolder extends RecyclerView.ViewHolder {
|
||||||
final TextView mContentView;
|
final TextView mTitleView;
|
||||||
|
final TextView mSubtitleView;
|
||||||
|
final ImageView mIconView;
|
||||||
|
|
||||||
ViewHolder(View view) {
|
ViewHolder(View view) {
|
||||||
super(view);
|
super(view);
|
||||||
mContentView = view.findViewById(R.id.content);
|
mTitleView = view.findViewById(R.id.title);
|
||||||
|
mSubtitleView = view.findViewById(R.id.subtitle);
|
||||||
|
mIconView = view.findViewById(R.id.icon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,252 @@
|
|||||||
package com.majinnaibu.monstercards.ui.shared;
|
package com.majinnaibu.monstercards.ui.shared;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.database.Cursor;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.os.Build;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.provider.DocumentsContract;
|
||||||
|
import android.provider.OpenableColumns;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
|
||||||
|
import androidx.activity.result.ActivityResultLauncher;
|
||||||
|
import androidx.activity.result.contract.ActivityResultContracts;
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
import androidx.appcompat.app.ActionBar;
|
import androidx.appcompat.app.ActionBar;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.navigation.NavController;
|
||||||
|
import androidx.navigation.Navigation;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.MainActivity;
|
||||||
import com.majinnaibu.monstercards.MonsterCardsApplication;
|
import com.majinnaibu.monstercards.MonsterCardsApplication;
|
||||||
|
import com.majinnaibu.monstercards.R;
|
||||||
import com.majinnaibu.monstercards.data.MonsterRepository;
|
import com.majinnaibu.monstercards.data.MonsterRepository;
|
||||||
|
import com.majinnaibu.monstercards.importers.DnDBeyondImporter;
|
||||||
|
import com.majinnaibu.monstercards.importers.Open5eImporter;
|
||||||
|
import com.majinnaibu.monstercards.models.Monster;
|
||||||
|
import com.majinnaibu.monstercards.utils.Logger;
|
||||||
|
import com.majinnaibu.monstercards.utils.SnackbarHelper;
|
||||||
|
import com.majinnaibu.monstercards.utils.ToastHelper;
|
||||||
|
|
||||||
|
import com.majinnaibu.monstercards.data.ImportConfig;
|
||||||
|
import com.majinnaibu.monstercards.models.ImportSource;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers;
|
||||||
|
import io.reactivex.rxjava3.observers.DisposableCompletableObserver;
|
||||||
|
import io.reactivex.rxjava3.schedulers.Schedulers;
|
||||||
|
|
||||||
public class MCFragment extends Fragment {
|
public class MCFragment extends Fragment {
|
||||||
|
private String mPendingExportContent;
|
||||||
|
private ActivityResultLauncher<Intent> mCreateDocumentLauncher;
|
||||||
|
private ActivityResultLauncher<Intent> mOpenDocumentLauncher;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
mCreateDocumentLauncher = registerForActivityResult(
|
||||||
|
new ActivityResultContracts.StartActivityForResult(),
|
||||||
|
result -> {
|
||||||
|
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||||
|
Uri uri = result.getData().getData();
|
||||||
|
if (uri != null && mPendingExportContent != null) {
|
||||||
|
writeContentToUri(uri, mPendingExportContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mPendingExportContent = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
mOpenDocumentLauncher = registerForActivityResult(
|
||||||
|
new ActivityResultContracts.StartActivityForResult(),
|
||||||
|
result -> {
|
||||||
|
if (result.getResultCode() == Activity.RESULT_OK && result.getData() != null) {
|
||||||
|
Intent data = result.getData();
|
||||||
|
List<Uri> uris = new ArrayList<>();
|
||||||
|
if (data.getClipData() != null) {
|
||||||
|
ClipData clipData = data.getClipData();
|
||||||
|
for (int i = 0; i < clipData.getItemCount(); i++) {
|
||||||
|
Uri uri = clipData.getItemAt(i).getUri();
|
||||||
|
if (uri != null) {
|
||||||
|
uris.add(uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (data.getData() != null) {
|
||||||
|
uris.add(data.getData());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!uris.isEmpty() && getActivity() instanceof MainActivity) {
|
||||||
|
((MainActivity) getActivity()).importMultipleFilesFromUris(uris);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importMonsterFromFile() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
|
||||||
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("*/*");
|
||||||
|
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
|
||||||
|
try {
|
||||||
|
mOpenDocumentLauncher.launch(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to launch file picker", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.failed_to_import_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void importCollectionFromFile() {
|
||||||
|
importMonsterFromFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void showImportDialog() {
|
||||||
|
Context context = requireContext();
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle(R.string.dialog_import_title);
|
||||||
|
|
||||||
|
View view = getLayoutInflater().inflate(R.layout.dialog_import, null);
|
||||||
|
builder.setView(view);
|
||||||
|
|
||||||
|
AlertDialog dialog = builder.create();
|
||||||
|
|
||||||
|
final EditText input = view.findViewById(R.id.edit_text_url);
|
||||||
|
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||||
|
if (clipboard != null && clipboard.hasPrimaryClip()) {
|
||||||
|
ClipData clip = clipboard.getPrimaryClip();
|
||||||
|
if (clip != null && clip.getItemCount() > 0) {
|
||||||
|
CharSequence clipText = clip.getItemAt(0).getText();
|
||||||
|
if (clipText != null) {
|
||||||
|
String clipStr = clipText.toString().trim();
|
||||||
|
if (new DnDBeyondImporter().canImport(clipStr) || new Open5eImporter().canImport(clipStr)) {
|
||||||
|
input.setText(clipStr);
|
||||||
|
input.selectAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_import_url).setOnClickListener(v -> {
|
||||||
|
String urlOrId = input.getText().toString().trim();
|
||||||
|
if (!urlOrId.isEmpty()) {
|
||||||
|
if (getActivity() instanceof MainActivity) {
|
||||||
|
((MainActivity) getActivity()).importMonsterFromInputAndNavigate(urlOrId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_import_file).setOnClickListener(v -> {
|
||||||
|
importMonsterFromFile();
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
|
||||||
|
view.findViewById(R.id.button_import_source).setOnClickListener(v -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
showSourcePicker();
|
||||||
|
});
|
||||||
|
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void showSourcePicker() {
|
||||||
|
Context context = requireContext();
|
||||||
|
List<ImportSource> sources = ImportConfig.SOURCES;
|
||||||
|
if (sources.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] repoNames = new String[sources.size()];
|
||||||
|
for (int i = 0; i < sources.size(); i++) {
|
||||||
|
repoNames[i] = sources.get(i).projectName;
|
||||||
|
}
|
||||||
|
|
||||||
|
new AlertDialog.Builder(context)
|
||||||
|
.setTitle(R.string.dialog_select_import_source)
|
||||||
|
.setItems(repoNames, (d, which) -> {
|
||||||
|
ImportSource selected = sources.get(which);
|
||||||
|
if (getActivity() instanceof MainActivity) {
|
||||||
|
((MainActivity) getActivity()).startImportFromSource(selected);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.setNegativeButton(R.string.dialog_cancel, null)
|
||||||
|
.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createNewMonster() {
|
||||||
|
Monster monster = new Monster();
|
||||||
|
monster.name = getString(R.string.default_monster_name);
|
||||||
|
MonsterRepository repository = getMonsterRepository();
|
||||||
|
repository.addMonster(monster)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new DisposableCompletableObserver() {
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
navigateToEditMonster(monster.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@io.reactivex.rxjava3.annotations.NonNull Throwable e) {
|
||||||
|
Logger.logError("Error creating monster", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, getString(R.string.snackbar_failed_to_create_monster));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void navigateToEditMonster(@NonNull UUID monsterId) {
|
||||||
|
try {
|
||||||
|
NavController navController = Navigation.findNavController(requireView());
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putString("monster_id", monsterId.toString());
|
||||||
|
navController.navigate(R.id.edit_monster_navigation, args);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Error navigating to edit monster", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String readContentsFromUri(@NonNull Uri uri) {
|
||||||
|
Context context = getContext();
|
||||||
|
if (context == null) return null;
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
try (InputStream inputStream = context.getContentResolver().openInputStream(uri);
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(Objects.requireNonNull(inputStream), StandardCharsets.UTF_8))) {
|
||||||
|
String line;
|
||||||
|
while ((line = reader.readLine()) != null) {
|
||||||
|
builder.append(line).append("\n");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Error reading URI contents for import", e);
|
||||||
|
Context ctx = getContext();
|
||||||
|
if (ctx != null) {
|
||||||
|
ToastHelper.showLong(ctx, "An error occurred while reading the file.");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
public MonsterCardsApplication getApplication() {
|
public MonsterCardsApplication getApplication() {
|
||||||
return (MonsterCardsApplication) requireActivity().getApplication();
|
return (MonsterCardsApplication) requireActivity().getApplication();
|
||||||
}
|
}
|
||||||
@@ -32,4 +269,76 @@ public class MCFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void exportToFile(@NonNull String defaultFileName, @NonNull String content) {
|
||||||
|
mPendingExportContent = content;
|
||||||
|
Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT);
|
||||||
|
intent.addCategory(Intent.CATEGORY_OPENABLE);
|
||||||
|
intent.setType("*/*");
|
||||||
|
intent.putExtra(Intent.EXTRA_TITLE, defaultFileName);
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
|
Uri downloadsUri = Uri.parse("content://com.android.externalstorage.documents/document/primary%3ADownload");
|
||||||
|
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, downloadsUri);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mCreateDocumentLauncher.launch(intent);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to launch document creation picker", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.snackbar_export_failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeContentToUri(@NonNull Uri uri, @NonNull String content) {
|
||||||
|
Context context = getContext();
|
||||||
|
if (context == null) return;
|
||||||
|
try (OutputStream out = context.getContentResolver().openOutputStream(uri)) {
|
||||||
|
if (out != null) {
|
||||||
|
out.write(content.getBytes(StandardCharsets.UTF_8));
|
||||||
|
out.flush();
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
String fileName = getFileNameFromUri(context, uri);
|
||||||
|
String message = getString(R.string.snackbar_export_success, fileName);
|
||||||
|
SnackbarHelper.showLong(view, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Failed to write export content to URI", e);
|
||||||
|
View view = getView();
|
||||||
|
if (view != null) {
|
||||||
|
SnackbarHelper.showLong(view, R.string.snackbar_export_failed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFileNameFromUri(@NonNull Context context, @NonNull Uri uri) {
|
||||||
|
String displayName = null;
|
||||||
|
if ("content".equals(uri.getScheme())) {
|
||||||
|
try (Cursor cursor = context.getContentResolver().query(uri, new String[]{OpenableColumns.DISPLAY_NAME}, null, null, null)) {
|
||||||
|
if (cursor != null && cursor.moveToFirst()) {
|
||||||
|
int nameIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME);
|
||||||
|
if (nameIndex != -1) {
|
||||||
|
displayName = cursor.getString(nameIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Logger.logError("Error querying display name from content URI", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return displayName != null ? displayName : defaultFileNameFromUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String defaultFileNameFromUri(@NonNull Uri uri) {
|
||||||
|
String path = uri.getPath();
|
||||||
|
if (path != null) {
|
||||||
|
int lastSlash = path.lastIndexOf('/');
|
||||||
|
if (lastSlash >= 0 && lastSlash < path.length() - 1) {
|
||||||
|
return path.substring(lastSlash + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return uri.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.majinnaibu.monstercards.utils;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Centralized helper for managing Snackbar notifications and durations across the app.
|
||||||
|
*/
|
||||||
|
public class SnackbarHelper {
|
||||||
|
// Configurable default durations in milliseconds
|
||||||
|
public static int DEFAULT_SHORT_DURATION = 2500; // 2.5 seconds
|
||||||
|
public static int DEFAULT_LONG_DURATION = 4000; // 4.0 seconds (e.g. for Undo or action messages)
|
||||||
|
|
||||||
|
public static Snackbar makeShort(@NonNull View view, @StringRes int resId) {
|
||||||
|
return make(view, view.getContext().getString(resId), DEFAULT_SHORT_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar makeShort(@NonNull View view, @NonNull CharSequence message) {
|
||||||
|
return make(view, message, DEFAULT_SHORT_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar makeLong(@NonNull View view, @StringRes int resId) {
|
||||||
|
return make(view, view.getContext().getString(resId), DEFAULT_LONG_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar makeLong(@NonNull View view, @NonNull CharSequence message) {
|
||||||
|
return make(view, message, DEFAULT_LONG_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar makeIndefinite(@NonNull View view, @StringRes int resId) {
|
||||||
|
return Snackbar.make(view, resId, Snackbar.LENGTH_INDEFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar makeIndefinite(@NonNull View view, @NonNull CharSequence message) {
|
||||||
|
return Snackbar.make(view, message, Snackbar.LENGTH_INDEFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Snackbar make(@NonNull View view, @NonNull CharSequence message, int durationMs) {
|
||||||
|
return Snackbar.make(view, message, durationMs);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showShort(@NonNull View view, @StringRes int resId) {
|
||||||
|
makeShort(view, resId).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showShort(@NonNull View view, @NonNull CharSequence message) {
|
||||||
|
makeShort(view, message).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showLong(@NonNull View view, @StringRes int resId) {
|
||||||
|
makeLong(view, resId).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showLong(@NonNull View view, @NonNull CharSequence message) {
|
||||||
|
makeLong(view, message).show();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package com.majinnaibu.monstercards.utils;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.annotation.StringRes;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Centralized helper for managing Toast notifications and durations across the app.
|
||||||
|
*/
|
||||||
|
public class ToastHelper {
|
||||||
|
// Configurable default durations
|
||||||
|
public static int DEFAULT_SHORT_DURATION = Toast.LENGTH_SHORT; // ~2.0 seconds
|
||||||
|
public static int DEFAULT_LONG_DURATION = Toast.LENGTH_LONG; // ~3.5 seconds
|
||||||
|
|
||||||
|
private static Toast sCurrentToast;
|
||||||
|
|
||||||
|
public static void showShort(@NonNull Context context, @StringRes int resId) {
|
||||||
|
show(context, context.getString(resId), DEFAULT_SHORT_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showShort(@NonNull Context context, @NonNull String message) {
|
||||||
|
show(context, message, DEFAULT_SHORT_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showLong(@NonNull Context context, @StringRes int resId) {
|
||||||
|
show(context, context.getString(resId), DEFAULT_LONG_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void showLong(@NonNull Context context, @NonNull String message) {
|
||||||
|
show(context, message, DEFAULT_LONG_DURATION);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void show(@NonNull Context context, @NonNull String message, int duration) {
|
||||||
|
if (sCurrentToast != null) {
|
||||||
|
sCurrentToast.cancel();
|
||||||
|
}
|
||||||
|
sCurrentToast = Toast.makeText(context.getApplicationContext(), message, duration);
|
||||||
|
sCurrentToast.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
10
Android/app/src/main/res/drawable/ic_expand_less_24.xml
Normal file
10
Android/app/src/main/res/drawable/ic_expand_less_24.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M12,8l-6,6 1.41,1.41L12,10.83l4.59,4.58L18,14z"/>
|
||||||
|
</vector>
|
||||||
10
Android/app/src/main/res/drawable/ic_expand_more_24.xml
Normal file
10
Android/app/src/main/res/drawable/ic_expand_more_24.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
|
||||||
|
</vector>
|
||||||
@@ -5,166 +5,6 @@
|
|||||||
android:viewportWidth="108"
|
android:viewportWidth="108"
|
||||||
android:viewportHeight="108">
|
android:viewportHeight="108">
|
||||||
<path
|
<path
|
||||||
android:fillColor="#3DDC84"
|
android:fillColor="@color/colorPrimaryDark"
|
||||||
android:pathData="M0,0h108v108h-108z" />
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M9,0L9,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,0L19,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,0L29,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,0L39,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,0L49,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,0L59,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,0L69,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,0L79,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M89,0L89,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M99,0L99,108"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,9L108,9"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,19L108,19"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,29L108,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,39L108,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,49L108,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,59L108,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,69L108,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,79L108,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,89L108,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M0,99L108,99"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,29L89,29"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,39L89,39"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,49L89,49"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,59L89,59"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,69L89,69"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M19,79L89,79"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M29,19L29,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M39,19L39,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M49,19L49,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M59,19L59,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M69,19L69,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
<path
|
|
||||||
android:fillColor="#00000000"
|
|
||||||
android:pathData="M79,19L79,89"
|
|
||||||
android:strokeWidth="0.8"
|
|
||||||
android:strokeColor="#33FFFFFF" />
|
|
||||||
</vector>
|
</vector>
|
||||||
|
|||||||
BIN
Android/app/src/main/res/drawable/ic_launcher_foreground.png
Normal file
BIN
Android/app/src/main/res/drawable/ic_launcher_foreground.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
BIN
Android/app/src/main/res/drawable/ic_logo.png
Normal file
BIN
Android/app/src/main/res/drawable/ic_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 485 KiB |
10
Android/app/src/main/res/drawable/ic_share_24.xml
Normal file
10
Android/app/src/main/res/drawable/ic_share_24.xml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24"
|
||||||
|
android:tint="?attr/colorControlNormal">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M18,16.08c-0.76,0 -1.44,0.3 -1.96,0.77L8.91,12.7c0.05,-0.23 0.09,-0.47 0.09,-0.7s-0.04,-0.47 -0.09,-0.7l7.05,-4.11c0.54,0.5 1.25,0.81 2.04,0.81 1.66,0 3,-1.34 3,-3s-1.34,-3 -3,-3 -3,1.34 -3,3c0,0.23 0.04,0.47 0.09,0.7L8.04,9.81C7.5,9.31 6.79,9 6,9c-1.66,0 -3,1.34 -3,3s1.34,3 3,3c0.79,0 1.5,-0.31 2.04,-0.81l7.12,4.16c-0.05,0.21 -0.08,0.43 -0.08,0.65 0,1.61 1.31,2.92 2.92,2.92 1.61,0 2.92,-1.31 2.92,-2.92s-1.31,-2.92 -2.92,-2.92z"/>
|
||||||
|
</vector>
|
||||||
BIN
Android/app/src/main/res/drawable/ic_splash_combined.png
Normal file
BIN
Android/app/src/main/res/drawable/ic_splash_combined.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 98 KiB |
BIN
Android/app/src/main/res/drawable/ic_splash_logo.png
Normal file
BIN
Android/app/src/main/res/drawable/ic_splash_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 100 KiB |
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<!-- Solid dark red background -->
|
||||||
|
<item android:drawable="@color/colorPrimaryDark" />
|
||||||
|
|
||||||
|
<!-- Centered logo + Spindle's End font text -->
|
||||||
|
<item
|
||||||
|
android:width="280dp"
|
||||||
|
android:height="280dp"
|
||||||
|
android:drawable="@drawable/ic_splash_combined"
|
||||||
|
android:gravity="center" />
|
||||||
|
</layer-list>
|
||||||
BIN
Android/app/src/main/res/font/spindles_end.ttf
Normal file
BIN
Android/app/src/main/res/font/spindles_end.ttf
Normal file
Binary file not shown.
@@ -3,7 +3,27 @@
|
|||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
android:id="@+id/container"
|
android:id="@+id/container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="?attr/colorSurface">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.AppBarLayout
|
||||||
|
android:id="@+id/app_bar_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent">
|
||||||
|
|
||||||
|
<com.google.android.material.appbar.MaterialToolbar
|
||||||
|
android:id="@+id/toolbar"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="?attr/actionBarSize"
|
||||||
|
android:background="?attr/colorPrimary"
|
||||||
|
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar"
|
||||||
|
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
|
||||||
|
app:navigationIconTint="@android:color/white"
|
||||||
|
app:titleTextColor="@android:color/white" />
|
||||||
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||||
android:id="@+id/nav_view"
|
android:id="@+id/nav_view"
|
||||||
@@ -11,7 +31,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="0dp"
|
android:layout_marginStart="0dp"
|
||||||
android:layout_marginEnd="0dp"
|
android:layout_marginEnd="0dp"
|
||||||
android:background="?android:attr/windowBackground"
|
android:background="?attr/colorSurface"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
@@ -19,7 +39,6 @@
|
|||||||
|
|
||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/nav_host_fragment"
|
android:id="@+id/nav_host_fragment"
|
||||||
|
|
||||||
android:name="androidx.navigation.fragment.NavHostFragment"
|
android:name="androidx.navigation.fragment.NavHostFragment"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
@@ -28,8 +47,8 @@
|
|||||||
app:layout_constraintHorizontal_bias="0.0"
|
app:layout_constraintHorizontal_bias="0.0"
|
||||||
app:layout_constraintLeft_toLeftOf="parent"
|
app:layout_constraintLeft_toLeftOf="parent"
|
||||||
app:layout_constraintRight_toRightOf="parent"
|
app:layout_constraintRight_toRightOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toBottomOf="@id/app_bar_layout"
|
||||||
app:layout_constraintVertical_bias="0.0"
|
app:layout_constraintVertical_bias="0.0"
|
||||||
app:navGraph="@navigation/mobile_navigation" />
|
app:navGraph="@navigation/mobile_navigation" />
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
34
Android/app/src/main/res/layout/activity_splash.xml
Normal file
34
Android/app/src/main/res/layout/activity_splash.xml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/colorPrimaryDark">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/splash_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="24dp"
|
||||||
|
android:fontFamily="@font/spindles_end"
|
||||||
|
android:text="@string/app_title_splash"
|
||||||
|
android:textColor="@android:color/white"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
app:layout_constraintBottom_toTopOf="@id/splash_logo"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/splash_logo"
|
||||||
|
android:layout_width="220dp"
|
||||||
|
android:layout_height="220dp"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
|
android:scaleType="fitCenter"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:srcCompat="@drawable/ic_logo" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
45
Android/app/src/main/res/layout/collection_list_item.xml
Normal file
45
Android/app/src/main/res/layout/collection_list_item.xml
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/collection_name"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:textAppearance="?attr/textAppearanceListItem"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:maxLines="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/collection_count"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="8dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?android:attr/textColorSecondary" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/collection_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:textAppearance="?attr/textAppearanceListItemSecondary"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
@@ -59,6 +59,7 @@
|
|||||||
android:id="@+id/decrement"
|
android:id="@+id/decrement"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
android:paddingVertical="8dp"
|
android:paddingVertical="8dp"
|
||||||
android:text="@string/label_decrement_field"
|
android:text="@string/label_decrement_field"
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
|||||||
50
Android/app/src/main/res/layout/dialog_import.xml
Normal file
50
Android/app/src/main/res/layout/dialog_import.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="24dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/dialog_import_message"
|
||||||
|
android:paddingBottom="8dp" />
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/edit_text_url"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/dialog_import_url_hint"
|
||||||
|
android:inputType="textUri"
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:singleLine="true" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_import_url"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/action_import_from_url" />
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:background="?android:attr/listDivider" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_import_file"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/action_import_monster_from_file" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/button_import_source"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:text="@string/action_import_from_source" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
tools:context=".ui.collections.CollectionDetailFragment">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/collection_header"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="16dp"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_collection_name"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/detail_collection_description"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:visibility="gone" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/header_divider"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:background="?android:attr/listDivider"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/collection_header" />
|
||||||
|
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/collection_monster_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:clipToPadding="false"
|
||||||
|
android:padding="@dimen/padding_normal"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/header_divider"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
tools:listitem="@layout/card_monster" />
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_add_monster_to_collection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:contentDescription="@string/action_add_monster"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:srcCompat="@android:drawable/ic_input_add"
|
||||||
|
app:tint="@android:color/white" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
@@ -6,17 +6,76 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.collections.CollectionsFragment">
|
tools:context=".ui.collections.CollectionsFragment">
|
||||||
|
|
||||||
<TextView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/text_collections"
|
android:id="@+id/collection_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="8dp"
|
app:layoutManager="LinearLayoutManager"
|
||||||
android:layout_marginTop="8dp"
|
|
||||||
android:layout_marginEnd="8dp"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="20sp"
|
|
||||||
app:layout_constraintBottom_toBottomOf="parent"
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
tools:listitem="@layout/collection_list_item" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/empty_state"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="32dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/empty_state_logo"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="140dp"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
|
app:srcCompat="@drawable/ic_logo" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_state_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/empty_collections_title"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_state_subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/empty_collections_subtitle"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/empty_state_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/action_add_collection"
|
||||||
|
app:cornerRadius="20dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_add_collection"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:contentDescription="@string/action_add_collection"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:srcCompat="@android:drawable/ic_input_add"
|
||||||
|
app:tint="@android:color/white" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -20,4 +20,66 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:listitem="@layout/card_monster" />
|
tools:listitem="@layout/card_monster" />
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/empty_state"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="32dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/empty_state_logo"
|
||||||
|
android:layout_width="140dp"
|
||||||
|
android:layout_height="140dp"
|
||||||
|
android:contentDescription="@string/app_name"
|
||||||
|
app:srcCompat="@drawable/ic_logo" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_state_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/empty_dashboard_title"
|
||||||
|
android:textColor="?android:attr/textColorPrimary"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/empty_state_subtitle"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/empty_dashboard_subtitle"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/empty_state_button"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:text="@string/action_add_to_dashboard"
|
||||||
|
app:cornerRadius="20dp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
|
android:id="@+id/fab_add_to_dashboard"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_margin="@dimen/fab_margin"
|
||||||
|
android:contentDescription="@string/action_add_to_dashboard"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:srcCompat="@android:drawable/ic_input_add"
|
||||||
|
app:tint="@android:color/white" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".ui.editmonster.EditBasicInfoFragment">
|
android:clipToPadding="false"
|
||||||
|
android:padding="16dp"
|
||||||
|
tools:context=".ui.editmonster.EditAbilityScoresFragment">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user