diff --git a/Makefile b/Makefile index c4d6741be..dd313b7f4 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ apple_extension_gen: $(MAKE) -C apple extension_gen droid: + @if ! [ -e android/Omnivore/app/src/main/res/values/secrets.xml ]; then \ + cp android/Omnivore/secrets.xml android/Omnivore/app/src/main/res/values/secrets.xml; \ + fi studio android/Omnivore webview_gen: diff --git a/android/Omnivore/README.md b/android/Omnivore/README.md new file mode 100644 index 000000000..cd631fb4f --- /dev/null +++ b/android/Omnivore/README.md @@ -0,0 +1,11 @@ +# Omnivore - Android + +## Setup + +From the root directory run the following command: + +`make droid` + +This will copy a secrets.xml file into the strings directory. +If you have a PSPDF license key then paste that value into the +`pspdfkit_license_key` entry in that file. diff --git a/android/Omnivore/app/.gitignore b/android/Omnivore/app/.gitignore index 6a4362e1c..0631eecca 100644 --- a/android/Omnivore/app/.gitignore +++ b/android/Omnivore/app/.gitignore @@ -1,3 +1,4 @@ /build keystore.properties -*.keystore \ No newline at end of file +*.keystore +src/main/res/values/secrets.xml \ No newline at end of file diff --git a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/MainActivity.kt b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/MainActivity.kt index ff2d4f155..abe2cec31 100644 --- a/android/Omnivore/app/src/main/java/app/omnivore/omnivore/MainActivity.kt +++ b/android/Omnivore/app/src/main/java/app/omnivore/omnivore/MainActivity.kt @@ -10,16 +10,20 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color -import app.omnivore.omnivore.ui.theme.OmnivoreTheme import androidx.core.view.ViewCompat import androidx.core.view.WindowCompat import androidx.core.view.WindowInsetsCompat import app.omnivore.omnivore.ui.auth.LoginViewModel import app.omnivore.omnivore.ui.home.HomeViewModel -import app.omnivore.omnivore.ui.reader.PDFReaderViewModel import app.omnivore.omnivore.ui.reader.WebReaderViewModel import app.omnivore.omnivore.ui.root.RootView +import app.omnivore.omnivore.ui.theme.OmnivoreTheme +import com.pspdfkit.PSPDFKit import dagger.hilt.android.AndroidEntryPoint +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch + @AndroidEntryPoint class MainActivity : ComponentActivity() { @@ -30,6 +34,18 @@ class MainActivity : ComponentActivity() { val homeViewModel: HomeViewModel by viewModels() val webReaderViewModel: WebReaderViewModel by viewModels() + val context = this + + GlobalScope.launch(Dispatchers.IO) { + val licenseKey = getString(R.string.pspdfkit_license_key) + + if (licenseKey.length > 30) { + PSPDFKit.initialize(context, licenseKey) + } else { + PSPDFKit.initialize(context, null) + } + } + setContent { OmnivoreTheme { Box( diff --git a/android/Omnivore/secrets.xml b/android/Omnivore/secrets.xml new file mode 100644 index 000000000..89a05bdea --- /dev/null +++ b/android/Omnivore/secrets.xml @@ -0,0 +1,4 @@ + + + unset + \ No newline at end of file