Customize Android Tips

Replace Tips Data

To modify the existing tips, set the companion field CaptureStandaloneActivity.tipsConfigCreator anytime before the capture flow is started to change what is displayed.

// The returned `ArrayList` from the tips config creator defines what set of tips will be shown in the tips activity
CaptureStandaloneActivity.tipsConfigCreator = { currentCaptureConfig ->
    arrayListOf(
        // Create a `CaptureTipData` for each tip you want to display
        CaptureTipData(
            tipIcon = R.drawable.icon_tip1,
            tipTitle = R.string.title_tip1,
            tipDescription = R.string.description_tip1
        ),
        CaptureTipData(
            tipIcon = R.drawable.icon_tip2,
            tipTitle = R.string.title_tip2,
            tipDescription = R.string.description_tip2
        )
    ).apply {
        // If you need to conditionally include tips based on what the current config capture is running with,
        // a `CaptureConfig` is passed in representing the current configuration of the instance of the capture
        // flow that is about to launch capture tips.
        if (currentCaptureConfig.enableLongCapture) {
            add(
                CaptureTipData(
                    tipIcon = R.drawable.icon_tip3,
                    tipTitle = R.string.title_tip3,
                    tipDescription = R.string.description_tip3
                )
            )
        }
    }
}
// The returned `ArrayList` from the tips config creator defines what set of tips will be shown in the tips activity
CaptureStandaloneActivity.Companion.setTipsConfigCreator(new Function1<CaptureConfig, ArrayList<CaptureTipData>>() {
    @Override
    public ArrayList<CaptureTipData> invoke(CaptureConfig currentCaptureConfig) {
        ArrayList<CaptureTipData> tips = new ArrayList<>();
        // Create a `CaptureTipData` for each tip you want to display
        tips.add(new CaptureTipData(R.drawable.icon_tip1, R.drawable.gradiant_tip, R.string.title_tip1, R.string.description_tip1));
        tips.add(new CaptureTipData(R.drawable.icon_tip2, R.drawable.gradiant_tip, R.string.title_tip2, R.string.description_tip2));

        // If you need to conditionally include tips based on what the current config capture is running with,
        // a `CaptureConfig` is passed in representing the current configuration of the instance of the capture
        // flow that is about to launch capture tips.
        if(currentCaptureConfig.getEnableLongCapture()) {
            tips.add(new CaptureTipData(R.drawable.icon_tip3, R.drawable.gradiant_tip, R.string.title_tip3, R.string.description_tip3));
        }

        return tips;
    }
});

Edit Tip Data

If you just want to replace a single tip or just a few properties of one, you can also do that by updating the CaptureStandaloneActivity.tipsConfigCreator as such.

// The capture configuration you use in your application
val myCaptureConfig = CaptureConfig()

// Generate the default tips
val tips = CaptureStandaloneActivity.tipsConfigCreator(myCaptureConfig)

// Modify the tip you want to change and replace it in the list
val updatedTip = tips[1].copy(tipIcon = R.drawable.my_tip_icon, tipTitle = R.string.my_tip_title)
tips.removeAt(1)
tips.add(1, updatedTip)

// Set the creator to use your custom list
CaptureStandaloneActivity.tipsConfigCreator = { tips }
// The capture configuration you use in your application
CaptureConfig myCaptureConfig = new CaptureConfig();

// Generate the default tips
ArrayList<CaptureTipData> tips = CaptureStandaloneActivity.Companion.getTipsConfigCreator().invoke(myCaptureConfig);

// Modify the tip you want to change and replace it in the list
CaptureTipData updatedTip = tips.get(1).copy(R.drawable.icon_tip1, R.drawable.gradiant_tip, R.string.title_tip1, R.string.description_tip1);
tips.remove(tips.get(1));
tips.add(1, updatedTip);

// Set the creator to use your custom list
CaptureStandaloneActivity.Companion.setTipsConfigCreator(new Function1<CaptureConfig, ArrayList<CaptureTipData>>() {
    @Override
    public ArrayList<CaptureTipData> invoke(CaptureConfig captureConfig) {
        return tips;
    }
});