diff --git a/.github/workflows/build-terre.yml b/.github/workflows/build-terre.yml index 7031bae5..edf986b2 100644 --- a/.github/workflows/build-terre.yml +++ b/.github/workflows/build-terre.yml @@ -51,7 +51,6 @@ jobs: run: sh release-linux-arm64.sh - name: Compress run: 7z a -tzip release/WebGAL_Terre_Linux_Arm64.zip release/* - - name: Upload Artifact uses: actions/upload-artifact@v4 with: @@ -122,3 +121,48 @@ jobs: with: name: WebGAL_Terre_Windows_Setup path: bundle/WebGal_Terre_Setup.exe + build-android: + name: Build Android APK + runs-on: ubuntu-latest + env: + KEYSTORE: ${{ secrets.KEYSTORE }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version-file: package.json + cache: 'yarn' + - name: Set up Java + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + - name: Decode and save keystore + if: ${{ env.KEYSTORE != '' }} + run: | + echo "${{ secrets.KEYSTORE }}" | base64 --decode > packages/terre-android/app/keystore.jks + - name: Save key.properties + if: ${{ env.KEYSTORE != '' }} + run: | + echo "storePassword=${{ secrets.STORE_PASSWORD }}" >> packages/terre-android/key.properties + echo "keyPassword=${{ secrets.KEY_PASSWORD }}" >> packages/terre-android/key.properties + echo "keyAlias=${{ secrets.KEY_ALIAS }}" >> packages/terre-android/key.properties + echo "storeFile=keystore.jks" >> packages/terre-android/key.properties + - name: Build + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: sh release-android.sh + - name: Upload Release Artifact + if: ${{ env.KEYSTORE != '' }} + uses: actions/upload-artifact@v4 + with: + name: WebGAL_Terre_Android + path: release/WebGAL_Terre_Android.apk + - name: Upload Debug Artifact + if: ${{ env.KEYSTORE == '' }} + uses: actions/upload-artifact@v4 + with: + name: WebGAL_Terre_Android_debug + path: release/WebGAL_Terre_Android_debug.apk diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 38e724e2..b7478eca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,7 +9,7 @@ jobs: release: name: Release runs-on: ubuntu-latest - needs: ['build-linux','build-arm64','build-mac','build-windows','build-windows-nsis'] + needs: ['build-linux','build-arm64','build-mac','build-windows','build-windows-nsis','build-android'] steps: - name: Checkout uses: actions/checkout@v4 @@ -78,3 +78,15 @@ jobs: asset_path: WebGAL_Terre_Windows_Setup/WebGal_Terre_Setup.exe asset_name: WebGAL_Terre_Windows_Setup_${{ github.ref_name }}.exe asset_content_type: application/vnd.microsoft.portable-executable + + - name: Upload Android Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + KEYSTORE: ${{ secrets.KEYSTORE }} + if: ${{ env.KEYSTORE != '' }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: WebGAL_Terre_Android/WebGAL_Terre_Android.apk + asset_name: WebGAL_Terre_Android_${{ github.ref_name }}.apk + asset_content_type: application/vnd.android.package-archive diff --git a/packages/terre-android/.gitignore b/packages/terre-android/.gitignore new file mode 100644 index 00000000..c7eeed4e --- /dev/null +++ b/packages/terre-android/.gitignore @@ -0,0 +1,24 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties +app/libnode/bin +app/libnode/include +app/libnode/nodejs-mobile-* +app/src/main/assets/terre + +# key +key.properties +**/*.keystore +**/*.jks \ No newline at end of file diff --git a/packages/terre-android/LICENSE b/packages/terre-android/LICENSE new file mode 100644 index 00000000..a612ad98 --- /dev/null +++ b/packages/terre-android/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/packages/terre-android/README.md b/packages/terre-android/README.md new file mode 100644 index 00000000..2f3206dd --- /dev/null +++ b/packages/terre-android/README.md @@ -0,0 +1,3 @@ +# WebGAL Terre Android + +Running with [nodejs-mobile](https://github.com/nodejs-mobile/nodejs-mobile) \ No newline at end of file diff --git a/packages/terre-android/app/.gitignore b/packages/terre-android/app/.gitignore new file mode 100644 index 00000000..42afabfd --- /dev/null +++ b/packages/terre-android/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/packages/terre-android/app/build.gradle.kts b/packages/terre-android/app/build.gradle.kts new file mode 100644 index 00000000..5e75f827 --- /dev/null +++ b/packages/terre-android/app/build.gradle.kts @@ -0,0 +1,174 @@ +import java.io.FileInputStream +import java.security.MessageDigest +import java.nio.file.Files +import java.net.URI +import java.util.Properties +import java.util.zip.ZipInputStream + +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) + alias(libs.plugins.kotlin.compose) +} + +val keystoreProperties = Properties() +val keystorePropertiesFile = rootProject.file("key.properties") + +if (keystorePropertiesFile.exists()) { + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} + +android { + namespace = "com.openwebgal.terre" + compileSdk = 35 + + defaultConfig { + applicationId = "com.openwebgal.terre" + minSdk = 24 + targetSdk = 35 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + + externalNativeBuild { + cmake { + cppFlags("") + arguments("-DANDROID_STL=c++_shared") + } + } + ndk { + abiFilters.addAll(listOf("armeabi-v7a", "arm64-v8a", "x86_64")) + } + } + signingConfigs { + if (keystorePropertiesFile.exists()) + create("release") { + keyAlias = keystoreProperties["keyAlias"] as? String + ?: throw IllegalArgumentException("Key alias is missing") + keyPassword = keystoreProperties["keyPassword"] as? String + ?: throw IllegalArgumentException("Key password is missing") + storeFile = (keystoreProperties["storeFile"] as? String)?.let { file(it) } + ?: throw IllegalArgumentException("Store file is missing") + storePassword = keystoreProperties["storePassword"] as? String + ?: throw IllegalArgumentException("Store password is missing") + } + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + if (keystorePropertiesFile.exists()) + signingConfig = signingConfigs.getByName("release") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } + buildFeatures { + compose = true + } + externalNativeBuild { + cmake { + path = file("src/main/cpp/CMakeLists.txt") + version = "3.22.1" + } + } + sourceSets { + getByName("main") { + jniLibs.srcDirs("libnode/bin/") + } + } +} + +dependencies { + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.ui.tooling.preview) + implementation(libs.androidx.material3) + implementation(libs.androidx.browser) + implementation(libs.androidx.lifecycle.viewmodel.compose) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} + +abstract class DownloadNodejsTask : DefaultTask() { + @TaskAction + fun run() { + val url = + "https://github.com/nodejs-mobile/nodejs-mobile/releases/download/v18.20.4/nodejs-mobile-v18.20.4-android.zip" + val expectedMD5 = "4fe60de25381937b03642404513ec26b" + val zipFile = project.file("./libnode/nodejs-mobile-v18.20.4-android.zip") + val extractDir = project.file("./libnode") + + if (zipFile.exists()) { + val calculatedMD5 = MessageDigest.getInstance("MD5") + .digest(Files.readAllBytes(zipFile.toPath())) + .joinToString("") { "%02x".format(it) } + + if (calculatedMD5 != expectedMD5) { + zipFile.delete() + println("MD5 mismatch. File deleted: $zipFile") + } + } + + if (!zipFile.exists()) { + zipFile.parentFile.mkdirs() + println("Downloading Node.js from: $url") + zipFile.outputStream().use { os -> + URI.create(url).toURL().openStream().use { input -> + input.copyTo(os) + } + } + + val calculatedMD5 = MessageDigest.getInstance("MD5") + .digest(Files.readAllBytes(zipFile.toPath())) + .joinToString("") { "%02x".format(it) } + + if (calculatedMD5 != expectedMD5) { + throw GradleException("MD5 verification failed for $zipFile") + } + + println("Extracting Node.js to: $extractDir") + extractDir.mkdirs() + ZipInputStream(zipFile.inputStream()).use { zis -> + var entry = zis.nextEntry + while (entry != null) { + val targetFile = File(extractDir, entry.name) + if (entry.isDirectory) { + targetFile.mkdirs() + } else { + targetFile.parentFile.mkdirs() + targetFile.outputStream().use { fos -> + zis.copyTo(fos) + } + } + zis.closeEntry() + entry = zis.nextEntry + } + } + } + } +} + +tasks.register("downloadNodejs") + +tasks.named("preBuild") { + dependsOn("downloadNodejs") +} \ No newline at end of file diff --git a/packages/terre-android/app/proguard-rules.pro b/packages/terre-android/app/proguard-rules.pro new file mode 100644 index 00000000..481bb434 --- /dev/null +++ b/packages/terre-android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/packages/terre-android/app/src/androidTest/java/com/openwebgal/terre/ExampleInstrumentedTest.kt b/packages/terre-android/app/src/androidTest/java/com/openwebgal/terre/ExampleInstrumentedTest.kt new file mode 100644 index 00000000..888fd52d --- /dev/null +++ b/packages/terre-android/app/src/androidTest/java/com/openwebgal/terre/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.openwebgal.terre + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.openwebgal.terre", appContext.packageName) + } +} \ No newline at end of file diff --git a/packages/terre-android/app/src/main/AndroidManifest.xml b/packages/terre-android/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..b75fdfdf --- /dev/null +++ b/packages/terre-android/app/src/main/AndroidManifest.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/cpp/CMakeLists.txt b/packages/terre-android/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 00000000..3463dde9 --- /dev/null +++ b/packages/terre-android/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,50 @@ +# For more information about using CMake with Android Studio, read the +# documentation: https://d.android.com/studio/projects/add-native-code.html. +# For more examples on how to use CMake, see https://github.com/android/ndk-samples. + +# Sets the minimum CMake version required for this project. +cmake_minimum_required(VERSION 3.22.1) + +# Declares the project name. The project name can be accessed via ${ PROJECT_NAME}, +# Since this is the top level CMakeLists.txt, the project name is also accessible +# with ${CMAKE_PROJECT_NAME} (both CMake variables are in-sync within the top level +# build script scope). +project("terre") + +# Creates and names a library, sets it as either STATIC +# or SHARED, and provides the relative paths to its source code. +# You can define multiple libraries, and CMake builds them for you. +# Gradle automatically packages shared libraries with your APK. +# +# In this top level CMakeLists.txt, ${CMAKE_PROJECT_NAME} is used to define +# the target library name; in the sub-module's CMakeLists.txt, ${PROJECT_NAME} +# is preferred for the same purpose. +# +# In order to load a library into your app from Java/Kotlin, you must call +# System.loadLibrary() and pass the name of the library defined here; +# for GameActivity/NativeActivity derived applications, the same library name must be +# used in the AndroidManifest.xml file. +add_library(${CMAKE_PROJECT_NAME} SHARED + # List C/C++ source files with relative paths to this CMakeLists.txt. + native-lib.cpp) + +# Includes node's header files. +include_directories(${CMAKE_SOURCE_DIR}/../../../libnode/include/node/) + +# Imports the pre-built libnode shared library. +add_library(libnode SHARED IMPORTED) + +# Specifies the path to the libnode shared library. +set_target_properties(libnode + PROPERTIES IMPORTED_LOCATION + ${CMAKE_SOURCE_DIR}/../../../libnode/bin/${ANDROID_ABI}/libnode.so) + +# Specifies libraries CMake should link to your target library. You +# can link libraries from various origins, such as libraries defined in this +# build script, prebuilt third-party libraries, or Android system libraries. +target_link_libraries(${CMAKE_PROJECT_NAME} + # Link the libnode library. + libnode + # List libraries link to the target library + android + log) \ No newline at end of file diff --git a/packages/terre-android/app/src/main/cpp/native-lib.cpp b/packages/terre-android/app/src/main/cpp/native-lib.cpp new file mode 100644 index 00000000..9b084f11 --- /dev/null +++ b/packages/terre-android/app/src/main/cpp/native-lib.cpp @@ -0,0 +1,121 @@ +#include +#include +#include +#include "node.h" +#include +#include +#include + +int pipe_stdout[2]; +int pipe_stderr[2]; +pthread_t thread_stdout; +pthread_t thread_stderr; +const char *ADBTAG = "NODEJS-MOBILE"; + +void *thread_stderr_func(void *) { + ssize_t redirect_size; + char buf[2048]; + while ((redirect_size = read(pipe_stderr[0], buf, sizeof buf - 1)) > 0) { + //__android_log will add a new line anyway. + if (buf[redirect_size - 1] == '\n') + --redirect_size; + buf[redirect_size] = 0; + __android_log_write(ANDROID_LOG_ERROR, ADBTAG, buf); + } + return 0; +} + +void *thread_stdout_func(void *) { + ssize_t redirect_size; + char buf[2048]; + while ((redirect_size = read(pipe_stdout[0], buf, sizeof buf - 1)) > 0) { + //__android_log will add a new line anyway. + if (buf[redirect_size - 1] == '\n') + --redirect_size; + buf[redirect_size] = 0; + __android_log_write(ANDROID_LOG_INFO, ADBTAG, buf); + } + return 0; +} + +int start_redirecting_stdout_stderr() { + //set stdout as unbuffered. + setvbuf(stdout, 0, _IONBF, 0); + pipe(pipe_stdout); + dup2(pipe_stdout[1], STDOUT_FILENO); + + //set stderr as unbuffered. + setvbuf(stderr, 0, _IONBF, 0); + pipe(pipe_stderr); + dup2(pipe_stderr[1], STDERR_FILENO); + + if (pthread_create(&thread_stdout, 0, thread_stdout_func, 0) == -1) + return -1; + pthread_detach(thread_stdout); + + if (pthread_create(&thread_stderr, 0, thread_stderr_func, 0) == -1) + return -1; + pthread_detach(thread_stderr); + + return 0; +} + + +//node's libUV requires all arguments being on contiguous memory. +extern "C" jint JNICALL +Java_com_openwebgal_terre_MainActivity_startNodeWithArguments( + JNIEnv *env, + jobject /* this */, + jobjectArray arguments) { + + //argc + jsize argument_count = env->GetArrayLength(arguments); + + //Compute byte size need for all arguments in contiguous memory. + int c_arguments_size = 0; + for (int i = 0; i < argument_count; i++) { + c_arguments_size += strlen( + env->GetStringUTFChars((jstring) env->GetObjectArrayElement(arguments, i), 0)); + c_arguments_size++; // for '\0' + } + + //Stores arguments in contiguous memory. + char *args_buffer = (char *) calloc(c_arguments_size, sizeof(char)); + + //argv to pass into node. + char *argv[argument_count]; + + //To iterate through the expected start position of each argument in args_buffer. + char *current_args_position = args_buffer; + + //Populate the args_buffer and argv. + for (int i = 0; i < argument_count; i++) { + const char *current_argument = env->GetStringUTFChars( + (jstring) env->GetObjectArrayElement(arguments, i), 0); + + //Copy current argument to its expected position in args_buffer + strncpy(current_args_position, current_argument, strlen(current_argument)); + + //Save current argument start position in argv + argv[i] = current_args_position; + + //Increment to the next argument's expected position. + current_args_position += strlen(current_args_position) + 1; + } + //Start threads to show stdout and stderr in logcat. + if (start_redirecting_stdout_stderr() == -1) { + __android_log_write(ANDROID_LOG_ERROR, ADBTAG, + "Couldn't start redirecting stdout and stderr to logcat."); + } + + //Start node, with argc and argv. + return jint(node::Start(argument_count, argv)); +} + +extern "C" +JNIEXPORT jint JNICALL +Java_com_openwebgal_terre_MainActivity_stopNode( + JNIEnv *env, + jobject /* this */) { + return jint(node::Stop(reinterpret_cast(env))); +} \ No newline at end of file diff --git a/packages/terre-android/app/src/main/ic_launcher-playstore.png b/packages/terre-android/app/src/main/ic_launcher-playstore.png new file mode 100644 index 00000000..97730189 Binary files /dev/null and b/packages/terre-android/app/src/main/ic_launcher-playstore.png differ diff --git a/packages/terre-android/app/src/main/java/com/openwebgal/terre/MainActivity.kt b/packages/terre-android/app/src/main/java/com/openwebgal/terre/MainActivity.kt new file mode 100644 index 00000000..0c09f09a --- /dev/null +++ b/packages/terre-android/app/src/main/java/com/openwebgal/terre/MainActivity.kt @@ -0,0 +1,432 @@ +package com.openwebgal.terre + +import android.content.Context +import android.content.Intent +import android.content.pm.PackageManager +import android.content.res.AssetManager +import android.net.Uri +import android.os.Bundle +import android.util.Log +import android.widget.Toast +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.rememberScrollState +import androidx.compose.foundation.verticalScroll +import androidx.compose.material3.CircularProgressIndicator +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TextButton +import androidx.compose.material3.TopAppBar +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.collectAsState +import androidx.compose.runtime.getValue +import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.unit.dp +import androidx.lifecycle.viewmodel.compose.viewModel +import com.openwebgal.terre.ui.theme.TerreTheme +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import java.io.BufferedReader +import java.io.File +import java.io.FileOutputStream +import java.io.IOException +import java.io.InputStream +import java.io.InputStreamReader +import java.io.OutputStream +import java.util.concurrent.Executors + +class MainActivity : ComponentActivity() { + + companion object { + init { + System.loadLibrary("terre") + System.loadLibrary("node") + } + } + + private external fun startNodeWithArguments(arguments: Array): Int + private external fun stopNode(): Int + + private val nodeDirName = "terre" + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + TerreTheme { + MainScreen( + launchUrl = ::launchUrl, + start = ::start, + stop = ::stop, + ) + } + } + } + + fun start() { + try { + applicationContext.getExternalFilesDir(null) // May return null, call to create directory + val externalFilesDir = applicationContext.getExternalFilesDir(null) + Log.i("ASSETS", externalFilesDir?.absolutePath.toString()) + if (externalFilesDir != null) { + val nodeDir = "${externalFilesDir.absolutePath}/$nodeDirName" + copyAssets(nodeDir) + val executor = Executors.newSingleThreadExecutor() + executor.submit { + copyAssets(nodeDir) + startNodeWithArguments( + arrayOf( + "node", + "$nodeDir/main.js", + "--cwd", + nodeDir + ) + ) + } + } else { + Log.e("StorageError", "External files directory is unavailable") + } + } catch (e: Exception) { + e.printStackTrace() + } + } + + fun stop() { + try { + stopNode() + } catch (e: Exception) { + e.printStackTrace() + } + } + + private fun copyAssets(nodeDir: String) { + if (wasAPKUpdated()) { + Log.i("ASSETS", "Start Copy Assets") +// val nodeDirReference = File(nodeDir) +// if (nodeDirReference.exists()) { +// deleteFolderRecursively(nodeDirReference) +// } + copyAssetFolder(applicationContext.assets, nodeDirName, nodeDir) + + saveLastUpdateTime() + + Log.i("ASSETS", "Copy Assets Finished") + } + } + + private fun deleteFolderRecursively(file: File): Boolean { + return try { + var res = true + val childFiles = file.listFiles() ?: return file.delete() + + for (childFile in childFiles) { + res = if (childFile.isDirectory) { + res and deleteFolderRecursively(childFile) + } else { + res and childFile.delete() + } + } + res and file.delete() + res + } catch (e: Exception) { + e.printStackTrace() + false + } + } + + private fun copyAssetFolder( + assetManager: AssetManager, + fromAssetPath: String, + toPath: String + ): Boolean { + return try { + val files = assetManager.list(fromAssetPath) ?: return copyAsset( + assetManager, + fromAssetPath, + toPath + ) + var res = true + + if (files.isEmpty()) { + res = copyAsset(assetManager, fromAssetPath, toPath) + } else { + File(toPath).mkdirs() + for (file in files) { + res = copyAssetFolder(assetManager, "$fromAssetPath/$file", "$toPath/$file") + } + } + res + } catch (e: Exception) { + e.printStackTrace() + false + } + } + + private fun copyAsset( + assetManager: AssetManager, + fromAssetPath: String, + toPath: String + ): Boolean { + var `in`: InputStream? = null + var out: OutputStream? = null + return try { + `in` = assetManager.open(fromAssetPath) + File(toPath).createNewFile() + out = FileOutputStream(toPath) + copyFile(`in`, out) + `in`.close() + out.flush() + out.close() + true + } catch (e: Exception) { + e.printStackTrace() + false + } finally { + try { + `in`?.close() + out?.close() + } catch (e: IOException) { + e.printStackTrace() + } + } + } + + private fun copyFile(inputStream: InputStream, outputStream: OutputStream) { + val buffer = ByteArray(1024) + var read: Int + while (inputStream.read(buffer).also { read = it } != -1) { + outputStream.write(buffer, 0, read) + } + } + + private fun launchUrl(url: String) { + val intent = Intent(Intent.ACTION_VIEW).apply { + data = Uri.parse(url) + } + try { + startActivity(intent) + } catch (e: Exception) { + e.printStackTrace() + Toast.makeText(this, "Could not open browser", Toast.LENGTH_SHORT).show() + } + } + + private fun wasAPKUpdated(): Boolean { + val prefs = + applicationContext.getSharedPreferences("NODEJS_MOBILE_PREFS", Context.MODE_PRIVATE) + val previousLastUpdateTime = prefs.getLong("NODEJS_MOBILE_APK_LastUpdateTime", 0) + var lastUpdateTime: Long = 1 + try { + val packageInfo = + applicationContext.packageManager.getPackageInfo(applicationContext.packageName, 0) + lastUpdateTime = packageInfo.lastUpdateTime + } catch (e: PackageManager.NameNotFoundException) { + e.printStackTrace() + } + return lastUpdateTime != previousLastUpdateTime + } + + private fun saveLastUpdateTime() { + var lastUpdateTime: Long = 1 + try { + val packageInfo = + applicationContext.packageManager.getPackageInfo(applicationContext.packageName, 0) + lastUpdateTime = packageInfo.lastUpdateTime + } catch (e: PackageManager.NameNotFoundException) { + e.printStackTrace() + } + val prefs = + applicationContext.getSharedPreferences("NODEJS_MOBILE_PREFS", Context.MODE_PRIVATE) + val editor = prefs.edit() + editor.putLong("NODEJS_MOBILE_APK_LastUpdateTime", lastUpdateTime) + editor.apply() + } +} + +@Composable +fun MainScreen( + terreViewModel: TerreViewModel = viewModel(), + launchUrl: (String) -> Unit, + start: () -> Unit, + stop: () -> Unit, +) { + + val isCopyingAssets by terreViewModel.isCopyingAssets.collectAsState() + + LaunchedEffect(Unit) { + terreViewModel.startNode(start) + } + + Scaffold( + modifier = Modifier.fillMaxSize(), + topBar = { + TopAppBar( + terreViewModel = terreViewModel, + launchUrl = launchUrl, + start = start, + stop = stop + ) + }, + ) { innerPadding -> + Column( + modifier = Modifier + .fillMaxSize() + .padding(innerPadding), + verticalArrangement = Arrangement.Top, + horizontalAlignment = Alignment.Start, + ) { + if (isCopyingAssets) + Box(modifier = Modifier.fillMaxSize()) { + Column( + horizontalAlignment = Alignment.CenterHorizontally + ) { + CircularProgressIndicator() + Spacer(modifier = Modifier.height(16.dp)) + Text( + text = "正在复制资产,请稍候...", + style = MaterialTheme.typography.bodyMedium + ) + } + } + LogcatView(terreViewModel) + } + } +} + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun TopAppBar( + terreViewModel: TerreViewModel, + launchUrl: (String) -> Unit, + start: () -> Unit, + stop: () -> Unit, +) { + val isNodeRunning by terreViewModel.isNodeRunning.collectAsState() + TopAppBar( + title = { Text("WebGAL Terre") }, + actions = { +// if (!isNodeRunning) { +// TextButton(onClick = { +// terreViewModel.startNode(start) +// }) { +// Text("启动") +// } +// } + if (isNodeRunning) { + TextButton(onClick = { + launchUrl("http://localhost:3001/") + }) { + Text("打开浏览器") + } + } + TextButton(onClick = { + terreViewModel.stopNode(stop) + }) { + Text("关闭") + } + }, + colors = TopAppBarDefaults.topAppBarColors( + containerColor = MaterialTheme.colorScheme.inversePrimary + ) + + ) +} + +private const val ADBTAG = "NODEJS-MOBILE" + +@Composable +fun LogcatView(terreViewModel: TerreViewModel) { + val coroutineScope = rememberCoroutineScope() + val scrollState = rememberScrollState() + val logLines by terreViewModel.logLines.collectAsState() + + LaunchedEffect(key1 = Unit) { + coroutineScope.launch(Dispatchers.IO) { + try { + clearLogcat() + + val process = ProcessBuilder("logcat").redirectErrorStream(true).start() + val bufferedReader = BufferedReader(InputStreamReader(process.inputStream)) + + var line: String? + while (bufferedReader.readLine().also { line = it } != null && isActive) { + line?.let { logLine -> + if (logLine.contains(ADBTAG) || logLine.contains("ASSETS") || logLine.contains( + "E/" + ) + ) { + withContext(Dispatchers.Main) { + terreViewModel.addLogLine( + cleanLog(logLine) + ) + } + } + } + } + process.destroy() + Log.d("LogcatView", "Logcat reading stopped.") + bufferedReader.close() + } catch (e: IOException) { + Log.e( + "LogcatView", + "Error reading logcat in coroutine: ${e.message}" + ) + } + } + } + + LaunchedEffect(logLines.size) { + if (logLines.isNotEmpty()) { + scrollState.animateScrollTo(scrollState.maxValue) + } + } + + Column( + modifier = Modifier + .fillMaxWidth() + .verticalScroll(scrollState) + ) { + logLines.forEach { line -> + Text( + line, + style = MaterialTheme.typography.bodySmall, + modifier = Modifier.padding(horizontal = 8.dp, vertical = 2.dp), + ) + } + } +} + +fun clearLogcat() { + try { + val process = Runtime.getRuntime().exec("logcat -c") + process.waitFor() + } catch (e: IOException) { + Log.e("LogcatView", "Error clearing logcat: ${e.message}") + } catch (e: InterruptedException) { + Log.e("LogcatView", "Error clearing logcat: ${e.message}") + Thread.currentThread().interrupt() + } +} + +fun cleanLog(logLine: String): String { + val lastPart = logLine.split("$ADBTAG:").last() + val cleanedLog = lastPart.replace(Regex("\u001B\\[[;\\d]*m"), "").trim() + return cleanedLog +} \ No newline at end of file diff --git a/packages/terre-android/app/src/main/java/com/openwebgal/terre/TerreViewModel.kt b/packages/terre-android/app/src/main/java/com/openwebgal/terre/TerreViewModel.kt new file mode 100644 index 00000000..e989d693 --- /dev/null +++ b/packages/terre-android/app/src/main/java/com/openwebgal/terre/TerreViewModel.kt @@ -0,0 +1,48 @@ +package com.openwebgal.terre + +import androidx.lifecycle.ViewModel +import kotlinx.coroutines.flow.MutableStateFlow +import kotlinx.coroutines.flow.StateFlow +import kotlinx.coroutines.flow.asStateFlow + +class TerreViewModel : ViewModel() { + private val MAX_LOG_LINES = 500 + + private val _isCopyingAssets = MutableStateFlow(false) + val isCopyingAssets: StateFlow = _isCopyingAssets.asStateFlow() + + private val _isNodeRunning = MutableStateFlow(false) + val isNodeRunning: StateFlow = _isNodeRunning.asStateFlow() + + private val _logLines = MutableStateFlow>(emptyList()) + val logLines: StateFlow> = _logLines.asStateFlow() + + fun updateIsCopyingAssets(isCopyingAssets: Boolean) { + _isCopyingAssets.value = isCopyingAssets + } + + fun startNode(start: () -> Unit) { + if (!_isNodeRunning.value) { + start() + _isNodeRunning.value = true + } + } + + fun stopNode(stop: () -> Unit) { + if (_isNodeRunning.value) { + stop() + _isNodeRunning.value = false + } + } + + fun addLogLine(line: String) { + _logLines.value += line + if (_logLines.value.size > MAX_LOG_LINES) { + _logLines.value = _logLines.value.drop(1) + } + } + + fun clearLogLines() { + _logLines.value = emptyList() + } +} \ No newline at end of file diff --git a/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Color.kt b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Color.kt new file mode 100644 index 00000000..ad1031cc --- /dev/null +++ b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.openwebgal.terre.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Theme.kt b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Theme.kt new file mode 100644 index 00000000..b35b717b --- /dev/null +++ b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Theme.kt @@ -0,0 +1,57 @@ +package com.openwebgal.terre.ui.theme + +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun TerreTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Type.kt b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Type.kt new file mode 100644 index 00000000..7489b848 --- /dev/null +++ b/packages/terre-android/app/src/main/java/com/openwebgal/terre/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.openwebgal.terre.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/drawable/ic_launcher_background.xml b/packages/terre-android/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 00000000..07d5da9c --- /dev/null +++ b/packages/terre-android/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/packages/terre-android/app/src/main/res/drawable/ic_launcher_foreground.xml b/packages/terre-android/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 00000000..2b068d11 --- /dev/null +++ b/packages/terre-android/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 00000000..036d09bc --- /dev/null +++ b/packages/terre-android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 00000000..fc8c0895 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..77dcdf0a Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 00000000..341dfbd4 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 00000000..5462c170 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..3431c03b Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 00000000..44b8d450 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 00000000..28af855f Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..a42dc96b Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..5e4e8b03 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 00000000..78d52bad Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..2d1718f8 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..a74e949b Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 00000000..3aa0d6ee Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp new file mode 100644 index 00000000..e52d1054 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.webp differ diff --git a/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 00000000..15a83ab3 Binary files /dev/null and b/packages/terre-android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/packages/terre-android/app/src/main/res/values/colors.xml b/packages/terre-android/app/src/main/res/values/colors.xml new file mode 100644 index 00000000..f8c6127d --- /dev/null +++ b/packages/terre-android/app/src/main/res/values/colors.xml @@ -0,0 +1,10 @@ + + + #FFBB86FC + #FF6200EE + #FF3700B3 + #FF03DAC5 + #FF018786 + #FF000000 + #FFFFFFFF + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/values/ic_launcher_background.xml b/packages/terre-android/app/src/main/res/values/ic_launcher_background.xml new file mode 100644 index 00000000..036a7729 --- /dev/null +++ b/packages/terre-android/app/src/main/res/values/ic_launcher_background.xml @@ -0,0 +1,4 @@ + + + #005CAF + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/values/strings.xml b/packages/terre-android/app/src/main/res/values/strings.xml new file mode 100644 index 00000000..dd9ad4a0 --- /dev/null +++ b/packages/terre-android/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + WebGAL Terre + \ No newline at end of file diff --git a/packages/terre-android/app/src/main/res/values/themes.xml b/packages/terre-android/app/src/main/res/values/themes.xml new file mode 100644 index 00000000..c99534a8 --- /dev/null +++ b/packages/terre-android/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +