diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..f009d26
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.sh text eol=lf
+*.bat text eol=crlf
diff --git a/app/src/main/java/com/khush/sample/MainApplication.kt b/app/src/main/java/com/khush/sample/MainApplication.kt
index b7b45d3..19e8093 100644
--- a/app/src/main/java/com/khush/sample/MainApplication.kt
+++ b/app/src/main/java/com/khush/sample/MainApplication.kt
@@ -16,7 +16,7 @@ class MainApplication : Application() {
.setNotificationConfig(
NotificationConfig(
true,
- smallIcon = R.drawable.ic_launcher_foreground
+ smallIcon = R.drawable.ic_notif_android
)
)
.enableLogs(true)
diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable/ic_launcher_foreground.xml
similarity index 100%
rename from app/src/main/res/drawable-v24/ic_launcher_foreground.xml
rename to app/src/main/res/drawable/ic_launcher_foreground.xml
diff --git a/app/src/main/res/drawable/ic_notif_android.xml b/app/src/main/res/drawable/ic_notif_android.xml
new file mode 100644
index 0000000..d8ed1a2
--- /dev/null
+++ b/app/src/main/res/drawable/ic_notif_android.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/gradlew.bat b/gradlew.bat
index ac1b06f..107acd3 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,89 +1,89 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem https://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Resolve any "." and ".." in APP_HOME to make it shorter.
-for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto execute
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/ketch/build.gradle b/ketch/build.gradle
index 25a4e57..3d499ad 100644
--- a/ketch/build.gradle
+++ b/ketch/build.gradle
@@ -22,6 +22,9 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
+ androidResources {
+ resourcePrefix = "ketch_"
+ }
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
diff --git a/ketch/src/main/java/com/ketch/internal/notification/DownloadNotificationManager.kt b/ketch/src/main/java/com/ketch/internal/notification/DownloadNotificationManager.kt
index 0bed409..4a062d7 100644
--- a/ketch/src/main/java/com/ketch/internal/notification/DownloadNotificationManager.kt
+++ b/ketch/src/main/java/com/ketch/internal/notification/DownloadNotificationManager.kt
@@ -12,6 +12,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.work.ForegroundInfo
import com.ketch.NotificationConfig
+import com.ketch.R
import com.ketch.internal.utils.DownloadConst
import com.ketch.internal.utils.NotificationConst
import com.ketch.internal.utils.TextUtil
@@ -138,7 +139,7 @@ internal class DownloadNotificationManager(
PendingIntent.FLAG_IMMUTABLE
)
- var nb = notificationBuilder
+ val nb = notificationBuilder
.setSmallIcon(notificationConfig.smallIcon)
.setContentTitle("Downloading $fileName")
.setContentIntent(pendingIntentOpen)
@@ -147,12 +148,22 @@ internal class DownloadNotificationManager(
.setOngoing(true)
if (length != 0L) {
- nb = nb.addAction(-1, NotificationConst.PAUSE_BUTTON_TEXT, pendingIntentPause)
+ nb
+ .addAction(
+ R.drawable.ketch_ic_notif_pause,
+ NotificationConst.PAUSE_BUTTON_TEXT,
+ pendingIntentPause
+ )
}
foregroundInfo = ForegroundInfo(
notificationId,
- nb.addAction(-1, NotificationConst.CANCEL_BUTTON_TEXT, pendingIntentCancel)
+ nb
+ .addAction(
+ R.drawable.ketch_ic_notif_cancel,
+ NotificationConst.CANCEL_BUTTON_TEXT,
+ pendingIntentCancel
+ )
.setDeleteIntent(pendingIntentDismiss)
.build(),
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
diff --git a/ketch/src/main/java/com/ketch/internal/notification/NotificationReceiver.kt b/ketch/src/main/java/com/ketch/internal/notification/NotificationReceiver.kt
index c5b1404..46cb9f5 100644
--- a/ketch/src/main/java/com/ketch/internal/notification/NotificationReceiver.kt
+++ b/ketch/src/main/java/com/ketch/internal/notification/NotificationReceiver.kt
@@ -12,6 +12,7 @@ import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
import com.ketch.Ketch
+import com.ketch.R
import com.ketch.internal.utils.DownloadConst
import com.ketch.internal.utils.NotificationConst
import com.ketch.internal.utils.TextUtil
@@ -93,13 +94,19 @@ internal class NotificationReceiver : BroadcastReceiver() {
intent.extras?.getString(NotificationConst.KEY_NOTIFICATION_CHANNEL_NAME)
?: NotificationConst.DEFAULT_VALUE_NOTIFICATION_CHANNEL_NAME
val notificationImportance =
- intent.extras?.getInt(NotificationConst.KEY_NOTIFICATION_CHANNEL_IMPORTANCE)
+ intent.extras?.getInt(
+ NotificationConst.KEY_NOTIFICATION_CHANNEL_IMPORTANCE,
+ NotificationConst.DEFAULT_VALUE_NOTIFICATION_CHANNEL_IMPORTANCE
+ )
?: NotificationConst.DEFAULT_VALUE_NOTIFICATION_CHANNEL_IMPORTANCE
val notificationChannelDescription =
intent.extras?.getString(NotificationConst.KEY_NOTIFICATION_CHANNEL_DESCRIPTION)
?: NotificationConst.DEFAULT_VALUE_NOTIFICATION_CHANNEL_DESCRIPTION
val notificationSmallIcon =
- intent.extras?.getInt(NotificationConst.KEY_NOTIFICATION_SMALL_ICON)
+ intent.extras?.getInt(
+ NotificationConst.KEY_NOTIFICATION_SMALL_ICON,
+ NotificationConst.DEFAULT_VALUE_NOTIFICATION_SMALL_ICON
+ )
?: NotificationConst.DEFAULT_VALUE_NOTIFICATION_SMALL_ICON
val fileName = intent.extras?.getString(DownloadConst.KEY_FILE_NAME) ?: ""
val currentProgress = intent.extras?.getInt(DownloadConst.KEY_PROGRESS) ?: 0
@@ -171,7 +178,7 @@ internal class NotificationReceiver : BroadcastReceiver() {
PendingIntent.FLAG_IMMUTABLE
)
- var notificationBuilder =
+ val notificationBuilder =
NotificationCompat.Builder(context, NotificationConst.NOTIFICATION_CHANNEL_ID)
.setSmallIcon(notificationSmallIcon)
.setContentText(
@@ -196,24 +203,34 @@ internal class NotificationReceiver : BroadcastReceiver() {
// add retry and cancel button for failed download
if (intent.action == NotificationConst.ACTION_DOWNLOAD_FAILED) {
- notificationBuilder = notificationBuilder.addAction(
- -1,
- NotificationConst.RETRY_BUTTON_TEXT,
- pendingIntentRetry
- )
+ notificationBuilder
+ .addAction(
+ R.drawable.ketch_ic_notif_retry,
+ NotificationConst.RETRY_BUTTON_TEXT,
+ pendingIntentRetry
+ )
.setProgress(DownloadConst.MAX_VALUE_PROGRESS, currentProgress, false)
- .addAction(-1, NotificationConst.CANCEL_BUTTON_TEXT, pendingIntentCancel)
+ .addAction(
+ R.drawable.ketch_ic_notif_cancel,
+ NotificationConst.CANCEL_BUTTON_TEXT,
+ pendingIntentCancel
+ )
.setSubText("$currentProgress%")
}
// add resume and cancel button for paused download
if (intent.action == NotificationConst.ACTION_DOWNLOAD_PAUSED) {
- notificationBuilder = notificationBuilder.addAction(
- -1,
- NotificationConst.RESUME_BUTTON_TEXT,
- pendingIntentResume
- )
+ notificationBuilder
+ .addAction(
+ R.drawable.ketch_ic_notif_resume,
+ NotificationConst.RESUME_BUTTON_TEXT,
+ pendingIntentResume
+ )
.setProgress(DownloadConst.MAX_VALUE_PROGRESS, currentProgress, false)
- .addAction(-1, NotificationConst.CANCEL_BUTTON_TEXT, pendingIntentCancel)
+ .addAction(
+ R.drawable.ketch_ic_notif_cancel,
+ NotificationConst.CANCEL_BUTTON_TEXT,
+ pendingIntentCancel
+ )
.setSubText("$currentProgress%")
}
diff --git a/ketch/src/main/java/com/ketch/internal/utils/NotificationConst.kt b/ketch/src/main/java/com/ketch/internal/utils/NotificationConst.kt
index bd3df3f..c9dfd9e 100644
--- a/ketch/src/main/java/com/ketch/internal/utils/NotificationConst.kt
+++ b/ketch/src/main/java/com/ketch/internal/utils/NotificationConst.kt
@@ -10,7 +10,7 @@ internal object NotificationConst {
const val KEY_NOTIFICATION_CHANNEL_IMPORTANCE = "key_notification_channel_importance"
const val DEFAULT_VALUE_NOTIFICATION_CHANNEL_IMPORTANCE = 2 // LOW
const val KEY_NOTIFICATION_SMALL_ICON = "key_small_notification_icon"
- const val DEFAULT_VALUE_NOTIFICATION_SMALL_ICON = -1
+ const val DEFAULT_VALUE_NOTIFICATION_SMALL_ICON = 0
const val KEY_NOTIFICATION_ID = "key_notification_id"
// Actions
diff --git a/ketch/src/main/res/drawable/ketch_ic_notif_cancel.xml b/ketch/src/main/res/drawable/ketch_ic_notif_cancel.xml
new file mode 100644
index 0000000..25d4782
--- /dev/null
+++ b/ketch/src/main/res/drawable/ketch_ic_notif_cancel.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/ketch/src/main/res/drawable/ketch_ic_notif_pause.xml b/ketch/src/main/res/drawable/ketch_ic_notif_pause.xml
new file mode 100644
index 0000000..104da05
--- /dev/null
+++ b/ketch/src/main/res/drawable/ketch_ic_notif_pause.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/ketch/src/main/res/drawable/ketch_ic_notif_resume.xml b/ketch/src/main/res/drawable/ketch_ic_notif_resume.xml
new file mode 100644
index 0000000..afca045
--- /dev/null
+++ b/ketch/src/main/res/drawable/ketch_ic_notif_resume.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/ketch/src/main/res/drawable/ketch_ic_notif_retry.xml b/ketch/src/main/res/drawable/ketch_ic_notif_retry.xml
new file mode 100644
index 0000000..c94750a
--- /dev/null
+++ b/ketch/src/main/res/drawable/ketch_ic_notif_retry.xml
@@ -0,0 +1,11 @@
+
+
+
+
+