Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #116 from NIFCLOUD-mbaas/develop
Browse files Browse the repository at this point in the history
Release v1.4.0
  • Loading branch information
harapekokoro authored Mar 6, 2023
2 parents 0420435 + bad24c7 commit 920d9b1
Show file tree
Hide file tree
Showing 28 changed files with 461 additions and 314 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/kotlin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ jobs:
- name: Setup Kotlin
uses: fwilhe2/setup-kotlin@main
- name: Setup JDK 11
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: '11'
- name: build and test
run: ./gradlew build test --continue --info
- name: Archive Result Files
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: build_test_report
path: /Users/runner/work/ncmb_kotlin/ncmb_kotlin/build/reports/tests/testDebugUnitTest
- name: make NCMB.jar
run: ./gradlew clean makeJar
- name: upload NCMB.jar
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: NCMB.jar
path: ./release/NCMB.jar
Expand Down
4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2017-2021 FUJITSU CLOUD TECHNOLOGIES LIMITED All Rights Reserved.
Copyright 2017-2023 FUJITSU CLOUD TECHNOLOGIES LIMITED All Rights Reserved.

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -188,7 +188,7 @@ Copyright 2017-2021 FUJITSU CLOUD TECHNOLOGIES LIMITED All Rights Reserved.
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [2021] [FUJITSU CLOUD TECHNOLOGIES LIMITED]
Copyright [2023] [FUJITSU CLOUD TECHNOLOGIES LIMITED]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
- Android 8.x ~ 13.x
- API levels 26 ~ 33
- Android Studio 2020.3.1 Patch 2 ~ 2021.3.1
(※2023年1月時点)
(※2023年3月時点)

## テクニカルサポート窓口対応バージョン

