Skip to content

Commit

Permalink
Add a notification icon of type byte[] for flutter
Browse files Browse the repository at this point in the history
  • Loading branch information
fingerart committed Jul 9, 2020
1 parent fa93687 commit edc1f49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ hbrecorder.isBusyRecording();
// Set notification icon by passing, for example R.drawable.myicon
// Defaults to R.drawable.icon
hbrecorder.setNotificationSmallIcon(int);
// Set notification title
// Set notification icon by byte array
hbrecorder.setNotificationSmallIcon(byte[]);
// Set notification title
// Defaults to "Recording your screen"
hbrecorder.setNotificationTitle(String);
// Set notification description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import android.os.Bundle;
import android.os.Environment;

import androidx.annotation.DrawableRes;
import androidx.annotation.RequiresApi;

import android.os.Handler;
Expand Down Expand Up @@ -182,13 +183,18 @@ public boolean isBusyRecording() {
}

/*Change notification icon*/
public void setNotificationSmallIcon(int drawable) {
public void setNotificationSmallIcon(@DrawableRes int drawable) {
Bitmap icon = BitmapFactory.decodeResource(context.getResources(), drawable);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
icon.compress(Bitmap.CompressFormat.PNG, 100, stream);
byteArray = stream.toByteArray();
}

/*Change notification icon*/
public void setNotificationSmallIcon(byte[] bytes) {
byteArray = bytes;
}

/*Set notification title*/
public void setNotificationTitle(String Title) {
notificationTitle = Title;
Expand Down

0 comments on commit edc1f49

Please sign in to comment.