diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 5ae388ee2..000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,73 +0,0 @@ -version: 2.1 - -jobs: - test: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./gradlew check - shadow_jar: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./gradlew shadowJar - - persist_to_workspace: - root: build - paths: - - libs/stellar-sdk.jar - deploy: - docker: - - image: cimg/go:1.17 - steps: - - attach_workspace: - at: ./build - - run: - name: "Install github.com/github-release/github-release v0.10.0" - command: | - go get github.com/github-release/github-release@v0.10.0 - - run: - name: "Upload JAR to GitHub Release" - command: | - github-release upload -s ${GITHUB_TOKEN} -u ${CIRCLE_PROJECT_USERNAME} -r ${CIRCLE_PROJECT_REPONAME} -t ${CIRCLE_TAG} -f ./build/libs/stellar-sdk.jar -n java-stellar-sdk.jar - - after_deploy: - docker: - - image: circleci/openjdk:11 - steps: - - checkout - - run: ./after_deploy.sh - -workflows: - version: 2 - test-and-deploy: - jobs: - - test: - filters: # required since `deploy` has tag filters AND requires `build` - tags: - only: /.*/ - - shadow_jar: - requires: - - test - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ - - deploy: - requires: - - shadow_jar - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ - - after_deploy: - requires: - - deploy - filters: - tags: - only: /.*/ - branches: - ignore: /.*/ diff --git a/.github/workflows/test-deploy.yml b/.github/workflows/test-deploy.yml new file mode 100644 index 000000000..0f94a09cc --- /dev/null +++ b/.github/workflows/test-deploy.yml @@ -0,0 +1,134 @@ +name: "Test and Deploy" + +on: + push: + branches: + - master + pull_request: + release: + types: + - created + +env: + JAVA_VERSION: '17' + JAVA_DISTRIBUTION: 'microsoft' + +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Test + run: ./gradlew check + + build: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Build + run: ./gradlew build + - name: Persist JAR Artifacts + uses: actions/upload-artifact@v3 + with: + name: libs + path: build/libs/*.jar + + javadoc: + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK + uses: actions/setup-java@v2 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: Generate Documentation + run: ./gradlew javadoc + - name: Persist Documentation + uses: actions/upload-artifact@v3 + with: + name: javadoc + path: javadoc + + android-test: + needs: build + runs-on: macos-13 + name: android-test (api ${{ matrix.emulator.api-level }}) + strategy: + fail-fast: false + matrix: + # minSdk and targetSdk, see ${project_root}/android_test/app/build.gradle.kts + # TODO: Investigate why it is unstable on API 33. + emulator: [ + { api-level: 26, target: google_apis }, + { api-level: 32, target: playstore } + ] + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Download JAR Artifact + uses: actions/download-artifact@v2 + with: + name: libs + path: android_test/app/libs/ + - uses: actions/setup-java@v3 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.JAVA_DISTRIBUTION }} + - name: run tests + uses: reactivecircus/android-emulator-runner@v2 + with: + working-directory: ./android_test + api-level: ${{ matrix.emulator.api-level }} + target: ${{ matrix.emulator.target }} + script: ./gradlew connectedCheck + arch: x86_64 + profile: 'pixel_2' + + deploy: + needs: [ build, javadoc ] # TODO: add android-test when it is stable. + permissions: + contents: write + if: github.event_name == 'release' && github.event.action == 'created' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Download JAR Artifact + uses: actions/download-artifact@v2 + with: + name: libs + path: libs + - name: Download Java Documentation + uses: actions/download-artifact@v2 + with: + name: javadoc + path: javadoc + - name: Archive Documentation + run: tar -czf stellar-sdk-javadoc.tar.gz javadoc + - name: Upload artifacts to GitHub Release + uses: softprops/action-gh-release@v1 + with: + files: | + libs/*.jar + stellar-sdk-javadoc.tar.gz + - name: Upload Documentation to GitHub Pages + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: javadoc + diff --git a/CHANGELOG.md b/CHANGELOG.md index ce615de9d..7bef5d5f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,59 @@ As this project is pre 1.0, breaking changes may happen for minor version bumps. ## Pending +## 0.41.0 +* Add support for Soroban Preview 11. ([#530](https://github.com/stellar/java-stellar-sdk/pull/530)) +* New effects have been added to support Protocol 20 (Soroban) ([#535](https://github.com/stellar/java-stellar-sdk/pull/535)): + - `ContractCredited` occurs when a Stellar asset moves into its corresponding Stellar Asset Contract instance + - `ContractDebited` occurs when a Stellar asset moves out of its corresponding Stellar Asset Contract instance +* Add helper functions to sign authorization entries. ([#537](https://github.com/stellar/java-stellar-sdk/pull/537)) + +### Breaking changes +* Bump dependencies & Remove unnecessary dependencies like guava. ([#523](https://github.com/stellar/java-stellar-sdk/pull/523)) +* No longer provide a shadow jar that contains embedded, relocated third-party dependencies. ([#528](https://github.com/stellar/java-stellar-sdk/issues/528)) + Instead the default `stellar-sdk.jar` and the `com.github.stellar:java-stellar-sdk:{version}` dependency are now packaged + as 'thin library' jar, having no embedded dependencies. + - if your project used `stellar-sdk.jar` directly on classpath loader, will need to obtain the `.jar` for each dependency version listed in `build.gradle.kts` + and include all in your project classpath, or consider downloading the 'uber' jar from the published artifacts on repo + `https://jitpack.io/com/github/stellar/java-stellar-sdk/{version}/java-stellar-sdk-{version}-uber.jar` + - if your project utilizes dependency management for build such as gradle/maven, then you can choose from the following artifacts + using the dependency classifier: + ```kotlin + implementation("com.github.stellar:java-stellar-sdk:{version}") // thin jar + implementation("com.github.stellar:java-stellar-sdk:{version}:uber") // uber jar + implementation("com.github.stellar:java-stellar-sdk:{version}:javadoc") // javadoc jar + implementation("com.github.stellar:java-stellar-sdk:{version}:sources") // sources jar + ``` + + - When using the 'thin' jar in dependency management, it will automatically fetch dependencies transitively. + If your project declares dependencies that are also declared here, then your project will override + the preferences of this project and may cause runtime conflict. + + - When using the 'uber' jar in dependency management or as `.jar` in classpath , be aware that it does not relocate the dependent packages. + +* `Utils.claimableBalanceIdToXDR` and `Utils.xdrToClaimableBalanceId` have been removed. ([#503](https://github.com/stellar/java-stellar-sdk/pull/503)) +* The types of the following fields have changed. ([#498](https://github.com/stellar/java-stellar-sdk/pull/498)) + | field | before | now | + | ----------------------------------------- | ------ | ---------- | + | LedgerBounds.minLedger | int | long | + | LedgerBounds.maxLedger | int | long | + | MemoId.id | long | BigInteger | + | TimeBounds.minTime | long | BigInteger | + | TimeBounds.maxTime | long | BigInteger | + | TransactionBuilder.baseFee | int | long | + | TransactionPreconditions.TIMEOUT_INFINITE | long | BigInteger | + | TransactionPreconditions.minSeqAge | Long | BigInteger | + | TransactionPreconditions.minSeqLedgerGap | int | long | + +## 0.41.0-beta.3 +* Fix the bug in Transaction.isSorobanTransaction to accommodate BumpFootprintExpirationOperation. ([#518](https://github.com/stellar/java-stellar-sdk/pull/518)) + +## 0.41.0-beta.0 +* Add support for Soroban Preview 10. ([#490](https://github.com/stellar/java-stellar-sdk/issues/490)) +* Correct the data type of certain fields to store the expected design values. ([#497](https://github.com/stellar/java-stellar-sdk/pull/497)) +* Add source account comparison to `ClawbackClaimableBalanceOperation`, `LiquidityPoolWithdrawOperation`, and `LiquidityPoolDepositOperation` for equality check. ([#484](https://github.com/stellar/java-stellar-sdk/pull/484)) +* Add basic implementation of `liquidity_pools?account` ([#426](https://github.com/stellar/java-stellar-sdk/pull/426)) + ## 0.40.1 * Fix the issue of unable to parse liquidity_pool_revoked effect properly. ([#521](https://github.com/stellar/java-stellar-sdk/pull/521)) * Define cursor, order and limit in AssetsRequestBuilder object. ([#522](https://github.com/stellar/java-stellar-sdk/pull/522)) diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..82b783708 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +XDRS = xdr/Stellar-SCP.x \ +xdr/Stellar-ledger-entries.x \ +xdr/Stellar-ledger.x \ +xdr/Stellar-overlay.x \ +xdr/Stellar-transaction.x \ +xdr/Stellar-types.x \ +xdr/Stellar-contract-env-meta.x \ +xdr/Stellar-contract-meta.x \ +xdr/Stellar-contract-spec.x \ +xdr/Stellar-contract.x \ +xdr/Stellar-internal.x \ +xdr/Stellar-contract-config-setting.x + +XDRGEN_COMMIT=f0c41458ca0b66b4649b18deddc9f7a11199f1f9 +XDRNEXT_COMMIT=9ac02641139e6717924fdad716f6e958d0168491 + +.PHONY: xdr xdr-clean xdr-update + +xdr-generate: $(XDRS) + docker run -it --rm -v $$PWD:/wd -w /wd ruby /bin/bash -c '\ + gem install specific_install -v 0.3.8 && \ + gem specific_install https://github.com/stellar/xdrgen.git -b $(XDRGEN_COMMIT) && \ + xdrgen \ + --language java \ + --namespace org.stellar.sdk.xdr \ + --output src/main/java/org/stellar/sdk/xdr/ \ + $(XDRS)' + ./gradlew :spotlessApply + +xdr/%.x: + curl -Lsf -o $@ https://raw.githubusercontent.com/stellar/stellar-xdr/$(XDRNEXT_COMMIT)/$(@F) + +xdr-clean: + rm xdr/*.x || true + rm src/main/java/org/stellar/sdk/xdr/*.java || true + +xdr-update: xdr-clean xdr-generate \ No newline at end of file diff --git a/after_deploy.sh b/after_deploy.sh deleted file mode 100755 index 4df2347b8..000000000 --- a/after_deploy.sh +++ /dev/null @@ -1,16 +0,0 @@ -echo "machine github.com login stellar-jenkins password $GITHUB_TOKEN" >~/.netrc -git clone -b gh-pages "https://stellar-jenkins@github.com/stellar/java-stellar-sdk.git" javadoc - -if [ ! -d "javadoc" ]; then - echo "Error cloning" - exit 1 -fi - -rm -rf javadoc/* # Remove all files without hidden (.git) -javadoc -public -splitindex -windowtitle "java-stellar-sdk documentation" -d ./javadoc -sourcepath ./src/main/java/ -subpackages org.stellar.sdk -exclude org.stellar.sdk.xdr -cd javadoc -git config user.name "post-release-script" -git config user.email "post-release-script@stellar.org" -git add . -git commit -m $CIRCLE_TAG -git push origin gh-pages diff --git a/android_test/.gitignore b/android_test/.gitignore new file mode 100644 index 000000000..aa724b770 --- /dev/null +++ b/android_test/.gitignore @@ -0,0 +1,15 @@ +*.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 diff --git a/android_test/README.md b/android_test/README.md new file mode 100644 index 000000000..fa6194375 --- /dev/null +++ b/android_test/README.md @@ -0,0 +1,4 @@ +# Android Test +This folder contains a simple project for testing whether stellar-sdk can be successfully integrated into an Android project. + +This project is based on a template project created using Android Studio, and I have tried my best not to make any excessive modifications. \ No newline at end of file diff --git a/android_test/app/.gitignore b/android_test/app/.gitignore new file mode 100644 index 000000000..42afabfd2 --- /dev/null +++ b/android_test/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/android_test/app/build.gradle.kts b/android_test/app/build.gradle.kts new file mode 100644 index 000000000..e4ef7f80a --- /dev/null +++ b/android_test/app/build.gradle.kts @@ -0,0 +1,79 @@ +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") +} + +android { + namespace = "org.stellar.javastellarsdkdemoapp" + compileSdk = 33 + + defaultConfig { + applicationId = "org.stellar.javastellarsdkdemoapp" + minSdk = 26 + targetSdk = 33 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.3" + } + packaging { + resources { + excludes += "/META-INF/{AL2.0,LGPL2.1}" + } + } +} + +dependencies { + + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.1") + implementation("androidx.activity:activity-compose:1.7.2") + implementation(platform("androidx.compose:compose-bom:2023.03.00")) + implementation("androidx.compose.ui:ui") + implementation("androidx.compose.ui:ui-graphics") + implementation("androidx.compose.ui:ui-tooling-preview") + implementation("androidx.compose.material3:material3") + implementation(files("libs/stellar-sdk.jar")) + // Since we are adding local jar(libs/stellar-sdk.jar) as dependency, + // gradle cannot automatically download the required third-party dependencies. + implementation("com.squareup.okhttp3:okhttp:4.11.0") + implementation("com.squareup.okhttp3:okhttp-sse:4.11.0") + implementation("com.moandjiezana.toml:toml4j:0.7.2") + implementation("com.google.code.gson:gson:2.10.1") + implementation("net.i2p.crypto:eddsa:0.3.0") + implementation("commons-codec:commons-codec:1.16.0") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.uiautomator:uiautomator:2.3.0-alpha03") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) + androidTestImplementation("androidx.compose.ui:ui-test-junit4") + debugImplementation("androidx.compose.ui:ui-tooling") + debugImplementation("androidx.compose.ui:ui-test-manifest") +} \ No newline at end of file diff --git a/android_test/app/libs/README.md b/android_test/app/libs/README.md new file mode 100644 index 000000000..fb24dd7e4 --- /dev/null +++ b/android_test/app/libs/README.md @@ -0,0 +1 @@ +You need to place stellar-sdk.jar into this folder. \ No newline at end of file diff --git a/android_test/app/proguard-rules.pro b/android_test/app/proguard-rules.pro new file mode 100644 index 000000000..481bb4348 --- /dev/null +++ b/android_test/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/android_test/app/src/androidTest/java/org/stellar/javastellarsdkdemoapp/MainInstrumentedTest.kt b/android_test/app/src/androidTest/java/org/stellar/javastellarsdkdemoapp/MainInstrumentedTest.kt new file mode 100644 index 000000000..9c538f291 --- /dev/null +++ b/android_test/app/src/androidTest/java/org/stellar/javastellarsdkdemoapp/MainInstrumentedTest.kt @@ -0,0 +1,62 @@ +package org.stellar.javastellarsdkdemoapp + +import android.content.Intent +import androidx.test.ext.junit.runners.AndroidJUnit4 +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.uiautomator.By +import androidx.test.uiautomator.UiDevice +import androidx.test.uiautomator.Until +import org.junit.Assert.* +import org.junit.Test +import org.junit.runner.RunWith + +private const val ONE_MINUTE = 1000L * 60 +private const val PACKAGE = "org.stellar.javastellarsdkdemoapp" + +/** + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class MainInstrumentedTest { + @Test + fun testGetNetwork() { + val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) + // open app + device.pressHome() + val launcherPackage: String = device.launcherPackageName + assertNotNull(launcherPackage) + device.wait( + Until.hasObject(By.pkg(launcherPackage).depth(0)), + ONE_MINUTE + ) + val context = InstrumentationRegistry.getInstrumentation().context + val intent = + context.packageManager.getLaunchIntentForPackage(PACKAGE) + intent?.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK) + context.startActivity(intent) + // wait for app to appear + device.wait( + Until.hasObject(By.pkg(PACKAGE).depth(0)), + ONE_MINUTE + ) + + // get text + val textNoNetworkInfo = device.wait( + Until.findObject(By.text("No network info")), + ONE_MINUTE + ) + assertNotNull(textNoNetworkInfo) + + // get button + val button = device.wait( + Until.findObject(By.text("Get Network")), + ONE_MINUTE + ) + assertNotNull(button) + + // click button and wait text to appear + button.click() + + assertTrue(device.wait(Until.hasObject(By.text("public")), ONE_MINUTE * 5)) + } +} \ No newline at end of file diff --git a/android_test/app/src/main/AndroidManifest.xml b/android_test/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000..9fd8d46b2 --- /dev/null +++ b/android_test/app/src/main/AndroidManifest.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/MainActivity.kt b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/MainActivity.kt new file mode 100644 index 000000000..a7b0f7fab --- /dev/null +++ b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/MainActivity.kt @@ -0,0 +1,119 @@ +package org.stellar.javastellarsdkdemoapp + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Button +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Surface +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import androidx.compose.ui.unit.dp +import androidx.lifecycle.ViewModel +import androidx.lifecycle.ViewModelProvider +import androidx.lifecycle.viewModelScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import org.stellar.javastellarsdkdemoapp.ui.theme.JavaStellarSDKDemoAppTheme +import org.stellar.sdk.Server + +private const val HORIZON_SERVER = "https://horizon.stellar.org/" +private const val PUBLIC = "Public Global Stellar Network ; September 2015" +private const val TESTNET = "Test SDF Network ; September 2015" + +class MainActivity : ComponentActivity() { + private lateinit var networkViewModel: NetworkViewModel + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + + networkViewModel = ViewModelProvider(this).get(NetworkViewModel::class.java) + + setContent { + JavaStellarSDKDemoAppTheme { + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background + ) { + Main(networkViewModel) + } + } + } + } +} + +class NetworkViewModel : ViewModel() { + private val _network = mutableStateOf(null) + val network: String? get() = _network.value + + fun fetchNetworkPassphrase() { + viewModelScope.launch { + _network.value = withContext(Dispatchers.IO) { + getNetwork() + } + } + } +} + +@Composable +fun Main(networkViewModel: NetworkViewModel, modifier: Modifier = Modifier) { + Column( + modifier = modifier.fillMaxSize(), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Button( + onClick = { networkViewModel.fetchNetworkPassphrase() } + ) { + Text(text = "Get Network") + } + + Spacer(modifier = Modifier.height(16.dp)) + + Text( + text = networkViewModel.network ?: "No network info", + modifier = Modifier.padding(horizontal = 16.dp) + ) + } +} + +@Preview(showBackground = true) +@Composable +fun MainPreview() { + JavaStellarSDKDemoAppTheme { + val networkViewModel = NetworkViewModel() + Main(networkViewModel) + } +} + +private fun getNetwork(): String? { + val server = Server(HORIZON_SERVER) + return try { + when (server.root().networkPassphrase) { + PUBLIC -> { + "public" + } + + TESTNET -> { + "testnet" + } + + else -> { + "others" + } + } + } catch (e: Exception) { + null + } +} \ No newline at end of file diff --git a/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Color.kt b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Color.kt new file mode 100644 index 000000000..f7d8cbce3 --- /dev/null +++ b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package org.stellar.javastellarsdkdemoapp.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/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Theme.kt b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Theme.kt new file mode 100644 index 000000000..46f1756e7 --- /dev/null +++ b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Theme.kt @@ -0,0 +1,70 @@ +package org.stellar.javastellarsdkdemoapp.ui.theme + +import android.app.Activity +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.runtime.SideEffect +import androidx.compose.ui.graphics.toArgb +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.platform.LocalView +import androidx.core.view.WindowCompat + +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 JavaStellarSDKDemoAppTheme( + 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 + } + val view = LocalView.current + if (!view.isInEditMode) { + SideEffect { + val window = (view.context as Activity).window + window.statusBarColor = colorScheme.primary.toArgb() + WindowCompat.getInsetsController(window, view).isAppearanceLightStatusBars = darkTheme + } + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Type.kt b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Type.kt new file mode 100644 index 000000000..315916918 --- /dev/null +++ b/android_test/app/src/main/java/org/stellar/javastellarsdkdemoapp/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package org.stellar.javastellarsdkdemoapp.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/android_test/app/src/main/res/drawable/ic_launcher_background.xml b/android_test/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 000000000..07d5da9cb --- /dev/null +++ b/android_test/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/android_test/app/src/main/res/drawable/ic_launcher_foreground.xml b/android_test/app/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 000000000..2b068d114 --- /dev/null +++ b/android_test/app/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/android_test/app/src/main/res/mipmap-anydpi/ic_launcher.xml b/android_test/app/src/main/res/mipmap-anydpi/ic_launcher.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/android_test/app/src/main/res/mipmap-anydpi/ic_launcher.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android_test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/android_test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 000000000..6f3b755bf --- /dev/null +++ b/android_test/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/android_test/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/android_test/app/src/main/res/mipmap-hdpi/ic_launcher.webp new file mode 100644 index 000000000..c209e78ec Binary files /dev/null and b/android_test/app/src/main/res/mipmap-hdpi/ic_launcher.webp differ diff --git a/android_test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/android_test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp new file mode 100644 index 000000000..b2dfe3d1b Binary files /dev/null and b/android_test/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp differ diff --git a/android_test/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/android_test/app/src/main/res/mipmap-mdpi/ic_launcher.webp new file mode 100644 index 000000000..4f0f1d64e Binary files /dev/null and b/android_test/app/src/main/res/mipmap-mdpi/ic_launcher.webp differ diff --git a/android_test/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/android_test/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp new file mode 100644 index 000000000..62b611da0 Binary files /dev/null and b/android_test/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp differ diff --git a/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp new file mode 100644 index 000000000..948a3070f Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher.webp differ diff --git a/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..1b9a6956b Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp differ diff --git a/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp new file mode 100644 index 000000000..28d4b77f9 Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp differ diff --git a/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9287f5083 Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp differ diff --git a/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp new file mode 100644 index 000000000..aa7d6427e Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp differ diff --git a/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp new file mode 100644 index 000000000..9126ae37c Binary files /dev/null and b/android_test/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp differ diff --git a/android_test/app/src/main/res/values/colors.xml b/android_test/app/src/main/res/values/colors.xml new file mode 100644 index 000000000..f8c6127d3 --- /dev/null +++ b/android_test/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/android_test/app/src/main/res/values/strings.xml b/android_test/app/src/main/res/values/strings.xml new file mode 100644 index 000000000..fb91d5377 --- /dev/null +++ b/android_test/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + JavaStellarSDKDemoApp + \ No newline at end of file diff --git a/android_test/app/src/main/res/values/themes.xml b/android_test/app/src/main/res/values/themes.xml new file mode 100644 index 000000000..3ef499ada --- /dev/null +++ b/android_test/app/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +