I work on clinical apps and it's extremely important that a pre-release or not yet validated version of my app isn't used in a clinical capacity. Partner hospitals or clinics some times get a bench build to test a site specific issue and the result of someone walking onto the floor with that build could be catastrophic (some one could literally die).
I'm currently doing the watermarking via build flavors. There are 3 activities, and the layouts for these activities are duplicated. The clinical variant has no watermark and the demo variant has a "NOT FOR CLINICAL USE" watermark as a TextView
with red text and alpha=0.2 on top of everything.
This works so far, but I don't like the fact that there are duplicated layouts: devs may forget to update both layouts when there is a change.
I'm wondering if there's a way to have some kind of a window listener that is invoked every time a new window is displayed and it renders the watermark on top of the window contents?
Note: I'm aware of this approach, but I'd prefer something that is limited to the scope of the app and doesn't use hidden APIs that require reflection.