Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
L
location share white
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
location share white
Commits
512d392a
Commit
512d392a
authored
Nov 29, 2024
by
wanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
...fcm
parent
df6e2756
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
96 additions
and
50 deletions
+96
-50
build.gradle.kts
app/build.gradle.kts
+1
-1
google-services.json
app/google-services.json
+6
-6
AndroidManifest.xml
app/src/main/AndroidManifest.xml
+1
-1
FCMManager.kt
...c/main/java/com/base/locationsharewhite/fcm/FCMManager.kt
+7
-1
FcmReceiver.kt
.../main/java/com/base/locationsharewhite/fcm/FcmReceiver.kt
+25
-14
MessagingService.kt
.../java/com/base/locationsharewhite/fcm/MessagingService.kt
+47
-21
MyApplication.kt
.../java/com/base/locationsharewhite/helper/MyApplication.kt
+5
-3
MainActivity.kt
.../java/com/base/locationsharewhite/ui/main/MainActivity.kt
+1
-1
SettingActivity.kt
...ava/com/base/locationsharewhite/ui/set/SettingActivity.kt
+1
-1
activity_setting.xml
app/src/main/res/layout/activity_setting.xml
+2
-1
No files found.
app/build.gradle.kts
View file @
512d392a
...
...
@@ -13,7 +13,7 @@ android {
compileSdk
=
34
defaultConfig
{
applicationId
=
"com.
base.locationsharewhite
"
applicationId
=
"com.
tool.advanced.cleaner
"
minSdk
=
24
targetSdk
=
34
versionCode
=
1
...
...
app/google-services.json
View file @
512d392a
{
"project_info"
:
{
"project_number"
:
"
953792647345
"
,
"project_id"
:
"
pdf-test-d0ae7
"
,
"storage_bucket"
:
"
pdf-test-d0ae7.appspot.com
"
"project_number"
:
"
755421476297
"
,
"project_id"
:
"
comtooladvancedcleaner
"
,
"storage_bucket"
:
"
comtooladvancedcleaner.firebasestorage.app
"
},
"client"
:
[
{
"client_info"
:
{
"mobilesdk_app_id"
:
"1:
953792647345:android:c5234e8bfc859f8b20d290
"
,
"mobilesdk_app_id"
:
"1:
755421476297:android:c66d8129d83b17e8af6418
"
,
"android_client_info"
:
{
"package_name"
:
"com.
base.locationsharewhite
"
"package_name"
:
"com.
tool.advanced.cleaner
"
}
},
"oauth_client"
:
[],
"api_key"
:
[
{
"current_key"
:
"AIzaSy
BT6B1oPmkojGX0TgBOI9bDkx5pdEFXWoo
"
"current_key"
:
"AIzaSy
AhCB4trMZPymkWCNl_m-bFGPpASG6bsQI
"
}
],
"services"
:
{
...
...
app/src/main/AndroidManifest.xml
View file @
512d392a
...
...
@@ -131,7 +131,7 @@
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
<action
android:name=
"com.google.android.c2dm.intent.RECEIVE"
/>
<category
android:name=
"co
nfine.scream
"
/>
<category
android:name=
"co
m.tool.advanced.cleaner
"
/>
</intent-filter>
</receiver>
<receiver
...
...
app/src/main/java/com/base/locationsharewhite/fcm/FCMManager.kt
View file @
512d392a
package
com.base.locationsharewhite.fcm
import
android.content.Context
import
android.util.Log
import
com.base.locationsharewhite.helper.EventUtils
...
...
@@ -11,6 +13,7 @@ import com.google.firebase.messaging.FirebaseMessaging
import
org.json.JSONObject
object
FCMManager
{
fun
initFirebase
(
context
:
Context
?)
{
FirebaseApp
.
initializeApp
(
context
!!
)
LogEx
.
logDebug
(
"initFirebase"
,
"initFirebase"
)
...
...
@@ -40,6 +43,9 @@ object FCMManager {
}
}
/**
* 有vpn有google商店才能获取
*/
private
fun
getToken
()
{
FirebaseMessaging
.
getInstance
().
token
.
addOnCompleteListener
(
object
:
OnCompleteListener
<
String
>
{
...
...
@@ -59,7 +65,7 @@ object FCMManager {
AppPreferences
.
getInstance
().
put
(
"token"
,
token
)
// Handle new token
Log
.
d
(
"FCM"
,
"FCM Registration Token: $token"
)
Log
Ex
.
logDebug
(
"FCM"
,
"FCM Registration Token: $token"
)
}
})
}
...
...
app/src/main/java/com/base/locationsharewhite/fcm/FcmReceiver.kt
View file @
512d392a
package
com.base.locationsharewhite.fcm
;
package
com.base.locationsharewhite.fcm
import
android.content.BroadcastReceiver;
import
android.content.Context;
import
android.content.Intent;
import
android.content.BroadcastReceiver
import
android.content.Context
import
android.content.Intent
import
com.applovin.sdk.AppLovinSdkUtils.runOnUiThread
import
com.base.locationsharewhite.BuildConfig
import
com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.locationsharewhite.helper.EventUtils.event
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.utils.LogEx.logDebug
import
com.base.locationsharewhite.utils.ToastUtils.toast
import
com.base.locationsharewhite.helper.EventUtils;
import
com.base.locationsharewhite.utils.LogEx;
class
FcmReceiver
:
BroadcastReceiver
()
{
private
val
TAG
=
"FcmReceiver"
override
fun
onReceive
(
context
:
Context
,
intent
:
Intent
)
{
LogEx
.
logDebug
(
"FCM"
,
"FcmReceiver"
)
event
(
"FCM_Received"
,
null
,
null
,
false
)
public
class
FcmReceiver
extends
BroadcastReceiver
{
private
String
TAG
=
"FcmReceiver"
;
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_FCM
,
null
)
@Override
public
void
onReceive
(
Context
context
,
Intent
intent
)
{
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"onReceive"
,
false
);
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
null
,
null
,
false
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
context
,
PopupConstObject
.
POPUP_WHERE_FCM
,
null
);
if
(
BuildConfig
.
DEBUG
)
{
runOnUiThread
{
runCatching
{
MyApplication
.
appContext
.
toast
(
"FcmReceiver fcm"
)
}
}
}
}
}
app/src/main/java/com/base/locationsharewhite/fcm/MessagingService.kt
View file @
512d392a
package
com.base.locationsharewhite.fcm;
import
android.annotation.SuppressLint;
import
androidx.annotation.NonNull;
import
com.base.locationsharewhite.helper.EventUtils;
import
com.base.locationsharewhite.utils.LogEx;
import
com.google.firebase.messaging.FirebaseMessagingService;
import
com.google.firebase.messaging.RemoteMessage;
package
com.base.locationsharewhite.fcm
import
android.annotation.SuppressLint
import
com.applovin.sdk.AppLovinSdkUtils.runOnUiThread
import
com.base.locationsharewhite.BuildConfig
import
com.base.locationsharewhite.fcm.NotificationUiUtil.sendNotificationIfCan
import
com.base.locationsharewhite.helper.EventUtils.event
import
com.base.locationsharewhite.helper.MyApplication
import
com.base.locationsharewhite.utils.LogEx
import
com.base.locationsharewhite.utils.ToastUtils.toast
import
com.google.firebase.messaging.FirebaseMessagingService
import
com.google.firebase.messaging.RemoteMessage
import
org.json.JSONException
import
org.json.JSONObject
@SuppressLint
(
"MissingFirebaseInstanceTokenRefresh"
)
public
class
MessagingService
extends
FirebaseMessagingService
{
private
static
final
String
TAG
=
"MessagingService"
;
@Override
public
void
onMessageReceived
(
@NonNull
RemoteMessage
remoteMessage
)
{
super
.
onMessageReceived
(
remoteMessage
);
LogEx
.
INSTANCE
.
logDebug
(
TAG
,
"onMessageReceived"
,
false
);
EventUtils
.
INSTANCE
.
event
(
"FCM_Received"
,
null
,
null
,
false
);
NotificationUiUtil
.
INSTANCE
.
sendNotificationIfCan
(
this
,
PopupConstObject
.
POPUP_WHERE_FCM
,
null
);
class
MessagingService
:
FirebaseMessagingService
()
{
override
fun
onMessageReceived
(
remoteMessage
:
RemoteMessage
)
{
super
.
onMessageReceived
(
remoteMessage
)
val
id
=
remoteMessage
.
messageId
val
ext
=
JSONObject
()
try
{
ext
.
put
(
"getMessageType"
,
remoteMessage
.
messageType
)
ext
.
put
(
"getData"
,
remoteMessage
.
data
)
ext
.
put
(
"getCollapseKey"
,
remoteMessage
.
collapseKey
)
ext
.
put
(
"getFrom"
,
remoteMessage
.
from
)
ext
.
put
(
"getPriority"
,
remoteMessage
.
priority
)
ext
.
put
(
"getSenderId"
,
remoteMessage
.
senderId
)
ext
.
put
(
"getSentTime"
,
remoteMessage
.
sentTime
)
}
catch
(
e
:
JSONException
)
{
event
(
"FCM_Received_Error"
,
id
,
ext
,
false
)
throw
RuntimeException
(
e
)
}
finally
{
}
event
(
"FCM_Received"
,
id
,
ext
,
false
)
LogEx
.
logDebug
(
"FCM"
,
"MessagingService"
)
sendNotificationIfCan
(
this
,
PopupConstObject
.
POPUP_WHERE_FCM
,
null
)
if
(
BuildConfig
.
DEBUG
)
{
runOnUiThread
{
runCatching
{
MyApplication
.
appContext
.
toast
(
"MessagingService fcm"
)
}
}
}
}
companion
object
{
private
const
val
TAG
=
"MessagingService"
}
}
\ No newline at end of file
app/src/main/java/com/base/locationsharewhite/helper/MyApplication.kt
View file @
512d392a
package
com.base.locationsharewhite.helper
import
FCMManager
import
com.base.locationsharewhite.fcm.
FCMManager
import
android.app.Activity
import
android.app.Application
import
android.content.Context
...
...
@@ -21,6 +21,7 @@ import com.base.locationsharewhite.service.StayJobService.Companion.startJob
import
com.base.locationsharewhite.ui.splash.SplashActivity
import
com.base.locationsharewhite.utils.AppPreferences
import
com.base.locationsharewhite.utils.LogEx
import
com.facebook.FacebookSdk
import
com.hjq.language.MultiLanguages
import
com.hjq.language.OnLanguageListener
import
java.util.Locale
...
...
@@ -81,9 +82,10 @@ class MyApplication : Application() {
}
private
fun
initApp
()
{
// FacebookSdk.sdkInitialize(applicationContext)
FacebookSdk
.
sdkInitialize
(
applicationContext
)
val
token
=
AppPreferences
.
getInstance
().
getString
(
"token"
,
""
)
val
topic
=
AppConfig
.
packageName
+
"_push"
LogEx
.
logDebug
(
TAG
,
"topic=${topic}"
)
LogEx
.
logDebug
(
TAG
,
"topic=${topic}
token=$token
"
)
FCMManager
.
initFirebase
(
this
)
FCMManager
.
subscribeToTopic
(
topic
)
InstallHelps
.
init
()
...
...
app/src/main/java/com/base/locationsharewhite/ui/main/MainActivity.kt
View file @
512d392a
...
...
@@ -94,7 +94,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>(), OnMapReadyCallback {
mainPresenter
.
startLocationJob
(
lifecycleScope
)
showAllowAllTimeDialog
()
changeLanguage
(
this
)
//
changeLanguage(this)
}
private
fun
showNotificationDialog
()
{
...
...
app/src/main/java/com/base/locationsharewhite/ui/set/SettingActivity.kt
View file @
512d392a
...
...
@@ -61,7 +61,7 @@ class SettingActivity : BaseActivity<ActivitySettingBinding>() {
override
fun
onResumeOneShoot
()
{
super
.
onResumeOneShoot
()
changeLanguage
(
this
)
//
changeLanguage(this)
}
override
fun
onResume
()
{
...
...
app/src/main/res/layout/activity_setting.xml
View file @
512d392a
...
...
@@ -99,7 +99,8 @@
android:layout_marginTop=
"18dp"
android:background=
"?android:attr/selectableItemBackground"
android:clickable=
"true"
android:focusable=
"true"
>
android:focusable=
"true"
android:visibility=
"gone"
>
<ImageView
android:layout_width=
"wrap_content"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment