Appboy / appboy-android-sdk

Public repo for the Braze Android SDK
https://www.braze.com
Other
152 stars 102 forks source link

[Question]: How can I disable content card right to left swipe feature? [ I don't want my users to delete the content card ] #258

Closed vinaykumar2197 closed 1 year ago

vinaykumar2197 commented 1 year ago

Braze Android SDK Version

24.2.0

Steps To Reproduce

I don't want my users to swipe the content card to left or right. How can I disable this swiping feature?

Expected Behavior

NA

Actual Incorrect Behavior

NA

Verbose Logs

na

Additional Information

Screenshot 2023-02-01 at 5 55 50 PM
bryanlogan commented 1 year ago

Card.isDismissibleByUser = false

vinaykumar2197 commented 1 year ago

I am using braze's fragment view to render the content card like :

 <fragment
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="com.braze.ui.contentcards.ContentCardsFragment"
            android:id="@+id/braze_content_feed" />
class ContentFeedFragment : BaseFragment() {

    @Inject
    lateinit var analytics: ContentFeedScreenAnalytics

    @Inject
    lateinit var toolbarHandlerListener: ToolbarHandlerListener

    @Inject
    lateinit var statusBarHelper: StatusBarHelper

    @Inject
    lateinit var toggler: Toggler

    @Inject
    lateinit var messagingRefreshable: IPushMessagingRefreshable

    val rootView: View by bindView(R.id.fragment_content_feed_root_view)

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        return inflater.inflate(R.layout.fragment_content_feed, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        messagingRefreshable.fetchContentCardFromRemote()
        initView()
        statusBarHelper.ensureStatusBarTransparent(view)
    }

    private fun initView() {
        view?.let {
            statusBarHelper.updateFitSystemWindow(rootView, true)
        }
    }

}

where can I put Card.isDismissibleByUser = false in the above code and what is Card object here ?

bryanlogan commented 1 year ago

From your ContentCardFragment, you can set an IContentCardUpdateHandler via setContentCardUpdateHandler. This will give you a chance to do whatever you need on the Card.

https://www.braze.com/docs/developer_guide/platform_integration_guides/android/content_cards/customization/default_feed/

vinaykumar2197 commented 1 year ago

Thanks @bryanlogan. I hope copying the DefaultContentCardsUpdateHandler class file directly from above link would not result in crashes in the production. Is it properly tested?

radixdev commented 1 year ago

Hi @vinaykumar2197 ,

Yes, we have extensive testing for all of the Content Card methods and classes.