Resolve conflict with new Context attribute: deviceId
Rename our context.deviceId to context.npDeviceId
This commit is contained in:
parent
5a97c8b7e7
commit
d6c270c81c
@ -32,7 +32,7 @@ object Account {
|
|||||||
.edit().putInt(PREF_ACCOUNT_TYPE, value.toInt())
|
.edit().putInt(PREF_ACCOUNT_TYPE, value.toInt())
|
||||||
.apply()
|
.apply()
|
||||||
|
|
||||||
var Context.deviceId: String?
|
var Context.npDeviceId: String?
|
||||||
get() = this.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
get() = this.getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE)
|
||||||
.getString(PREF_DEVICE_ID, null)
|
.getString(PREF_DEVICE_ID, null)
|
||||||
set(value) {
|
set(value) {
|
||||||
@ -81,7 +81,7 @@ object Account {
|
|||||||
|
|
||||||
fun logout(context: Context) {
|
fun logout(context: Context) {
|
||||||
getAccount(context)?.logout(context)
|
getAccount(context)?.logout(context)
|
||||||
context.deviceId = null
|
context.npDeviceId = null
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Context.setTypeSSO() {
|
fun Context.setTypeSSO() {
|
||||||
|
@ -11,8 +11,8 @@ import okhttp3.Request
|
|||||||
import okhttp3.sse.EventSource
|
import okhttp3.sse.EventSource
|
||||||
import okhttp3.sse.EventSources
|
import okhttp3.sse.EventSources
|
||||||
import org.unifiedpush.distributor.nextpush.account.Account.accountType
|
import org.unifiedpush.distributor.nextpush.account.Account.accountType
|
||||||
import org.unifiedpush.distributor.nextpush.account.Account.deviceId
|
|
||||||
import org.unifiedpush.distributor.nextpush.account.Account.getAccount
|
import org.unifiedpush.distributor.nextpush.account.Account.getAccount
|
||||||
|
import org.unifiedpush.distributor.nextpush.account.Account.npDeviceId
|
||||||
import org.unifiedpush.distributor.nextpush.account.AccountType
|
import org.unifiedpush.distributor.nextpush.account.AccountType
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.* // ktlint-disable no-wildcard-imports
|
import org.unifiedpush.distributor.nextpush.api.provider.* // ktlint-disable no-wildcard-imports
|
||||||
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider.Companion.mApiEndpoint
|
import org.unifiedpush.distributor.nextpush.api.provider.ApiProvider.Companion.mApiEndpoint
|
||||||
@ -41,7 +41,7 @@ class Api(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun apiSync() {
|
fun apiSync() {
|
||||||
context.deviceId?.let {
|
context.npDeviceId?.let {
|
||||||
syncDevice(it)
|
syncDevice(it)
|
||||||
}
|
}
|
||||||
?: run {
|
?: run {
|
||||||
@ -56,7 +56,7 @@ class Api(context: Context) {
|
|||||||
?.subscribe(object : DisposableObserver<ApiResponse>() {
|
?.subscribe(object : DisposableObserver<ApiResponse>() {
|
||||||
override fun onNext(response: ApiResponse) {
|
override fun onNext(response: ApiResponse) {
|
||||||
response.deviceId.let {
|
response.deviceId.let {
|
||||||
context.deviceId = it
|
context.npDeviceId = it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ class Api(context: Context) {
|
|||||||
|
|
||||||
override fun onComplete() {
|
override fun onComplete() {
|
||||||
// Sync once it is registered
|
// Sync once it is registered
|
||||||
context.deviceId?.let {
|
context.npDeviceId?.let {
|
||||||
syncDevice(it)
|
syncDevice(it)
|
||||||
}
|
}
|
||||||
Log.d(TAG, "mApi register: onComplete")
|
Log.d(TAG, "mApi register: onComplete")
|
||||||
@ -102,7 +102,7 @@ class Api(context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun apiDeleteDevice(block: () -> Unit = {}) {
|
fun apiDeleteDevice(block: () -> Unit = {}) {
|
||||||
val deviceId = context.deviceId ?: return
|
val deviceId = context.npDeviceId ?: return
|
||||||
try {
|
try {
|
||||||
withApiProvider { apiProvider, then ->
|
withApiProvider { apiProvider, then ->
|
||||||
apiProvider.deleteDevice(deviceId)
|
apiProvider.deleteDevice(deviceId)
|
||||||
@ -128,7 +128,7 @@ class Api(context: Context) {
|
|||||||
then()
|
then()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
context.deviceId = null
|
context.npDeviceId = null
|
||||||
}
|
}
|
||||||
} catch (e: NoProviderException) {
|
} catch (e: NoProviderException) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
@ -140,7 +140,7 @@ class Api(context: Context) {
|
|||||||
block: (String?) -> Unit
|
block: (String?) -> Unit
|
||||||
) {
|
) {
|
||||||
// The unity of connector token must already be checked here
|
// The unity of connector token must already be checked here
|
||||||
val parameters = context.deviceId?.let {
|
val parameters = context.npDeviceId?.let {
|
||||||
mutableMapOf(
|
mutableMapOf(
|
||||||
"deviceId" to it,
|
"deviceId" to it,
|
||||||
"appName" to appName
|
"appName" to appName
|
||||||
|
Loading…
x
Reference in New Issue
Block a user