Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 69 additions & 69 deletions packages/alphatab/src/AlphaTabApiBase.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/alphatab/src/DisplaySettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class DisplaySettings {
* | JSON | `display.resources.` | `var settings = { display: { resources: { wordsFonts: '...'} } };` |
* | JSON | `resources.` | `var settings = { resources: { wordsFonts: '...'} };` |
* | .net | `Display.Resources.` | `settings.Display.Resources.WordsFonts = ...` |
* | Android | `display.resources.` | `settings.display.resources.wordsFonts = ...` |
* | Kotlin | `display.resources.` | `settings.display.resources.wordsFonts = ...` |
* ## Types
*
* ### Fonts
Expand Down
2 changes: 1 addition & 1 deletion packages/alphatab/src/LogLevel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export enum LogLevel {
* Trace level (high-volume internal flow details, implies all other levels).
* @remarks
* The published JavaScript files do not contain trace messages; they are only written when running alphaTab
* from its TypeScript sources and on .NET and Android.
* from its TypeScript sources and on .NET and Kotlin.
* @since 1.9.0
*/
Trace = -1,
Expand Down
2 changes: 1 addition & 1 deletion packages/alphatab/src/NotationSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export class NotationSettings {
* settings.Notation.Elements[AlphaTab.NotationElement.TrackNames] = false;
* ```
* @example
* Android
* Kotlin
* ```kotlin
* val settings = AlphaTab.Settings();
* settings.notation.elements[alphaTab.NotationElement.ScoreTitle] = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/alphatab/src/generated/DisplaySettingsJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export interface DisplaySettingsJson {
* | JSON | `display.resources.` | `var settings = { display: { resources: { wordsFonts: '...'} } };` |
* | JSON | `resources.` | `var settings = { resources: { wordsFonts: '...'} };` |
* | .net | `Display.Resources.` | `settings.Display.Resources.WordsFonts = ...` |
* | Android | `display.resources.` | `settings.display.resources.wordsFonts = ...` |
* | Kotlin | `display.resources.` | `settings.display.resources.wordsFonts = ...` |
* ## Types
*
* ### Fonts
Expand Down
2 changes: 1 addition & 1 deletion packages/alphatab/src/generated/NotationSettingsJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export interface NotationSettingsJson {
* settings.Notation.Elements[AlphaTab.NotationElement.TrackNames] = false;
* ```
* @example
* Android
* Kotlin
* ```kotlin
* val settings = AlphaTab.Settings();
* settings.notation.elements[alphaTab.NotationElement.ScoreTitle] = false;
Expand Down
6 changes: 3 additions & 3 deletions packages/kotlin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"private": true,
"type": "module",
"scripts": {
"clean": "rimraf src/android/src/main-generated && rimraf src/android/src/test-generated",
"clean": "rimraf src/core/src/main-generated && rimraf src/core/src/test-generated",
"transpile": "tsx scripts/transpile.ts",
"build": "npm run transpile && node scripts/gradlew.mjs assembleRelease",
"test": "node scripts/gradlew.mjs testReleaseUnitTest --info"
"build": "npm run transpile && node scripts/gradlew.mjs assemble",
"test": "node scripts/gradlew.mjs :core:check --info"
}
}
4 changes: 2 additions & 2 deletions packages/kotlin/scripts/transpile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ transpiler(
{
name: 'Kotlin',
emit: createEmit(
path.resolve(__dirname, '../src/android/src/main-generated/java'),
path.resolve(__dirname, '../src/android/src/test-generated/java')
path.resolve(__dirname, '../src/core/src/main-generated/java'),
path.resolve(__dirname, '../src/core/src/test-generated/java')
)
}
],
Expand Down
164 changes: 25 additions & 139 deletions packages/kotlin/src/android/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,80 +1,22 @@
import com.android.build.api.variant.HostTestBuilder
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.FileInputStream
import java.util.Properties
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// AGP 9+ has built-in Kotlin support; a separate kotlin-android plugin is no
// longer applied. See https://issuetracker.google.com/438678642.
alias(libs.plugins.android.library)
alias(libs.plugins.dokka)
alias(libs.plugins.mavenPublish)
`maven-publish`
signing
}


val props = Properties()
val propsFile = project.rootProject.file("local.properties")
if (propsFile.exists()) {
FileInputStream(propsFile).use {
props.load(it)
}
}

fun loadSetting(envKey: String, propKey: String, setter: (value: String) -> Unit) {
if (props.containsKey(propKey)) {
setter(props.getProperty(propKey))
} else {
val env = providers
.environmentVariable(envKey)
if (env.isPresent) {
setter(env.get())
}
}
}

var libDescription =
"alphaTab is a cross platform music notation and guitar tablature rendering library. " +
"The \"alphaTab.net\" attribution in rendered scores must stay visible, " +
"see https://alphatab.net/docs/attribution"
var libAuthorId = "danielku15"
var libAuthorName = "Daniel Kuschny"
var libOrgUrl = "https://github.com/coderline"
var libCompany = "CoderLine"
var libVersion = "1.10.0-SNAPSHOT"
var libProjectUrl = "https://github.com/CoderLine/alphaTab"
var libGitUrlHttp = "https://github.com/CoderLine/alphaTab.git"
var libGitUrlGit = "scm:git:git://github.com/CoderLine/alphaTab.git"
var libLicenseSpdx = "MPL-2.0"
var libLicenseUrl = "https://opensource.org/licenses/MPL-2.0"
var libIssuesUrl = "https://github.com/CoderLine/alphaTab/issues"
val libGroup = "net.alphatab"
val libArtifactId = "alphaTab"

loadSetting("ALPHATAB_DESCRIPTION", "alphatabDescription") { libDescription = it }
loadSetting("ALPHATAB_AUTHOR_ID", "alphatabAuthorId") { libAuthorId = it }
loadSetting("ALPHATAB_AUTHOR_NAME", "alphatabAuthorName") { libAuthorName = it }
loadSetting("ALPHATAB_ORG_URL", "alphatabOrgUrl") { libOrgUrl = it }
loadSetting("ALPHATAB_COMPANY", "alphatabCompany") { libCompany = it }
loadSetting("ALPHATAB_VERSION", "alphatabVersion") { libVersion = it }
loadSetting("ALPHATAB_PROJECT_URL", "alphatabProjectUrl") { libProjectUrl = it }
loadSetting("ALPHATAB_GIT_URL_HTTP", "alphatabGitUrlHttp") { libGitUrlHttp = it }
loadSetting("ALPHATAB_GIT_URL_GIT", "alphatabGitUrlGit") { libGitUrlGit = it }
loadSetting("ALPHATAB_LICENSE_SPDX", "alphatabLicenseSpdx") { libLicenseSpdx = it }
loadSetting("ALPHATAB_LICENSE_URL", "alphatabLicenseUrl") { libLicenseUrl = it }
loadSetting("ALPHATAB_ISSUES_URL", "alphatabIssuesUrl") { libIssuesUrl = it }

group = libGroup
version = libVersion

val javaVersion = JavaVersion.VERSION_17;
var jvmTargetVersion = JvmTarget.JVM_17

kotlin {
compilerOptions {
jvmTarget.set(jvmTargetVersion)
moduleName.set("alphaTab-android")
freeCompilerArgs.addAll(
listOf(
"-Xno-call-assertions",
Expand All @@ -85,15 +27,6 @@ kotlin {
}
}

// AGP 9 only generates unit-test tasks for the debug variant by default. Our
// pipeline runs tests against the release variant (matches published artifact),
// so enable the release host unit-test explicitly.
androidComponents {
beforeVariants(selector().withBuildType("release")) { variantBuilder ->
variantBuilder.hostTests[HostTestBuilder.UNIT_TEST_TYPE]?.enable = true
}
}

android {
namespace = project.group.toString()
compileSdk = 37
Expand All @@ -116,20 +49,13 @@ android {
targetCompatibility = javaVersion
}


sourceSets {
getByName("main") {
java.srcDirs("src/main-generated/java")
kotlin.srcDirs("src/main-generated/java")
assets.srcDirs(
"../../../alphatab/font/bravura",
"../../../alphatab/font/sonivox"
)
}
getByName("test") {
java.srcDirs("src/test-generated/java")
kotlin.srcDirs("src/test-generated/java")
}
}

androidResources {
Expand All @@ -147,85 +73,45 @@ android {
}
}

evaluationDependsOn(":core")
val core = project(":core")

// The Android integration uses internal members of the core, like AlphaTab.Windows does in C#
// through InternalsVisibleTo. Both artifacts are therefore published and consumed in lockstep.
tasks.withType<KotlinCompile>().configureEach {
friendPaths.from(core.tasks.named("jar"))
}

dependencies {
api(core)
constraints {
api("${core.group}:alphaTab-core") {
version {
strictly(core.version.toString())
}
}
}

implementation(libs.androidx.core.ktx)
implementation(libs.androidx.appcompat)
testImplementation(libs.junit)
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)

implementation(libs.alphaskia)
implementation(libs.alphaskia.android)
implementation(libs.kotlinx.coroutines.core)
implementation(libs.alphaskia)

testImplementation(libs.alphaskia.macos)
testImplementation(libs.alphaskia.linux)
testImplementation(libs.alphaskia.windows)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.klaxon)
}

publishing {
repositories {
maven {
name = "DistPath"
url = rootProject.projectDir.resolve("dist").toURI()
}
}
androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
}

internal fun Project.findOptionalProperty(propertyName: String) =
findProperty(propertyName)?.toString()

mavenPublishing {
publishToMavenCentral(automaticRelease = true)
coordinates(libGroup, libArtifactId, libVersion)
signAllPublications()

coordinates(group.toString(), "alphaTab", version.toString())
configure(
AndroidSingleVariantLibrary(
variant = "release",
sourcesJar = true,
publishJavadocJar = true
)
)

val inMemoryKeyFile = project.findOptionalProperty("signingInMemoryKeyFile")
if (inMemoryKeyFile != null) {
val inMemoryKeyId = project.findOptionalProperty("signingInMemoryKeyId")
val inMemoryKeyPassword =
project.findOptionalProperty("signingInMemoryKeyPassword").orEmpty()
val signing = project.extensions.getByType(SigningExtension::class.java)
val inMemoryKey = File(inMemoryKeyFile).readText()
signing.useInMemoryPgpKeys(inMemoryKeyId, inMemoryKey, inMemoryKeyPassword)
}

pom {
name = libArtifactId
description = libDescription
url = libProjectUrl
licenses {
license {
name = libLicenseSpdx
url = libLicenseUrl
}
}
developers {
developer {
id = libAuthorId
name = libAuthorName
organization = libCompany
organizationUrl = libOrgUrl
}
}
scm {
url = libGitUrlHttp
connection = "scm:git:$libGitUrlGit"
developerConnection = "scm:git:$libGitUrlGit"
}
issueManagement {
system = "GitHub"
url = libIssuesUrl
}
name = "alphaTab"
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package alphaTab.platform.android

import alphaTab.Environment
import alphaTab.EnvironmentPartials
import alphaTab.RenderEngineFactory
import alphaTab.alphaSkia.AlphaSkiaAndroid
import alphaTab.core.ecmaScript.ArrayBuffer
import android.graphics.Typeface
import android.os.Build
import android.util.DisplayMetrics
import kotlin.contracts.ExperimentalContracts

Expand All @@ -28,6 +31,16 @@ internal class AndroidEnvironment {
screenHeight = context.resources.displayMetrics.heightPixels

AndroidCanvas.initialize(context)
Environment.renderEngines.set(
"android",
RenderEngineFactory(true) { AndroidCanvas() }
)
EnvironmentPartials.printHostInfo = { print ->
print("Device Brand: ${Build.MANUFACTURER}");
print("Device Model: ${Build.MODEL}");
print("SDK Version: ${Build.VERSION.SDK_INT}");
print("Screen Size: ${screenWidth}x${screenHeight}");
}

var bravuraBytes: ByteArray;
context.assets.open("Bravura.otf").use {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import alphaTab.platform.Cursors
import alphaTab.platform.IContainer
import alphaTab.platform.IMouseEventArgs
import alphaTab.platform.IUiFacade
import alphaTab.platform.jvm.JavaThreadAlphaSynthWorker
import alphaTab.platform.jvm.JavaThreadAlphaTabRendererWorker
import alphaTab.platform.skia.AlphaSkiaImage
import alphaTab.platform.worker.AlphaSynthAudioExporterWorkerApi
import alphaTab.platform.worker.AlphaSynthWebWorkerApi
Expand Down
Loading
Loading