Set ver, clean up dependencies

This commit is contained in:
advplyr 2021-09-02 12:19:26 -05:00
parent 495af35043
commit 06657538a9
12 changed files with 112 additions and 45 deletions

1
.gitignore vendored
View file

@ -90,3 +90,4 @@ sw.*
*.swp *.swp
/resources/ /resources/
/android/app/release/

View file

@ -1,6 +1,3 @@
//apply plugin: 'com.android.application'
//apply plugin: 'kotlin-android'
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'kotlin-android' id 'kotlin-android'
@ -13,8 +10,8 @@ android {
applicationId "com.audiobookshelf.app" applicationId "com.audiobookshelf.app"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1 versionCode 3
versionName "1.0" versionName "0.1.0-beta"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions { aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. // 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" androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation project(':capacitor-cordova-android-plugins') 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-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

View file

@ -2,14 +2,5 @@
<widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <widget version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<access origin="*" /> <access origin="*" />
<feature name="File">
<param name="android-package" value="org.apache.cordova.file.FileUtils"/>
<param name="onload" value="true"/>
</feature>
<feature name="Media">
<param name="android-package" value="org.apache.cordova.media.AudioHandler"/>
</feature>
</widget> </widget>

View file

@ -5,7 +5,7 @@ ext {
androidxActivityVersion = '1.2.0' androidxActivityVersion = '1.2.0'
androidxAppCompatVersion = '1.2.0' androidxAppCompatVersion = '1.2.0'
androidxCoordinatorLayoutVersion = '1.1.0' androidxCoordinatorLayoutVersion = '1.1.0'
androidxCoreVersion = '1.3.2' androidxCoreVersion = '1.6.0'
androidxFragmentVersion = '1.3.0' androidxFragmentVersion = '1.3.0'
junitVersion = '4.13.1' junitVersion = '4.13.1'
androidxJunitVersion = '1.1.2' androidxJunitVersion = '1.1.2'
@ -13,7 +13,7 @@ ext {
cordovaAndroidVersion = '7.0.0' cordovaAndroidVersion = '7.0.0'
androidx_app_compat_version = '1.2.0' androidx_app_compat_version = '1.2.0'
androidx_car_version = '1.0.0-alpha7' 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_media_version = '1.0.1'
androidx_preference_version = '1.1.1' androidx_preference_version = '1.1.1'
androidx_test_runner_version = '1.3.0' androidx_test_runner_version = '1.3.0'

View file

@ -1,13 +1,16 @@
<template> <template>
<div class="w-full h-16 bg-primary relative"> <div class="w-full h-16 bg-primary relative">
<div id="appbar" class="absolute top-0 left-0 w-full h-full z-30 flex items-center px-2"> <div id="appbar" class="absolute top-0 left-0 w-full h-full z-30 flex items-center px-2">
<nuxt-link v-show="!showBack" to="/" class="mr-4"> <nuxt-link v-show="!showBack" to="/" class="mr-3">
<img src="/Logo.png" class="h-12 w-12" /> <img src="/Logo.png" class="h-10 w-10" />
</nuxt-link> </nuxt-link>
<a v-if="showBack" @click="back" class="rounded-full h-12 w-12 flex items-center justify-center hover:bg-white hover:bg-opacity-10 mr-2 cursor-pointer"> <a v-if="showBack" @click="back" class="rounded-full h-10 w-10 flex items-center justify-center hover:bg-white hover:bg-opacity-10 mr-2 cursor-pointer">
<span class="material-icons text-4xl text-white">arrow_back</span> <span class="material-icons text-3xl text-white">arrow_back</span>
</a> </a>
<p class="text-xl font-book">AudioBookshelf</p> <div>
<p class="text-lg font-book leading-4">AudioBookshelf</p>
<!-- <a class="text-xs text-success leading-4 flex items-center py-1" :href="appListingUrl" target="_blank">Update available! <span class="material-icons text-sm leading-4 px-2">launch</span></a> -->
</div>
<div class="flex-grow" /> <div class="flex-grow" />
<ui-menu :label="username" :items="menuItems" @action="menuAction" class="ml-5" /> <ui-menu :label="username" :items="menuItems" @action="menuAction" class="ml-5" />
</div> </div>
@ -40,6 +43,16 @@ export default {
}, },
username() { username() {
return this.user ? this.user.username : 'err' return this.user ? this.user.username : 'err'
},
// hasUpdate() {
// return this.$store.state.hasUpdate
// },
appListingUrl() {
if (this.$platform === 'android') {
return process.env.ANDROID_APP_URL
} else {
return process.env.IOS_APP_URL
}
} }
}, },
methods: { methods: {

View file

@ -5,14 +5,14 @@
<template v-for="audiobook in shelf"> <template v-for="audiobook in shelf">
<div :key="audiobook.id" class="relative px-4"> <div :key="audiobook.id" class="relative px-4">
<nuxt-link :to="`/audiobook/${audiobook.id}`"> <nuxt-link :to="`/audiobook/${audiobook.id}`">
<cards-book-cover :audiobook="audiobook" :width="cardWidth" class="mx-auto -mb-px" /> <cards-book-cover :audiobook="audiobook" :width="cardWidth" class="mx-auto -mb-px" style="box-shadow: 4px 1px 8px #11111166, -4px 1px 8px #11111166, 1px -4px 8px #11111166" />
</nuxt-link> </nuxt-link>
</div> </div>
</template> </template>
<div class="bookshelfDivider h-4 w-full absolute bottom-0 left-0 right-0 z-10" /> <div class="bookshelfDivider h-4 w-full absolute bottom-0 left-0 right-0 z-10" />
</div> </div>
</template> </template>
<div class="w-full py-16 text-center text-xl"> <div v-show="!groupedBooks.length" class="w-full py-16 text-center text-xl">
<div class="py-4">No Audiobooks</div> <div class="py-4">No Audiobooks</div>
<ui-btn v-if="hasFilters" @click="clearFilter">Clear Filter</ui-btn> <ui-btn v-if="hasFilters" @click="clearFilter">Clear Filter</ui-btn>
</div> </div>

View file

@ -45,6 +45,63 @@ export default {
if (this.$refs.streamContainer && this.$refs.streamContainer.audioPlayerReady) { if (this.$refs.streamContainer && this.$refs.streamContainer.audioPlayerReady) {
this.$refs.streamContainer.streamOpen(stream) 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() { mounted() {
@ -56,6 +113,11 @@ export default {
if (!this.$server.connected) { if (!this.$server.connected) {
this.$router.push('/connect') this.$router.push('/connect')
} }
// var checkForUpdateFlag = localStorage.getItem('checkForUpdate')
// if (!checkForUpdateFlag || checkForUpdateFlag !== '1') {
// this.checkForUpdate()
// }
} }
} }
</script> </script>

View file

@ -4,7 +4,9 @@ export default {
ssr: false, ssr: false,
env: { env: {
PROD: '1' PROD: '1',
ANDROID_APP_URL: 'https://play.google.com/store/apps/details?id=com.audiobookshelf.app',
IOS_APP_URL: ''
}, },
publicRuntimeConfig: { publicRuntimeConfig: {

12
package-lock.json generated
View file

@ -1,6 +1,6 @@
{ {
"name": "audiobookshelf-app", "name": "audiobookshelf-app",
"version": "1.0.0", "version": "v0.1.0-beta",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@ -4395,16 +4395,6 @@
"resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz",
"integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=" "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": { "core-js": {
"version": "3.16.0", "version": "3.16.0",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.0.tgz",

View file

@ -1,6 +1,6 @@
{ {
"name": "audiobookshelf-app", "name": "audiobookshelf-app",
"version": "1.0.0", "version": "v0.1.0-beta",
"author": "advplyr", "author": "advplyr",
"scripts": { "scripts": {
"dev": "nuxt --hostname localhost --port 1337", "dev": "nuxt --hostname localhost --port 1337",
@ -17,8 +17,6 @@
"@capacitor/toast": "^1.0.2", "@capacitor/toast": "^1.0.2",
"@nuxtjs/axios": "^5.13.6", "@nuxtjs/axios": "^5.13.6",
"axios": "^0.21.1", "axios": "^0.21.1",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-media": "^5.0.3",
"core-js": "^3.15.1", "core-js": "^3.15.1",
"hls.js": "^1.0.9", "hls.js": "^1.0.9",
"nuxt": "^2.15.7", "nuxt": "^2.15.7",

View file

@ -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'); const MyNativeAudio = registerPlugin('MyNativeAudio');
export default MyNativeAudio; export default MyNativeAudio;

View file

@ -3,14 +3,24 @@ export const state = () => ({
streamAudiobook: null, streamAudiobook: null,
playOnLoad: false, playOnLoad: false,
serverUrl: null, serverUrl: null,
user: null user: null,
currentVersion: null,
latestVersion: null,
hasUpdate: true
}) })
export const actions = { export const actions = {}
}
export const mutations = { export const mutations = {
setCurrentVersion(state, verObj) {
state.currentVersion = verObj
},
setLatestVersion(state, verObj) {
state.latestVersion = verObj
},
setHasUpdate(state, val) {
state.hasUpdate = val
},
closeStream(state, audiobookId) { closeStream(state, audiobookId) {
if (state.streamAudiobook && state.streamAudiobook.id !== audiobookId) { if (state.streamAudiobook && state.streamAudiobook.id !== audiobookId) {
return return