Skip to content

Commit

Permalink
Covert NotificationOpenReceivers to Kotlin
Browse files Browse the repository at this point in the history
Ran the auto convert in Android Studio and updated comment in code
  • Loading branch information
jkasten2 committed Oct 27, 2021
1 parent c988d12 commit 00f1367
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class GenerateNotificationOpenIntent(
)
}

// See NotificationOpenedReceiverAndroid22AndOlder.java for details
// See NotificationOpenedReceiverAndroid22AndOlder.kt for details
@Deprecated("Use getNewBaseIntentAndroidAPI23Plus instead for Android 6+")
private fun getNewBaseIntentAndroidAPI22AndOlder(): Intent {
val intent = Intent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,22 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.onesignal

package com.onesignal;
import android.app.Activity
import android.content.Intent
import android.os.Bundle

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class NotificationOpenedReceiver extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NotificationOpenedProcessor.processFromContext(this, getIntent());
finish();
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
NotificationOpenedProcessor.processFromContext(this, getIntent());
finish();
}
class NotificationOpenedReceiver : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NotificationOpenedProcessor.processFromContext(this, intent)
finish()
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
NotificationOpenedProcessor.processFromContext(this, getIntent())
finish()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.onesignal

package com.onesignal;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.app.Activity
import android.content.Intent
import android.os.Bundle

/**
* This is the same as NotificationOpenedReceiver expect it doesn't contain
Expand All @@ -41,20 +40,16 @@
* results in the app not resuming, when using reverse Activity trampoline.
* Oddly enough cold starts of the app were not a problem.
*/
public class NotificationOpenedReceiverAndroid22AndOlder extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
NotificationOpenedProcessor.processFromContext(this, getIntent());
finish();
class NotificationOpenedReceiverAndroid22AndOlder : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
NotificationOpenedProcessor.processFromContext(this, intent)
finish()
}

@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
NotificationOpenedProcessor.processFromContext(this, getIntent());
finish();
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
NotificationOpenedProcessor.processFromContext(this, getIntent())
finish()
}

}

0 comments on commit 00f1367

Please sign in to comment.