Remove AppNameProvider, we have buildMeta now.
This commit is contained in:
parent
177a5bc78a
commit
7386da257c
3 changed files with 3 additions and 71 deletions
|
|
@ -18,6 +18,7 @@ package io.element.android.libraries.push.impl
|
||||||
|
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
import com.squareup.anvil.annotations.ContributesBinding
|
||||||
import io.element.android.libraries.core.log.logger.LoggerTag
|
import io.element.android.libraries.core.log.logger.LoggerTag
|
||||||
|
import io.element.android.libraries.core.meta.BuildMeta
|
||||||
import io.element.android.libraries.di.AppScope
|
import io.element.android.libraries.di.AppScope
|
||||||
import io.element.android.libraries.matrix.api.MatrixClient
|
import io.element.android.libraries.matrix.api.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.core.EventId
|
import io.element.android.libraries.matrix.api.core.EventId
|
||||||
|
|
@ -28,7 +29,6 @@ import io.element.android.libraries.push.impl.pushgateway.PushGatewayNotifyReque
|
||||||
import io.element.android.libraries.pushproviders.api.PusherSubscriber
|
import io.element.android.libraries.pushproviders.api.PusherSubscriber
|
||||||
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
import io.element.android.libraries.pushstore.api.UserPushStoreFactory
|
||||||
import io.element.android.libraries.pushstore.api.clientsecret.PushClientSecret
|
import io.element.android.libraries.pushstore.api.clientsecret.PushClientSecret
|
||||||
import io.element.android.services.toolbox.api.appname.AppNameProvider
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ private val loggerTag = LoggerTag("PushersManager", LoggerTag.PushLoggerTag)
|
||||||
@ContributesBinding(AppScope::class)
|
@ContributesBinding(AppScope::class)
|
||||||
class PushersManager @Inject constructor(
|
class PushersManager @Inject constructor(
|
||||||
// private val localeProvider: LocaleProvider,
|
// private val localeProvider: LocaleProvider,
|
||||||
private val appNameProvider: AppNameProvider,
|
private val buildMeta: BuildMeta,
|
||||||
// private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
// private val getDeviceInfoUseCase: GetDeviceInfoUseCase,
|
||||||
private val pushGatewayNotifyRequest: PushGatewayNotifyRequest,
|
private val pushGatewayNotifyRequest: PushGatewayNotifyRequest,
|
||||||
private val pushClientSecret: PushClientSecret,
|
private val pushClientSecret: PushClientSecret,
|
||||||
|
|
@ -88,7 +88,7 @@ class PushersManager @Inject constructor(
|
||||||
appId = PushConfig.pusher_app_id,
|
appId = PushConfig.pusher_app_id,
|
||||||
profileTag = DEFAULT_PUSHER_FILE_TAG + "_" /* TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())*/,
|
profileTag = DEFAULT_PUSHER_FILE_TAG + "_" /* TODO + abs(activeSessionHolder.getActiveSession().myUserId.hashCode())*/,
|
||||||
lang = "en", // TODO localeProvider.current().language,
|
lang = "en", // TODO localeProvider.current().language,
|
||||||
appDisplayName = appNameProvider.getAppName(),
|
appDisplayName = buildMeta.applicationName,
|
||||||
deviceDisplayName = "MyDevice", // TODO getDeviceInfoUseCase.execute().displayName().orEmpty(),
|
deviceDisplayName = "MyDevice", // TODO getDeviceInfoUseCase.execute().displayName().orEmpty(),
|
||||||
url = gateway,
|
url = gateway,
|
||||||
defaultPayload = createDefaultPayload(pushClientSecret.getSecretForUser(userId))
|
defaultPayload = createDefaultPayload(pushClientSecret.getSecretForUser(userId))
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.services.toolbox.api.appname
|
|
||||||
|
|
||||||
interface AppNameProvider {
|
|
||||||
fun getAppName(): String
|
|
||||||
}
|
|
||||||
|
|
@ -1,47 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2023 New Vector Ltd
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package io.element.android.services.toolbox.impl.appname
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import com.squareup.anvil.annotations.ContributesBinding
|
|
||||||
import io.element.android.libraries.androidutils.system.getApplicationLabel
|
|
||||||
import io.element.android.libraries.di.AppScope
|
|
||||||
import io.element.android.libraries.di.ApplicationContext
|
|
||||||
import io.element.android.services.toolbox.api.appname.AppNameProvider
|
|
||||||
import timber.log.Timber
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
@ContributesBinding(AppScope::class)
|
|
||||||
class DefaultAppNameProvider @Inject constructor(@ApplicationContext private val context: Context) :
|
|
||||||
AppNameProvider {
|
|
||||||
|
|
||||||
override fun getAppName(): String {
|
|
||||||
return try {
|
|
||||||
val appPackageName = context.packageName
|
|
||||||
var appName = context.getApplicationLabel(appPackageName)
|
|
||||||
|
|
||||||
// Use appPackageName instead of appName if appName contains any non-ASCII character
|
|
||||||
if (!appName.matches("\\A\\p{ASCII}*\\z".toRegex())) {
|
|
||||||
appName = appPackageName
|
|
||||||
}
|
|
||||||
appName
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Timber.e(e, "## AppNameProvider() : failed")
|
|
||||||
"ElementAndroid"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue