From 38ecc20a55f43fc2dbf35aeb2f867935a7a4f4ae Mon Sep 17 00:00:00 2001 From: up9cloud <8325632+up9cloud@users.noreply.github.com> Date: Thu, 27 Jun 2024 19:56:55 -0700 Subject: [PATCH] bump td to v1.8.31 --- CHANGELOG.md | 4 + README.md | 7 +- android/build.gradle | 38 ++++- android/gradle.properties | 3 - android/gradlew | 160 ------------------ android/gradlew.bat | 90 ---------- .../up9cloud/libtdjson/LibtdjsonPlugin.java | 9 +- example/README.md | 2 +- example/android/.gitignore | 2 + example/android/app/build.gradle | 52 +++--- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 19 ++- .../libtdjson_example/MainActivity.java | 2 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- example/android/build.gradle | 19 +-- example/android/gradle.properties | 2 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- example/android/settings.gradle | 30 +++- example/android/settings_aar.gradle | 1 - example/ios/Podfile.lock | 14 +- .../ios/Runner/GeneratedPluginRegistrant.m | 6 +- .../Flutter/GeneratedPluginRegistrant.swift | 2 +- example/macos/Podfile.lock | 10 +- example/pubspec.lock | 64 ++++--- example/pubspec.yaml | 6 +- init.sh | 7 + ios/libtdjson.podspec | 2 +- macos/libtdjson.podspec | 2 +- pubspec.lock | 18 +- pubspec.yaml | 7 +- 32 files changed, 221 insertions(+), 380 deletions(-) delete mode 100644 android/gradle.properties delete mode 100755 android/gradlew delete mode 100755 android/gradlew.bat rename example/android/app/src/main/java/io/github/up9cloud/{libtdjson => }/libtdjson_example/MainActivity.java (66%) delete mode 100644 example/android/settings_aar.gradle create mode 100644 init.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9ba0f..5053965 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG +## 0.2.1 + +* Bump TDLib version to 1.8.31 + ## 0.2.0 * Bump TDLib version to 1.8.30 diff --git a/README.md b/README.md index 51d4b46..1662589 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ A flutter plugin for [TDLib JSON interface](https://github.com/tdlib/td#using-fr | package | td version | | ------- | ------------------------------------- | +| 0.2.1 | 1.8.31 (Android, iOS, macOS) | | 0.2.0 | 1.8.30 (Android, iOS, macOS) | | 0.1.4 | 1.8.1 (Android, iOS, macOS) | | 0.1.3 | 1.7.9 (Android, iOS, macOS) | @@ -39,7 +40,7 @@ Make sure you are using supported one ```yml dependencies: - libtdjson: ^0.2.0 + libtdjson: ^0.2.1 ``` - If you want to build android, you have to add envs for github maven, see `./android/build.gradle` @@ -100,7 +101,7 @@ Make sure you are using supported one cd .. flutter run --debug # link .dylib to search path, e.q: - # ln -s $(pwd)/build/ios/Debug-iphonesimulator/XCFrameworkIntermediates/flutter_libtdjson/libtdjson.dylib ~/Library/Developer/CoreSimulator/Devices/FD63D560-544B-4B18-8F2F-03B093156DE2/data/Containers/Bundle/Application/3D0AD268-62C8-4A78-91AF-C3966EA8027B/Runner.app/Frameworks/libtdjson.dylib + # ln -s $(pwd)/build/ios/Debug-iphonesimulator/XCFrameworkIntermediates/flutter_libtdjson/libtdjson.dylib ~/Library/Developer/CoreSimulator/Devices/FD63D560-544B-4B18-8F2F-03B093156DE2/data/Containers/Bundle/Application/004B7B3D-4665-4217-A9C7-2D2193107E80/Runner.app/Frameworks/libtdjson.dylib # Reload with `R` ``` @@ -108,7 +109,7 @@ Make sure you are using supported one - Add changelog for new version in `./CHANGELOG.md` - Bump version info in `./README.md` - Git commit (message example: `bump td to vx.x.x`) -- Git add tag (`git tag vx.x.x`, the tag version should be same as the version in pubspec.yaml) +- Git add tag (`git tag v?.?.?`, the tag version should be same as the version in pubspec.yaml) - Push with tags (`git push && git push --tags`) - Wait for CI task diff --git a/android/build.gradle b/android/build.gradle index 10d684d..f0fbf8b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -1,5 +1,5 @@ -group 'io.github.up9cloud.libtdjson' -version '1.0-SNAPSHOT' +group = "io.github.up9cloud.libtdjson.flutter_libtdjson" +version = "1.0" buildscript { repositories { @@ -8,7 +8,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.2.0' + classpath("com.android.tools.build:gradle:7.3.0") } } @@ -27,19 +27,43 @@ rootProject.allprojects { } } -apply plugin: 'com.android.library' +apply plugin: "com.android.library" android { - compileSdkVersion 33 + if (project.android.hasProperty("namespace")) { + namespace = "io.github.up9cloud.libtdjson" + } + + compileSdk = 34 + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } defaultConfig { - minSdkVersion 16 + minSdk = 21 ndk { abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86_64' } } + + dependencies { + testImplementation("junit:junit:4.13.2") + testImplementation("org.mockito:mockito-core:5.0.0") + } + + testOptions { + unitTests.all { + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true + } + } + } } dependencies { - implementation "io.github.up9cloud:td:1.8.30" + implementation "io.github.up9cloud:td:1.8.31" } diff --git a/android/gradle.properties b/android/gradle.properties deleted file mode 100644 index 94adc3a..0000000 --- a/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/android/gradlew b/android/gradlew deleted file mode 100755 index 9d82f78..0000000 --- a/android/gradlew +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/env bash - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn ( ) { - echo "$*" -} - -die ( ) { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; -esac - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules -function splitJvmOpts() { - JVM_OPTS=("$@") -} -eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS -JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" - -exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/android/gradlew.bat b/android/gradlew.bat deleted file mode 100755 index aec9973..0000000 --- a/android/gradlew.bat +++ /dev/null @@ -1,90 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windowz variants - -if not "%OS%" == "Windows_NT" goto win9xME_args -if "%@eval[2+2]" == "4" goto 4NT_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* -goto execute - -:4NT_args -@rem Get arguments from the 4NT Shell from JP Software -set CMD_LINE_ARGS=%$ - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="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 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/android/src/main/java/io/github/up9cloud/libtdjson/LibtdjsonPlugin.java b/android/src/main/java/io/github/up9cloud/libtdjson/LibtdjsonPlugin.java index a13b3ae..3468ce9 100644 --- a/android/src/main/java/io/github/up9cloud/libtdjson/LibtdjsonPlugin.java +++ b/android/src/main/java/io/github/up9cloud/libtdjson/LibtdjsonPlugin.java @@ -1,14 +1,13 @@ package io.github.up9cloud.libtdjson; +import androidx.annotation.NonNull; + import io.flutter.embedding.engine.plugins.FlutterPlugin; -import io.flutter.plugin.common.PluginRegistry.Registrar; public class LibtdjsonPlugin implements FlutterPlugin { - public static void registerWith(Registrar registrar) {} - @Override - public void onDetachedFromEngine(FlutterPluginBinding binding) {} + public void onAttachedToEngine(@NonNull FlutterPluginBinding binding) {} @Override - public void onAttachedToEngine(FlutterPluginBinding binding) {} + public void onDetachedFromEngine(@NonNull FlutterPluginBinding binding) {} } diff --git a/example/README.md b/example/README.md index bcde126..77f8a96 100644 --- a/example/README.md +++ b/example/README.md @@ -23,7 +23,7 @@ Demonstrates how to use the libtdjson plugin. ### Regenerate ./android ```bash -flutter create -a java --template plugin --platforms android --project-name libtdjson --org io.github.up9cloud.libtdjson _tmp +flutter create -a java --template plugin --platforms android --project-name libtdjson --org io.github.up9cloud _tmp rm -fr android mv ./_tmp/example/android . rm -fr _tmp diff --git a/example/android/.gitignore b/example/android/.gitignore index 0a741cb..6f56801 100644 --- a/example/android/.gitignore +++ b/example/android/.gitignore @@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java # Remember to never publicly share your keystore. # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app key.properties +**/*.keystore +**/*.jks diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index 3dbcf51..7d60e14 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -1,50 +1,58 @@ +plugins { + id "com.android.application" + id "kotlin-android" + // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. + id "dev.flutter.flutter-gradle-plugin" +} + def localProperties = new Properties() -def localPropertiesFile = rootProject.file('local.properties') +def localPropertiesFile = rootProject.file("local.properties") if (localPropertiesFile.exists()) { - localPropertiesFile.withReader('UTF-8') { reader -> + localPropertiesFile.withReader("UTF-8") { reader -> localProperties.load(reader) } } -def flutterRoot = localProperties.getProperty('flutter.sdk') -if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") -} - -def flutterVersionCode = localProperties.getProperty('flutter.versionCode') +def flutterVersionCode = localProperties.getProperty("flutter.versionCode") if (flutterVersionCode == null) { - flutterVersionCode = '1' + flutterVersionCode = "1" } -def flutterVersionName = localProperties.getProperty('flutter.versionName') +def flutterVersionName = localProperties.getProperty("flutter.versionName") if (flutterVersionName == null) { - flutterVersionName = '1.0' + flutterVersionName = "1.0" } -apply plugin: 'com.android.application' -apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" - android { - compileSdkVersion 33 + namespace = "io.github.up9cloud.libtdjson_example" + compileSdk = flutter.compileSdkVersion + ndkVersion = flutter.ndkVersion + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "io.github.up9cloud.libtdjson.libtdjson_example" - minSdkVersion flutter.minSdkVersion - targetSdkVersion 30 - versionCode flutterVersionCode.toInteger() - versionName flutterVersionName + applicationId = "io.github.up9cloud.libtdjson_example" + // You can update the following values to match your application needs. + // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. + minSdk = flutter.minSdkVersion + targetSdk = flutter.targetSdkVersion + versionCode = flutterVersionCode.toInteger() + versionName = flutterVersionName } buildTypes { release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. - signingConfig signingConfigs.debug + signingConfig = signingConfigs.debug } } } flutter { - source '../..' + source = "../.." } diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml index e61f6e4..399f698 100644 --- a/example/android/app/src/debug/AndroidManifest.xml +++ b/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index d8141be..91186c0 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,11 +1,13 @@ - - + + + + + + + + diff --git a/example/android/app/src/main/java/io/github/up9cloud/libtdjson/libtdjson_example/MainActivity.java b/example/android/app/src/main/java/io/github/up9cloud/libtdjson_example/MainActivity.java similarity index 66% rename from example/android/app/src/main/java/io/github/up9cloud/libtdjson/libtdjson_example/MainActivity.java rename to example/android/app/src/main/java/io/github/up9cloud/libtdjson_example/MainActivity.java index a3a3e70..88ffffa 100644 --- a/example/android/app/src/main/java/io/github/up9cloud/libtdjson/libtdjson_example/MainActivity.java +++ b/example/android/app/src/main/java/io/github/up9cloud/libtdjson_example/MainActivity.java @@ -1,4 +1,4 @@ -package io.github.up9cloud.libtdjson.libtdjson_example; +package io.github.up9cloud.libtdjson_example; import io.flutter.embedding.android.FlutterActivity; diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml index 449a9f9..06952be 100644 --- a/example/android/app/src/main/res/values-night/styles.xml +++ b/example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@