├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── raw │ │ │ └── sound.mp3 │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── styles.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ ├── mipmap-anydpi-v26 │ │ │ ├── ic_launcher.xml │ │ │ └── ic_launcher_round.xml │ │ ├── drawable-v24 │ │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ │ └── ic_launcher_background.xml │ │ └── layout │ │ │ └── sample_activity.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── ir │ │ └── zadak │ │ └── notification │ │ └── Sample.java ├── proguard-rules.pro └── build.gradle ├── zadaknotify ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable-xhdpi │ │ │ └── ic_launcher.png │ │ ├── drawable-nodpi │ │ │ └── ic_placeholder.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ └── strings.xml │ │ └── layout │ │ │ └── notification_custom.xml │ │ ├── java │ │ └── ir │ │ │ └── zadak │ │ │ └── zadaknotify │ │ │ ├── interfaces │ │ │ ├── OnImageLoadingCompleted.java │ │ │ ├── ImageLoader.java │ │ │ └── PendingIntentNotification.java │ │ │ ├── constants │ │ │ └── BroadcastActions.java │ │ │ ├── notification │ │ │ ├── Simple.java │ │ │ ├── Progress.java │ │ │ ├── Builder.java │ │ │ ├── ZadakNotification.java │ │ │ ├── Custom.java │ │ │ ├── Wear.java │ │ │ └── Load.java │ │ │ ├── pendingintent │ │ │ ├── ClickPendingIntentBroadCast.java │ │ │ ├── DismissPendingIntentBroadCast.java │ │ │ ├── ClickPendingIntentActivity.java │ │ │ └── DismissPendingIntentActivity.java │ │ │ └── model │ │ │ └── NotificationBean.java │ │ └── AndroidManifest.xml ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .idea ├── encodings.xml ├── vcs.xml ├── misc.xml ├── modules.xml └── runConfigurations.xml ├── .github └── workflows │ └── android.yml ├── gradle.properties ├── LICENSE ├── .gitignore ├── gradlew.bat ├── README.md └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /zadaknotify/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':zadaknotify' 2 | -------------------------------------------------------------------------------- /app/src/main/res/raw/sound.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/raw/sound.mp3 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /zadaknotify/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/zadaknotify/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /zadaknotify/src/main/res/drawable-nodpi/ic_placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mehrdadsafari/ZadakNotification/HEAD/zadaknotify/src/main/res/drawable-nodpi/ic_placeholder.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /zadaknotify/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #CC2f2f2f 4 | #FFFFFF 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #008577 4 | #00574B 5 | #D81B60 6 | 7 | -------------------------------------------------------------------------------- /zadaknotify/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 18sp 4 | 14sp 5 | 8dp 6 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/interfaces/OnImageLoadingCompleted.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.interfaces; 2 | 3 | import android.graphics.Bitmap; 4 | 5 | public interface OnImageLoadingCompleted { 6 | 7 | void imageLoadingCompleted(Bitmap bitmap); 8 | } 9 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Jun 04 13:31:44 IRDT 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip 7 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/interfaces/ImageLoader.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.interfaces; 2 | 3 | public interface ImageLoader { 4 | void load(String uri, OnImageLoadingCompleted onCompleted); 5 | 6 | void load(int imageResId, OnImageLoadingCompleted onCompleted); 7 | } 8 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/interfaces/PendingIntentNotification.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.interfaces; 2 | 3 | import android.app.PendingIntent; 4 | 5 | public interface PendingIntentNotification { 6 | 7 | public PendingIntent onSettingPendingIntent(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /zadaknotify/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/constants/BroadcastActions.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.constants; 2 | 3 | public class BroadcastActions { 4 | public static final String ACTION_CLICK_INTENT = "ir.zadak.zadaknotify.action.click.intent"; 5 | public static final String ACTION_DISMISS_INTENT = "ir.zadak.zadaknotify.action.dismiss.intent"; 6 | } 7 | -------------------------------------------------------------------------------- /.github/workflows/android.yml: -------------------------------------------------------------------------------- 1 | name: Android CI 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | - uses: actions/checkout@v1 12 | - name: set up JDK 1.8 13 | uses: actions/setup-java@v1 14 | with: 15 | java-version: 1.8 16 | - name: Build with Gradle 17 | run: ./gradlew build 18 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/notification/Simple.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.notification; 2 | 3 | import android.support.v4.app.NotificationCompat; 4 | 5 | public class Simple extends Builder { 6 | public Simple(NotificationCompat.Builder builder, int identifier, String tag) { 7 | super(builder, identifier, tag); 8 | } 9 | 10 | @Override 11 | public void build() { 12 | super.build(); 13 | super.notificationNotify(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /zadaknotify/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 28 5 | 6 | 7 | defaultConfig { 8 | minSdkVersion 16 9 | targetSdkVersion 28 10 | versionCode 1 11 | versionName "1.0" 12 | 13 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 14 | 15 | } 16 | 17 | buildTypes { 18 | release { 19 | minifyEnabled false 20 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 21 | } 22 | } 23 | 24 | } 25 | 26 | dependencies { 27 | implementation fileTree(dir: 'libs', include: ['*.jar']) 28 | 29 | implementation 'com.android.support:appcompat-v7:28.0.0' 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12sp 5 | 14sp 6 | 18sp 7 | 22sp 8 | 35sp 9 | 60sp 10 | 11 | 12 | 13 | 2dp 14 | 4dp 15 | 8dp 16 | 12dp 17 | 16dp 18 | 20dp 19 | 24dp 20 | 21 | -------------------------------------------------------------------------------- /zadaknotify/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ZadakNotify 3 | Notification 4 | Notification Custom 5 | Title 6 | Message 7 | Small Icon 8 | Background 9 | extra_voice_reply 10 | Reply 11 | 12 | Yes 13 | No 14 | Maybe 15 | 16 | 17 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | 15 | 16 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /zadaknotify/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 28 5 | defaultConfig { 6 | applicationId "ir.zadak.notification" 7 | minSdkVersion 16 8 | targetSdkVersion 28 9 | versionCode 1 10 | versionName "1.0" 11 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | repositories { 20 | maven { url 'https://jitpack.io' } 21 | } 22 | } 23 | 24 | dependencies { 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | //noinspection GradleCompatible 27 | implementation 'com.android.support:appcompat-v7:28.0.0' 28 | implementation 'com.github.mehrdadsafari:ZadakNotification:0.0.2' 29 | implementation 'com.squareup.picasso:picasso:2.71828' 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 15 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/notification/Progress.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.notification; 2 | 3 | import android.support.v4.app.NotificationCompat; 4 | 5 | public class Progress extends Builder { 6 | public Progress(NotificationCompat.Builder builder, int identifier, String tag) { 7 | super(builder, identifier, tag); 8 | } 9 | 10 | @Override 11 | public void build() { 12 | super.build(); 13 | super.notificationNotify(); 14 | } 15 | 16 | public Progress update(int identifier, int progress, int max, boolean indeterminate) { 17 | NotificationCompat.Builder builder = new NotificationCompat.Builder(ZadakNotification.mSingleton.mContext); 18 | builder.setProgress(max, progress, indeterminate); 19 | 20 | notification = builder.build(); 21 | notificationNotify(identifier); 22 | return this; 23 | } 24 | 25 | public Progress value(int progress, int max, boolean indeterminate) { 26 | builder.setProgress(max, progress, indeterminate); 27 | return this; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Mehrdad Safari 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Built application files 2 | *.apk 3 | *.ap_ 4 | 5 | # Files for the ART/Dalvik VM 6 | *.dex 7 | 8 | # Java class files 9 | *.class 10 | 11 | # Generated files 12 | bin/ 13 | gen/ 14 | out/ 15 | 16 | # Gradle files 17 | .gradle/ 18 | build/ 19 | 20 | # Local configuration file (sdk path, etc) 21 | local.properties 22 | 23 | # Proguard folder generated by Eclipse 24 | proguard/ 25 | 26 | # Log Files 27 | *.log 28 | 29 | # Android Studio Navigation editor temp files 30 | .navigation/ 31 | 32 | # Android Studio captures folder 33 | captures/ 34 | 35 | # IntelliJ 36 | *.iml 37 | .idea/workspace.xml 38 | .idea/tasks.xml 39 | .idea/gradle.xml 40 | .idea/assetWizardSettings.xml 41 | .idea/dictionaries 42 | .idea/libraries 43 | .idea/caches 44 | 45 | # Keystore files 46 | # Uncomment the following line if you do not want to check your keystore files in. 47 | #*.jks 48 | 49 | # External native build folder generated in Android Studio 2.2 and later 50 | .externalNativeBuild 51 | 52 | # Google Services (e.g. APIs or Firebase) 53 | google-services.json 54 | 55 | # Freeline 56 | freeline.py 57 | freeline/ 58 | freeline_project_description.json 59 | 60 | # fastlane 61 | fastlane/report.xml 62 | fastlane/Preview.html 63 | fastlane/screenshots 64 | fastlane/test_output 65 | fastlane/readme.md 66 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ZadakNotification 3 | 4 | Type 5 | The fields can\'t be empty! 6 | 7 | 8 | Title 9 | Insert Title 10 | Message 11 | Big Text 12 | Url Image 13 | Url 14 | Big Text 15 | Insert Message 16 | Notify Simple 17 | Notify Custom 18 | 5 new messages 19 | 20 | 21 | Simple 22 | Big Text 23 | Inbox Style 24 | 25 | 26 | 27 | Message 1 28 | Message 2 29 | Message 3 30 | Message 4 31 | Message 5 32 | 33 | 34 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/pendingintent/ClickPendingIntentBroadCast.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.pendingintent; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import ir.zadak.zadaknotify.constants.BroadcastActions; 8 | import ir.zadak.zadaknotify.interfaces.PendingIntentNotification; 9 | import ir.zadak.zadaknotify.notification.ZadakNotification; 10 | 11 | 12 | public class ClickPendingIntentBroadCast implements PendingIntentNotification { 13 | private final Bundle mBundle; 14 | private final int mIdentifier; 15 | 16 | public ClickPendingIntentBroadCast(Bundle bundle, int identifier) { 17 | this.mBundle = bundle; 18 | this.mIdentifier = identifier; 19 | } 20 | 21 | @Override 22 | public PendingIntent onSettingPendingIntent() { 23 | Intent clickIntentBroadcast = new Intent(BroadcastActions.ACTION_CLICK_INTENT); 24 | clickIntentBroadcast.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 25 | clickIntentBroadcast.setPackage(ZadakNotification.mSingleton.mContext.getPackageName()); 26 | if (mBundle != null) { 27 | clickIntentBroadcast.putExtras(mBundle); 28 | } 29 | 30 | return PendingIntent.getBroadcast(ZadakNotification.mSingleton.mContext, mIdentifier, clickIntentBroadcast, 31 | PendingIntent.FLAG_UPDATE_CURRENT); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/pendingintent/DismissPendingIntentBroadCast.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.pendingintent; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import ir.zadak.zadaknotify.constants.BroadcastActions; 8 | import ir.zadak.zadaknotify.interfaces.PendingIntentNotification; 9 | import ir.zadak.zadaknotify.notification.ZadakNotification; 10 | 11 | 12 | public class DismissPendingIntentBroadCast implements PendingIntentNotification { 13 | private final Bundle mBundle; 14 | private final int mIdentifier; 15 | 16 | public DismissPendingIntentBroadCast(Bundle bundle, int identifier) { 17 | this.mBundle = bundle; 18 | this.mIdentifier = identifier; 19 | } 20 | 21 | @Override 22 | public PendingIntent onSettingPendingIntent() { 23 | Intent clickIntentBroadcast = new Intent(BroadcastActions.ACTION_DISMISS_INTENT); 24 | clickIntentBroadcast.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 25 | clickIntentBroadcast.setPackage(ZadakNotification.mSingleton.mContext.getPackageName()); 26 | if (mBundle != null) { 27 | clickIntentBroadcast.putExtras(mBundle); 28 | } 29 | 30 | return PendingIntent.getBroadcast(ZadakNotification.mSingleton.mContext, mIdentifier, clickIntentBroadcast, 31 | PendingIntent.FLAG_UPDATE_CURRENT); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/pendingintent/ClickPendingIntentActivity.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.pendingintent; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import ir.zadak.zadaknotify.constants.BroadcastActions; 8 | import ir.zadak.zadaknotify.interfaces.PendingIntentNotification; 9 | import ir.zadak.zadaknotify.notification.ZadakNotification; 10 | 11 | 12 | public class ClickPendingIntentActivity implements PendingIntentNotification { 13 | private final Class mActivity; 14 | private final Bundle mBundle; 15 | private final int mIdentifier; 16 | 17 | public ClickPendingIntentActivity(Class activity, Bundle bundle, int identifier) { 18 | this.mActivity = activity; 19 | this.mBundle = bundle; 20 | this.mIdentifier = identifier; 21 | } 22 | 23 | @Override 24 | public PendingIntent onSettingPendingIntent() { 25 | Intent clickIntentActivity = new Intent(ZadakNotification.mSingleton.mContext, mActivity); 26 | clickIntentActivity.setAction(BroadcastActions.ACTION_CLICK_INTENT); 27 | clickIntentActivity.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 28 | clickIntentActivity.setPackage(ZadakNotification.mSingleton.mContext.getPackageName()); 29 | 30 | if (mBundle != null) { 31 | clickIntentActivity.putExtras(mBundle); 32 | } 33 | return PendingIntent.getActivity(ZadakNotification.mSingleton.mContext, mIdentifier, clickIntentActivity, 34 | PendingIntent.FLAG_UPDATE_CURRENT); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/pendingintent/DismissPendingIntentActivity.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.pendingintent; 2 | 3 | import android.app.PendingIntent; 4 | import android.content.Intent; 5 | import android.os.Bundle; 6 | 7 | import ir.zadak.zadaknotify.constants.BroadcastActions; 8 | import ir.zadak.zadaknotify.interfaces.PendingIntentNotification; 9 | import ir.zadak.zadaknotify.notification.ZadakNotification; 10 | 11 | 12 | public class DismissPendingIntentActivity implements PendingIntentNotification { 13 | private final Class mActivity; 14 | private final Bundle mBundle; 15 | private final int mIdentifier; 16 | 17 | public DismissPendingIntentActivity(Class activity, Bundle bundle, int identifier) { 18 | this.mActivity = activity; 19 | this.mBundle = bundle; 20 | this.mIdentifier = identifier; 21 | } 22 | 23 | @Override 24 | public PendingIntent onSettingPendingIntent() { 25 | Intent dismissIntentActivity = new Intent(ZadakNotification.mSingleton.mContext, mActivity); 26 | dismissIntentActivity.setAction(BroadcastActions.ACTION_DISMISS_INTENT); 27 | dismissIntentActivity.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); 28 | dismissIntentActivity.setPackage(ZadakNotification.mSingleton.mContext.getPackageName()); 29 | if (mBundle != null) { 30 | dismissIntentActivity.putExtras(mBundle); 31 | } 32 | 33 | return PendingIntent.getActivity(ZadakNotification.mSingleton.mContext, mIdentifier, dismissIntentActivity, 34 | PendingIntent.FLAG_UPDATE_CURRENT); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | 19 | 22 | 25 | 26 | 27 | 28 | 34 | 35 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/notification/Builder.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.notification; 2 | 3 | import android.app.Notification; 4 | import android.support.v4.app.NotificationCompat; 5 | import android.support.v4.app.NotificationManagerCompat; 6 | import android.util.Log; 7 | import android.widget.RemoteViews; 8 | 9 | public abstract class Builder { 10 | private static final String TAG = Builder.class.getSimpleName(); 11 | protected String tag; 12 | protected Notification notification; 13 | protected NotificationCompat.Builder builder; 14 | protected int notificationId; 15 | 16 | public Builder(NotificationCompat.Builder builder, int identifier, String tag) { 17 | this.builder = builder; 18 | this.notificationId = identifier; 19 | this.tag = tag; 20 | } 21 | 22 | public void build() { 23 | notification = builder.build(); 24 | } 25 | 26 | public void setBigContentView(RemoteViews views) { 27 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { 28 | notification.bigContentView = views; 29 | return; 30 | } 31 | Log.w(TAG, "Version does not support big content view"); 32 | } 33 | 34 | protected Notification notificationNotify() { 35 | if (tag != null) { 36 | return notificationNotify(tag, notificationId); 37 | } 38 | return notificationNotify(notificationId); 39 | } 40 | 41 | protected Notification notificationNotify(int identifier) { 42 | NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ZadakNotification.mSingleton.mContext); 43 | notificationManager.notify(identifier, notification); 44 | return notification; 45 | } 46 | 47 | protected Notification notificationNotify(String tag, int identifier) { 48 | NotificationManagerCompat notificationManager = NotificationManagerCompat.from(ZadakNotification.mSingleton.mContext); 49 | notificationManager.notify(tag, identifier, notification); 50 | return notification; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/notification/ZadakNotification.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.notification; 2 | 3 | import android.app.NotificationManager; 4 | import android.content.Context; 5 | 6 | public class ZadakNotification { 7 | private static final String TAG = ZadakNotification.class.getSimpleName(); 8 | public static ZadakNotification mSingleton = null; 9 | public final Context mContext; 10 | public boolean shutdown; 11 | 12 | public ZadakNotification(Context context) { 13 | this.mContext = context; 14 | } 15 | 16 | public static ZadakNotification with(Context context) { 17 | if (mSingleton == null) { 18 | synchronized (ZadakNotification.class) { 19 | if (mSingleton == null) { 20 | mSingleton = new Contractor(context).build(); 21 | } 22 | } 23 | } 24 | return mSingleton; 25 | } 26 | 27 | public Load load() { 28 | return new Load(); 29 | } 30 | 31 | public void cancel(int identifier) { 32 | NotificationManager notifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); 33 | notifyManager.cancel(identifier); 34 | } 35 | 36 | public void cancel(String tag, int identifier) { 37 | NotificationManager notifyManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE); 38 | notifyManager.cancel(tag, identifier); 39 | } 40 | 41 | public void shutdown() { 42 | if (this == mSingleton) { 43 | throw new UnsupportedOperationException("Default singleton instance cannot be shutdown."); 44 | } 45 | if (shutdown) { 46 | return; 47 | } 48 | shutdown = true; 49 | } 50 | 51 | private static class Contractor { 52 | private final Context mContext; 53 | 54 | public Contractor(Context context) { 55 | if (context == null) { 56 | throw new IllegalArgumentException("Context must not be null."); 57 | } 58 | this.mContext = context.getApplicationContext(); 59 | } 60 | 61 | public ZadakNotification build() { 62 | return new ZadakNotification(mContext); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /zadaknotify/src/main/res/layout/notification_custom.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 22 | 23 | 33 | 34 | 45 | 46 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/model/NotificationBean.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.model; 2 | 3 | import android.app.PendingIntent; 4 | import android.graphics.Bitmap; 5 | import android.net.Uri; 6 | 7 | public class NotificationBean { 8 | private int identifier; 9 | private String title; 10 | private String message; 11 | private String bigTextStyle; 12 | private String ticker; 13 | private int background; 14 | private int smallIcon; 15 | private int colorLight; 16 | private int ledOnMs; 17 | private int ledOffMs; 18 | private long when; 19 | private long[] vibratorTime; 20 | private boolean autoCancel; 21 | private Bitmap largeIcon; 22 | private Uri sound; 23 | private PendingIntent clickPendingIntent; 24 | private PendingIntent dismissPendingIntent; 25 | 26 | public NotificationBean() { 27 | super(); 28 | } 29 | 30 | public int getIdentifier() { 31 | return identifier; 32 | } 33 | 34 | public void setIdentifier(int identifier) { 35 | this.identifier = identifier; 36 | } 37 | 38 | public String getTitle() { 39 | return title; 40 | } 41 | 42 | public void setTitle(String title) { 43 | this.title = title; 44 | } 45 | 46 | public String getMessage() { 47 | return message; 48 | } 49 | 50 | public void setMessage(String message) { 51 | this.message = message; 52 | } 53 | 54 | public String getBigTextStyle() { 55 | return bigTextStyle; 56 | } 57 | 58 | public void setBigTextStyle(String bigTextStyle) { 59 | this.bigTextStyle = bigTextStyle; 60 | } 61 | 62 | public String getTicker() { 63 | return ticker; 64 | } 65 | 66 | public void setTicker(String ticker) { 67 | this.ticker = ticker; 68 | } 69 | 70 | public int getBackground() { 71 | return background; 72 | } 73 | 74 | public void setBackground(int background) { 75 | this.background = background; 76 | } 77 | 78 | public int getSmallIcon() { 79 | return smallIcon; 80 | } 81 | 82 | public void setSmallIcon(int smallIcon) { 83 | this.smallIcon = smallIcon; 84 | } 85 | 86 | public int getColorLight() { 87 | return colorLight; 88 | } 89 | 90 | public void setColorLight(int colorLight) { 91 | this.colorLight = colorLight; 92 | } 93 | 94 | public int getLedOnMs() { 95 | return ledOnMs; 96 | } 97 | 98 | public void setLedOnMs(int ledOnMs) { 99 | this.ledOnMs = ledOnMs; 100 | } 101 | 102 | public int getLedOffMs() { 103 | return ledOffMs; 104 | } 105 | 106 | public void setLedOffMs(int ledOffMs) { 107 | this.ledOffMs = ledOffMs; 108 | } 109 | 110 | public long getWhen() { 111 | return when; 112 | } 113 | 114 | public void setWhen(long when) { 115 | this.when = when; 116 | } 117 | 118 | public long[] getVibratorTime() { 119 | return vibratorTime; 120 | } 121 | 122 | public void setVibratorTime(long[] vibratorTime) { 123 | this.vibratorTime = vibratorTime; 124 | } 125 | 126 | public boolean isAutoCancel() { 127 | return autoCancel; 128 | } 129 | 130 | public void setAutoCancel(boolean autoCancel) { 131 | this.autoCancel = autoCancel; 132 | } 133 | 134 | public Bitmap getLargeIcon() { 135 | return largeIcon; 136 | } 137 | 138 | public void setLargeIcon(Bitmap largeIcon) { 139 | this.largeIcon = largeIcon; 140 | } 141 | 142 | public Uri getSound() { 143 | return sound; 144 | } 145 | 146 | public void setSound(Uri sound) { 147 | this.sound = sound; 148 | } 149 | 150 | public PendingIntent getClickPendingIntent() { 151 | return clickPendingIntent; 152 | } 153 | 154 | public void setClickPendingIntent(PendingIntent clickPendingIntent) { 155 | this.clickPendingIntent = clickPendingIntent; 156 | } 157 | 158 | public PendingIntent getDismissPendingIntent() { 159 | return dismissPendingIntent; 160 | } 161 | 162 | public void setDismissPendingIntent(PendingIntent dismissPendingIntent) { 163 | this.dismissPendingIntent = dismissPendingIntent; 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /zadaknotify/src/main/java/ir/zadak/zadaknotify/notification/Custom.java: -------------------------------------------------------------------------------- 1 | package ir.zadak.zadaknotify.notification; 2 | 3 | import android.annotation.SuppressLint; 4 | import android.annotation.TargetApi; 5 | import android.graphics.Bitmap; 6 | import android.os.Looper; 7 | import android.support.annotation.DrawableRes; 8 | import android.support.v4.app.NotificationCompat; 9 | import android.text.Spanned; 10 | import android.widget.RemoteViews; 11 | 12 | import ir.zadak.zadaknotify.R; 13 | import ir.zadak.zadaknotify.interfaces.ImageLoader; 14 | import ir.zadak.zadaknotify.interfaces.OnImageLoadingCompleted; 15 | 16 | 17 | @TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN) 18 | public class Custom extends Builder implements OnImageLoadingCompleted { 19 | private static final String TAG = Custom.class.getSimpleName(); 20 | private RemoteViews mRemoteView; 21 | private String mTitle; 22 | private String mMessage; 23 | private Spanned mMessageSpanned; 24 | private String mUri; 25 | private int mSmallIcon; 26 | private int mBackgroundResId; 27 | private int mPlaceHolderResourceId; 28 | private ImageLoader mImageLoader; 29 | 30 | 31 | public Custom(NotificationCompat.Builder builder, int identifier, String title, String message, Spanned messageSpanned, int smallIcon, String tag) { 32 | super(builder, identifier, tag); 33 | this.mRemoteView = new RemoteViews(ZadakNotification.mSingleton.mContext.getPackageName(), R.layout.notification_custom); 34 | this.mTitle = title; 35 | this.mMessage = message; 36 | this.mMessageSpanned = messageSpanned; 37 | this.mSmallIcon = smallIcon; 38 | this.mPlaceHolderResourceId = R.drawable.ic_launcher; 39 | this.init(); 40 | } 41 | 42 | private void init() { 43 | this.setTitle(); 44 | this.setMessage(); 45 | this.setSmallIcon(); 46 | } 47 | 48 | private void setTitle() { 49 | mRemoteView.setTextViewText(R.id.notification_text_title, mTitle); 50 | } 51 | 52 | private void setMessage() { 53 | if (mMessageSpanned != null) { 54 | mRemoteView.setTextViewText(R.id.notification_text_message, mMessageSpanned); 55 | } else { 56 | mRemoteView.setTextViewText(R.id.notification_text_message, mMessage); 57 | } 58 | } 59 | 60 | private void setSmallIcon() { 61 | if (mSmallIcon <= 0) { 62 | mRemoteView.setImageViewResource(R.id.notification_img_icon, R.drawable.ic_launcher); 63 | } 64 | mRemoteView.setImageViewResource(R.id.notification_img_icon, mSmallIcon); 65 | } 66 | 67 | @SuppressLint("ResourceType") 68 | public Custom background(@DrawableRes int resource) { 69 | if (resource <= 0) { 70 | throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!"); 71 | } 72 | 73 | if (mUri != null) { 74 | throw new IllegalStateException("Background Already Set!"); 75 | } 76 | 77 | this.mBackgroundResId = resource; 78 | return this; 79 | } 80 | 81 | @SuppressLint("ResourceType") 82 | public Custom setPlaceholder(@DrawableRes int resource) { 83 | if (resource <= 0) { 84 | throw new IllegalArgumentException("Resource ID Should Not Be Less Than Or Equal To Zero!"); 85 | } 86 | 87 | this.mPlaceHolderResourceId = resource; 88 | return this; 89 | } 90 | 91 | public Custom setImageLoader(ImageLoader imageLoader) { 92 | this.mImageLoader = imageLoader; 93 | return this; 94 | } 95 | 96 | public Custom background(String uri) { 97 | if (mBackgroundResId > 0) { 98 | throw new IllegalStateException("Background Already Set!"); 99 | } 100 | 101 | if (mUri != null) { 102 | throw new IllegalStateException("Background Already Set!"); 103 | } 104 | 105 | if (uri == null) { 106 | throw new IllegalArgumentException("Path Must Not Be Null!"); 107 | } 108 | if (uri.trim().length() == 0) { 109 | throw new IllegalArgumentException("Path Must Not Be Empty!"); 110 | } 111 | 112 | if (mImageLoader == null) { 113 | throw new IllegalStateException("You have to set an ImageLoader!"); 114 | } 115 | 116 | this.mUri = uri; 117 | return this; 118 | } 119 | 120 | @Override 121 | public void build() { 122 | if (!(Looper.getMainLooper().getThread() == Thread.currentThread())) { 123 | throw new IllegalStateException("Method call should happen from the main thread."); 124 | } 125 | 126 | super.build(); 127 | setBigContentView(mRemoteView); 128 | loadImageBackground(); 129 | super.notificationNotify(); 130 | } 131 | 132 | private void loadImageBackground() { 133 | 134 | mRemoteView.setImageViewResource(R.id.notification_img_background, mPlaceHolderResourceId); 135 | if (mUri != null) { 136 | mImageLoader.load(mUri, this); 137 | } else { 138 | mImageLoader.load(mBackgroundResId, this); 139 | } 140 | } 141 | 142 | @Override 143 | public void imageLoadingCompleted(Bitmap bitmap) { 144 | if (bitmap == null) { 145 | throw new IllegalArgumentException("bitmap cannot be null"); 146 | } 147 | mRemoteView.setImageViewBitmap(R.id.notification_img_background, bitmap); 148 | super.notificationNotify(); 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZadakNotification 2 | # Download 3 | # Step 1: 4 | Add it in your root build.gradle at the end of repositories: 5 | ``` groovy 6 | allprojects { 7 | repositories { 8 | maven { url 'https://jitpack.io' } 9 | } 10 | } 11 | ``` 12 | # Step 2: 13 | Add the dependency: 14 | ```groovy 15 | implementation 'com.github.mehrdadsafari:ZadakNotification:0.0.2' 16 | ``` 17 | 18 | # Introduction 19 | 20 | ![Screenshots](https://raw.githubusercontent.com/halysongoncalves/pugnotification/master/art/screenshot.png) 21 | 22 | You're probably tired of writing code to display notifications in your applications, the library abstracts all the notifications construction process for you in a single line of code. this library support Android Wear. 23 | 24 | ```java 25 | ZadakNotification.with(context) 26 | .load() 27 | .notificationChannelId(CHANNEL_ID) 28 | .identifier(identifier) 29 | .title(title) 30 | .message(message) 31 | .bigTextStyle(bigtext) 32 | .smallIcon(smallIcon) 33 | .largeIcon(largeIcon) 34 | .flags(Notification.DEFAULT_ALL) 35 | .button(icon, title, pendingIntent) 36 | .click(cctivity, bundle) 37 | .dismiss(activity, bundle) 38 | .color(color) 39 | .ticker(ticker) 40 | .when(when) 41 | .vibrate(vibrate) 42 | .lights(color, ledOnMs, ledOfMs) 43 | .sound(sound) 44 | .autoCancel(autoCancel) 45 | .simple() 46 | .build(); 47 | ``` 48 | # Simple Notification 49 | 50 | Simple notification with just text and message. 51 | 52 | ```java 53 | ZadakNotification.with(context) 54 | .load() 55 | .notificationChannelId(CHANNEL_ID) 56 | .title(title) 57 | .message(message) 58 | .bigTextStyle(bigtext) 59 | .smallIcon(R.drawable.ic_launcher) 60 | .largeIcon(R.drawable.ic_launcher) 61 | .flags(Notification.DEFAULT_ALL) 62 | .simple() 63 | .build(); 64 | ``` 65 | 66 | # Progress Notification 67 | 68 | Simple notification with progress. 69 | 70 | ```java 71 | ZadakNotification.with(context) 72 | .load() 73 | .notificationChannelId(CHANNEL_ID) 74 | .identifier(identifier) 75 | .smallIcon(R.drawable.ic_launcher) 76 | .progress() 77 | .value(progress,max, indeterminate) 78 | .build(); 79 | ``` 80 | 81 | ```java 82 | ZadakNotification.with(context) 83 | .load() 84 | .notificationChannelId(CHANNEL_ID) 85 | .identifier(identifier) 86 | .smallIcon(R.drawable.ic_launcher) 87 | .progress() 88 | .update(identifier,progress,max, indeterminate) 89 | .build(); 90 | ``` 91 | 92 | # Custom Notification 93 | 94 | We have changed the way the library handles the download images for custom notifications. Previously disrespectfully because of the Picasso library. But many users were asking for the option of being able to choose how to download the image. 95 | So we serve the requests and modify the library to allow the download of image management as an example: 96 | 97 | ```java 98 | ZadakNotification.with(context) 99 | .load() 100 | .notificationChannelId(CHANNEL_ID) 101 | .title(title) 102 | .message(message) 103 | .bigTextStyle(bigtext) 104 | .smallIcon(R.drawable.ic_launcher) 105 | .largeIcon(R.drawable.ic_launcher) 106 | .flags(Notification.DEFAULT_ALL) 107 | .color(android.R.color.background_dark) 108 | .custom() 109 | .background(url) 110 | .setImageLoader(Callback) 111 | .setPlaceholder(R.drawable.ic_placeholder) 112 | .build(); 113 | ``` 114 | 115 | 116 | # Wear Notification 117 | 118 | ```java 119 | ZadakNotification.with(mContext).load() 120 | .notificationChannelId(CHANNEL_ID) 121 | .smallIcon(R.drawable.ic_launcher) 122 | .autoCancel(true) 123 | .largeIcon(R.drawable.ic_launcher) 124 | .title(title) 125 | .message(message) 126 | .bigTextStyle(bigtext) 127 | .flags(Notification.DEFAULT_ALL) 128 | .wear() 129 | .background(Bitmap) 130 | .setRemoteInput(icon, title, pendingIntent, remoteInput) 131 | .setPages(List listNotification) 132 | .setHideIcon(Boolean) 133 | .build(); 134 | ``` 135 | 136 | Now just the client implement the ImageLoader interface and implement a way to manage the download of the image. Below we use the Picasso: 137 | 138 | ```java 139 | @Override 140 | public void load(String uri, final OnImageLoadingCompleted onCompleted) { 141 | viewTarget = getViewTarget(onCompleted); 142 | Picasso.with(this).load(uri).into(viewTarget); 143 | } 144 | 145 | private static Target getViewTarget(final OnImageLoadingCompleted onCompleted) { 146 | return new Target() { 147 | @Override 148 | public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { 149 | onCompleted.imageLoadingCompleted(bitmap); 150 | } 151 | 152 | @Override 153 | public void onBitmapFailed(Drawable errorDrawable) { 154 | } 155 | 156 | @Override 157 | public void onPrepareLoad(Drawable placeHolderDrawable) { 158 | } 159 | }; 160 | } 161 | ``` 162 | ZadakNotification supports placeholders if download the image in the background is not successful. The library already have a default placeholder size 622x384. 163 | 164 | # Important note 165 | For disable the swipe delete notification use 166 | ``` 167 | .setOngoing(true) 168 | ``` 169 | Cancel Notification 170 | ``` 171 | ZadakNotification.with(mContext).cancel(identifier); 172 | ``` 173 | # ProGuard 174 | 175 | If you use the Picasso to manage the download of the image, add the line below to your proguard file: 176 | 177 | ``` 178 | -dontwarn com.squareup.okhttp.** 179 | ``` 180 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/sample_activity.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 13 | 14 | 22 | 23 | 27 | 28 | 36 | 37 | 47 | 48 | 49 | 53 | 54 | 61 | 62 | 71 | 72 | 73 | 74 | 75 | 76 | 80 | 81 | 82 | 89 | 90 | 99 | 100 | 101 | 102 | 107 | 108 | 115 | 116 | 125 | 126 | 127 | 128 |