diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt index 9c003f59..e7107c99 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsBarFragment.kt @@ -14,9 +14,12 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.alfresco.content.actions.sheet.ProcessDefinitionsSheet import com.alfresco.content.common.EntryListener +import com.alfresco.content.data.CommonRepository.Companion.KEY_FEATURES_MOBILE import com.alfresco.content.data.ContextualActionData import com.alfresco.content.data.Entry +import com.alfresco.content.data.MobileConfigDataEntry import com.alfresco.content.data.ParentEntry +import com.alfresco.content.data.getJsonFromSharedPrefs import com.alfresco.events.on import com.alfresco.ui.getDrawableForAttribute import kotlinx.coroutines.delay @@ -24,6 +27,8 @@ import kotlinx.coroutines.delay class ContextualActionsBarFragment : Fragment(), MavericksView, EntryListener { private val viewModel: ContextualActionsViewModel by fragmentViewModel() private lateinit var view: LinearLayout + var mobileConfigData: MobileConfigDataEntry? = null + var menuActionEnabled = false override fun onCreateView( inflater: LayoutInflater, @@ -39,6 +44,10 @@ class ContextualActionsBarFragment : Fragment(), MavericksView, EntryListener { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) + mobileConfigData = getJsonFromSharedPrefs(requireContext(), KEY_FEATURES_MOBILE) + val menus = mobileConfigData?.featuresMobile?.menus ?: emptyList() + menuActionEnabled = menus.isEmpty() || menus.any { it.enabled } + lifecycleScope.on { // delayed back to present the toast delay(1000) @@ -52,8 +61,10 @@ class ContextualActionsBarFragment : Fragment(), MavericksView, EntryListener { (requireActivity() as AppCompatActivity).supportActionBar?.title = entry.name - view.removeAllViews() - addButtons(view, it.topActions, entry) + if (menuActionEnabled) { + view.removeAllViews() + addButtons(view, it.topActions, entry) + } } private fun addButtons(container: LinearLayout, actions: List, entry: Entry) { @@ -122,7 +133,12 @@ class ContextualActionsBarFragment : Fragment(), MavericksView, EntryListener { setImageResource(R.drawable.ic_more_vert) setOnClickListener { withState(viewModel) { state -> - ContextualActionsSheet.with(ContextualActionData.withEntries(state.entries)).show(childFragmentManager, null) + ContextualActionsSheet.with( + ContextualActionData.withEntries( + state.entries, + mobileConfigData = mobileConfigData, + ), + ).show(childFragmentManager, null) } } } diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsSheet.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsSheet.kt index 93c1584f..d16f3e38 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsSheet.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsSheet.kt @@ -54,10 +54,18 @@ class ContextualActionsSheet : BottomSheetDialogFragment(), MavericksView { setHeader(state) binding.recyclerView.withModels { - if (state.actions.isEmpty()) { + if (state.actions == null) { actionListLoading { id("loading") } } - state.actions.forEach { + if (state.actions?.isEmpty() == true) { + val error = Pair(R.string.no_actions_available_title, R.string.no_actions_available_message) + viewEmptyMessage { + id("empty_message") + title(error.first) + message(error.second) + } + } + state.actions?.forEach { val entry = it.entry as Entry actionListRow { id(it.title) diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsState.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsState.kt index a6a743ce..c1071699 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsState.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ContextualActionsState.kt @@ -10,7 +10,7 @@ import com.alfresco.content.data.Entry data class ContextualActionsState( val entries: List = emptyList(), val isMultiSelection: Boolean = false, - val actions: List = emptyList(), + val actions: List? = null, val topActions: List = emptyList(), val fetch: Async = Uninitialized, val appMenu: List? = null, diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/ViewEmptyMessage.kt b/actions/src/main/kotlin/com/alfresco/content/actions/ViewEmptyMessage.kt new file mode 100644 index 00000000..be8c78c6 --- /dev/null +++ b/actions/src/main/kotlin/com/alfresco/content/actions/ViewEmptyMessage.kt @@ -0,0 +1,30 @@ +package com.alfresco.content.actions + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import android.widget.FrameLayout +import androidx.annotation.StringRes +import com.airbnb.epoxy.ModelProp +import com.airbnb.epoxy.ModelView +import com.alfresco.content.actions.databinding.ViewEmptyMessageBinding + +@ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT) +class ViewEmptyMessage @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0, +) : FrameLayout(context, attrs, defStyleAttr) { + + private val binding = ViewEmptyMessageBinding.inflate(LayoutInflater.from(context), this) + + @ModelProp + fun setTitle(@StringRes stringRes: Int) { + binding.title.text = resources.getText(stringRes) + } + + @ModelProp + fun setMessage(@StringRes stringRes: Int) { + binding.message.text = resources.getText(stringRes) + } +} diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewProcessErrorMessage.kt b/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewErrorMessage.kt similarity index 94% rename from actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewProcessErrorMessage.kt rename to actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewErrorMessage.kt index 4c123312..323961dc 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewProcessErrorMessage.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ListViewErrorMessage.kt @@ -11,7 +11,7 @@ import com.airbnb.epoxy.ModelView import com.alfresco.content.actions.databinding.ViewListProcessMessageBinding @ModelView(autoLayout = ModelView.Size.MATCH_WIDTH_MATCH_HEIGHT) -class ListViewProcessErrorMessage @JvmOverloads constructor( +class ListViewErrorMessage @JvmOverloads constructor( context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, diff --git a/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ProcessDefinitionsSheet.kt b/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ProcessDefinitionsSheet.kt index fb5dcb26..58de0001 100644 --- a/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ProcessDefinitionsSheet.kt +++ b/actions/src/main/kotlin/com/alfresco/content/actions/sheet/ProcessDefinitionsSheet.kt @@ -67,7 +67,7 @@ class ProcessDefinitionsSheet : BottomSheetDialogFragment(), MavericksView { } if (state.listProcessDefinitions?.isEmpty() == true) { val args = viewModel.emptyMessageArgs() - listViewProcessErrorMessage { + listViewErrorMessage { id("empty_message") iconRes(args.first) title(args.second) diff --git a/actions/src/main/res/layout/view_empty_message.xml b/actions/src/main/res/layout/view_empty_message.xml new file mode 100644 index 00000000..966603f6 --- /dev/null +++ b/actions/src/main/res/layout/view_empty_message.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + diff --git a/actions/src/main/res/values/strings.xml b/actions/src/main/res/values/strings.xml index 9ce12cc4..8fc9bea9 100644 --- a/actions/src/main/res/values/strings.xml +++ b/actions/src/main/res/values/strings.xml @@ -94,4 +94,7 @@ Workflows unavailable! Workflows will appear here when created. + No Actions Available> + Contact your administrator for help.> + diff --git a/listview/src/main/kotlin/com/alfresco/content/listview/ListFragment.kt b/listview/src/main/kotlin/com/alfresco/content/listview/ListFragment.kt index a7840c04..abe97567 100644 --- a/listview/src/main/kotlin/com/alfresco/content/listview/ListFragment.kt +++ b/listview/src/main/kotlin/com/alfresco/content/listview/ListFragment.kt @@ -202,8 +202,6 @@ abstract class ListFragment, S : ListViewState>(layoutID: val menus = getJsonFromSharedPrefs(requireContext(), KEY_FEATURES_MOBILE)?.featuresMobile ?.menus - println("ListFragment.onViewCreated === ${menus?.size}") - menuActionsEnabled = menus?.isEmpty() == true || menus?.any { it.enabled } == true loadingAnimation = view.findViewById(R.id.loading_animation) @@ -383,6 +381,11 @@ abstract class ListFragment, S : ListViewState>(layoutID: open fun onItemLongClicked(entry: Entry) {} open fun onItemMoreClicked(entry: Entry) { - ContextualActionsSheet.with(ContextualActionData.withEntries(listOf(entry), mobileConfigData = getJsonFromSharedPrefs(requireContext(), KEY_FEATURES_MOBILE))).show(childFragmentManager, null) + ContextualActionsSheet.with( + ContextualActionData.withEntries( + listOf(entry), + mobileConfigData = getJsonFromSharedPrefs(requireContext(), KEY_FEATURES_MOBILE), + ), + ).show(childFragmentManager, null) } } diff --git a/viewer/src/main/kotlin/com/alfresco/content/viewer/ViewerFragment.kt b/viewer/src/main/kotlin/com/alfresco/content/viewer/ViewerFragment.kt index e6efa28c..f2e11892 100644 --- a/viewer/src/main/kotlin/com/alfresco/content/viewer/ViewerFragment.kt +++ b/viewer/src/main/kotlin/com/alfresco/content/viewer/ViewerFragment.kt @@ -15,8 +15,11 @@ import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.MavericksView import com.airbnb.mvrx.withState import com.alfresco.content.actions.ContextualActionsBarFragment +import com.alfresco.content.data.CommonRepository.Companion.KEY_FEATURES_MOBILE import com.alfresco.content.data.ContextualActionData import com.alfresco.content.data.Entry +import com.alfresco.content.data.MobileConfigDataEntry +import com.alfresco.content.data.getJsonFromSharedPrefs import com.alfresco.content.fragmentViewModelWithArgs import com.alfresco.content.mimetype.MimeType import com.alfresco.content.viewer.common.ChildViewerArgs @@ -136,8 +139,14 @@ class ViewerFragment : Fragment(), MavericksView { } private fun configureActionBar(entry: Entry) { + val mobileConfigDataEntry = getJsonFromSharedPrefs(requireContext(), KEY_FEATURES_MOBILE) val fragment = ContextualActionsBarFragment().apply { - arguments = bundleOf(Mavericks.KEY_ARG to ContextualActionData.withEntries(listOf(entry))) + arguments = bundleOf( + Mavericks.KEY_ARG to ContextualActionData.withEntries( + listOf(entry), + mobileConfigData = mobileConfigDataEntry, + ), + ) } parentFragmentManager.beginTransaction().replace(R.id.action_list_bar, fragment).commit() }