Skip to content
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

refactor: Splitting FCMService.kt file into multiple files; some cleanup too #265

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,12 @@
<permission android:name="${applicationId}.permission.PushHandlerActivity" android:protectionLevel="signature"></permission>
</config-file>

<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:name="com.adobe.phonegap.push.PushHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.PushHandlerActivity"/>
<activity android:name="com.adobe.phonegap.push.BackgroundHandlerActivity" android:exported="true" android:permission="${applicationId}.permission.BackgroundHandlerActivity">
<intent-filter>
<action android:name="com.adobe.phonegap.push.background.MESSAGING_EVENT"/>
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<config-file target="AndroidManifest.xml" parent="/manifest/application">
<activity android:exported="true" android:name="com.adobe.phonegap.push.PushHandlerActivity" android:permission="${applicationId}.permission.PushHandlerActivity">
<intent-filter>
<action android:name="com.adobe.phonegap.push.background.MESSAGING_EVENT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<receiver android:name="com.adobe.phonegap.push.BackgroundActionButtonHandler"/>
Expand Down Expand Up @@ -75,10 +74,14 @@
<source-file src="src/android/com/adobe/phonegap/push/FCMService.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushConstants.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushHandlerActivity.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/BackgroundHandlerActivity.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushPlugin.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/BackgroundActionButtonHandler.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushDismissedHandler.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/PushUtils.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/NotificationUtils.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/MessagesStore.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/AndroidUtils.kt" target-dir="java/com/adobe/phonegap/push/"/>
<source-file src="src/android/com/adobe/phonegap/push/StringExtensions.kt" target-dir="java/com/adobe/phonegap/push/"/>
</platform>

<platform name="browser">
Expand Down
29 changes: 29 additions & 0 deletions src/android/com/adobe/phonegap/push/AndroidUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.adobe.phonegap.push

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import com.google.firebase.messaging.FirebaseMessagingService

object AndroidUtils {

/**
* Get the Application Name from Label
*/
fun getAppName(context: Context): String {
return context.packageManager.getApplicationLabel(context.applicationInfo) as String
}

fun intentForLaunchActivity(context: Context): Intent? {
val pm = context.packageManager
val packageName = context.packageName
return pm?.getLaunchIntentForPackage(packageName)
}

fun getPushSharedPref(context: Context): SharedPreferences {
return context.getSharedPreferences(
PushConstants.COM_ADOBE_PHONEGAP_PUSH,
FirebaseMessagingService.MODE_PRIVATE
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class BackgroundActionButtonHandler : BroadcastReceiver() {

val notificationManager =
context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationManager.cancel(FCMService.getAppName(context), notId)
notificationManager.cancel(AndroidUtils.getAppName(context), notId)

intent.extras?.let { extras ->
Log.d(TAG, "Intent Extras: $extras")
Expand Down
132 changes: 0 additions & 132 deletions src/android/com/adobe/phonegap/push/BackgroundHandlerActivity.kt

This file was deleted.

Loading