Expand All @@ -31,7 +31,7 @@
※なお、mobile backend にて大規模な改修が行われた際は、1年半以内のSDKであっても対応出来ない場合がございます。<br>
その際は[informationブログ](https://mbaas.nifcloud.com/info/)にてお知らせいたします。予めご了承ください。

- v1.0.0 ~ (※2023年1月時点)
- v1.0.0 ~ (※2023年3月時点)

# インストール
Android Studioでプロジェクトを開き、以下の手順でSDKをインストールしてください。
Expand Down Expand Up @@ -61,7 +61,7 @@ dependencies {
ActivityのonCreateメソッド内に以下を記載します。

```kotlin
NCMB.initialize(this.getApplicationContext(),"YOUR_APPLICATION_KEY","YOUR_CLIENT_KEY");
NCMB.initialize(this.applicationContext,"YOUR_APPLICATION_KEY","YOUR_CLIENT_KEY");
```

* 利用する機能に合わせて使用するライブラリのimport
Expand Down
14 changes: 8 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ buildscript {


android {
compileSdkVersion 29
compileSdkVersion 31

buildToolsVersion "29.0.2"
defaultConfig {
minSdkVersion 20
targetSdkVersion 29
targetSdkVersion 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -78,6 +78,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.4'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.4'
implementation 'androidx.test:core-ktx:1.4.0'
testImplementation 'junit:junit:4.13.2'
testImplementation "com.nhaarman:mockito-kotlin:1.5.0"
testImplementation 'org.mockito:mockito-inline:3.11.0'
Expand All @@ -90,8 +91,8 @@ dependencies {
testImplementation 'org.yaml:snakeyaml:1.17'
testImplementation 'org.skyscreamer:jsonassert:1.5.0'
testImplementation 'org.robolectric:robolectric:4.5.1'
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation "org.jetbrains.kotlin:kotlin-test"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"
def lifecycle_version = "1.1.1"
testImplementation "android.arch.core:core-testing:$lifecycle_version"
def coroutines_version = '1.3.9' //Kotlin coroutines用ライブラリ(async, await)のバージョン
Expand All @@ -105,9 +106,10 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging-ktx'

// Use the Kotlin test library.
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation "org.jetbrains.kotlin:kotlin-test"
// Use the Kotlin JUnit integration.
testImplementation("org.jetbrains.kotlin:kotlin-test-junit")
testImplementation "org.jetbrains.kotlin:kotlin-test-junit"

}

task clearJar(type: Delete) {
Expand Down
28 changes: 13 additions & 15 deletions src/main/java/com/nifcloud/mbaas/core/NCMB.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class NCMB {
/**
* Version of this SDK
*/
const val SDK_VERSION = "1.3.0"
const val SDK_VERSION = "1.4.0"

/**
* Prefix of keys in metadata for NCMB settings
Expand Down Expand Up @@ -151,23 +151,21 @@ class NCMB {
val utils = NCMBNotificationUtils(context)
utils.settingDefaultChannels()
}
NCMBInstallation().getDeviceTokenInBackground(NCMBCallback { e, deviceToken ->
if (e != null) {
Log.d("error", "devicetoken GET ERROR : " + e.message)
NCMBInstallation().getDeviceTokenInBackground(NCMBCallback { err1, deviceToken ->
if (err1 != null) {
Log.d("error", "devicetoken GET ERROR : " + err1.message)
} else {
Log.d("success", "deviceToken :$deviceToken")
val installationObj = NCMBInstallation.currentInstallation
if (installationObj != null) {
installationObj.deviceToken = deviceToken as String
installationObj.saveInBackground(NCMBCallback { e, ncmbInstallation ->
if (e != null) {
Log.d("error","installation SAVE ERROR : " + e.message)
} else {
val result = ncmbInstallation as NCMBInstallation
Log.d("success","installation DONE ObjectID :" + result.getObjectId())
}
})
}
installationObj.deviceToken = deviceToken as String
installationObj.saveInBackground(NCMBCallback { err2, ncmbInstallation ->
if (err2 != null) {
Log.d("error","installation SAVE ERROR : " + err2.message)
} else {
val result = ncmbInstallation as NCMBInstallation
Log.d("success","installation DONE ObjectID :" + result.getObjectId())
}
})
}
})
}
Expand Down
78 changes: 74 additions & 4 deletions src/main/java/com/nifcloud/mbaas/core/NCMBBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,81 @@ open class NCMBBase(){
* @param key field name to get the value
* @return value of specified key or null
*/
open fun getString(key: String): String? {
open fun getString(key: String, value: String? = null): String? {
return try {
mFields.getString(key)
} catch (e: JSONException) {
null
return value
}
}

/**
* get int value from given key
*
* @param key field name to get the value
* @return value of specified key or null
*/
fun getInt(key: String, value: Int? = null): Int?{
return try{
mFields.get(key) as Int
} catch (e: JSONException){
return value
}
}

/**
* get double value from given key
*
* @param key field name to get the value
* @return value of specified key or null
*/
fun getDouble(key: String, value: Double? = null): Double?{
return try{
mFields.get(key) as Double
} catch (e: JSONException){
return value
}
}

/**
* get boolean value from given key
*
* @param key field name to get the value
* @return value of specified key or null
*/
fun getBoolean(key: String, value: Boolean? = null): Boolean?{
return try{
mFields.get(key) as Boolean
} catch (e: JSONException){
return value
}
}

/**
* get JSONObject value from given key
*
* @param key field name to get the value
* @return value of specified key or null
*/
fun getJson(key: String, value: JSONObject? = null): JSONObject?{
return try{
mFields.get(key) as JSONObject
} catch (e: JSONException){
return value
}
}

/**
* get JSONArray value from given key
*
* @param key field name to get the value
* @return value of specified key or null
*/
fun getArray(key: String, value: JSONArray? = null): JSONArray?{
return try{
mFields.get(key) as JSONArray
} catch (e: JSONException){
return value
}
}

Expand Down Expand Up @@ -247,7 +317,7 @@ open class NCMBBase(){
}

@Throws(NCMBException::class)
fun getDate(key : String): Date? {
fun getDate(key : String, value : Date? = null): Date? {
try {
if (!mFields.isNull(key)) {
val df: SimpleDateFormat = NCMBDateFormat.getIso8601()
Expand All @@ -256,7 +326,7 @@ open class NCMBBase(){
return df.parse(dateJson.getString("iso"))
}
}
return null
return value
} catch (e: JSONException) {
return null
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/com/nifcloud/mbaas/core/NCMBAclTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ import org.junit.Test
import org.junit.rules.TestRule
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
import org.skyscreamer.jsonassert.JSONAssert
import androidx.test.core.app.ApplicationProvider

/**
* 主に通信を行うNCMBConnectionテストクラス
*/
@RunWith(RobolectricTestRunner::class)
@Config(sdk = intArrayOf(26), manifest = Config.NONE)
@Config(sdk = [27], manifest = Config.NONE)
class NCMBAclTest {

private var mServer: MockWebServer = MockWebServer()
Expand All @@ -44,11 +44,11 @@ class NCMBAclTest {

@Before
fun setup() {
var ncmbDispatcher = NCMBDispatcher("")
val ncmbDispatcher = NCMBDispatcher("")
mServer.dispatcher = ncmbDispatcher
mServer.start()
NCMB.initialize(
RuntimeEnvironment.application.getApplicationContext(),
ApplicationProvider.getApplicationContext(),
"appKey",
"cliKey",
mServer.url("/").toString(),
Expand Down
Loading

0 comments on commit 920d9b1

Please sign in to comment.