Please give a brief summary of your issue:
Can’t figure out how to customize thumbnail and search toolbar colors.
Please describe your issue and provide steps to reproduce it:
When using the PdfViewCtrlTabHostFragment2 can’t figure out the theming components to add to customize the background color of the toolbar when in the Thumbnail fragment. See screenshots below
Also, is there a way to dynamically change the toolbar color for those fragments? I am able to dynamically change the general toolbar color by doing this:
class PDFTronFragment : PdfViewCtrlTabHostFragment2() {
override fun initViews() {
super.initViews()
applyWhiteLabelIfNeeded()
}
private fun applyWhiteLabelIfNeeded() {
if (BuildConfig.FLAVOR.isCFA()) {
val color = activity?.getPrimaryColor() ?: return
val gd = GradientDrawable()
gd.gradientType = GradientDrawable.LINEAR_GRADIENT
gd.gradientRadius = 200f * (resources.displayMetrics?.density ?: 1f)
gd.colors = intArrayOf(
color.shadeColor(10),
color.shadeColor()
)
toolbar?.background = gd
toolbar?.setTitleTextAppearance(context, R.style.PTToolbarTitleAppearance)
}
}
}
But when tapping the thumbnail button in the bottom bar the background of the toolbar reverts to the color white
Can I grab the thumbnail fragment’s toolbar dynamically like I do in the code above by calling getToolbar()?
Thanks for contacting us. Could you let us know your high level use case for needing to set the toolbar colors programatically? Typically the Android convention is to set the toolbar color via styles. We do not support setting the colors via dynamic values programatically for all our components.
Hi Andrew, one of our products is an app that our customers can customize for their own customers. With this, we allow them to choose a custom white label color that we apply programatically. We are able to get the toolbar and the mSearchToolbar and set a custom background, but we have not been able to do the same for the thumbnail view.
toolbar?.background = gd
mSearchToolbar?.background = gd
We are hoping to do this for the mThumbFragment as well.
I wanted to ditto what @jenny.brown says here. We allow our clients to white label the app for their clients. We do not know the white labeling colors until runtime and styles only allows for known colors by compile time. This is why we are trying to change the toolbar colors at runtime once we get the hex values from our servers.
Yes it’s okay to comment out super.onPageThumbnailOptionSelected(thumbnailEditMode, checkedItem), since this overridden method is just referencing the the source code for super.onPageThumbnailOptionSelected.
I see what you mean, alternatively I could add some API to allow you to inject a custom ThumbnailsViewFragment in your custom PdfViewCtrlTabHostFragment2. However, you will need to update to a newer snapshot version of the SDK. Would this be an option for you?
@Branden_Fung That would be great if you could create an api to inject out own custom class that extends the ThumbnailsViewFragment. We have no problem updating which PDFTron SDK snapshot we are referencing
Thanks for getting back to us about the API to create your own ThumbnailViewFragment class. Could you let us know if this item is blocking you, or any timelines you may have?