Skip to content

ionic-team/OSPrivacyScreenLib-Android

Repository files navigation

OSPrivacyScreenLib

The OSPrivacyScreenLib-Android is a library built using Kotlin that provides privacy screen features for Android applications. It prevents sensitive information from being visible in app switchers and when leaving an app.

The OSPrivacyScreenController class provides the main features of the Library, which are:

  • Enabling/disabling privacy screen protection
  • Managing screenshot prevention
  • Handling app switcher privacy
  • Configuring background dimming options

Index

Motivation

This library is used by the Privacy Screen Plugin for OutSystems' Capacitor Plugin. It provides a robust solution for protecting sensitive information when an app goes into the background or appears in the app switcher.

Usage

In your app-level gradle file, import the OSPrivacyScreenLib library:

dependencies { implementation("com.capacitorjs:osprivacyscreen-android:1.0.0") }

Methods

The library offers the OSPrivacyScreenController class that provides the following methods:

Enable privacy screen protection

Obtain the current location of the device

fun enable(
activity: Activity,
config: OSPrivacyScreenConfig? = null
): Boolean

Input parameters:

  • activity: the Activity from the app using the library
  • config: Optional configuration options for customizing privacy screen behavior

Returns a Boolean indicating if privacy screen was successfully enabled.

Disable privacy screen protection

fun disable(
activity: Activity
): Boolean

Input parameters:

  • activity: the Activity from the app using the library

Returns a Boolean indicating if privacy screen was successfully disabled.

Check privacy screen status

fun isEnabled(): Boolean

Returns a Boolean indicating if privacy screen protection is currently active.

Configuration

The library supports configuration through the OSPrivacyScreenConfig class:

data class OSPrivacyScreenConfig(
val dimBackground: Boolean = false // Use dim effect instead of splash screen
)

Troubleshooting

Common issues and solutions:

  1. Privacy screen not showing

    • Verify the activity reference is valid
    • Ensure proper configuration in AndroidManifest.xml
    • Check if any other overlay permissions are conflicting
  2. Splash screen not appearing

    • Verify splash screen resource exists
    • Check theme configuration
    • Consider using dimBackground option instead
  3. Performance issues

    • Minimize heavy operations during screen transitions
    • Use appropriate configuration for device capabilities

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

OSPrivacyScreenLib is available under the MIT license. See the LICENSE file for more info.

Support

About

No description, website, or topics provided.

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published