Skip to content

This library is to apply a watermark to your app in all of your activity and fragment

License

Notifications You must be signed in to change notification settings

Gkemon/App-Watermark

Repository files navigation

Logo

App watermark for Android

Maintained Maintained Maintained

Create an watermark for your Android app.

Suppose you have a freemium app and wanna show an watermark in your app after a free trial to lessen it's user experience to buy the premium version. Then this library is compatible for your use-case. Not only this use-case, you can use it in a lot of use-cases where you wish to lessen the content access capacity of your users or preview a content all over the app content (A revenge of downvoting my question 😛 )


Demo

  • Simple: Extremely simple to use. For using Step Builder Design Patten undernath,here IDE greatly helps developers to complete the steps for creating an watermark.
  • Powerful: Customize almost everything. It uses a layout resource which will be shown in your app as an watermark. So as an developer,you are very used to with layout resources and you are very powerful to customize it.
  • Transparent: It shows logs,success-responses, failure-responses , that's why developer will nofity any event inside the process.
📖 Table of Contents

-----------------------------------------------------

➤ Table of Contents

-----------------------------------------------------

➤ Installation

Step 1. Add the JitPack repository to your root build.gradle at the end of repositories

allprojects {
    repositories {
        // ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

dependencies {
        implementation 'com.github.Gkemon:App-Watermark:1.0.0'
}

-----------------------------------------------------

➤ Getting Started

You can generate app Watermark using just 2 mandatory components.

  • AppCompatActivity. (From which activity you wanna acatually show your watermark, e.g: MainActivity) [Mandatory]
  • Layout resource. (The layout which you wanna show as the watermark, e.g: R.layout.layout_water_mark) [Mandatory]
  • Background color. ( e.g: R.color.deepRed. If you skip it then it will consider the background color of your defined layout resourc.) [Optional]
  • Opacity. (Default opacity of background color is 50 if you don't set opacity manually.Best practice is never set it above 80 because it will decrease the transparent level of your background color, which might be cause not showing the main UI or content properly) [Optional]

By Java:

First initialize it from an activity from where you want to show the watermark-

AppWaterMarkBuilder.doConfigure()
                .setAppCompatActivity(MainActivity.this)
                .setWatermarkProperty(R.layout.layout_water_mark)
		/* You can also set opacity or opacity with a default background color.
		 * Just call like that ".setWatermarkProperty(R.layout.layout_water_mark, 40, R.color.colorAccent)" */
		.showAlsoOutsideOfTheApp()/*Optional: Call it if anyone wanna show the watermark globally allover the other apps.*/
                .showWatermarkAfterConfig(new WatermarkListener() { /*This callback is also optional here */
                    @Override
                    public void onSuccess() {
                     Log.d(TAG, "Successfully showing water mark");
                    }

                    @Override
                    public void onFailure(String message, Throwable throwable) {
		     Log.d(TAG, "Failed: "+message");
                    }

                    @Override
                    public void showLog(String log, @Nullable Throwable throwable) {
 		     Log.d(TAG, "Log: "+log");
                    }
                });

Then you can hide and show it from any where in your app-

  /* For hiding the watermark without callback*/
  AppWaterMarkBuilder.hideWatermark() 
 
  /* For hiding the watermark with callback*/
  AppWaterMarkBuilder.hideWatermark(new WatermarkListener() {
                    @Override
                    public void onSuccess() {
                     Log.d(TAG, "Successfully showing water mark");
                    }

                    @Override
                    public void onFailure(String message, Throwable throwable) {
		     Log.d(TAG, "Failed: "+message");
                    }

                    @Override
                    public void showLog(String log, @Nullable Throwable throwable) {
 		     Log.d(TAG, "Log: "+log");
                    }
                })
    
    /* For showing the watermark without callback*/
  AppWaterMarkBuilder.showWatermark() 
 
  /* For showing the watermark with callback*/
  AppWaterMarkBuilder.showWatermark(new WatermarkListener() {
                    @Override
                    public void onSuccess() {
                     Log.d(TAG, "Successfully showing water mark");
                    }

                    @Override
                    public void onFailure(String message, Throwable throwable) {
		     Log.d(TAG, "Failed: "+message");
                    }

                    @Override
                    public void showLog(String log, @Nullable Throwable throwable) {
 		     Log.d(TAG, "Log: "+log");
                    }
                })

By Kotlin:

First initialize it from an activity from where you want to show the watermark-

                 doConfigure()
                .setAppCompatActivity(this@MainActivity)
                .setWatermarkProperty(R.layout.layout_water_mark)
		/* You can also set opacity or opacity with a default background color.
		 * Just call like that ".setWatermarkProperty(R.layout.layout_water_mark, 40, R.color.colorAccent)" */
                .showWatermarkAfterConfig(object : WatermarkListener { /*This callback is also optional here */
                    override fun onSuccess() {
                        Log.d(TAG, "Successfully showing water mark")
                    }

                    override fun onFailure(message: String?, throwable: Throwable?) {
                        Log.d(TAG, "Failed: $message")
                    }

                    override fun showLog(log: String?, throwable: Throwable?) {
                        Log.d(TAG, "Log: $log")
                    }
                })

Then you can hide and show it from any where in your app-

   /* For hiding the watermark without callback*/
   AppWaterMarkBuilder.hideWatermark() 
 
   /* For hiding the watermark with callback*/
   AppWaterMarkBuilder.hideWatermark(new WatermarkListener() {object : WatermarkListener {
                override fun onSuccess() {
                    Log.d(MainActivity.TAG, "Successfully showing water mark")
                }

                override fun onFailure(message: String?, throwable: Throwable?) {
                    Log.d(MainActivity.TAG, "Failed: $message")
                }

                override fun showLog(log: String?, throwable: Throwable?) {
                    Log.d(MainActivity.TAG, "Log: $log")
                }
            })
    
   /* For showing the watermark without callback*/
    AppWaterMarkBuilder.showWatermark() 
 
   /* For showing the watermark with callback*/
    AppWaterMarkBuilder.showWatermark(object : WatermarkListener {
                override fun onSuccess() {
                    Log.d(MainActivity.TAG, "Successfully showing water mark")
                }

                override fun onFailure(message: String?, throwable: Throwable?) {
                    Log.d(MainActivity.TAG, "Failed: $message")
                }

                override fun showLog(log: String?, throwable: Throwable?) {
                    Log.d(MainActivity.TAG, "Log: $log")
                }
            })

-----------------------------------------------------

linkedin LinkedIn   inbox Inbox

Icon is made by Freepik from www.flaticon.com

➤ License

The source code is licensed under the Apache License 2.0.

-----------------------------------------------------