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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Latest
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: 14.x
node-version: 22.x
- uses: actions/checkout@v2
- name: Restore Dependency Cache
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.OS }}-dependency-cache-${{ hashFiles('**/package.json') }}
Expand All @@ -33,10 +33,10 @@ jobs:
with:
path: core/
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
verify-android:
runs-on: ubuntu-latest
timeout-minutes: 30
Expand All @@ -49,9 +49,9 @@ jobs:
PORTALS_KEY: ${{ secrets.portals_key }}
run: echo portals_key=\"$PORTALS_KEY\" > ./local.properties
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
- run: npm run verify
working-directory: ./
4 changes: 2 additions & 2 deletions .github/workflows/docs-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
PORTALS_KEY: ${{ secrets.portals_key }}
run: echo portals_key=\"$PORTALS_KEY\" > ./local.properties
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Generate Docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docs-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ jobs:
PORTALS_KEY: ${{ secrets.portals_key }}
run: echo portals_key=\"$PORTALS_KEY\" > ./local.properties
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Generate Docs
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-android-old.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
PORTALS_KEY: ${{ secrets.portals_key }}
run: echo portals_key=\"$PORTALS_KEY\" > ./local.properties
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Grant execute permission for publishing script
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Grant execute permission for publishing script
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
run: echo portals_key=\"$PORTALS_KEY\" > ./local.properties

- name: set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
Expand Down
17 changes: 11 additions & 6 deletions IonicPortals/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
id("com.android.library")
id("maven-publish")
Expand All @@ -10,10 +12,10 @@ if (System.getenv("PORTALS_PUBLISH") == "true") {

android {
namespace = "io.ionic.portals"
compileSdk = 35
compileSdk = 36

defaultConfig {
minSdk = 23
minSdk = 24
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

Expand All @@ -33,18 +35,21 @@ android {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
publishing {
singleVariant("release")
}
}

kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

dependencies {
implementation(kotlin("reflect"))

api("com.capacitorjs:core:[7.0.0,7.1.0)")
api("com.capacitorjs:core:[8.0.0,9.0.0)")
compileOnly("io.ionic:liveupdates:0.5.5")

implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ object PortalManager {
val rsaSignature = Signature.getInstance("SHA256withRSA")
rsaSignature.initVerify(pubKey)
rsaSignature.update(header)
rsaSignature.update(jwtDelimiter.toByte())
rsaSignature.update(jwtDelimiter.code.toByte())
rsaSignature.update(payload)

val result = rsaSignature.verify(tokenSignature)
Expand All @@ -215,7 +215,7 @@ object PortalManager {
registrationError()
false
}
} catch (e: Exception) {
} catch (_: Exception) {
registrationError()
}

Expand Down
3 changes: 1 addition & 2 deletions IonicPortals/src/main/kotlin/io/ionic/portals/PortalView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class PortalView : FrameLayout {
portalFragment?.onInflate(context, attributeSet, null)
}

val handler = Handler()
val runnable = Runnable {
val thisView = findViewById<PortalView>(id)
if(thisView != null) {
Expand All @@ -206,7 +205,7 @@ class PortalView : FrameLayout {
}
}

handler.post(runnable)
post(runnable)
}
}

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Ionic Portals is a solution that lets you add web-based experiences to your nati
The test projects within the repository will only work with a valid Portals key. Add the following new line to the `local.properties` file in the project root and enter your Portals key.

```
portals_key=""
portals_key=YOUR_PORTALS_KEY
```

Note: This file is in the `.gitignore` and is not committed to repos by default.
28 changes: 19 additions & 9 deletions TestApp/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.jetbrains.kotlin.konan.properties.Properties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.FileInputStream
import com.android.build.api.variant.BuildConfigField

Expand All @@ -9,7 +10,7 @@ plugins {

android {
namespace = "io.ionic.portals.testapp"
compileSdk = 35
compileSdk = 36

buildFeatures {
buildConfig = true
Expand All @@ -18,7 +19,7 @@ android {
defaultConfig {
applicationId = "io.ionic.portals.testapp"
minSdk = 24
targetSdk = 35
targetSdk = 36
versionCode = 1
versionName = "1.0"

Expand All @@ -33,18 +34,20 @@ android {
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
}

kotlinOptions {
jvmTarget = "1.8"
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

androidComponents {
onVariants {
it.buildConfigFields.put("PORTALS_KEY", BuildConfigField("String", getPortalsKey(), "portals registration key"))
it.buildConfigFields?.put("PORTALS_KEY", BuildConfigField("String", getPortalsKey(), "portals registration key"))
}
}

Expand All @@ -67,5 +70,12 @@ fun getPortalsKey(): String {
val propFile = rootProject.file("local.properties")
val properties = Properties()
properties.load(FileInputStream(propFile))
return properties.getProperty("portals_key") ?: ""
}
val raw = properties.getProperty("portals_key") ?: ""
val normalized = if (raw.length >= 2 && raw.first() == '"' && raw.last() == '"') {
raw.substring(1, raw.length - 1)
} else {
raw
}
val escaped = normalized.replace("\\", "\\\\").replace("\"", "\\\"")
return "\"$escaped\""
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package io.ionic.portals.testapp

import android.content.Intent
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.ionic.portals.PortalManager
import org.junit.Before
Expand All @@ -21,26 +21,22 @@ class UnregisteredTests {

@Before
fun setUp() {
scenario = ActivityScenario.launch(MainActivity::class.java).onActivity { activity ->
activity.sendBroadcast(
Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS)
)
};
scenario = ActivityScenario.launch(MainActivity::class.java)
}

@Test
fun when_portals_is_not_registered__display_unregistered_view() {
// Dismiss the invalid key dialog when it is displayed
onView(withText("OK")).perform(click())
onView(withText("OK")).inRoot(isDialog()).perform(click())

// Verify that the unregistered view is displayed
onView(withText(io.ionic.portals.R.string.unregistered_text)).check(matches(isDisplayed()))
}

@Test
fun when_portals_is_registered_with_bad_key__display_error_dialog() {
// Recreate the activity to trigger the dialog
onView(withText(io.ionic.portals.R.string.invalid_portals_key)).check(matches(isDisplayed()))
onView(withText(io.ionic.portals.R.string.invalid_portals_key))
.inRoot(isDialog())
.check(matches(isDisplayed()))
}

companion object {
Expand All @@ -50,4 +46,4 @@ class UnregisteredTests {
PortalManager.register("this is a bad key")
}
}
}
}
35 changes: 22 additions & 13 deletions TestAppCompose/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import org.jetbrains.kotlin.konan.properties.Properties
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.FileInputStream
import com.android.build.api.variant.BuildConfigField

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("org.jetbrains.kotlin.plugin.compose")
}

android {
namespace = "io.ionic.portals.composetestapp"
compileSdk = 35
compileSdk = 36

buildFeatures {
buildConfig = true
Expand All @@ -18,7 +20,7 @@ android {
defaultConfig {
applicationId = "io.ionic.portals.composetestapp"
minSdk = 24
targetSdk = 35
targetSdk = 36
versionCode = 1
versionName = "1.0"

Expand All @@ -35,28 +37,28 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.15"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}

kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

androidComponents {
onVariants {
it.buildConfigFields.put("PORTALS_KEY",
it.buildConfigFields?.put("PORTALS_KEY",
BuildConfigField("String", getPortalsKey(), "portals registration key")
)
}
Expand Down Expand Up @@ -87,5 +89,12 @@ fun getPortalsKey(): String {
val propFile = rootProject.file("local.properties")
val properties = Properties()
properties.load(FileInputStream(propFile))
return properties.getProperty("portals_key") ?: ""
}
val raw = properties.getProperty("portals_key") ?: ""
val normalized = if (raw.length >= 2 && raw.first() == '"' && raw.last() == '"') {
raw.substring(1, raw.length - 1)
} else {
raw
}
val escaped = normalized.replace("\\", "\\\\").replace("\"", "\\\"")
return "\"$escaped\""
}
Loading
Loading