Skip to content

Commit 00f1367

Browse files
committed
Covert NotificationOpenReceivers to Kotlin
Ran the auto convert in Android Studio and updated comment in code
1 parent c988d12 commit 00f1367

File tree

3 files changed

+29
-39
lines changed

3 files changed

+29
-39
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotificationOpenIntent.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class GenerateNotificationOpenIntent(
4444
)
4545
}
4646

47-
// See NotificationOpenedReceiverAndroid22AndOlder.java for details
47+
// See NotificationOpenedReceiverAndroid22AndOlder.kt for details
4848
@Deprecated("Use getNewBaseIntentAndroidAPI23Plus instead for Android 6+")
4949
private fun getNewBaseIntentAndroidAPI22AndOlder(): Intent {
5050
val intent = Intent(

OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedReceiver.java renamed to OneSignalSDK/onesignal/src/main/java/com/onesignal/NotificationOpenedReceiver.kt

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,22 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27+
package com.onesignal
2728

28-
package com.onesignal;
29+
import android.app.Activity
30+
import android.content.Intent
31+
import android.os.Bundle
2932

30-
import android.app.Activity;
31-
import android.content.Intent;
32-
import android.os.Bundle;
33-
34-
public class NotificationOpenedReceiver extends Activity {
35-
36-
@Override
37-
protected void onCreate(Bundle savedInstanceState) {
38-
super.onCreate(savedInstanceState);
39-
NotificationOpenedProcessor.processFromContext(this, getIntent());
40-
finish();
41-
}
42-
43-
@Override
44-
protected void onNewIntent(Intent intent) {
45-
super.onNewIntent(intent);
46-
NotificationOpenedProcessor.processFromContext(this, getIntent());
47-
finish();
48-
}
33+
class NotificationOpenedReceiver : Activity() {
34+
override fun onCreate(savedInstanceState: Bundle?) {
35+
super.onCreate(savedInstanceState)
36+
NotificationOpenedProcessor.processFromContext(this, intent)
37+
finish()
38+
}
4939

40+
override fun onNewIntent(intent: Intent) {
41+
super.onNewIntent(intent)
42+
NotificationOpenedProcessor.processFromContext(this, getIntent())
43+
finish()
44+
}
5045
}
Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27+
package com.onesignal
2728

28-
package com.onesignal;
29-
30-
import android.app.Activity;
31-
import android.content.Intent;
32-
import android.os.Bundle;
29+
import android.app.Activity
30+
import android.content.Intent
31+
import android.os.Bundle
3332

3433
/**
3534
* This is the same as NotificationOpenedReceiver expect it doesn't contain
@@ -41,20 +40,16 @@
4140
* results in the app not resuming, when using reverse Activity trampoline.
4241
* Oddly enough cold starts of the app were not a problem.
4342
*/
44-
public class NotificationOpenedReceiverAndroid22AndOlder extends Activity {
45-
46-
@Override
47-
protected void onCreate(Bundle savedInstanceState) {
48-
super.onCreate(savedInstanceState);
49-
NotificationOpenedProcessor.processFromContext(this, getIntent());
50-
finish();
43+
class NotificationOpenedReceiverAndroid22AndOlder : Activity() {
44+
override fun onCreate(savedInstanceState: Bundle?) {
45+
super.onCreate(savedInstanceState)
46+
NotificationOpenedProcessor.processFromContext(this, intent)
47+
finish()
5148
}
5249

53-
@Override
54-
protected void onNewIntent(Intent intent) {
55-
super.onNewIntent(intent);
56-
NotificationOpenedProcessor.processFromContext(this, getIntent());
57-
finish();
50+
override fun onNewIntent(intent: Intent) {
51+
super.onNewIntent(intent)
52+
NotificationOpenedProcessor.processFromContext(this, getIntent())
53+
finish()
5854
}
59-
6055
}

0 commit comments

Comments
 (0)