Commit 946b42be authored by Leonardo Aramaki's avatar Leonardo Aramaki

Merge branch 'develop' into observe-channel-changes

parents b7bdffa8 fd74ea32
File mode changed from 100644 to 100755
......@@ -61,7 +61,14 @@ interface Analytics {
fun logServerSwitch(serverUrl: String, serverCount: Int) {}
/**
* Logs the admin opening.
* Logs the admin opening event.
*/
fun logOpenAdmin() {}
/**
* Logs the reset password event.
*
* @param resetPasswordSucceeded True if successful reset password, false otherwise.
*/
fun logResetPassword(resetPasswordSucceeded: Boolean) {}
}
......@@ -70,4 +70,10 @@ class AnalyticsManager @Inject constructor(
analytics.forEach { it.logOpenAdmin() }
}
}
fun logResetPassword(resetPasswordSucceeded: Boolean) {
if (analyticsTrackingInteractor.get()) {
analytics.forEach { it.logResetPassword(resetPasswordSucceeded) }
}
}
}
......@@ -23,10 +23,17 @@ class OnBoardingPresenter @Inject constructor(
private val getAccountsInteractor: GetAccountsInteractor,
val settingsInteractor: GetSettingsInteractor,
val factory: RocketChatClientFactory
) : CheckServerPresenter(strategy, factory, settingsInteractor) {
) : CheckServerPresenter(
strategy = strategy,
factory = factory,
settingsInteractor = settingsInteractor,
refreshSettingsInteractor = refreshSettingsInteractor
) {
fun toSignInToYourServer() = navigator.toSignInToYourServer()
fun toCreateANewServer(createServerUrl: String) = navigator.toWebPage(createServerUrl)
fun connectToCommunityServer(communityServerUrl: String) {
connectToServer(communityServerUrl) {
if (totalSocialAccountsEnabled == 0 && !isNewAccountCreationEnabled) {
......@@ -63,8 +70,6 @@ class OnBoardingPresenter @Inject constructor(
}
}
fun toCreateANewServer(createServerUrl: String) = navigator.toWebPage(createServerUrl)
private fun connectToServer(serverUrl: String, block: () -> Unit) {
launchUI(strategy) {
// Check if we already have an account for this server...
......@@ -77,9 +82,9 @@ class OnBoardingPresenter @Inject constructor(
try {
withContext(DefaultDispatcher) {
setupConnectionInfo(serverUrl)
refreshSettingsInteractor.refresh(serverUrl)
// preparing next fragment before showing it
refreshServerAccounts()
checkEnabledAccounts(serverUrl)
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
......
......@@ -25,7 +25,13 @@ class ServerPresenter @Inject constructor(
private val getAccountsInteractor: GetAccountsInteractor,
val settingsInteractor: GetSettingsInteractor,
val factory: RocketChatClientFactory
) : CheckServerPresenter(strategy, factory, settingsInteractor, view) {
) : CheckServerPresenter(
strategy = strategy,
factory = factory,
settingsInteractor = settingsInteractor,
versionCheckView = view,
refreshSettingsInteractor = refreshSettingsInteractor
) {
fun checkServer(server: String) {
if (!server.isValidUrl()) {
......@@ -93,9 +99,8 @@ class ServerPresenter @Inject constructor(
view.showLoading()
try {
withContext(DefaultDispatcher) {
refreshSettingsInteractor.refresh(serverUrl)
// preparing next fragment before showing it
refreshServerAccounts()
checkEnabledAccounts(serverUrl)
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
......@@ -112,5 +117,4 @@ class ServerPresenter @Inject constructor(
}
}
}
}
\ No newline at end of file
package chat.rocket.android.main.presentation
import android.content.Context
import chat.rocket.android.R
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.emoji.Emoji
......@@ -36,13 +35,9 @@ import chat.rocket.common.model.UserStatus
import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.getCustomEmojis
import chat.rocket.core.internal.rest.logout
import chat.rocket.core.internal.rest.me
import chat.rocket.core.internal.rest.unregisterPushToken
import chat.rocket.core.model.Myself
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.withContext
import timber.log.Timber
import javax.inject.Inject
......@@ -51,23 +46,33 @@ class MainPresenter @Inject constructor(
private val strategy: CancelStrategy,
private val navigator: MainNavigator,
private val tokenRepository: TokenRepository,
private val serverInteractor: GetCurrentServerInteractor,
private val refreshSettingsInteractor: RefreshSettingsInteractor,
private val refreshPermissionsInteractor: RefreshPermissionsInteractor,
private val localRepository: LocalRepository,
private val navHeaderMapper: NavHeaderUiModelMapper,
private val saveAccountInteractor: SaveAccountInteractor,
private val getAccountsInteractor: GetAccountsInteractor,
private val removeAccountInteractor: RemoveAccountInteractor,
factory: RocketChatClientFactory,
private val groupedPush: GroupedPush,
serverInteractor: GetCurrentServerInteractor,
localRepository: LocalRepository,
removeAccountInteractor: RemoveAccountInteractor,
factory: RocketChatClientFactory,
dbManagerFactory: DatabaseManagerFactory,
getSettingsInteractor: GetSettingsInteractor,
managerFactory: ConnectionManagerFactory
) : CheckServerPresenter(strategy, factory, view = view) {
) : CheckServerPresenter(
strategy = strategy,
factory = factory,
serverInteractor = serverInteractor,
localRepository = localRepository,
removeAccountInteractor = removeAccountInteractor,
tokenRepository = tokenRepository,
managerFactory = managerFactory,
dbManagerFactory = dbManagerFactory,
tokenView = view,
navigator = navigator
) {
private val currentServer = serverInteractor.get()!!
private val manager = managerFactory.create(currentServer)
private val dbManager = dbManagerFactory.create(currentServer)
private val client: RocketChatClient = factory.create(currentServer)
private var settings: PublicSettings = getSettingsInteractor.get(serverInteractor.get()!!)
private val userDataChannel = Channel<Myself>()
......@@ -114,9 +119,7 @@ class MainPresenter @Inject constructor(
view.setupUserAccountInfo(model)
} catch (ex: Exception) {
when (ex) {
is RocketChatAuthException -> {
logout()
}
is RocketChatAuthException -> logout()
else -> {
Timber.d(ex, "Error loading my information for navheader")
ex.message?.let {
......@@ -163,36 +166,9 @@ class MainPresenter @Inject constructor(
}
}
/**
* Logout from current server.
*/
fun logout() {
launchUI(strategy) {
view.showProgress()
try {
clearTokens()
retryIO("logout") { client.logout() }
} catch (exception: RocketChatException) {
Timber.d(exception, "Error calling logout")
exception.message?.let {
view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
}
try {
disconnect()
removeAccountInteractor.remove(currentServer)
tokenRepository.remove(currentServer)
withContext(CommonPool) { dbManager.logout() }
navigator.switchOrAddNewServer()
} catch (ex: Exception) {
Timber.d(ex, "Error cleaning up the session...")
}
view.hideProgress()
}
setupConnectionInfo(currentServer)
super.logout(userDataChannel)
}
fun connect() {
......@@ -202,8 +178,8 @@ class MainPresenter @Inject constructor(
}
fun disconnect() {
manager.removeUserDataChannel(userDataChannel)
manager.disconnect()
setupConnectionInfo(currentServer)
super.disconnect(userDataChannel)
}
fun changeServer(serverUrl: String) {
......@@ -247,20 +223,6 @@ class MainPresenter @Inject constructor(
saveAccountInteractor.save(account)
}
private suspend fun clearTokens() {
serverInteractor.clear()
val pushToken = localRepository.get(LocalRepository.KEY_PUSH_TOKEN)
if (pushToken != null) {
try {
retryIO("unregisterPushToken") { client.unregisterPushToken(pushToken) }
view.invalidateToken(pushToken)
} catch (ex: Exception) {
Timber.d(ex, "Error unregistering push token")
}
}
localRepository.clearAllFromServer(currentServer)
}
private suspend fun subscribeMyselfUpdates() {
manager.addUserDataChannel(userDataChannel)
for (myself in userDataChannel) {
......
......@@ -4,9 +4,10 @@ import chat.rocket.android.authentication.server.presentation.VersionCheckView
import chat.rocket.android.core.behaviours.MessageView
import chat.rocket.android.main.uimodel.NavHeaderUiModel
import chat.rocket.android.server.domain.model.Account
import chat.rocket.android.server.presentation.TokenView
import chat.rocket.common.model.UserStatus
interface MainView : MessageView, VersionCheckView {
interface MainView : MessageView, VersionCheckView, TokenView {
/**
* Shows the current user status.
......@@ -31,8 +32,6 @@ interface MainView : MessageView, VersionCheckView {
fun closeServerSelection()
fun invalidateToken(token: String)
fun showProgress()
fun hideProgress()
......
......@@ -202,8 +202,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
.show()
}
override fun invalidateToken(token: String) =
invalidateFirebaseToken(token)
override fun invalidateToken(token: String) = invalidateFirebaseToken(token)
override fun showMessage(resId: Int) = showToast(resId)
......@@ -234,11 +233,11 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector,
fun showLogoutDialog() {
val builder = AlertDialog.Builder(this)
builder.setTitle(R.string.action_logout)
builder.setMessage(R.string.title_confirmation)
builder.setPositiveButton(R.string.action_logout) { _, _ -> presenter.logout()}
.setNegativeButton(R.string.action_stay) { dialog, _ -> dialog.cancel() }
builder.create().show()
builder.setTitle(R.string.title_are_you_sure)
.setPositiveButton(R.string.action_logout) { _, _ -> presenter.logout()}
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() }
.create()
.show()
}
fun setAvatar(avatarUrl: String) {
......
......@@ -5,19 +5,31 @@ import android.net.Uri
import chat.rocket.android.chatroom.domain.UriInteractor
import chat.rocket.android.core.behaviours.showMessage
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.helper.UserHelper
import chat.rocket.android.main.presentation.MainNavigator
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.RemoveAccountInteractor
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.server.presentation.CheckServerPresenter
import chat.rocket.android.util.extension.compressImageAndGetByteArray
import chat.rocket.android.util.extension.gethash
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extension.toHex
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.retryIO
import chat.rocket.common.RocketChatException
import chat.rocket.common.util.ifNull
import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.deleteOwnAccount
import chat.rocket.core.internal.rest.resetAvatar
import chat.rocket.core.internal.rest.setAvatar
import chat.rocket.core.internal.rest.updateProfile
import kotlinx.coroutines.experimental.DefaultDispatcher
import kotlinx.coroutines.experimental.withContext
import java.lang.Exception
import java.util.*
import javax.inject.Inject
......@@ -26,8 +38,23 @@ class ProfilePresenter @Inject constructor(
private val strategy: CancelStrategy,
private val uriInteractor: UriInteractor,
val userHelper: UserHelper,
navigator: MainNavigator,
serverInteractor: GetCurrentServerInteractor,
factory: RocketChatClientFactory
factory: RocketChatClientFactory,
removeAccountInteractor: RemoveAccountInteractor,
tokenRepository: TokenRepository,
dbManagerFactory: DatabaseManagerFactory,
managerFactory: ConnectionManagerFactory
) : CheckServerPresenter(
strategy = strategy,
factory = factory,
serverInteractor = serverInteractor,
removeAccountInteractor = removeAccountInteractor,
tokenRepository = tokenRepository,
dbManagerFactory = dbManagerFactory,
managerFactory = managerFactory,
tokenView = view,
navigator = navigator
) {
private val serverUrl = serverInteractor.get()!!
private val client: RocketChatClient = factory.create(serverUrl)
......@@ -147,4 +174,27 @@ class ProfilePresenter @Inject constructor(
}
}
}
fun deleteAccount(password: String) {
launchUI(strategy) {
view.showLoading()
try {
withContext(DefaultDispatcher) {
// REMARK: Backend API is only working with a lowercase hash.
// https://github.com/RocketChat/Rocket.Chat/issues/12573
retryIO { client.deleteOwnAccount(password.gethash().toHex().toLowerCase()) }
setupConnectionInfo(serverUrl)
logout(null)
}
} catch (exception: Exception) {
exception.message?.let {
view.showMessage(it)
}.ifNull {
view.showGenericErrorMessage()
}
} finally {
view.hideLoading()
}
}
}
}
\ No newline at end of file
......@@ -2,8 +2,9 @@ package chat.rocket.android.profile.presentation
import chat.rocket.android.core.behaviours.LoadingView
import chat.rocket.android.core.behaviours.MessageView
import chat.rocket.android.server.presentation.TokenView
interface ProfileView : LoadingView, MessageView {
interface ProfileView : TokenView, LoadingView, MessageView {
/**
* Shows the user profile.
......
......@@ -2,6 +2,7 @@ package chat.rocket.android.profile.ui
import DrawableHelper
import android.app.Activity
import android.app.AlertDialog
import android.content.Intent
import android.graphics.Bitmap
import android.os.Build
......@@ -11,6 +12,8 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.view.MenuInflater
import android.widget.EditText
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.ActionMode
import androidx.core.net.toUri
......@@ -29,6 +32,7 @@ import chat.rocket.android.util.extensions.inflate
import chat.rocket.android.util.extensions.showToast
import chat.rocket.android.util.extensions.textContent
import chat.rocket.android.util.extensions.ui
import chat.rocket.android.util.invalidateFirebaseToken
import com.facebook.drawee.backends.pipeline.Fresco
import dagger.android.support.AndroidSupportInjection
import io.reactivex.disposables.CompositeDisposable
......@@ -61,6 +65,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override fun onCreate(savedInstanceState: Bundle?) {
AndroidSupportInjection.inject(this)
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
}
override fun onCreateView(
......@@ -98,6 +103,25 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
}
}
override fun onPrepareOptionsMenu(menu: Menu) {
if (actionMode != null) {
menu.clear()
}
super.onPrepareOptionsMenu(menu)
}
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
super.onCreateOptionsMenu(menu, inflater)
inflater.inflate(R.menu.profile, menu)
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.action_delete_account -> showDeleteAccountDialog()
}
return true
}
override fun showProfile(avatarUrl: String, name: String, username: String, email: String?) {
ui {
image_avatar.setImageURI(avatarUrl)
......@@ -123,6 +147,8 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
showMessage(getString(R.string.msg_profile_update_successfully))
}
override fun invalidateToken(token: String) = invalidateFirebaseToken(token)
override fun showLoading() {
enableUserInput(false)
ui { view_loading.isVisible = true }
......@@ -148,7 +174,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
override fun showGenericErrorMessage() = showMessage(getString(R.string.msg_generic_error))
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
mode.menuInflater.inflate(R.menu.profile, menu)
mode.menuInflater.inflate(R.menu.action_mode_profile, menu)
mode.title = getString(R.string.title_update_profile)
return true
}
......@@ -239,6 +265,7 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_username.toString() != currentUsername ||
text_email.toString() != currentEmail)
}.subscribe { isValid ->
activity?.invalidateOptionsMenu()
if (isValid) {
startActionMode()
} else {
......@@ -264,4 +291,19 @@ class ProfileFragment : Fragment(), ProfileView, ActionMode.Callback {
text_email.isEnabled = value
}
}
fun showDeleteAccountDialog() {
val passwordEditText = EditText(context)
passwordEditText.hint = getString(R.string.msg_password)
val builder = AlertDialog.Builder(context)
builder.setTitle(R.string.title_are_you_sure)
.setView(passwordEditText)
.setPositiveButton(R.string.action_delete_account) { _, _ ->
presenter.deleteAccount(passwordEditText.text.toString())
}
.setNegativeButton(android.R.string.no) { dialog, _ -> dialog.cancel() }
.create()
.show()
}
}
......@@ -3,7 +3,11 @@ package chat.rocket.android.server.presentation
import chat.rocket.android.BuildConfig
import chat.rocket.android.authentication.server.presentation.VersionCheckView
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.db.DatabaseManagerFactory
import chat.rocket.android.helper.OauthHelper
import chat.rocket.android.infrastructure.LocalRepository
import chat.rocket.android.main.presentation.MainNavigator
import chat.rocket.android.server.domain.GetSettingsInteractor
import chat.rocket.android.server.domain.PublicSettings
import chat.rocket.android.server.domain.casLoginUrl
......@@ -18,6 +22,12 @@ import chat.rocket.android.server.domain.isLoginFormEnabled
import chat.rocket.android.server.domain.isRegistrationEnabledForNewUsers
import chat.rocket.android.server.domain.isWordpressAuthenticationEnabled
import chat.rocket.android.server.domain.wordpressUrl
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.domain.RemoveAccountInteractor
import chat.rocket.android.server.domain.TokenRepository
import chat.rocket.android.server.domain.RefreshSettingsInteractor
import chat.rocket.android.server.infraestructure.ConnectionManager
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.util.VersionInfo
import chat.rocket.android.util.extension.launchUI
......@@ -30,9 +40,15 @@ import chat.rocket.common.RocketChatException
import chat.rocket.common.RocketChatInvalidProtocolException
import chat.rocket.common.model.ServerInfo
import chat.rocket.core.RocketChatClient
import chat.rocket.core.internal.rest.logout
import chat.rocket.core.internal.rest.serverInfo
import chat.rocket.core.internal.rest.settingsOauth
import chat.rocket.core.internal.rest.unregisterPushToken
import chat.rocket.core.model.Myself
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.Job
import kotlinx.coroutines.experimental.channels.Channel
import kotlinx.coroutines.experimental.withContext
import timber.log.Timber
private const val SERVICE_NAME_FACEBOOK = "facebook"
......@@ -42,16 +58,26 @@ private const val SERVICE_NAME_LINKEDIN = "linkedin"
private const val SERVICE_NAME_GILAB = "gitlab"
private const val SERVICE_NAME_WORDPRESS = "wordpress"
abstract class CheckServerPresenter constructor(
private val strategy: CancelStrategy,
private val factory: RocketChatClientFactory,
private val settingsInteractor: GetSettingsInteractor? = null,
private val view: VersionCheckView? = null
private val serverInteractor: GetCurrentServerInteractor? = null,
private val localRepository: LocalRepository? = null,
private val removeAccountInteractor: RemoveAccountInteractor? = null,
private val tokenRepository: TokenRepository? = null,
private val managerFactory: ConnectionManagerFactory? = null,
private val dbManagerFactory: DatabaseManagerFactory? = null,
private val versionCheckView: VersionCheckView? = null,
private val tokenView: TokenView? = null,
private val navigator: MainNavigator? = null,
private val refreshSettingsInteractor: RefreshSettingsInteractor? = null
) {
private lateinit var currentServer: String
private lateinit var client: RocketChatClient
private lateinit var settings: PublicSettings
private lateinit var manager: ConnectionManager
private lateinit var dbManager: DatabaseManager
internal var state: String = ""
internal var facebookOauthUrl: String? = null
internal var githubOauthUrl: String? = null
......@@ -78,10 +104,22 @@ abstract class CheckServerPresenter constructor(
internal var isNewAccountCreationEnabled = false
internal fun setupConnectionInfo(serverUrl: String) {
settingsInteractor?.get(serverUrl)?.let {
currentServer = serverUrl
client = factory.create(serverUrl)
managerFactory?.create(serverUrl)?.let {
manager = it
}
dbManagerFactory?.create(serverUrl)?.let {
dbManager = it
}
}
internal suspend fun refreshServerAccounts() {
refreshSettingsInteractor?.refresh(currentServer)
settingsInteractor?.get(currentServer)?.let {
settings = it
}
client = factory.create(serverUrl)
state = ""
facebookOauthUrl = null
......@@ -117,28 +155,28 @@ abstract class CheckServerPresenter constructor(
client.serverInfo()
}
if (serverInfo.redirected) {
view?.updateServerUrl(serverInfo.url)
versionCheckView?.updateServerUrl(serverInfo.url)
}
val version = checkServerVersion(serverInfo)
when (version) {
is Version.VersionOk -> {
Timber.i("Your version is nice! (Requires: 0.62.0, Yours: ${version.version})")
view?.versionOk()
versionCheckView?.versionOk()
}
is Version.RecommendedVersionWarning -> {
Timber.i("Your server ${version.version} is bellow recommended version ${BuildConfig.RECOMMENDED_SERVER_VERSION}")
view?.alertNotRecommendedVersion()
versionCheckView?.alertNotRecommendedVersion()
}
is Version.OutOfDateError -> {
Timber.i("Oops. Looks like your server ${version.version} is out-of-date! Minimum server version required ${BuildConfig.REQUIRED_SERVER_VERSION}!")
view?.blockAndAlertNotRequiredVersion()
versionCheckView?.blockAndAlertNotRequiredVersion()
}
}
} catch (ex: Exception) {
Timber.d(ex, "Error getting server info")
when (ex) {
is RocketChatInvalidProtocolException -> view?.errorInvalidProtocol()
else -> view?.errorCheckingServerVersion()
is RocketChatInvalidProtocolException -> versionCheckView?.errorInvalidProtocol()
else -> versionCheckView?.errorCheckingServerVersion()
}
}
}
......@@ -162,8 +200,59 @@ abstract class CheckServerPresenter constructor(
}
}
private fun checkEnabledOauthAccounts(services: List<Map<String,Any>>, serverUrl: String) {
/**
* Logout the user from the current server.
*
* @param userDataChannel the user data channel to stop listening to changes (if currently subscribed).
*/
internal fun logout(userDataChannel: Channel<Myself>?) {
launchUI(strategy) {
try {
clearTokens()
retryIO("logout") { client.logout() }
} catch (exception: RocketChatException) {
Timber.e(exception, "Error calling logout")
}
try {
if (userDataChannel != null) {
disconnect(userDataChannel)
}
removeAccountInteractor?.remove(currentServer)
tokenRepository?.remove(currentServer)
withContext(CommonPool) { dbManager.logout() }
navigator?.switchOrAddNewServer()
} catch (ex: Exception) {
Timber.e(ex, "Error cleaning up the session...")
}
}
}
/**
* Stops listening to user data changes and disconnects the user.
*
* @param userDataChannel the user data channel to stop listening to changes.
*/
fun disconnect(userDataChannel: Channel<Myself>) {
manager.removeUserDataChannel(userDataChannel)
manager.disconnect()
}
private suspend fun clearTokens() {
serverInteractor?.clear()
val pushToken = localRepository?.get(LocalRepository.KEY_PUSH_TOKEN)
if (pushToken != null) {
try {
retryIO("unregisterPushToken") { client.unregisterPushToken(pushToken) }
tokenView?.invalidateToken(pushToken)
} catch (ex: Exception) {
Timber.e(ex, "Error unregistering push token")
}
}
localRepository?.clearAllFromServer(currentServer)
}
private fun checkEnabledOauthAccounts(services: List<Map<String,Any>>, serverUrl: String) {
if (settings.isFacebookAuthenticationEnabled()) {
getServiceMap(services, SERVICE_NAME_FACEBOOK)?.let { serviceMap ->
getOauthClientId(serviceMap)?.let { clientId ->
......@@ -552,4 +641,4 @@ abstract class CheckServerPresenter constructor(
data class OutOfDateError(private val currentVersion: String) : Version(currentVersion)
}
}
\ No newline at end of file
}
package chat.rocket.android.server.presentation
interface TokenView {
fun invalidateToken(token: String)
}
\ No newline at end of file
package chat.rocket.android.settings.password.presentation
import chat.rocket.android.analytics.AnalyticsManager
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.server.domain.GetCurrentServerInteractor
import chat.rocket.android.server.infraestructure.RocketChatClientFactory
......@@ -14,6 +15,7 @@ import javax.inject.Inject
class PasswordPresenter @Inject constructor(
private val view: PasswordView,
private val strategy: CancelStrategy,
private val analyticsManager: AnalyticsManager,
serverInteractor: GetCurrentServerInteractor,
factory: RocketChatClientFactory
) {
......@@ -30,10 +32,12 @@ class PasswordPresenter @Inject constructor(
client.updateProfile(me.id, null, null, password, null)
}
analyticsManager.logResetPassword(true)
view.showPasswordSuccessfullyUpdatedMessage()
view.hideLoading()
} catch (exception: RocketChatException) {
analyticsManager.logResetPassword(false)
view.showPasswordFailsUpdateMessage(exception.message)
} finally {
view.hideLoading()
}
}
......
package chat.rocket.android.settings.ui
import android.content.ActivityNotFoundException
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import androidx.appcompat.app.AppCompatActivity
import androidx.core.net.toUri
import androidx.fragment.app.Fragment
import chat.rocket.android.R
import chat.rocket.android.about.ui.AboutFragment
......@@ -84,7 +87,15 @@ class SettingsFragment : Fragment(), SettingsView, AdapterView.OnItemClickListen
shareIntent.putExtra(Intent.EXTRA_TEXT, shareSub)
startActivity(Intent.createChooser(shareIntent, getString(R.string.msg_share_using)))
}
resources.getString(R.string.title_rate_us) -> startAppPlayStore()
}
}
private fun startAppPlayStore() {
try {
startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.market_link).toUri()))
} catch (error: ActivityNotFoundException) {
startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.play_store_link).toUri()))
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/action_update_profile"
android:icon="@drawable/ic_check_white_24dp"
android:title="@string/action_update" />
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_update_profile"
android:icon="@drawable/ic_check_white_24dp"
android:title="@string/action_update" />
android:id="@+id/action_delete_account"
android:title="@string/action_delete_account"
app:showAsAction="never" />
</menu>
\ No newline at end of file
......@@ -16,12 +16,13 @@
<string name="title_settings">Einstellungen</string>
<string name="title_preferences">Preferences</string> <!-- TODO Add translation -->
<string name="title_change_password">Ändere Passwort</string>
<string name="title_rate_us">Bewerten Sie uns</string>
<string name="title_admin_panel">Admin panel</string> <!-- TODO Add translation -->
<string name="title_password">Ändere Passwort</string>
<string name="title_update_profile">Update Profil</string>
<string name="title_about">Über</string>
<string name="title_create_channel">Erstelle Raum</string>
<string name="title_confirmation">Are You Sure you want to logout?</string><!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string><!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Verbinde</string>
......@@ -34,7 +35,6 @@
<string name="action_create_channel">Erstelle Raum</string>
<string name="action_create">Erstelle</string>
<string name="action_logout">Abmelden</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Dateien</string>
<string name="action_confirm_password">Bestätige Passwort Änderung</string>
<string name="action_join_chat">Trete Chat bei</string>
......@@ -53,13 +53,15 @@
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Preferences</item> <!-- TODO Add translation -->
<item name="item_password">Ändere Passwort</item>
<item name="item_password">Über</item>
<item name="item_share_app">App teilen</item>
<item name="item_rate_us">Bewerten Sie uns</item>
<item name="item_password">Über</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -15,12 +15,14 @@
<string name="title_settings">Configuraciones</string>
<string name="title_preferences">Preferences</string> <!-- TODO Add translation -->
<string name="title_change_password">Cambia la contraseña</string>
<string name="title_rate_us">Nos califica</string>
<string name="title_admin_panel">Admin panel</string> <!-- TODO Add translation -->
<string name="title_password">Cambia la contraseña</string>
<string name="title_update_profile">Actualización del perfil</string>
<string name="title_about">Acerca de</string>
<string name="title_create_channel">Crear canal</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Conectar</string>
<string name="action_use_this_username">Usa este nombre de usuario</string>
......@@ -32,7 +34,6 @@
<string name="action_create_channel">Crear canal</string>
<string name="action_create">Create</string>
<string name="action_logout">Cerrar sesión</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Archivos</string>
<string name="action_confirm_password">Confirmar cambio de contraseña</string>
<string name="action_join_chat">Unirse al chat</string>
......@@ -51,13 +52,15 @@
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Preferences</item> <!-- TODO Add translation -->
<item name="item_password">Cambia la contraseña</item>
<item name="item_password">Acerca de</item>
<item name="item_share_app">Compartir aplicación</item>
<item name="item_rate_us">Nos califica</item>
<item name="item_password">Acerca de</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -16,14 +16,13 @@
<string name="title_settings">Paramètres</string>
<string name="title_preferences">Préférences</string>
<string name="title_change_password">Changer le mot de passe</string>
<string name="title_rate_us">évaluez nous</string>
<string name="title_admin_panel">Administration</string>
<string name="title_password">Changer le mot de passe</string>
<string name="title_update_profile">Mettre à jour le profil</string>
<string name="title_about">À propos</string>
<string name="title_create_channel">Créer salon</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Se connecter</string>
......@@ -36,7 +35,6 @@
<string name="action_create_channel">Créer salon</string>
<string name="action_create">Créer</string>
<string name="action_logout">Se déconnecter</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Fichiers</string>
<string name="action_confirm_password">Confirmer le mot de passe</string>
<string name="action_join_chat">Rejoignez le chat</string>
......@@ -55,13 +53,15 @@
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Préférences</item>
<item name="item_password">Changer le mot de passe</item>
<item name="item_password">À propos</item>
<item name="item_share_app">Partager l\'application</item>
<item name="item_rate_us">évaluez nous</item>
<item name="item_password">À propos</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -16,13 +16,13 @@
<string name="title_settings">सेटिंग्स</string>
<string name="title_preferences">प्राथमिकताएँ</string>
<string name="title_change_password">पासवर्ड बदलें</string>
<string name="title_rate_us">हमें रेटिंग दें</string>
<string name="title_admin_panel">एडमिन पैनल</string>
<string name="title_password">पासवर्ड बदलें</string>
<string name="title_update_profile">प्रोफ़ाइल अपडेट करें</string>
<string name="title_about">परिचय</string>
<string name="title_create_channel">चैनल बनाएं</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">जुडिये</string>
......@@ -35,7 +35,6 @@
<string name="action_create_channel">चैनल बनाएं</string>
<string name="action_create">बनाएं</string>
<string name="action_logout">लोग आउट करें</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">फ़ाइलें</string>
<string name="action_confirm_password">पासवर्ड परिवर्तन की पुष्टि करें</string>
<string name="action_join_chat">चैट में शामिल हों</string>
......@@ -54,13 +53,15 @@
<string name="action_create_server">नया सर्वर बनाएं</string>
<string name="action_register">रजिस्टर</string>
<string name="action_confirm">पुष्टि करें</string>
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">प्राथमिकताएँ</item>
<item name="item_password">पासवर्ड बदलें</item>
<item name="item_password">परिचय</item>
<item name="item_share_app">ऐप शेयर करें</item>
<item name="item_rate_us">हमें रेटिंग दें</item>
<item name="item_password">परिचय</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -18,12 +18,15 @@
<string name="title_settings">設定</string>
<string name="title_preferences">環境設定</string>
<string name="title_change_password">パスワードの変更</string>
<string name="title_rate_us">私たちを評価してください</string>
<string name="title_admin_panel">管理パネル</string>
<string name="title_password">パスワードの変更</string>
<string name="title_update_profile">プロフィールの更新</string>
<string name="title_about">About</string>
<string name="title_create_channel">新しいチャネルを作成</string>
<string name="title_confirmation">ログアウトしますか?</string>
<string name="title_are_you_sure">本気ですか?</string>
<!-- Actions -->
......@@ -37,7 +40,6 @@
<string name="action_create_channel">チャンネル作成</string>
<string name="action_create">作ります</string>
<string name="action_logout">ログアウト</string>
<string name="action_stay">いいえ</string>
<string name="action_files">ファイル</string>
<string name="action_confirm_password">変更したパスワードの確認</string>
<string name="action_join_chat">チャットに参加</string>
......@@ -56,13 +58,15 @@
<string name="action_create_server">新規サーバーを作成</string>
<string name="action_register">登録</string>
<string name="action_confirm">確認</string>
<string name="action_delete_account">アカウントを削除する</string>
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">環境設定</item>
<item name="item_password">パスワードの変更</item>
<item name="item_password">アプリ情報</item>
<item name="item_share_app">アプリを共有する</item>
<item name="item_rate_us">私たちを評価してください</item>
<item name="item_password">アプリ情報</item>
</string-array>
<!-- Regular information messages -->
......@@ -154,12 +158,10 @@
<string name="msg_continue_with_wordpress"><b>WordPress</b>でログイン</string>
<string name="msg_two_factor_authentication">二要素認証</string>
<string name="msg__your_2fa_code">あなたの 2FA コードは何ですか?</string>
<string name="msg_view_more">更に表示</string>
<string name="msg_view_less">隠す</string>
<!-- TODO - Add proper translation -->
<string name="msg_muted_on_this_channel">You are muted on this channel</string>
<string name="msg_muted_on_this_channel">あなたはこのチャンネルでミュートされています</string>
<!-- Create channel messages -->
<string name="msg_private_channel">プライベート</string>
......@@ -213,7 +215,6 @@
<string name="action_msg_share">Share</string>
<string name="action_title_editing">メッセージの編集</string>
<string name="action_msg_add_reaction">リアクションする</string>
<!-- TODO - Add proper translation -->
<string name="action_msg_copy_permalink">パーマリンクのコピー</string>
<!-- Permission messages -->
......
......@@ -16,13 +16,13 @@
<string name="title_settings">Configurações</string>
<string name="title_preferences">Preferencias</string>
<string name="title_change_password">Alterar senha</string>
<string name="title_rate_us">nos avalie</string>
<string name="title_admin_panel">Painel administrativo</string>
<string name="title_password">Alterar senha</string>
<string name="title_update_profile">Editar perfil</string>
<string name="title_about">Sobre</string>
<string name="title_create_channel">Criar chat</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Você tem certeza?</string>
<!-- Actions -->
<string name="action_connect">Conectar</string>
......@@ -35,7 +35,6 @@
<string name="action_create_channel">Criar chat</string>
<string name="action_create">Criar</string>
<string name="action_logout">Sair</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Arquivos</string>
<string name="action_confirm_password">Confirme a nova senha</string>
<string name="action_join_chat">Entrar no Chat</string>
......@@ -49,18 +48,20 @@
<string name="action_select_photo_from_gallery">Escolher foto da galeria</string>
<string name="action_take_photo">Tirar foto</string>
<string name="action_reset_avatar">Resetar avatar</string>
<string name="action_connect_server">Connect with a server</string> <!-- TODO Add translation -->
<string name="action_join_community">Join in the community</string> <!-- TODO Add translation -->
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_connect_server">Conectar com um servidor</string>
<string name="action_join_community">Junte-se à comunidade</string>
<string name="action_create_server">Criar um novo servidor</string>
<string name="action_register">Registrar</string>
<string name="action_confirm">Confirmar</string>
<string name="action_delete_account">Deletar conta</string>
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Preferencias</item>
<item name="item_password">Alterar senha</item>
<item name="item_password">Sobre</item>
<item name="item_share_app">Compartilhe o aplicativo</item>
<item name="item_rate_us">nos avalie</item>
<item name="item_password">Sobre</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -16,13 +16,13 @@
<string name="title_settings">Настройки</string>
<string name="title_preferences">Персональные</string>
<string name="title_change_password">Изменить пароль</string>
<string name="title_rate_us">оцените нас</string>
<string name="title_admin_panel">Панель админа</string>
<string name="title_password">Изменить пароль</string>
<string name="title_update_profile">Обновить профиль</string>
<string name="title_about">О программе</string>
<string name="title_create_channel">Создать новый канал</string>
<string name="title_confirmation">Вы действительно хотите выйти?</string>
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Подключиться</string>
......@@ -35,7 +35,6 @@
<string name="action_create_channel">Создать канал</string>
<string name="action_create">Создать</string>
<string name="action_logout">Выйти</string>
<string name="action_stay">Остаться</string>
<string name="action_files">Файлы</string>
<string name="action_confirm_password">Подтверждение изменения пароля</string>
<string name="action_join_chat">Присоединиться к чату</string>
......@@ -54,13 +53,15 @@
<string name="action_create_server">Создать новый сервер</string>
<string name="action_register">Зарегистрировать</string>
<string name="action_confirm">Подтвердить</string>
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Персональные</item>
<item name="item_password">Изменить пароль</item>
<item name="item_password">О программе</item>
<item name="item_rate_us">оцените нас</item>
<item name="item_share_app">добавить приложение</item>
<item name="item_password">О программе</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -16,13 +16,13 @@
<string name="title_settings">Ayarlar</string>
<string name="title_preferences">Tercihler</string>
<string name="title_change_password">Şifre Değişikliği</string>
<string name="title_rate_us">Bizi değerlendirin</string>
<string name="title_admin_panel">Yönetici Paneli</string>
<string name="title_password">Şifrenizi Değiştirin</string>
<string name="title_update_profile">Profilinizi Düzenleyin</string>
<string name="title_about">Hakkında</string>
<string name="title_create_channel">Yeni Kanal Oluştur</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Bağlan</string>
......@@ -35,7 +35,6 @@
<string name="action_create_channel">Yeni Kanal Oluştur</string>
<string name="action_create">Oluştur</string>
<string name="action_logout">Çıkış Yap</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Dosyalar</string>
<string name="action_confirm_password">Şifre Değişikliğini Onaylayın</string>
<string name="action_join_chat">Sohbete Bağlan</string>
......@@ -54,13 +53,15 @@
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Tercihler</item>
<item name="item_password">Şifre Değiştir</item>
<item name="item_password">Hakkında</item>
<item name="item_share_app">uygulamayı Paylaş</item>
<item name="item_rate_us">Bizi değerlendirin</item>
<item name="item_password">Hakkında</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -16,13 +16,13 @@
<string name="title_settings">Налаштування</string>
<string name="title_preferences">Персональні</string>
<string name="title_change_password">Змінити пароль</string>
<string name="title_rate_us">Оцініть нас</string>
<string name="title_admin_panel">Панель адміністратора</string>
<string name="title_password">Змінити пароль</string>
<string name="title_update_profile">Оновити профіль</string>
<string name="title_about">"Про програму"</string>
<string name="title_create_channel">Створити новий канал</string>
<string name="title_confirmation">Are You Sure you want to logout?</string> <!-- TODO Add translation -->
<string name="title_are_you_sure">Are you sure?</string> <!-- TODO Add translation -->
<!-- Actions -->
<string name="action_connect">Підключитися</string>
......@@ -35,7 +35,6 @@
<string name="action_create_channel">Створити канал</string>
<string name="action_create">Створити</string>
<string name="action_logout">Вийти</string>
<string name="action_stay">Stay</string> <!-- TODO Add translation -->
<string name="action_files">Файли</string>
<string name="action_confirm_password">Підтвердження зміни пароля</string>
<string name="action_join_chat">Приєднатися до чату</string>
......@@ -54,13 +53,15 @@
<string name="action_create_server">Create a new server</string> <!-- TODO Add translation -->
<string name="action_register">Register</string> <!-- TODO Add translation -->
<string name="action_confirm">Confirm</string> <!-- TODO Add translation -->
<string name="action_delete_account">Delete account</string> <!-- TODO Add translation -->
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Preferences</item> <!-- TODO Add translation -->
<item name="item_password">Change Password</item> <!-- TODO Add translation -->
<item name="item_password">About</item> <!-- TODO Add translation -->
<item name="item_share_app">поділитися прикладом</item>
<item name="item_rate_us">Оцініть нас</item>
<item name="item_password">About</item> <!-- TODO Add translation -->
</string-array>
<!-- Regular information messages -->
......
......@@ -5,4 +5,5 @@
<string name="community_server_url" translatable="false">open.rocket.chat</string>
<string name="create_server_url" translatable="false">cloud.rocket.chat/trial</string>
<string name="play_store_link" translatable="false">https://play.google.com/store/apps/details?id=chat.rocket.android</string>
<string name="market_link" translatable="false">market://details?id=chat.rocket.android</string>
</resources>
\ No newline at end of file
......@@ -28,12 +28,13 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="title_settings">Settings</string>
<string name="title_preferences">Preferences</string>
<string name="title_change_password">Change Password</string>
<string name="title_rate_us">Rate Us</string>
<string name="title_admin_panel">Admin panel</string>
<string name="title_password">Change Password</string>
<string name="title_update_profile">Update profile</string>
<string name="title_about">About</string>
<string name="title_create_channel">Create Channel</string>
<string name="title_confirmation">Are You Sure you want to logout?</string>
<string name="title_are_you_sure">Are you sure?</string>
<!-- Actions -->
<string name="action_connect">Connect</string>
......@@ -46,7 +47,6 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="action_create_channel">Create channel</string>
<string name="action_create">Create</string>
<string name="action_logout">Logout</string>
<string name="action_stay">Stay</string>
<string name="action_files">Files</string>
<string name="action_confirm_password">Confirm Password Change</string>
<string name="action_join_chat">Join Chat</string>
......@@ -65,13 +65,15 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="action_create_server">Create a new server</string>
<string name="action_register">Register</string>
<string name="action_confirm">Confirm</string>
<string name="action_delete_account">Delete account</string>
<!-- Settings List -->
<string-array name="settings_actions">
<item name="item_preferences">Preferences</item>
<item name="item_password">Change Password</item>
<item name="item_password">About</item>
<item name="item_share_app">Share App</item>
<item name="item_rate_us">Rate Us</item>
<item name="item_password">About</item>
</string-array>
<!-- Regular information messages -->
......
......@@ -67,4 +67,11 @@ class AnswersAnalytics : Analytics {
)
override fun logOpenAdmin() = Answers.getInstance().logCustom(CustomEvent("open_admin"))
override fun logResetPassword(resetPasswordSucceeded: Boolean) =
Answers.getInstance()
.logCustom(
CustomEvent("reset_password")
.putCustomAttribute("resetPasswordSucceeded", resetPasswordSucceeded.toString())
)
}
......@@ -60,4 +60,9 @@ class GoogleAnalyticsForFirebase @Inject constructor(val context: Context) :
}
override fun logOpenAdmin() = firebaseAnalytics.logEvent("open_admin", null)
override fun logResetPassword(resetPasswordSucceeded: Boolean) =
firebaseAnalytics.logEvent("reset_password", Bundle(1).apply {
putBoolean("resetPasswordSucceeded", resetPasswordSucceeded)
})
}
package chat.rocket.android.util.extension
import java.math.BigInteger
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException
@Throws(NoSuchAlgorithmException::class)
fun String.gethash(): ByteArray {
val digest = MessageDigest.getInstance("SHA-256")
digest.reset()
return digest.digest(this.toByteArray())
}
fun ByteArray.toHex(): String = String.format("%0" + this.size * 2 + "X", BigInteger(1, this))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment