Skip to content

Commit

Permalink
feat!: upgrade to Capacitor 5 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonz94 authored May 7, 2023
1 parent 674158f commit 643ac97
Show file tree
Hide file tree
Showing 13 changed files with 1,086 additions and 189 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

env:
NODE_VERSION: 18
JAVA_VERSION: 11
JAVA_VERSION: 17

jobs:
build:
Expand All @@ -26,7 +26,7 @@ jobs:
- name: Set up Java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
distribution: 'zulu'
java-version: ${{ env.JAVA_VERSION }}
- name: Install dependencies
run: npm ci
Expand Down
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,37 @@

All notable changes to this project will be documented in this file.

## [2.0.0-beta.3](https://github.com/jonz94/capacitor-sim/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2023-04-22)

### Features

- **android:** update gradle to 8.0.2 and gradle plugin to 8.0.0 ([5253c7e](https://github.com/jonz94/capacitor-sim/commit/5253c7e234bc1e7e240953a37af286a4718545e9))
- **android:** use java 17 ([ad2a8f9](https://github.com/jonz94/capacitor-sim/commit/ad2a8f95923446dbe0bdef0efd433faa9102189f))

## [2.0.0-beta.2](https://github.com/jonz94/capacitor-sim/compare/v1.0.5...v2.0.0-beta.2) (2023-04-16)

### Bug Fixes

- **android:** fix phone number is empty string on android 11 and above ([66a8844](https://github.com/jonz94/capacitor-sim/commit/66a884469f125d5295b8c7d80836e55ce063498a))
- **android:** resolve permission issue for android 13 ([d8939ff](https://github.com/jonz94/capacitor-sim/commit/d8939ff5419d162d0e8885b4d9cd888bb70d55c7))

## [2.0.0-beta.1](https://github.com/jonz94/capacitor-sim/compare/v2.0.0-beta.0...v2.0.0-beta.1) (2023-04-16)

### Bug Fixes

- **android:** resolve permission issue ([cfe5a8b](https://github.com/jonz94/capacitor-sim/commit/cfe5a8bd924801d8c108782c3822622660abd97d))

## [2.0.0-beta.0](https://github.com/jonz94/capacitor-sim/compare/v1.0.4...v2.0.0-beta.0) (2023-04-16)

### ⚠ BREAKING CHANGES

- upgrade to Capacitor 5

### Features

- add android 13 support ([804f90e](https://github.com/jonz94/capacitor-sim/commit/804f90e5f5044c7a7c20b08d3391e04661102122))
- upgrade to Capacitor 5 ([bb28f65](https://github.com/jonz94/capacitor-sim/commit/bb28f653419aac0d3435a5154456ca6941906020))

## [1.0.5](https://github.com/jonz94/capacitor-sim/compare/v1.0.4...v1.0.5) (2023-04-16)

### Bug Fixes
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ npx cap sync
### Variables

This plugin will use the following project variables (defined in your app's `variables.gradle` file):
- `$kotlinVersion` version of `org.jetbrains.kotlin:kotlin-stdlib-jdk7` (default: `1.7.10`)
- `$coreKtx` version of `androidx.core:core-ktx` (default: `1.8.0`)
- `$androidxCoreKTXVersion` version of `androidx.core:core-ktx` (default: `1.10.0`)
- `$kotlin_version` version of `org.jetbrains.kotlin:kotlin-stdlib` (default: `1.8.20`)

## Configuration

Expand Down
29 changes: 13 additions & 16 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
buildscript {
ext {
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.4.2'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.3'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.4.0'
kotlinVersion = project.hasProperty('kotlinVersion') ? rootProject.ext.kotlinVersion : '1.7.10'
coreKtx = project.hasProperty('coreKtx') ? rootProject.ext.coreKtx : '1.8.0'
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
androidxCoreKTXVersion = project.hasProperty('androidxCoreKTXVersion') ? rootProject.ext.androidxCoreKTXVersion : '1.10.0'
kotlin_version = project.hasProperty('kotlin_version') ? rootProject.ext.kotlinVersion : '1.8.20'
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -22,10 +22,10 @@ apply plugin: 'kotlin-android'

android {
namespace "dev.jonz94.capacitorjs.plugins.sim"
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 32
compileSdkVersion project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 33
defaultConfig {
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 32
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -40,11 +40,8 @@ android {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
}

Expand All @@ -60,6 +57,6 @@ dependencies {
testImplementation "junit:junit:$junitVersion"
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
implementation "androidx.core:core-ktx:$coreKtx"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
implementation "androidx.core:core-ktx:$androidxCoreKTXVersion"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
2 changes: 0 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ org.gradle.jvmargs=-Xmx1536m
# Android operating system, and which are packaged with your app's APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
Binary file modified android/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions android/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,10 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions android/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,23 @@ class SimPlugin : Plugin() {

val subscriptionManager = context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE) as SubscriptionManager

// require `READ_PHONE_STATE` permission
@SuppressLint("MissingPermission")
val subscriptionInfoList = subscriptionManager.activeSubscriptionInfoList

val carrierInfoCollection = JSArray()
if (subscriptionInfoList != null) {
for (subscriptionInfo in subscriptionInfoList) {
val carrierInfo = JSObject()
carrierInfo.put("number", subscriptionInfo.number)

@SuppressLint("MissingPermission")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
// require `READ_PHONE_NUMBERS` permission
carrierInfo.put("number", subscriptionManager.getPhoneNumber(subscriptionInfo.subscriptionId))
} else {
carrierInfo.put("number", subscriptionInfo.number)
}

carrierInfo.put("carrierName", subscriptionInfo.carrierName)
carrierInfo.put("isoCountryCode", subscriptionInfo.countryIso)

Expand Down
2 changes: 1 addition & 1 deletion ios/Plugin/SimPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class SimPlugin: CAPPlugin {
])
} else {
call.resolve([
"simCards": []
"simCards": [] as NSArray
])
}
}
Expand Down
Loading

0 comments on commit 643ac97

Please sign in to comment.