diff --git a/.gitignore b/.gitignore index a587440d..551e9ac1 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,5 @@ sw.* # Vim swap files *.swp -/resources/ \ No newline at end of file +/resources/ +/android/app/release/ \ No newline at end of file diff --git a/android/app/build.gradle b/android/app/build.gradle index 9b342af1..b726d401 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -1,6 +1,3 @@ -//apply plugin: 'com.android.application' -//apply plugin: 'kotlin-android' - plugins { id 'com.android.application' id 'kotlin-android' @@ -13,8 +10,8 @@ android { applicationId "com.audiobookshelf.app" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 1 - versionName "1.0" + versionCode 3 + versionName "0.1.0-beta" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. @@ -49,7 +46,7 @@ dependencies { androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion" implementation project(':capacitor-cordova-android-plugins') - implementation "androidx.core:core-ktx:+" + implementation "androidx.core:core-ktx:1.6.0" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" diff --git a/android/app/src/main/res/xml/config.xml b/android/app/src/main/res/xml/config.xml index 2e948702..1b1b0e0d 100644 --- a/android/app/src/main/res/xml/config.xml +++ b/android/app/src/main/res/xml/config.xml @@ -2,14 +2,5 @@ - - - - - - - - - \ No newline at end of file diff --git a/android/variables.gradle b/android/variables.gradle index 53fad2e1..94d47109 100644 --- a/android/variables.gradle +++ b/android/variables.gradle @@ -5,7 +5,7 @@ ext { androidxActivityVersion = '1.2.0' androidxAppCompatVersion = '1.2.0' androidxCoordinatorLayoutVersion = '1.1.0' - androidxCoreVersion = '1.3.2' + androidxCoreVersion = '1.6.0' androidxFragmentVersion = '1.3.0' junitVersion = '4.13.1' androidxJunitVersion = '1.1.2' @@ -13,7 +13,7 @@ ext { cordovaAndroidVersion = '7.0.0' androidx_app_compat_version = '1.2.0' androidx_car_version = '1.0.0-alpha7' - androidx_core_ktx_version = '1.3.1' + androidx_core_ktx_version = '1.6.0' androidx_media_version = '1.0.1' androidx_preference_version = '1.1.1' androidx_test_runner_version = '1.3.0' diff --git a/components/app/Appbar.vue b/components/app/Appbar.vue index 292b147d..9bf13c67 100644 --- a/components/app/Appbar.vue +++ b/components/app/Appbar.vue @@ -1,13 +1,16 @@ -
+
No Audiobooks
Clear Filter
diff --git a/layouts/default.vue b/layouts/default.vue index 23cf4db5..db18e197 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -45,6 +45,63 @@ export default { if (this.$refs.streamContainer && this.$refs.streamContainer.audioPlayerReady) { this.$refs.streamContainer.streamOpen(stream) } + }, + parseSemver(ver) { + if (!ver) return null + var groups = ver.match(/^v((([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?)$/) + if (groups && groups.length > 6) { + var total = Number(groups[3]) * 100 + Number(groups[4]) * 10 + Number(groups[5]) + if (isNaN(total)) { + console.warn('Invalid version total', groups[3], groups[4], groups[5]) + return null + } + return { + total, + version: groups[2], + major: Number(groups[3]), + minor: Number(groups[4]), + patch: Number(groups[5]), + preRelease: groups[6] || null + } + } else { + console.warn('Invalid semver string', ver) + } + return null + }, + checkForUpdate() { + if (!this.$config.version) { + return + } + var currVerObj = this.parseSemver(this.$config.version) + if (!currVerObj) { + console.error('Invalid version', this.$config.version) + return + } + console.log('Check for update, your version:', currVerObj.version) + this.$store.commit('setCurrentVersion', currVerObj) + + var largestVer = null + this.$axios.$get(`https://api.github.com/repos/advplyr/audiobookshelf-app/tags`).then((tags) => { + if (tags && tags.length) { + tags.forEach((tag) => { + var verObj = this.parseSemver(tag.name) + if (verObj) { + if (!largestVer || largestVer.total < verObj.total) { + largestVer = verObj + } + } + }) + } + }) + if (!largestVer) { + console.error('No valid version tags to compare with') + return + } + this.$store.commit('setLatestVersion', largestVer) + if (largestVer.total > currVerObj.total) { + console.log('Has Update!', largestVer.version) + this.$store.commit('setHasUpdate', true) + } } }, mounted() { @@ -56,6 +113,11 @@ export default { if (!this.$server.connected) { this.$router.push('/connect') } + + // var checkForUpdateFlag = localStorage.getItem('checkForUpdate') + // if (!checkForUpdateFlag || checkForUpdateFlag !== '1') { + // this.checkForUpdate() + // } } } diff --git a/nuxt.config.js b/nuxt.config.js index 683520aa..72508c28 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -4,7 +4,9 @@ export default { ssr: false, env: { - PROD: '1' + PROD: '1', + ANDROID_APP_URL: 'https://play.google.com/store/apps/details?id=com.audiobookshelf.app', + IOS_APP_URL: '' }, publicRuntimeConfig: { diff --git a/package-lock.json b/package-lock.json index d4a95315..fbbd5a8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "audiobookshelf-app", - "version": "1.0.0", + "version": "v0.1.0-beta", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -4395,16 +4395,6 @@ "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" }, - "cordova-plugin-file": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz", - "integrity": "sha512-m7cughw327CjONN/qjzsTpSesLaeybksQh420/gRuSXJX5Zt9NfgsSbqqKDon6jnQ9Mm7h7imgyO2uJ34XMBtA==" - }, - "cordova-plugin-media": { - "version": "5.0.3", - "resolved": "https://registry.npmjs.org/cordova-plugin-media/-/cordova-plugin-media-5.0.3.tgz", - "integrity": "sha512-UQPFlpk1zL4BY44zGi8RVmYCvcKBCN4Dyf8ovxqGYCC8zR1yhbTRWYDdO9vJdERwbfgWV7+z7FMWiSUfqWm9bQ==" - }, "core-js": { "version": "3.16.0", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz", diff --git a/package.json b/package.json index dc40eecc..023c97d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "audiobookshelf-app", - "version": "1.0.0", + "version": "v0.1.0-beta", "author": "advplyr", "scripts": { "dev": "nuxt --hostname localhost --port 1337", @@ -17,8 +17,6 @@ "@capacitor/toast": "^1.0.2", "@nuxtjs/axios": "^5.13.6", "axios": "^0.21.1", - "cordova-plugin-file": "^6.0.2", - "cordova-plugin-media": "^5.0.3", "core-js": "^3.15.1", "hls.js": "^1.0.9", "nuxt": "^2.15.7", diff --git a/plugins/my-native-audio.js b/plugins/my-native-audio.js index c615c951..5187e55d 100644 --- a/plugins/my-native-audio.js +++ b/plugins/my-native-audio.js @@ -1,4 +1,7 @@ -import { registerPlugin } from '@capacitor/core'; +import Vue from 'vue' +import { registerPlugin, Capacitor } from '@capacitor/core'; + +Vue.prototype.$platform = Capacitor.getPlatform() const MyNativeAudio = registerPlugin('MyNativeAudio'); export default MyNativeAudio; \ No newline at end of file diff --git a/store/index.js b/store/index.js index c33be5c9..6fb77666 100644 --- a/store/index.js +++ b/store/index.js @@ -3,14 +3,24 @@ export const state = () => ({ streamAudiobook: null, playOnLoad: false, serverUrl: null, - user: null + user: null, + currentVersion: null, + latestVersion: null, + hasUpdate: true }) -export const actions = { - -} +export const actions = {} export const mutations = { + setCurrentVersion(state, verObj) { + state.currentVersion = verObj + }, + setLatestVersion(state, verObj) { + state.latestVersion = verObj + }, + setHasUpdate(state, val) { + state.hasUpdate = val + }, closeStream(state, audiobookId) { if (state.streamAudiobook && state.streamAudiobook.id !== audiobookId) { return