diff --git a/build.gradle b/build.gradle index 2687053f5..919b0060f 100644 --- a/build.gradle +++ b/build.gradle @@ -3,13 +3,16 @@ buildscript { ext.kotlin_version = '1.4.10' + ext.latestAboutLibsRelease = "8.4.3" repositories { google() jcenter() + mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}" } } plugins { diff --git a/src/xrt/targets/openxr_android/build.gradle b/src/xrt/targets/openxr_android/build.gradle index 54b09ce6f..25d346c10 100644 --- a/src/xrt/targets/openxr_android/build.gradle +++ b/src/xrt/targets/openxr_android/build.gradle @@ -3,11 +3,19 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'com.mikepenz.aboutlibraries.plugin' androidGitVersion { tagPattern(/^v[0-9]+.*/) codeFormat = 'MNNPPPBBB' } + +def parseOpenXRVersion(def fn) { + def matches = file(fn).readLines().find { it.contains('XR_CURRENT_API_VERSION') } =~ ~/XR_MAKE_VERSION\(([^\)]+)\)/ + def components = matches[0][1].split(',').each { it.replace(' ', '').trim() } + String.join('.', components) +} + android { compileSdkVersion project.sharedTargetSdk buildToolsVersion '30.0.2' @@ -24,6 +32,9 @@ android { resValue "string", "monado_lib_version", "${versionName}" resValue "string", "app_name", "Monado XR" + + resValue "string", "library_openxrheaders_libraryVersion", parseOpenXRVersion("../../../external/openxr_includes/openxr/openxr.h") + externalNativeBuild { cmake { arguments "-DEIGEN3_INCLUDE_DIR=${project.eigenIncludeDir}", "-DANDROID_PLATFORM=26", "-DANDROID_STL=c++_shared", "-DANDROID_ARM_NEON=TRUE" @@ -34,7 +45,8 @@ android { buildTypes { release { minifyEnabled false - // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // Gradle plugin produces proguard-android-optimize.txt from @Keep annotations + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } @@ -65,10 +77,20 @@ android { } } +aboutLibraries { + configPath = "config" +} + dependencies { outOfProcessImplementation project(':src:xrt:ipc:android') implementation project(':src:xrt:auxiliary:android') implementation 'androidx.appcompat:appcompat:1.2.0' implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" implementation 'androidx.constraintlayout:constraintlayout:2.0.1' + implementation "com.mikepenz:aboutlibraries-core:${latestAboutLibsRelease}" + implementation "com.mikepenz:aboutlibraries:${latestAboutLibsRelease}" + implementation "androidx.cardview:cardview:1.*.*" + implementation "androidx.recyclerview:recyclerview:1.1.*" + implementation "com.google.android.material:material:1.1.*" + } diff --git a/src/xrt/targets/openxr_android/proguard-rules.pro b/src/xrt/targets/openxr_android/proguard-rules.pro new file mode 100644 index 000000000..047dbd573 --- /dev/null +++ b/src/xrt/targets/openxr_android/proguard-rules.pro @@ -0,0 +1,10 @@ +# Copyright 2020, Collabora, Ltd. +# SPDX-License-Identifier: BSL-1.0 +# see http://developer.android.com/guide/developing/tools/proguard.html +# Trying to keep most of them in source code annotations and let Gradle do the work + +# For library auto-detection in AboutLibraries +-keep class .R +-keep class **.R$* { + ; +} diff --git a/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/MainActivity.java b/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/MainActivity.java index 82195ee32..3eddd358e 100644 --- a/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/MainActivity.java +++ b/src/xrt/targets/openxr_android/src/main/java/org/freedesktop/monado/openxr_runtime/MainActivity.java @@ -13,9 +13,12 @@ import android.text.method.LinkMovementMethod; import android.widget.TextView; import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentTransaction; +import com.mikepenz.aboutlibraries.LibsBuilder; + public class MainActivity extends AppCompatActivity { @Override @@ -32,6 +35,20 @@ public class MainActivity extends AppCompatActivity { int status = VrModeStatus.detectStatus(this, BuildConfig.APPLICATION_ID); VrModeStatus statusFrag = VrModeStatus.newInstance(status); fragmentTransaction.add(R.id.statusFrame, statusFrag, null); + + + Fragment libsFragment = (new LibsBuilder()) + .withFields(R.string.class.getFields()) + + // We do this ourselves bigger + .withAboutIconShown(false) + // Let the fragment show our version + .withAboutVersionShown(true) + + // Not sure why you'd do this without license info + .withLicenseShown(true) + .supportFragment(); + fragmentTransaction.add(R.id.aboutFrame, libsFragment, null); fragmentTransaction.commit(); } } diff --git a/src/xrt/targets/openxr_android/src/main/res/layout/activity_main.xml b/src/xrt/targets/openxr_android/src/main/res/layout/activity_main.xml index 2b78955f2..96a4cd4a5 100644 --- a/src/xrt/targets/openxr_android/src/main/res/layout/activity_main.xml +++ b/src/xrt/targets/openxr_android/src/main/res/layout/activity_main.xml @@ -14,7 +14,7 @@ android:id="@+id/imageView" android:layout_width="@android:dimen/thumbnail_width" android:layout_height="@android:dimen/thumbnail_height" - android:layout_marginTop="24dp" + android:layout_marginTop="8dp" android:contentDescription="@string/monado_logo" android:scaleType="fitCenter" app:layout_constraintEnd_toEndOf="parent" @@ -39,12 +39,12 @@ android:id="@+id/textPowered" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="252dp" + android:layout_marginTop="8dp" android:text="@string/powered_by_monado" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toBottomOf="@+id/textView" /> + + +