-
Notifications
You must be signed in to change notification settings - Fork 763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android overhaul (includes important bug fixes and new functionality) #71
Closed
Closed
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c967bff
Migrate to FCM and refactor
Benjamin-Dobell ae36e8a
Namespace globally broadcast JS events
Benjamin-Dobell 521f0c7
Support FCM token invalidation
Benjamin-Dobell 9842411
Fixed initial intent behavior for background notifications
Benjamin-Dobell faf442e
Do not automatically dismiss all notifications
Benjamin-Dobell 812ced3
Android large icon support (URL or drawable name)
Benjamin-Dobell de8c172
Minor code simplification/clean-up
Benjamin-Dobell f084ebd
Move getInitialNotification() NotificationsAndroid (match iOS)
Benjamin-Dobell 59c6237
Android lights/LED support
Benjamin-Dobell 7ff0123
Android README updates
Benjamin-Dobell dc3e462
Expose invalidateToken() to JS
Benjamin-Dobell 3c1f7a7
Fixed native Android test compilation
Benjamin-Dobell 835cd86
Refactored ProxyService into LocalNotificationService
Benjamin-Dobell ff3ae15
Android background queue
Benjamin-Dobell a207aa4
RN 0.47 support (handle Android breaking change)
Benjamin-Dobell 30d3e8d
Updated README installation instructions for Android.
Benjamin-Dobell ee2e5b5
Ensure initial notification on cold boots is passed to new intents
tommeier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
android/src/main/java/com/wix/reactnativenotifications/core/BitmapLoader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.wix.reactnativenotifications.core; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.net.Uri; | ||
import android.util.Log; | ||
|
||
import com.facebook.common.executors.CallerThreadExecutor; | ||
import com.facebook.common.references.CloseableReference; | ||
import com.facebook.datasource.BaseDataSubscriber; | ||
import com.facebook.datasource.DataSource; | ||
import com.facebook.datasource.DataSubscriber; | ||
import com.facebook.drawee.backends.pipeline.Fresco; | ||
import com.facebook.imagepipeline.core.ImagePipeline; | ||
import com.facebook.imagepipeline.image.CloseableBitmap; | ||
import com.facebook.imagepipeline.image.CloseableImage; | ||
import com.facebook.imagepipeline.request.ImageRequest; | ||
import com.facebook.imagepipeline.request.ImageRequestBuilder; | ||
|
||
import static com.wix.reactnativenotifications.Defs.LOGTAG; | ||
|
||
public class BitmapLoader { | ||
public interface OnBitmapLoadedCallback { | ||
// The lifetime of the Bitmap is only valid for the duration of the callback. If the Bitmap | ||
// is required for a longer duration it should be copied. | ||
void onBitmapLoaded(Bitmap bitmap); | ||
} | ||
|
||
private final Context mContext; | ||
|
||
public BitmapLoader(Context context) { | ||
mContext = context; | ||
} | ||
|
||
public void loadUri(final Uri uri, final OnBitmapLoadedCallback callback) { | ||
final ImageRequest request = ImageRequestBuilder.newBuilderWithSource(uri) | ||
.setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH) | ||
.setProgressiveRenderingEnabled(false) | ||
.build(); | ||
|
||
final ImagePipeline imagePipeline = Fresco.getImagePipeline(); | ||
final DataSource<CloseableReference<CloseableImage>> dataSource = imagePipeline.fetchDecodedImage(request, mContext); | ||
|
||
final DataSubscriber<CloseableReference<CloseableImage>> dataSubscriber = new BaseDataSubscriber<CloseableReference<CloseableImage>>() { | ||
|
||
@Override | ||
protected void onNewResultImpl(final DataSource<CloseableReference<CloseableImage>> dataSource) { | ||
if (dataSource.isFinished()) { | ||
final CloseableReference<CloseableImage> imageReference = dataSource.getResult(); | ||
|
||
if (imageReference != null) { | ||
final CloseableImage image = imageReference.get(); | ||
|
||
if (image instanceof CloseableBitmap) { | ||
final Bitmap bitmap = ((CloseableBitmap) image).getUnderlyingBitmap(); | ||
callback.onBitmapLoaded(bitmap); | ||
image.close(); | ||
} else { | ||
Log.e(LOGTAG, "Image loaded from " + uri + " is not a bitmap image"); | ||
} | ||
|
||
imageReference.close(); | ||
} | ||
|
||
dataSource.close(); | ||
} | ||
} | ||
|
||
@Override | ||
protected void onFailureImpl(final DataSource<CloseableReference<CloseableImage>> dataSource) { | ||
Log.e(LOGTAG, "Failed to load image from " + uri, dataSource.getFailureCause()); | ||
dataSource.close(); | ||
} | ||
}; | ||
|
||
dataSource.subscribe(dataSubscriber, CallerThreadExecutor.getInstance()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which classpath are you using to match this with 10.2.6?
classpath "com.google.gms:google-services:3.0.0"
? its crashing when using 3.1.0 (unsure why yet)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah saw your note. Mine was crashing unless I included as follows: