From e4066e726e227dbed57752270a0c814a4e131b6c Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 10:58:38 -0500 Subject: [PATCH 01/18] Add empty collaborators as empty view with the same format from tags --- .../simplenote/CollaboratorsActivity.kt | 31 +++-- .../res/layout/activity_collaborators.xml | 125 ++++++------------ .../main/res/layout/empty_view_message.xml | 52 ++++++++ Simplenote/src/main/res/values/strings.xml | 1 + 4 files changed, 114 insertions(+), 95 deletions(-) create mode 100644 Simplenote/src/main/res/layout/empty_view_message.xml diff --git a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt index a29ad2e67..292f118f0 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt @@ -7,6 +7,7 @@ import android.view.MenuItem import android.view.View import android.widget.Toast import androidx.activity.viewModels +import androidx.annotation.DrawableRes import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.widget.Toolbar @@ -73,8 +74,18 @@ class CollaboratorsActivity : ThemedAppCompatActivity() { collaboratorsList.adapter = CollaboratorsAdapter(viewModel::clickRemoveCollaborator) collaboratorsList.isNestedScrollingEnabled = false collaboratorsList.layoutManager = LinearLayoutManager(this@CollaboratorsActivity) + collaboratorsList.setEmptyView(empty.root) - rowAddCollaborator.setOnClickListener { viewModel.clickAddCollaborator() } + buttonAddCollaborator.setOnClickListener { viewModel.clickAddCollaborator() } + } + + private fun ActivityCollaboratorsBinding.setEmptyListImage(@DrawableRes image: Int) { + if (image != -1) { + empty.image.visibility = View.VISIBLE + empty.image.setImageResource(image) + } else { + empty.image.visibility = View.GONE + } } private fun setupToolbar() { @@ -113,21 +124,17 @@ class CollaboratorsActivity : ThemedAppCompatActivity() { } private fun ActivityCollaboratorsBinding.handleCollaboratorsList(collaborators: List) { - sharedMessage.visibility = View.VISIBLE - collaboratorsList.visibility = View.VISIBLE - dividerLine.visibility = View.VISIBLE - buttonAddCollaborator.visibility = View.VISIBLE - emptyMessage.visibility = View.GONE - + setEmptyListImage(-1) + empty.message.visibility = View.GONE (collaboratorsList.adapter as CollaboratorsAdapter).submitList(collaborators) } private fun ActivityCollaboratorsBinding.handleEmptyCollaborators() { - sharedMessage.visibility = View.GONE - collaboratorsList.visibility = View.GONE - dividerLine.visibility = View.GONE - buttonAddCollaborator.visibility = View.VISIBLE - emptyMessage.visibility = View.VISIBLE + (collaboratorsList.adapter as CollaboratorsAdapter).submitList(emptyList()) + setEmptyListImage(R.drawable.ic_collaborate_24dp) + empty.title.text = getString(R.string.no_collaborators) + empty.message.visibility = View.VISIBLE + empty.message.text = getString(R.string.add_email_collaborator_message) } private fun showAddCollaboratorFragment(event: Event.AddCollaboratorEvent) { diff --git a/Simplenote/src/main/res/layout/activity_collaborators.xml b/Simplenote/src/main/res/layout/activity_collaborators.xml index 88384f426..9282bddea 100644 --- a/Simplenote/src/main/res/layout/activity_collaborators.xml +++ b/Simplenote/src/main/res/layout/activity_collaborators.xml @@ -1,95 +1,54 @@ - - + + - - - + android:orientation="vertical"> - - - - - - - - - - - + android:layout_height="match_parent" + android:background="@android:color/transparent" + android:clipToPadding="false" + android:divider="?attr/listDividerDrawable" + android:dividerHeight="@dimen/divider_height" + android:paddingBottom="@dimen/padding_list_bottom" + android:scrollbarStyle="outsideOverlay" + android:scrollbars="vertical" /> + + + + + + + - - - - diff --git a/Simplenote/src/main/res/layout/empty_view_message.xml b/Simplenote/src/main/res/layout/empty_view_message.xml new file mode 100644 index 000000000..08e04aae8 --- /dev/null +++ b/Simplenote/src/main/res/layout/empty_view_message.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + diff --git a/Simplenote/src/main/res/values/strings.xml b/Simplenote/src/main/res/values/strings.xml index 0717c567a..7dceda4ae 100644 --- a/Simplenote/src/main/res/values/strings.xml +++ b/Simplenote/src/main/res/values/strings.xml @@ -343,6 +343,7 @@ Please enter a valid email address Note was deleted. You cannot edit collaborators on a note that was deleted. Note was trashed. You cannot edit collaborators on a note that is in the trash. + No Collaborators Change passcode From 985939e3fa9b15b8071e02e03913562ab14ae035 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 11:31:52 -0500 Subject: [PATCH 02/18] Fix warning in activity_tags layout --- Simplenote/src/main/res/layout/activity_tags.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Simplenote/src/main/res/layout/activity_tags.xml b/Simplenote/src/main/res/layout/activity_tags.xml index 3bb513c73..ea943e453 100644 --- a/Simplenote/src/main/res/layout/activity_tags.xml +++ b/Simplenote/src/main/res/layout/activity_tags.xml @@ -31,8 +31,7 @@ - + layout="@layout/empty_view" /> Date: Mon, 27 Sep 2021 14:13:07 -0500 Subject: [PATCH 03/18] Add Shared With message as the header of the recycler view Since we are handling the empty view of the collaborators list with an empty view, the Shared With message is now the header of a recycler view and the data items are transformed to CollaboratorDataItem to submit the list items. --- .../simplenote/CollaboratorsActivity.kt | 6 +- .../simplenote/utils/CollaboratorsAdapter.kt | 61 +++++++++++++++---- .../res/layout/activity_collaborators.xml | 4 +- .../main/res/layout/collaborators_header.xml | 19 ++++++ 4 files changed, 75 insertions(+), 15 deletions(-) create mode 100644 Simplenote/src/main/res/layout/collaborators_header.xml diff --git a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt index 292f118f0..286056036 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt @@ -14,6 +14,8 @@ import androidx.appcompat.widget.Toolbar import androidx.recyclerview.widget.LinearLayoutManager import com.automattic.simplenote.databinding.ActivityCollaboratorsBinding import com.automattic.simplenote.utils.CollaboratorsAdapter +import com.automattic.simplenote.utils.CollaboratorsAdapter.* +import com.automattic.simplenote.utils.CollaboratorsAdapter.CollaboratorDataItem.* import com.automattic.simplenote.utils.toast import com.automattic.simplenote.viewmodels.CollaboratorsViewModel import com.automattic.simplenote.viewmodels.CollaboratorsViewModel.Event @@ -126,7 +128,9 @@ class CollaboratorsActivity : ThemedAppCompatActivity() { private fun ActivityCollaboratorsBinding.handleCollaboratorsList(collaborators: List) { setEmptyListImage(-1) empty.message.visibility = View.GONE - (collaboratorsList.adapter as CollaboratorsAdapter).submitList(collaborators) + + val items = listOf(HeaderItem) + collaborators.map { CollaboratorItem(it) } + (collaboratorsList.adapter as CollaboratorsAdapter).submitList(items) } private fun ActivityCollaboratorsBinding.handleEmptyCollaborators() { diff --git a/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt b/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt index 6897426d2..f69299ec3 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt @@ -6,38 +6,73 @@ import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import com.automattic.simplenote.databinding.CollaboratorRowBinding +import com.automattic.simplenote.databinding.CollaboratorsHeaderBinding class CollaboratorsAdapter( private val onDeleteClick: (collaborator: String) -> Unit, -) : ListAdapter(DIFF_CALLBACK) { +) : ListAdapter(DIFF_CALLBACK) { - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CollaboratorViewHolder { - val binding = CollaboratorRowBinding.inflate(LayoutInflater.from(parent.context), parent, false) - return CollaboratorViewHolder(binding, onDeleteClick) + sealed class CollaboratorDataItem { + abstract val id: Int + object HeaderItem : CollaboratorDataItem() { + override val id = Int.MIN_VALUE + } + data class CollaboratorItem(val email: String) : CollaboratorDataItem() { + override val id = email.hashCode() + } } - override fun onBindViewHolder(holder: CollaboratorViewHolder, position: Int) { - holder.bind(getItem(position)) + override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { + return when (viewType) { + ITEM_VIEW_TYPE_HEADER -> { + val binding = CollaboratorsHeaderBinding.inflate(LayoutInflater.from(parent.context), parent, false) + CollaboratorHeaderViewHolder(binding) + } + ITEM_VIEW_TYPE_ITEM -> { + val binding = CollaboratorRowBinding.inflate(LayoutInflater.from(parent.context), parent, false) + CollaboratorViewHolder(binding, onDeleteClick) + } + else -> throw ClassCastException("Unknown viewType $viewType") + } } + override fun getItemViewType(position: Int): Int { + return when (getItem(position)) { + is CollaboratorDataItem.HeaderItem -> ITEM_VIEW_TYPE_HEADER + is CollaboratorDataItem.CollaboratorItem -> ITEM_VIEW_TYPE_ITEM + } + } + + override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { + if (holder is CollaboratorViewHolder) { + holder.bind(getItem(position) as CollaboratorDataItem.CollaboratorItem) + } + } + + class CollaboratorHeaderViewHolder( + binding: CollaboratorsHeaderBinding + ) : RecyclerView.ViewHolder(binding.root) + class CollaboratorViewHolder( private val binding: CollaboratorRowBinding, private val onDeleteClick: (collaborator: String) -> Unit ): RecyclerView.ViewHolder(binding.root) { - fun bind(collaborator: String) { - binding.collaboratorText.text = collaborator - binding.collaboratorRemoveButton.setOnClickListener { onDeleteClick(collaborator) } + fun bind(collaborator: CollaboratorDataItem.CollaboratorItem) { + binding.collaboratorText.text = collaborator.email + binding.collaboratorRemoveButton.setOnClickListener { onDeleteClick(collaborator.email) } } } companion object { - val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { - override fun areItemsTheSame(oldItem: String, newItem: String): Boolean { - return oldItem == newItem + private const val ITEM_VIEW_TYPE_HEADER = 0 + private const val ITEM_VIEW_TYPE_ITEM = 1 + private val DIFF_CALLBACK = object : DiffUtil.ItemCallback() { + override fun areItemsTheSame(oldItem: CollaboratorDataItem, newItem: CollaboratorDataItem): Boolean { + return oldItem.id == newItem.id } - override fun areContentsTheSame(oldItem: String, newItem: String): Boolean { + override fun areContentsTheSame(oldItem: CollaboratorDataItem, newItem: CollaboratorDataItem): Boolean { return oldItem == newItem } } diff --git a/Simplenote/src/main/res/layout/activity_collaborators.xml b/Simplenote/src/main/res/layout/activity_collaborators.xml index 9282bddea..c3d19dad4 100644 --- a/Simplenote/src/main/res/layout/activity_collaborators.xml +++ b/Simplenote/src/main/res/layout/activity_collaborators.xml @@ -21,6 +21,8 @@ android:id="@+id/collaborators_list" android:layout_width="match_parent" android:layout_height="match_parent" + android:layout_marginStart="72dp" + android:layout_marginBottom="10dp" android:background="@android:color/transparent" android:clipToPadding="false" android:divider="?attr/listDividerDrawable" @@ -31,7 +33,7 @@ + layout="@layout/empty_view_message" /> + + + + \ No newline at end of file From 34c4d6cafef322bbd2e7ea5f9eddc9770422e992 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 14:37:56 -0500 Subject: [PATCH 04/18] Move sealed class to bottom with other classes --- .../simplenote/utils/CollaboratorsAdapter.kt | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt b/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt index f69299ec3..5bfcb7efd 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/utils/CollaboratorsAdapter.kt @@ -12,16 +12,6 @@ class CollaboratorsAdapter( private val onDeleteClick: (collaborator: String) -> Unit, ) : ListAdapter(DIFF_CALLBACK) { - sealed class CollaboratorDataItem { - abstract val id: Int - object HeaderItem : CollaboratorDataItem() { - override val id = Int.MIN_VALUE - } - data class CollaboratorItem(val email: String) : CollaboratorDataItem() { - override val id = email.hashCode() - } - } - override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return when (viewType) { ITEM_VIEW_TYPE_HEADER -> { @@ -49,6 +39,16 @@ class CollaboratorsAdapter( } } + sealed class CollaboratorDataItem { + abstract val id: Int + object HeaderItem : CollaboratorDataItem() { + override val id = Int.MIN_VALUE + } + data class CollaboratorItem(val email: String) : CollaboratorDataItem() { + override val id = email.hashCode() + } + } + class CollaboratorHeaderViewHolder( binding: CollaboratorsHeaderBinding ) : RecyclerView.ViewHolder(binding.root) From cbcb02e6564a4dca9ff00c4445c43fa32ca43d8a Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:15:20 -0500 Subject: [PATCH 05/18] Add SessionManager to provides the current user (auth or unauthorized) --- .../authentication/SessionManager.kt | 21 +++++++++++++++++++ .../automattic/simplenote/di/DataModule.kt | 8 +++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt diff --git a/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt b/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt new file mode 100644 index 000000000..2de457b2b --- /dev/null +++ b/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt @@ -0,0 +1,21 @@ +package com.automattic.simplenote.authentication + +import com.simperium.Simperium +import com.simperium.client.User +import javax.inject.Inject + +sealed class UserSession { + object UnauthorizedUser : UserSession() + data class AuthorizedUser(val user: User) : UserSession() +} + +class SessionManager @Inject constructor(private val simperium: Simperium) { + fun getCurrentUser(): UserSession { + val currentUser = simperium.user ?: return UserSession.UnauthorizedUser + + return when(currentUser.email != null && !currentUser.needsAuthorization()) { + true -> UserSession.AuthorizedUser(currentUser) + false -> UserSession.UnauthorizedUser + } + } +} \ No newline at end of file diff --git a/Simplenote/src/main/java/com/automattic/simplenote/di/DataModule.kt b/Simplenote/src/main/java/com/automattic/simplenote/di/DataModule.kt index daa55b411..763935ba2 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/di/DataModule.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/di/DataModule.kt @@ -1,6 +1,5 @@ package com.automattic.simplenote.di -import android.content.Context import com.automattic.simplenote.Simplenote import com.automattic.simplenote.models.Note import com.automattic.simplenote.models.Tag @@ -8,14 +7,16 @@ import com.automattic.simplenote.repositories.CollaboratorsRepository import com.automattic.simplenote.repositories.SimperiumCollaboratorsRepository import com.automattic.simplenote.repositories.SimperiumTagsRepository import com.automattic.simplenote.repositories.TagsRepository +import com.simperium.Simperium import com.simperium.client.Bucket import dagger.Binds import dagger.Module import dagger.Provides import dagger.hilt.InstallIn -import dagger.hilt.android.qualifiers.ApplicationContext import dagger.hilt.components.SingletonComponent +import kotlinx.coroutines.ExperimentalCoroutinesApi +@ExperimentalCoroutinesApi @Module @InstallIn(SingletonComponent::class) abstract class DataModule { @@ -25,6 +26,9 @@ abstract class DataModule { @Provides fun providesNotesBucket(simplenote: Simplenote): Bucket = simplenote.notesBucket + + @Provides + fun providesSimperium(simplenote: Simplenote): Simperium = simplenote.simperium } @Binds From fab1fc86d2584fce2dcafed3821638304b8a0440 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:16:25 -0500 Subject: [PATCH 06/18] Validate case in which the user tries to add themselves as collaborator --- .../simplenote/AddCollaboratorFragment.kt | 18 ++++---- .../viewmodels/AddCollaboratorViewModel.kt | 44 ++++++++++++------- Simplenote/src/main/res/values/strings.xml | 1 + 3 files changed, 40 insertions(+), 23 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/AddCollaboratorFragment.kt b/Simplenote/src/main/java/com/automattic/simplenote/AddCollaboratorFragment.kt index 2e67c5971..e6d223922 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/AddCollaboratorFragment.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/AddCollaboratorFragment.kt @@ -1,12 +1,12 @@ package com.automattic.simplenote import android.app.Dialog -import android.content.Context import android.content.DialogInterface import android.os.Bundle import android.os.Handler import android.view.ContextThemeWrapper import android.view.LayoutInflater +import androidx.annotation.StringRes import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatDialogFragment import androidx.core.widget.doAfterTextChanged @@ -14,6 +14,7 @@ import androidx.fragment.app.viewModels import com.automattic.simplenote.databinding.AddCollaboratorBinding import com.automattic.simplenote.utils.DisplayUtils import com.automattic.simplenote.viewmodels.AddCollaboratorViewModel +import com.automattic.simplenote.viewmodels.AddCollaboratorViewModel.Event import com.automattic.simplenote.widgets.MorphCircleToRectangle import dagger.hilt.android.AndroidEntryPoint @@ -83,16 +84,17 @@ class AddCollaboratorFragment(private val noteId: String) : AppCompatDialogFragm private fun setObservers() { viewModel.event.observe(this, { event -> when (event) { - AddCollaboratorViewModel.Event.Close, - AddCollaboratorViewModel.Event.NoteDeleted, // In case the note is deleted, the activity handles it. - AddCollaboratorViewModel.Event.NoteInTrash, // In case the note is trashed, the activity handles it. - AddCollaboratorViewModel.Event.CollaboratorAdded -> dismiss() - AddCollaboratorViewModel.Event.InvalidCollaborator -> setErrorInputField() + Event.Close, + Event.NoteDeleted, // In case the note is deleted, the activity handles it. + Event.NoteInTrash, // In case the note is trashed, the activity handles it. + Event.CollaboratorAdded -> dismiss() + Event.InvalidCollaborator -> setErrorInputField(R.string.invalid_collaborator) + Event.CollaboratorCurrentUser -> setErrorInputField(R.string.collaborator_is_current_user) } }) } - private fun setErrorInputField() { - binding.collaboratorInput.error = getString(R.string.invalid_collaborator) + private fun setErrorInputField(@StringRes message: Int) { + binding.collaboratorInput.error = getString(message) } } diff --git a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt index 9d26f643b..de9f1872d 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt @@ -4,6 +4,8 @@ import androidx.lifecycle.LiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.automattic.simplenote.analytics.AnalyticsTracker +import com.automattic.simplenote.authentication.SessionManager +import com.automattic.simplenote.authentication.UserSession import com.automattic.simplenote.repositories.CollaboratorsActionResult import com.automattic.simplenote.repositories.CollaboratorsRepository import dagger.hilt.android.lifecycle.HiltViewModel @@ -12,39 +14,51 @@ import javax.inject.Inject @HiltViewModel class AddCollaboratorViewModel @Inject constructor( - private val collaboratorsRepository: CollaboratorsRepository + private val collaboratorsRepository: CollaboratorsRepository, + private val sessionManager: SessionManager ) : ViewModel() { private val _event = SingleLiveEvent() val event: LiveData = _event fun addCollaborator(noteId: String, collaborator: String) { - viewModelScope.launch { - when (collaboratorsRepository.isValidCollaborator(collaborator)) { - true -> when (collaboratorsRepository.addCollaborator(noteId, collaborator)) { - is CollaboratorsActionResult.CollaboratorsList -> { - _event.value = Event.CollaboratorAdded + when(isCurrentUser(collaborator)) { + true -> _event.value = Event.CollaboratorCurrentUser + false -> viewModelScope.launch { + when (collaboratorsRepository.isValidCollaborator(collaborator)) { + true -> when (collaboratorsRepository.addCollaborator(noteId, collaborator)) { + is CollaboratorsActionResult.CollaboratorsList -> { + _event.value = Event.CollaboratorAdded - AnalyticsTracker.track( - AnalyticsTracker.Stat.COLLABORATOR_ADDED, - AnalyticsTracker.CATEGORY_NOTE, - "collaborator_added_to_note", - mapOf("source" to "collaborators") - ) + AnalyticsTracker.track( + AnalyticsTracker.Stat.COLLABORATOR_ADDED, + AnalyticsTracker.CATEGORY_NOTE, + "collaborator_added_to_note", + mapOf("source" to "collaborators") + ) + } + CollaboratorsActionResult.NoteDeleted -> _event.value = Event.NoteDeleted + CollaboratorsActionResult.NoteInTrash -> _event.value = Event.NoteInTrash } - CollaboratorsActionResult.NoteDeleted -> _event.value = Event.NoteDeleted - CollaboratorsActionResult.NoteInTrash -> _event.value = Event.NoteInTrash + false -> _event.value = Event.InvalidCollaborator } - false -> _event.value = Event.InvalidCollaborator } } } + private fun isCurrentUser(collaborator: String): Boolean { + return when(val currentUser = sessionManager.getCurrentUser()) { + is UserSession.AuthorizedUser -> currentUser.user.email == collaborator + is UserSession.UnauthorizedUser -> false // This should not happen + } + } + fun close() { _event.value = Event.Close } sealed class Event { object InvalidCollaborator : Event() + object CollaboratorCurrentUser : Event() object CollaboratorAdded : Event() object Close : Event() object NoteInTrash : Event() diff --git a/Simplenote/src/main/res/values/strings.xml b/Simplenote/src/main/res/values/strings.xml index 7dceda4ae..04e913a90 100644 --- a/Simplenote/src/main/res/values/strings.xml +++ b/Simplenote/src/main/res/values/strings.xml @@ -341,6 +341,7 @@ Email Address Accept Please enter a valid email address + Please enter an email address different than your account\'s email Note was deleted. You cannot edit collaborators on a note that was deleted. Note was trashed. You cannot edit collaborators on a note that is in the trash. No Collaborators From be79b3d4e7e0be4194f5bd38fe950b74fb7fc34b Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:22:10 -0500 Subject: [PATCH 07/18] Change error message --- Simplenote/src/main/res/values/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simplenote/src/main/res/values/strings.xml b/Simplenote/src/main/res/values/strings.xml index 04e913a90..b396a2f0b 100644 --- a/Simplenote/src/main/res/values/strings.xml +++ b/Simplenote/src/main/res/values/strings.xml @@ -341,7 +341,7 @@ Email Address Accept Please enter a valid email address - Please enter an email address different than your account\'s email + You cannot add yourself as a collaborator Note was deleted. You cannot edit collaborators on a note that was deleted. Note was trashed. You cannot edit collaborators on a note that is in the trash. No Collaborators From 5da80b8fb68065af782dd84728618e92091b7657 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:35:27 -0500 Subject: [PATCH 08/18] Add blank end line for git --- Simplenote/src/main/res/layout/collaborators_header.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simplenote/src/main/res/layout/collaborators_header.xml b/Simplenote/src/main/res/layout/collaborators_header.xml index 52da49033..4cc68fed6 100644 --- a/Simplenote/src/main/res/layout/collaborators_header.xml +++ b/Simplenote/src/main/res/layout/collaborators_header.xml @@ -16,4 +16,4 @@ android:textColor="?attr/colorAccent" android:textSize="14sp" android:textStyle="normal" /> - \ No newline at end of file + From 97552205c3ba4921890189edf3408b818e41ede8 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:41:30 -0500 Subject: [PATCH 09/18] Add . to comments --- .../simplenote/viewmodels/AddCollaboratorViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt index de9f1872d..d3939e2cf 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt @@ -48,7 +48,7 @@ class AddCollaboratorViewModel @Inject constructor( private fun isCurrentUser(collaborator: String): Boolean { return when(val currentUser = sessionManager.getCurrentUser()) { is UserSession.AuthorizedUser -> currentUser.user.email == collaborator - is UserSession.UnauthorizedUser -> false // This should not happen + is UserSession.UnauthorizedUser -> false // This should not happen. } } From 861478e86ed3e869a4df1c9e2f45d973c330d102 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 15:53:15 -0500 Subject: [PATCH 10/18] Add test to validate whether the user is adding his account --- .../viewmodels/AddCollaboratorViewModelTest.kt | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModelTest.kt b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModelTest.kt index 48127f96d..b45d41a8d 100644 --- a/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModelTest.kt +++ b/Simplenote/src/test/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModelTest.kt @@ -1,10 +1,13 @@ package com.automattic.simplenote.viewmodels import androidx.arch.core.executor.testing.InstantTaskExecutorRule +import com.automattic.simplenote.authentication.SessionManager import com.automattic.simplenote.models.Note import com.automattic.simplenote.repositories.SimperiumCollaboratorsRepository +import com.simperium.Simperium import com.simperium.client.Bucket import com.simperium.client.BucketObjectMissingException +import com.simperium.client.User import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.TestCoroutineDispatcher import kotlinx.coroutines.test.runBlockingTest @@ -23,7 +26,8 @@ class AddCollaboratorViewModelTest { private val notesBucket = Mockito.mock(Bucket::class.java) as Bucket private val collaboratorsRepository = SimperiumCollaboratorsRepository(notesBucket, TestCoroutineDispatcher()) - private val viewModel = AddCollaboratorViewModel(collaboratorsRepository) + private val simperium = Mockito.mock(Simperium::class.java) + private val viewModel = AddCollaboratorViewModel(collaboratorsRepository, SessionManager(simperium)) private val noteId = "key1" private val note = Note(noteId).apply { @@ -35,6 +39,11 @@ class AddCollaboratorViewModelTest { @Before fun setup() { whenever(notesBucket.get(any())).thenReturn(note) + val user = User().apply { + email = "test@test.com" + accessToken = "124556" + } + whenever(simperium.user).thenReturn(user) } @Test @@ -69,6 +78,13 @@ class AddCollaboratorViewModelTest { assertEquals(AddCollaboratorViewModel.Event.NoteDeleted, viewModel.event.value) } + @Test + fun addSameAccountShouldTriggerCollaboratorCurrentUser() = runBlockingTest { + viewModel.addCollaborator(noteId, "test@test.com") + + assertEquals(AddCollaboratorViewModel.Event.CollaboratorCurrentUser, viewModel.event.value) + } + @Test fun closeShouldTriggerEventClose() { viewModel.close() From aa2f314192239ee97ca17ac7401fd2f89ad00609 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Mon, 27 Sep 2021 21:24:49 -0500 Subject: [PATCH 11/18] Add 4dp on image button to make a total of 16dp from right side --- Simplenote/src/main/res/layout/collaborator_row.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/Simplenote/src/main/res/layout/collaborator_row.xml b/Simplenote/src/main/res/layout/collaborator_row.xml index 4fc48ce04..6f32d849f 100644 --- a/Simplenote/src/main/res/layout/collaborator_row.xml +++ b/Simplenote/src/main/res/layout/collaborator_row.xml @@ -33,6 +33,7 @@ android:minHeight="11dp" android:minWidth="11dp" android:padding="@dimen/padding_medium" + android:layout_marginEnd="4dp" android:src="@drawable/ic_cross_24dp" android:tint="?attr/notePreviewColor"> From 98189e52ea227c629ef1b7612fd1f97831613944 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 10:07:12 -0500 Subject: [PATCH 12/18] Reduce 72dp to 16 dp in collaborator rows --- Simplenote/src/main/res/layout/activity_collaborators.xml | 1 - Simplenote/src/main/res/layout/collaborator_row.xml | 6 +++--- Simplenote/src/main/res/layout/collaborators_header.xml | 3 ++- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Simplenote/src/main/res/layout/activity_collaborators.xml b/Simplenote/src/main/res/layout/activity_collaborators.xml index c3d19dad4..b48ae6d6c 100644 --- a/Simplenote/src/main/res/layout/activity_collaborators.xml +++ b/Simplenote/src/main/res/layout/activity_collaborators.xml @@ -21,7 +21,6 @@ android:id="@+id/collaborators_list" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginStart="72dp" android:layout_marginBottom="10dp" android:background="@android:color/transparent" android:clipToPadding="false" diff --git a/Simplenote/src/main/res/layout/collaborator_row.xml b/Simplenote/src/main/res/layout/collaborator_row.xml index 6f32d849f..dd4ef5dd1 100644 --- a/Simplenote/src/main/res/layout/collaborator_row.xml +++ b/Simplenote/src/main/res/layout/collaborator_row.xml @@ -15,12 +15,12 @@ android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="0dp" + style="?android:attr/textAppearanceMedium" + android:layout_marginStart="@dimen/padding_large" android:textColor="?attr/noteTitleColor" tools:text="Test" - android:layout_marginEnd="@dimen/padding_small" android:textSize="16sp" - style="?android:attr/textAppearanceMedium"> - + android:layout_marginEnd="@dimen/padding_small" /> Date: Tue, 28 Sep 2021 10:36:30 -0500 Subject: [PATCH 13/18] Add collaborators menu to markdown fragment --- .../simplenote/NoteMarkdownFragment.java | 29 ++++++++++++++++--- .../src/main/res/menu/note_markdown.xml | 15 +++++++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java b/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java index a908d75e5..60d8a8a22 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java @@ -1,6 +1,11 @@ package com.automattic.simplenote; +import static com.automattic.simplenote.Simplenote.SCROLL_POSITION_PREFERENCES; +import static com.automattic.simplenote.analytics.AnalyticsTracker.CATEGORY_NOTE; +import static com.automattic.simplenote.utils.SimplenoteLinkify.SIMPLENOTE_LINK_PREFIX; + import android.content.Context; +import android.content.Intent; import android.content.SharedPreferences; import android.os.AsyncTask; import android.os.Bundle; @@ -41,9 +46,6 @@ import java.lang.ref.SoftReference; import java.util.Set; -import static com.automattic.simplenote.Simplenote.SCROLL_POSITION_PREFERENCES; -import static com.automattic.simplenote.utils.SimplenoteLinkify.SIMPLENOTE_LINK_PREFIX; - public class NoteMarkdownFragment extends Fragment implements Bucket.Listener { public static final String ARG_ITEM_ID = "item_id"; @@ -185,6 +187,9 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { case R.id.menu_delete: NoteUtils.showDialogDeletePermanently(requireActivity(), mNote); return true; + case R.id.menu_collaborators: + navigateToCollaborators(); + return true; case R.id.menu_trash: if (!isAdded()) { return false; @@ -194,7 +199,7 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { return true; case R.id.menu_copy_internal: AnalyticsTracker.track( - AnalyticsTracker.Stat.INTERNOTE_LINK_COPIED, + AnalyticsTracker.Stat.INTERNOTE_LINK_COPIED, AnalyticsTracker.CATEGORY_LINK, "internote_link_copied_markdown" ); @@ -215,6 +220,22 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { } } + private void navigateToCollaborators() { + if (getActivity() == null || mNote == null) { + return; + } + + Intent intent = new Intent(requireActivity(), CollaboratorsActivity.class); + intent.putExtra(CollaboratorsActivity.NOTE_ID_ARG, mNote.getSimperiumKey()); + startActivity(intent); + + AnalyticsTracker.track( + AnalyticsTracker.Stat.EDITOR_COLLABORATORS_ACCESSED, + CATEGORY_NOTE, + "collaborators_ui_accessed" + ); + } + private void deleteNote() { NoteUtils.deleteNote(mNote, getActivity()); requireActivity().finish(); diff --git a/Simplenote/src/main/res/menu/note_markdown.xml b/Simplenote/src/main/res/menu/note_markdown.xml index 1e5f87902..47d8c6993 100644 --- a/Simplenote/src/main/res/menu/note_markdown.xml +++ b/Simplenote/src/main/res/menu/note_markdown.xml @@ -81,16 +81,23 @@ android:checkable="true" android:enabled="false" android:title="@string/publish" - app:showAsAction="never"> - + app:showAsAction="never"> - + app:showAsAction="never"> + + + + + From 6a898bbae08dcdfd0e979691b9026fa4abba6413 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 10:56:34 -0500 Subject: [PATCH 14/18] Reformat new files added in this PR --- .../authentication/SessionManager.kt | 4 +- .../viewmodels/AddCollaboratorViewModel.kt | 6 +-- .../main/res/layout/collaborators_header.xml | 6 +-- .../main/res/layout/empty_view_message.xml | 42 +++++++++---------- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt b/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt index 2de457b2b..47c49debe 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/authentication/SessionManager.kt @@ -13,9 +13,9 @@ class SessionManager @Inject constructor(private val simperium: Simperium) { fun getCurrentUser(): UserSession { val currentUser = simperium.user ?: return UserSession.UnauthorizedUser - return when(currentUser.email != null && !currentUser.needsAuthorization()) { + return when (currentUser.email != null && !currentUser.needsAuthorization()) { true -> UserSession.AuthorizedUser(currentUser) false -> UserSession.UnauthorizedUser } } -} \ No newline at end of file +} diff --git a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt index d3939e2cf..f47d95c06 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/viewmodels/AddCollaboratorViewModel.kt @@ -21,7 +21,7 @@ class AddCollaboratorViewModel @Inject constructor( val event: LiveData = _event fun addCollaborator(noteId: String, collaborator: String) { - when(isCurrentUser(collaborator)) { + when (isCurrentUser(collaborator)) { true -> _event.value = Event.CollaboratorCurrentUser false -> viewModelScope.launch { when (collaboratorsRepository.isValidCollaborator(collaborator)) { @@ -46,11 +46,11 @@ class AddCollaboratorViewModel @Inject constructor( } private fun isCurrentUser(collaborator: String): Boolean { - return when(val currentUser = sessionManager.getCurrentUser()) { + return when (val currentUser = sessionManager.getCurrentUser()) { is UserSession.AuthorizedUser -> currentUser.user.email == collaborator is UserSession.UnauthorizedUser -> false // This should not happen. } - } + } fun close() { _event.value = Event.Close diff --git a/Simplenote/src/main/res/layout/collaborators_header.xml b/Simplenote/src/main/res/layout/collaborators_header.xml index 9e2108f80..66d530929 100644 --- a/Simplenote/src/main/res/layout/collaborators_header.xml +++ b/Simplenote/src/main/res/layout/collaborators_header.xml @@ -1,16 +1,16 @@ + android:layout_height="wrap_content" + android:orientation="vertical"> - - + android:tint="?attr/emptyImageColor" /> - + android:textColor="?attr/notePreviewColor" + android:textSize="@dimen/text_empty" /> - + tools:visibility="visible" /> From 991134021961f5ff28c287f48df99a656c5cb493 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 11:25:12 -0500 Subject: [PATCH 15/18] Refactor show and hiding empty view in recycler view Avoid hardcoded parameters in method calls and improve code quality --- .../simplenote/CollaboratorsActivity.kt | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt index 286056036..e61e65142 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt +++ b/Simplenote/src/main/java/com/automattic/simplenote/CollaboratorsActivity.kt @@ -7,7 +7,6 @@ import android.view.MenuItem import android.view.View import android.widget.Toast import androidx.activity.viewModels -import androidx.annotation.DrawableRes import androidx.appcompat.app.AlertDialog import androidx.appcompat.view.ContextThemeWrapper import androidx.appcompat.widget.Toolbar @@ -79,15 +78,10 @@ class CollaboratorsActivity : ThemedAppCompatActivity() { collaboratorsList.setEmptyView(empty.root) buttonAddCollaborator.setOnClickListener { viewModel.clickAddCollaborator() } - } - private fun ActivityCollaboratorsBinding.setEmptyListImage(@DrawableRes image: Int) { - if (image != -1) { - empty.image.visibility = View.VISIBLE - empty.image.setImageResource(image) - } else { - empty.image.visibility = View.GONE - } + empty.image.setImageResource(R.drawable.ic_collaborate_24dp) + empty.title.text = getString(R.string.no_collaborators) + empty.message.text = getString(R.string.add_email_collaborator_message) } private fun setupToolbar() { @@ -126,19 +120,26 @@ class CollaboratorsActivity : ThemedAppCompatActivity() { } private fun ActivityCollaboratorsBinding.handleCollaboratorsList(collaborators: List) { - setEmptyListImage(-1) - empty.message.visibility = View.GONE - + hideEmptyView() val items = listOf(HeaderItem) + collaborators.map { CollaboratorItem(it) } (collaboratorsList.adapter as CollaboratorsAdapter).submitList(items) } private fun ActivityCollaboratorsBinding.handleEmptyCollaborators() { + showEmptyView() (collaboratorsList.adapter as CollaboratorsAdapter).submitList(emptyList()) - setEmptyListImage(R.drawable.ic_collaborate_24dp) - empty.title.text = getString(R.string.no_collaborators) + } + + private fun ActivityCollaboratorsBinding.hideEmptyView() { + empty.image.visibility = View.GONE + empty.title.visibility = View.GONE + empty.message.visibility = View.GONE + } + + private fun ActivityCollaboratorsBinding.showEmptyView() { + empty.image.visibility = View.VISIBLE + empty.title.visibility = View.VISIBLE empty.message.visibility = View.VISIBLE - empty.message.text = getString(R.string.add_email_collaborator_message) } private fun showAddCollaboratorFragment(event: Event.AddCollaboratorEvent) { From 9aa1abb289892f2998133c367f2242f060e00600 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 11:47:17 -0500 Subject: [PATCH 16/18] Reformat layouts files to collapse certain tags --- .../res/layout/activity_collaborators.xml | 26 ++++++------- .../src/main/res/layout/activity_tags.xml | 26 ++++++------- .../src/main/res/menu/note_markdown.xml | 38 +++++++------------ 3 files changed, 36 insertions(+), 54 deletions(-) diff --git a/Simplenote/src/main/res/layout/activity_collaborators.xml b/Simplenote/src/main/res/layout/activity_collaborators.xml index b48ae6d6c..8ebf76e98 100644 --- a/Simplenote/src/main/res/layout/activity_collaborators.xml +++ b/Simplenote/src/main/res/layout/activity_collaborators.xml @@ -1,20 +1,17 @@ - - - + - + app:tint="?attr/fabIconColor" /> diff --git a/Simplenote/src/main/res/layout/activity_tags.xml b/Simplenote/src/main/res/layout/activity_tags.xml index ea943e453..dbe2b091e 100644 --- a/Simplenote/src/main/res/layout/activity_tags.xml +++ b/Simplenote/src/main/res/layout/activity_tags.xml @@ -1,20 +1,17 @@ - - - + - + app:tint="?attr/fabIconColor" /> diff --git a/Simplenote/src/main/res/menu/note_markdown.xml b/Simplenote/src/main/res/menu/note_markdown.xml index 47d8c6993..28ff28050 100644 --- a/Simplenote/src/main/res/menu/note_markdown.xml +++ b/Simplenote/src/main/res/menu/note_markdown.xml @@ -1,7 +1,6 @@ - @@ -18,76 +17,67 @@ android:enabled="false" android:icon="@drawable/ic_info_24dp" android:title="@string/information" - app:showAsAction="always"/> + app:showAsAction="always" /> - + - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + app:showAsAction="never" /> - + + app:showAsAction="never" /> + app:showAsAction="never" /> @@ -97,7 +87,7 @@ android:id="@+id/menu_collaborators" android:enabled="true" android:title="@string/collaborators" - app:showAsAction="never"> + app:showAsAction="never" /> From c0c9db1a3608c9121085311ce1fb3f661c0c13eb Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 12:10:58 -0500 Subject: [PATCH 17/18] Add tests for SessionManager --- .../authentication/SessionManagerTest.kt | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Simplenote/src/test/java/com/automattic/simplenote/authentication/SessionManagerTest.kt diff --git a/Simplenote/src/test/java/com/automattic/simplenote/authentication/SessionManagerTest.kt b/Simplenote/src/test/java/com/automattic/simplenote/authentication/SessionManagerTest.kt new file mode 100644 index 000000000..f43d47ac6 --- /dev/null +++ b/Simplenote/src/test/java/com/automattic/simplenote/authentication/SessionManagerTest.kt @@ -0,0 +1,48 @@ +package com.automattic.simplenote.authentication + +import com.simperium.Simperium +import com.simperium.client.User +import org.junit.Assert.assertEquals +import org.junit.Test +import org.mockito.Mockito +import org.mockito.kotlin.whenever + +class SessionManagerTest { + private val simperium = Mockito.mock(Simperium::class.java) + private val sessionManager = SessionManager(simperium) + + @Test + fun whenUserHasTokenShouldReturnAuthorizedUser() { + val user = User().apply { + email = "test@test.com" + accessToken = "124556" + } + whenever(simperium.user).thenReturn(user) + + val result = sessionManager.getCurrentUser() + + assertEquals(UserSession.AuthorizedUser(user), result) + } + + @Test + fun whenUserDoesNotHasTokenShouldReturnUnauthorizedUser() { + val user = User().apply { + email = "test@test.com" + accessToken = null + } + whenever(simperium.user).thenReturn(user) + + val result = sessionManager.getCurrentUser() + + assertEquals(UserSession.UnauthorizedUser, result) + } + + @Test + fun whenUserIsNullShouldReturnUnauthorizedUser() { + whenever(simperium.user).thenReturn(null) + + val result = sessionManager.getCurrentUser() + + assertEquals(UserSession.UnauthorizedUser, result) + } +} \ No newline at end of file From 675ed916a8a3a68c3597e97d620adcdcbd149ce6 Mon Sep 17 00:00:00 2001 From: danilodominguezperez Date: Tue, 28 Sep 2021 12:13:37 -0500 Subject: [PATCH 18/18] Keep old format in case --- .../java/com/automattic/simplenote/NoteMarkdownFragment.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java b/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java index 60d8a8a22..5421fd26b 100644 --- a/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java +++ b/Simplenote/src/main/java/com/automattic/simplenote/NoteMarkdownFragment.java @@ -200,8 +200,8 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { case R.id.menu_copy_internal: AnalyticsTracker.track( AnalyticsTracker.Stat.INTERNOTE_LINK_COPIED, - AnalyticsTracker.CATEGORY_LINK, - "internote_link_copied_markdown" + AnalyticsTracker.CATEGORY_LINK, + "internote_link_copied_markdown" ); if (!isAdded()) {