From c86f7a2b4ee583dded987501305d926785d39746 Mon Sep 17 00:00:00 2001 From: aman-alfresco <87360222+aman-alfresco@users.noreply.github.com> Date: Thu, 12 May 2022 00:19:42 +0530 Subject: [PATCH 1/5] fixed issue of same folder is visible while moving in the list --- .../content/actions/ActionMoveFilesFolders.kt | 2 +- .../content/actions/ActionMoveFragment.kt | 14 ++++--- .../content/actions/MoveResultContract.kt | 6 ++- .../content/app/activity/MoveActivity.kt | 12 ++++++ .../main/res/navigation/nav_move_paths.xml | 26 ++++++++----- .../alfresco/content/browse/BrowseFragment.kt | 3 ++ .../content/browse/BrowseViewState.kt | 5 ++- .../com/alfresco/content/FragmentExt.kt | 37 ++++++++++++++++++- .../com/alfresco/content/NavControllerExt.kt | 18 +++++---- .../content/move/BrowseMoveFragment.kt | 11 ++++-- .../com/alfresco/content/move/MoveFragment.kt | 13 +++++-- .../alfresco/content/search/SearchFragment.kt | 3 ++ .../content/search/SearchResultsState.kt | 7 ++-- 13 files changed, 118 insertions(+), 39 deletions(-) diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFilesFolders.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFilesFolders.kt index 6e01508f4..e403716d2 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFilesFolders.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFilesFolders.kt @@ -19,7 +19,7 @@ data class ActionMoveFilesFolders( override suspend fun execute(context: Context): Entry { - val result = ActionMoveFragment.moveItem(context) + val result = ActionMoveFragment.moveItem(context, entry) if (!result.isNullOrEmpty()) { withContext(Dispatchers.IO) { BrowseRepository().moveNode(entry.id, result) diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFragment.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFragment.kt index 7293e56cf..9706b0570 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFragment.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ActionMoveFragment.kt @@ -4,21 +4,22 @@ import android.content.Context import android.os.Bundle import androidx.activity.result.ActivityResultLauncher import androidx.fragment.app.Fragment -import com.alfresco.content.withFragment +import com.alfresco.content.data.Entry +import com.alfresco.content.withNewFragment import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine /** * Mark as ActionMoveFragment */ -class ActionMoveFragment : Fragment() { +class ActionMoveFragment(private val entryObj: Entry?) : Fragment() { private lateinit var requestLauncher: ActivityResultLauncher private var onResult: CancellableContinuation? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - requestLauncher = registerForActivityResult(MoveResultContract()) { + requestLauncher = registerForActivityResult(MoveResultContract(entryObj)) { onResult?.resume(it, null) } } @@ -36,13 +37,14 @@ class ActionMoveFragment : Fragment() { * Generating ActionMoveFragment */ suspend fun moveItem( - context: Context + context: Context, + entry: Entry ): String? = - withFragment( + withNewFragment( context, TAG, { it.moveItems() }, - { ActionMoveFragment() } + { ActionMoveFragment(entry) } ) } } diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/MoveResultContract.kt b/actions/src/main/kotlin/com/alfresco/content/actions/MoveResultContract.kt index 769cc827f..305020064 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/MoveResultContract.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/MoveResultContract.kt @@ -5,13 +5,15 @@ import android.content.Context import android.content.Intent import androidx.activity.result.contract.ActivityResultContract import androidx.annotation.CallSuper +import com.alfresco.content.data.Entry /** * Mark as MoveResultContract */ -class MoveResultContract : ActivityResultContract() { +class MoveResultContract(private val entryObj: Entry?) : ActivityResultContract() { @CallSuper override fun createIntent(context: Context, input: Unit): Intent { + intent.putExtra(ENTRY_OBJ_KEY, entryObj) return intent } @@ -22,6 +24,8 @@ class MoveResultContract : ActivityResultContract() { companion object { const val OUTPUT_KEY = "targetParentId" + const val ENTRY_OBJ_KEY = "entryObj" + const val MOVE_ID_KEY = "moveId" lateinit var intent: Intent /** diff --git a/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt b/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt index db1e00604..4cdb8f527 100644 --- a/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt +++ b/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt @@ -11,9 +11,11 @@ import com.airbnb.mvrx.MavericksView import com.airbnb.mvrx.withState import com.alfresco.auth.activity.LoginViewModel import com.alfresco.content.actions.Action +import com.alfresco.content.actions.MoveResultContract.Companion.ENTRY_OBJ_KEY import com.alfresco.content.activityViewModel import com.alfresco.content.app.R import com.alfresco.content.app.widget.ActionBarController +import com.alfresco.content.data.Entry import com.alfresco.content.session.SessionManager import com.google.android.material.dialog.MaterialAlertDialogBuilder import java.lang.ref.WeakReference @@ -28,18 +30,28 @@ class MoveActivity : AppCompatActivity(), MavericksView { private val bottomView by lazy { findViewById(R.id.bottom_view) } private lateinit var actionBarController: ActionBarController private var signedOutDialog = WeakReference(null) + private var entryObj: Entry? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_move) + if (intent.extras != null) { + entryObj = intent.getParcelableExtra(ENTRY_OBJ_KEY) as Entry? + } + configure() } + override fun onNewIntent(intent: Intent?) { + super.onNewIntent(intent) + } + private fun configure() { val graph = navController.navInflater.inflate(R.navigation.nav_move_paths) graph.startDestination = R.id.nav_move val bundle = Bundle().apply { + putParcelable(ENTRY_OBJ_KEY, entryObj) } navController.setGraph(graph, bundle) setupActionToasts() diff --git a/app/src/main/res/navigation/nav_move_paths.xml b/app/src/main/res/navigation/nav_move_paths.xml index 0b3222525..9b8e06e76 100644 --- a/app/src/main/res/navigation/nav_move_paths.xml +++ b/app/src/main/res/navigation/nav_move_paths.xml @@ -10,16 +10,12 @@ android:label=""> - - + android:name="entryObj" + app:argType="com.alfresco.content.data.Entry" /> @@ -34,12 +30,15 @@ + - + @@ -54,12 +53,15 @@ + - + @@ -81,7 +83,11 @@ app:argType="boolean" android:defaultValue="false"/> - + + + diff --git a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt index c3d2dd6ec..a1ad04a25 100644 --- a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt +++ b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt @@ -20,6 +20,7 @@ import androidx.transition.TransitionManager import androidx.transition.TransitionSet import com.airbnb.mvrx.withState import com.alfresco.content.actions.CreateActionsSheet +import com.alfresco.content.actions.MoveResultContract.Companion.MOVE_ID_KEY import com.alfresco.content.data.Entry import com.alfresco.content.fragmentViewModelWithArgs import com.alfresco.content.listview.ListFragment @@ -34,6 +35,7 @@ import kotlinx.parcelize.Parcelize data class BrowseArgs( val path: String, val id: String?, + val moveId: String, val title: String? ) : Parcelable { companion object { @@ -45,6 +47,7 @@ data class BrowseArgs( return BrowseArgs( args.getString(PATH_KEY, ""), args.getString(ID_KEY, null), + args.getString(MOVE_ID_KEY, ""), args.getString(TITLE_KEY, null) ) } diff --git a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseViewState.kt b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseViewState.kt index 450db1a8b..99bb910c8 100644 --- a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseViewState.kt +++ b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseViewState.kt @@ -16,6 +16,7 @@ import java.time.temporal.ChronoField data class BrowseViewState( val path: String, val nodeId: String?, + val moveId: String, val parent: Entry? = null, override val entries: List = emptyList(), override val hasMoreItems: Boolean = false, @@ -26,7 +27,7 @@ data class BrowseViewState( val totalTransfersSize: Int = 0 ) : ListViewState { - constructor(args: BrowseArgs) : this(args.path, args.id) + constructor(args: BrowseArgs) : this(args.path, args.id, args.moveId) override val isCompact: Boolean get() = when (path) { @@ -40,7 +41,7 @@ data class BrowseViewState( if (response == null) return this val nextPage = response.pagination.skipCount > 0 - val pageEntries = response.entries + val pageEntries = response.entries.filter { it.id != moveId } val newEntries = if (nextPage) { baseEntries + pageEntries } else { diff --git a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt index 7c4e74093..10a515a9d 100644 --- a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt @@ -3,7 +3,6 @@ package com.alfresco.content import android.content.Context import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment -import java.lang.ClassCastException import kotlinx.coroutines.CancellableContinuation import kotlinx.coroutines.suspendCancellableCoroutine @@ -21,6 +20,16 @@ suspend fun withFragment( findFragmentAndResume(context, tag, continuation, factory) }) +suspend fun withNewFragment( + context: Context, + tag: String, + lambda: suspend (F) -> R, + factory: () -> F +): R = + lambda(suspendCancellableCoroutine { continuation -> + loadFragment(context, tag, continuation, factory) + }) + private fun findFragmentAndResume( context: Context, tag: String, @@ -52,3 +61,29 @@ private fun findFragmentAndResume( }.commit() } } + +private fun loadFragment( + context: Context, + tag: String, + continuation: CancellableContinuation, + factory: () -> F +) { + val fragmentManager = when (context) { + is AppCompatActivity -> context.supportFragmentManager + is Fragment -> context.childFragmentManager + else -> null + } + + if (fragmentManager == null) { + continuation.cancel(ClassCastException()) + return + } + + val fragment = factory() + fragmentManager.beginTransaction().add( + fragment, + tag + ).runOnCommit { + continuation.resume(fragment, null) + }.commit() +} diff --git a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt index 5a8b4e68d..a5220f6ac 100644 --- a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt @@ -18,10 +18,14 @@ fun NavController.navigateTo(entry: Entry) { private fun NavController.navigateToFolder(entry: Entry) { if (entry.isExtension) - navigateToChildFolder(entry.id, entry.name, modeFor(entry)) + navigateToChildFolder(entry.id, entry.name, mode = modeFor(entry)) else navigateToFolder(entry.id, entry.name, modeFor(entry)) } +fun NavController.navigateToFolder(entry: Entry, moveId: String) { + navigateToChildFolder(entry.id, entry.name, moveId, modeFor(entry)) +} + private fun modeFor(entry: Entry) = if (entry.hasOfflineStatus) { "local" @@ -48,8 +52,8 @@ private fun NavController.navigateFileLink(entry: Entry) = private fun NavController.navigateFolderLink(entry: Entry) = navigate(Uri.parse("$BASE_URI/browse/folder/$REMOTE/${entry.otherId}?title=${Uri.encode(entry.name)}")) -fun NavController.navigateToContextualSearch(id: String, title: String, isExtension: Boolean) = - navigate(Uri.parse("$BASE_URI/search/folder/$id/$isExtension?title=${Uri.encode(title)}")) +fun NavController.navigateToContextualSearch(id: String, title: String, isExtension: Boolean, moveId: String = "") = + navigate(Uri.parse("$BASE_URI/search/folder/$id/$isExtension/$moveId?title=${Uri.encode(title)}")) /** * navigate to browse parent folder @@ -61,15 +65,15 @@ fun NavController.navigateToParent(id: String, title: String, mode: String = REM /** * navigate to browse move parent folder */ -fun NavController.navigateToMoveParent(id: String, title: String, mode: String = REMOTE) { - navigate(Uri.parse("$BASE_URI/browse_move_parent/move/$mode/$id?title=${Uri.encode(title)}")) +fun NavController.navigateToMoveParent(id: String, moveId: String, title: String, mode: String = REMOTE) { + navigate(Uri.parse("$BASE_URI/browse_move_parent/move/$mode/$id/$moveId?title=${Uri.encode(title)}")) } /** * navigate to browse child folder */ -fun NavController.navigateToChildFolder(id: String, title: String, mode: String = REMOTE) { - navigate(Uri.parse("$BASE_URI/browse_child/extension/$mode/$id?title=${Uri.encode(title)}")) +fun NavController.navigateToChildFolder(id: String, title: String, moveId: String = "", mode: String = REMOTE) { + navigate(Uri.parse("$BASE_URI/browse_child/extension/$mode/$id/$moveId?title=${Uri.encode(title)}")) } /** diff --git a/move/src/main/java/com/alfresco/content/move/BrowseMoveFragment.kt b/move/src/main/java/com/alfresco/content/move/BrowseMoveFragment.kt index f93914070..b27070119 100644 --- a/move/src/main/java/com/alfresco/content/move/BrowseMoveFragment.kt +++ b/move/src/main/java/com/alfresco/content/move/BrowseMoveFragment.kt @@ -16,8 +16,8 @@ import com.alfresco.content.browse.BrowseViewState import com.alfresco.content.data.Entry import com.alfresco.content.fragmentViewModelWithArgs import com.alfresco.content.listview.ListFragment -import com.alfresco.content.navigateTo import com.alfresco.content.navigateToContextualSearch +import com.alfresco.content.navigateToFolder /** * Mark as BrowseMoveFragment @@ -62,7 +62,9 @@ class BrowseMoveFragment : ListFragment(R.layo override fun onOptionsItemSelected(item: MenuItem): Boolean { return when (item.itemId) { R.id.search -> { - findNavController().navigateToContextualSearch(args.id ?: "", args.title ?: "", true) + withState(viewModel) { state -> + findNavController().navigateToContextualSearch(args.id ?: "", args.title ?: "", true, state.moveId) + } true } R.id.new_folder -> { @@ -86,7 +88,8 @@ class BrowseMoveFragment : ListFragment(R.layo */ override fun onItemClicked(entry: Entry) { if (!entry.isFolder) return - - findNavController().navigateTo(entry) + withState(viewModel) { state -> + findNavController().navigateToFolder(entry, state.moveId) + } } } diff --git a/move/src/main/java/com/alfresco/content/move/MoveFragment.kt b/move/src/main/java/com/alfresco/content/move/MoveFragment.kt index f481c2a92..a4a9c03ca 100644 --- a/move/src/main/java/com/alfresco/content/move/MoveFragment.kt +++ b/move/src/main/java/com/alfresco/content/move/MoveFragment.kt @@ -6,6 +6,7 @@ import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import com.airbnb.mvrx.MavericksView import com.airbnb.mvrx.withState +import com.alfresco.content.data.Entry import com.alfresco.content.fragmentViewModelWithArgs import com.alfresco.content.navigateToMoveParent import kotlinx.parcelize.Parcelize @@ -15,17 +16,20 @@ import kotlinx.parcelize.Parcelize */ @Parcelize data class MoveArgs( - val path: String + val path: String, + val entryObj: Entry? ) : Parcelable { companion object { private const val PATH_KEY = "path" + private const val ENTRY_OBJ_KEY = "entryObj" /** * return the MoveArgs obj */ fun with(args: Bundle): MoveArgs { return MoveArgs( - args.getString(PATH_KEY, "") + args.getString(PATH_KEY, ""), + args.getParcelable(ENTRY_OBJ_KEY) ) } } @@ -44,8 +48,9 @@ class MoveFragment : Fragment(), MavericksView { args = MoveArgs.with(requireArguments()) val nodeId = viewModel.getMyFilesNodeId() - - findNavController().navigateToMoveParent(nodeId, "Personal Files") + args.entryObj?.let { + findNavController().navigateToMoveParent(nodeId, it.id, "Personal Files") + } } override fun invalidate() = withState(viewModel) { state -> diff --git a/search/src/main/kotlin/com/alfresco/content/search/SearchFragment.kt b/search/src/main/kotlin/com/alfresco/content/search/SearchFragment.kt index 240396c2a..5a265a31d 100644 --- a/search/src/main/kotlin/com/alfresco/content/search/SearchFragment.kt +++ b/search/src/main/kotlin/com/alfresco/content/search/SearchFragment.kt @@ -46,18 +46,21 @@ import kotlinx.parcelize.Parcelize data class ContextualSearchArgs( val id: String?, val title: String?, + val moveId: String, val isExtension: Boolean ) : Parcelable { companion object { private const val ID_KEY = "id" private const val TITLE_KEY = "title" private const val EXTENSION_KEY = "extension" + private const val MOVE_ID_KEY = "moveId" fun with(args: Bundle?): ContextualSearchArgs? { if (args == null) return null return ContextualSearchArgs( args.getString(ID_KEY, null), args.getString(TITLE_KEY, null), + args.getString(MOVE_ID_KEY, null), args.getBoolean(EXTENSION_KEY, false) ) } diff --git a/search/src/main/kotlin/com/alfresco/content/search/SearchResultsState.kt b/search/src/main/kotlin/com/alfresco/content/search/SearchResultsState.kt index 9ae07d0f8..6eaaed29c 100644 --- a/search/src/main/kotlin/com/alfresco/content/search/SearchResultsState.kt +++ b/search/src/main/kotlin/com/alfresco/content/search/SearchResultsState.kt @@ -34,10 +34,11 @@ data class SearchResultsState( val filters: SearchFilters = emptyFilters(), val contextId: String? = null, val contextTitle: String? = null, - val isExtension: Boolean = false + val isExtension: Boolean = false, + val moveId: String ) : ListViewState { - constructor(args: ContextualSearchArgs) : this(contextId = args.id, contextTitle = args.title, isExtension = args.isExtension) + constructor(args: ContextualSearchArgs) : this(contextId = args.id, contextTitle = args.title, isExtension = args.isExtension, moveId = args.moveId) val isContextual: Boolean get() { @@ -56,7 +57,7 @@ data class SearchResultsState( if (response == null) return this val nextPage = response.pagination.skipCount > 0 - val pageEntries = response.entries + val pageEntries = response.entries.filter { it.id != moveId } val newEntries = if (nextPage) { entries + pageEntries } else { From 23257ec1b9954250e0c8fe4cb94a8c07670fe64a Mon Sep 17 00:00:00 2001 From: aman-alfresco <87360222+aman-alfresco@users.noreply.github.com> Date: Thu, 12 May 2022 00:33:19 +0530 Subject: [PATCH 2/5] codacy correction --- common/src/main/kotlin/com/alfresco/content/FragmentExt.kt | 3 +++ .../main/kotlin/com/alfresco/content/NavControllerExt.kt | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt index 10a515a9d..485d6f01a 100644 --- a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt @@ -62,6 +62,9 @@ private fun findFragmentAndResume( } } +/** + * Load new instance of fragment + */ private fun loadFragment( context: Context, tag: String, diff --git a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt index a5220f6ac..9f65e17c4 100644 --- a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt @@ -33,6 +33,9 @@ private fun modeFor(entry: Entry) = REMOTE } +/** + * navigate to move screen + */ fun NavController.navigateToFolder(id: String, title: String, mode: String = REMOTE) { navigate(Uri.parse("$BASE_URI/browse/folder/$mode/$id?title=${Uri.encode(title)}")) } @@ -52,6 +55,9 @@ private fun NavController.navigateFileLink(entry: Entry) = private fun NavController.navigateFolderLink(entry: Entry) = navigate(Uri.parse("$BASE_URI/browse/folder/$REMOTE/${entry.otherId}?title=${Uri.encode(entry.name)}")) +/** + * navigate to contextual search + */ fun NavController.navigateToContextualSearch(id: String, title: String, isExtension: Boolean, moveId: String = "") = navigate(Uri.parse("$BASE_URI/search/folder/$id/$isExtension/$moveId?title=${Uri.encode(title)}")) From 2319af2c49fe49de2e30bd5cbc7f4862cbe87b28 Mon Sep 17 00:00:00 2001 From: aman-alfresco <87360222+aman-alfresco@users.noreply.github.com> Date: Thu, 12 May 2022 09:32:23 +0530 Subject: [PATCH 3/5] codacy correction --- common/src/main/kotlin/com/alfresco/content/FragmentExt.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt index 485d6f01a..3ead1528c 100644 --- a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt @@ -27,7 +27,7 @@ suspend fun withNewFragment( factory: () -> F ): R = lambda(suspendCancellableCoroutine { continuation -> - loadFragment(context, tag, continuation, factory) + findNewFragmentInstance(context, tag, continuation, factory) }) private fun findFragmentAndResume( @@ -63,9 +63,9 @@ private fun findFragmentAndResume( } /** - * Load new instance of fragment + * finding new instance of fragment */ -private fun loadFragment( +private fun findNewFragmentInstance( context: Context, tag: String, continuation: CancellableContinuation, From 7d8404c3c32119e3cb2c3a58938713f2ff6750c7 Mon Sep 17 00:00:00 2001 From: aman-alfresco <87360222+aman-alfresco@users.noreply.github.com> Date: Thu, 12 May 2022 09:41:46 +0530 Subject: [PATCH 4/5] codacy correction --- .../src/main/kotlin/com/alfresco/content/FragmentExt.kt | 8 ++++++-- .../main/kotlin/com/alfresco/content/NavControllerExt.kt | 6 +++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt index 3ead1528c..11dfff0a7 100644 --- a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt @@ -20,6 +20,10 @@ suspend fun withFragment( findFragmentAndResume(context, tag, continuation, factory) }) +/** + * Calls the specified [lambda] with the a [F] fragment as the receiver and returns its result. + * creates [F] fragment new instance using [factory]. + */ suspend fun withNewFragment( context: Context, tag: String, @@ -27,7 +31,7 @@ suspend fun withNewFragment( factory: () -> F ): R = lambda(suspendCancellableCoroutine { continuation -> - findNewFragmentInstance(context, tag, continuation, factory) + findFragment(context, tag, continuation, factory) }) private fun findFragmentAndResume( @@ -65,7 +69,7 @@ private fun findFragmentAndResume( /** * finding new instance of fragment */ -private fun findNewFragmentInstance( +private fun findFragment( context: Context, tag: String, continuation: CancellableContinuation, diff --git a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt index 9f65e17c4..481292e32 100644 --- a/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/NavControllerExt.kt @@ -22,6 +22,9 @@ private fun NavController.navigateToFolder(entry: Entry) { else navigateToFolder(entry.id, entry.name, modeFor(entry)) } +/** + * navigate to move screen + */ fun NavController.navigateToFolder(entry: Entry, moveId: String) { navigateToChildFolder(entry.id, entry.name, moveId, modeFor(entry)) } @@ -33,9 +36,6 @@ private fun modeFor(entry: Entry) = REMOTE } -/** - * navigate to move screen - */ fun NavController.navigateToFolder(id: String, title: String, mode: String = REMOTE) { navigate(Uri.parse("$BASE_URI/browse/folder/$mode/$id?title=${Uri.encode(title)}")) } From b2d7d77151b96add13f1407fda4d69181b7f6bdf Mon Sep 17 00:00:00 2001 From: aman-alfresco <87360222+aman-alfresco@users.noreply.github.com> Date: Thu, 12 May 2022 10:32:45 +0530 Subject: [PATCH 5/5] codacy correction --- .../java/com/alfresco/content/app/activity/MoveActivity.kt | 4 ---- common/src/main/kotlin/com/alfresco/content/FragmentExt.kt | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt b/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt index 4cdb8f527..31e7c934c 100644 --- a/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt +++ b/app/src/main/java/com/alfresco/content/app/activity/MoveActivity.kt @@ -43,10 +43,6 @@ class MoveActivity : AppCompatActivity(), MavericksView { configure() } - override fun onNewIntent(intent: Intent?) { - super.onNewIntent(intent) - } - private fun configure() { val graph = navController.navInflater.inflate(R.navigation.nav_move_paths) graph.startDestination = R.id.nav_move diff --git a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt index 11dfff0a7..ed08e0621 100644 --- a/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt +++ b/common/src/main/kotlin/com/alfresco/content/FragmentExt.kt @@ -31,7 +31,7 @@ suspend fun withNewFragment( factory: () -> F ): R = lambda(suspendCancellableCoroutine { continuation -> - findFragment(context, tag, continuation, factory) + findNewInstance(context, tag, continuation, factory) }) private fun findFragmentAndResume( @@ -69,7 +69,7 @@ private fun findFragmentAndResume( /** * finding new instance of fragment */ -private fun findFragment( +private fun findNewInstance( context: Context, tag: String, continuation: CancellableContinuation,