Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
c0f39ef6
Commit
c0f39ef6
authored
Jan 30, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove firebase
parent
8232345e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
127 additions
and
138 deletions
+127
-138
build.gradle
+8
-6
src/main/AndroidManifest.xml
+17
-17
src/main/java/com/common/base/BaseActivity.java
+7
-10
src/main/java/com/common/service/MsgHandleService.java
+69
-76
src/main/java/com/common/service/MsgInstanceIdService.java
+19
-18
src/main/java/tech/starwin/LibConfig.java
+2
-4
src/main/java/tech/starwin/network/DefaultHeaderAddInterceptor.java
+0
-2
src/main/java/tech/starwin/utils/LogUtils.java
+0
-1
src/main/java/tech/starwin/utils/TrackEventHelper.java
+5
-4
No files found.
build.gradle
View file @
c0f39ef6
...
...
@@ -98,20 +98,22 @@ dependencies {
api
'com.squareup.retrofit2:converter-gson:2.4.0'
api
'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
//
firebase core
api
'com.google.firebase:firebase-core:16.0.3'
//
firebase cloud message
api
'com.google.firebase:firebase-messaging:17.3.2'
//
firebase core
//
api 'com.google.firebase:firebase-core:16.0.3'
//
firebase cloud message
//
api 'com.google.firebase:firebase-messaging:17.3.2'
//firebase remoteConfig
// api 'com.google.firebase:firebase-config:16.0.0'
api
'com.android.installreferrer:installreferrer:1.0'
api
'com.google.android.gms:play-services-auth:15.0.1'
api
'com.google.android.gms:play-services-auth-api-phone:15.0.1'
api
'com.google.android.gms:play-services-ads:15.0.1'
//facebook accountKit SDK
api
'com.facebook.android:account-kit-sdk:4.37.0'
api
'com.google.android.gms:play-services-auth:15.0.1'
api
'com.google.android.gms:play-services-auth-api-phone:15.0.1'
//facebook SDK
// api 'com.facebook.android:facebook-android-sdk:[4,5)'
...
...
src/main/AndroidManifest.xml
View file @
c0f39ef6
...
...
@@ -22,24 +22,24 @@
android:name=
"android.max_aspect"
android:value=
"2.5"
/>
<!-- TODO - Firebase配置-->
<!--FireBase 推送-->
<meta-data
android:name=
"com.google.firebase.messaging.default_notification_channel_id"
android:value=
"${CHANNEL_NAME}"
/>
<meta-data
android:name=
"firebase_messaging_auto_init_enabled"
android:value=
"false"
/>
<service
android:name=
"com.common.service.MsgHandleService"
>
<intent-filter>
<action
android:name=
"com.google.firebase.MESSAGING_EVENT"
/>
</intent-filter>
</service>
<service
android:name=
"com.common.service.MsgInstanceIdService"
>
<intent-filter>
<action
android:name=
"com.google.firebase.INSTANCE_ID_EVENT"
/>
</intent-filter>
</service>
<!--<meta-data-->
<!--android:name="com.google.firebase.messaging.default_notification_channel_id"-->
<!--android:value="${CHANNEL_NAME}" />-->
<!--<meta-data-->
<!--android:name="firebase_messaging_auto_init_enabled"-->
<!--android:value="false" />-->
<!--<service android:name="com.common.service.MsgHandleService">-->
<!--<intent-filter>-->
<!--<action android:name="com.google.firebase.MESSAGING_EVENT" />-->
<!--</intent-filter>-->
<!--</service>-->
<!--<service android:name="com.common.service.MsgInstanceIdService">-->
<!--<intent-filter>-->
<!--<action android:name="com.google.firebase.INSTANCE_ID_EVENT" />-->
<!--</intent-filter>-->
<!--</service>-->
<!--AutoSize-->
<meta-data
...
...
src/main/java/com/common/base/BaseActivity.java
View file @
c0f39ef6
...
...
@@ -10,14 +10,12 @@ import android.support.annotation.Nullable;
import
android.support.v4.app.Fragment
;
import
android.support.v4.widget.DrawerLayout
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.FrameLayout
;
import
com.google.firebase.messaging.RemoteMessage
;
import
com.qmuiteam.qmui.util.QMUIStatusBarHelper
;
import
com.trello.rxlifecycle2.LifecycleTransformer
;
import
com.trello.rxlifecycle2.RxLifecycle
;
...
...
@@ -30,10 +28,8 @@ import tech.starwin.LibConfig;
import
tech.starwin.R
;
import
tech.starwin.base.BasePresenter
;
import
com.common.service.MsgHandleService
;
import
tech.starwin.mvp.IView
;
import
tech.starwin.utils.LogUtils
;
import
tech.starwin.utils.context_utils.AppLanguageUtils
;
import
tech.starwin.utils.PresenterHoler
;
import
tech.starwin.utils.context_utils.FragmentLauncher
;
...
...
@@ -101,13 +97,14 @@ public abstract class BaseActivity extends AppCompatActivity implements IView {
@Override
protected
void
onStart
()
{
super
.
onStart
();
//TODO - FireBase配置
//如果是通过FireBase CloudMessage 调起的界面,将消息交给Service处理
String
action
=
getIntent
().
getAction
()
==
null
?
""
:
getIntent
().
getAction
();
String
from
=
getIntent
().
getStringExtra
(
"from"
);
if
(
action
.
equals
(
"android.intent.action.MAIN"
)
&&
!
TextUtils
.
isEmpty
(
from
))
{
MsgHandleService
.
handleMsg
(
this
,
new
RemoteMessage
(
getIntent
().
getExtras
()));
}
//
String action = getIntent().getAction() == null ? "" : getIntent().getAction();
//
String from = getIntent().getStringExtra("from");
//
if (action.equals("android.intent.action.MAIN") &&
//
!TextUtils.isEmpty(from)) {
//
MsgHandleService.handleMsg(this, new RemoteMessage(getIntent().getExtras()));
//
}
lifecycleSubject
.
onNext
(
ActivityEvent
.
START
);
}
...
...
src/main/java/com/common/service/MsgHandleService.java
View file @
c0f39ef6
package
com
.
common
.
service
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.support.v4.app.NotificationCompat
;
import
com.google.firebase.messaging.FirebaseMessagingService
;
import
com.google.firebase.messaging.RemoteMessage
;
import
com.trello.rxlifecycle2.LifecycleTransformer
;
import
com.trello.rxlifecycle2.android.ActivityEvent
;
import
org.greenrobot.eventbus.EventBus
;
import
javax.annotation.Nonnull
;
import
io.reactivex.Observable
;
import
tech.starwin.LibConfig
;
import
tech.starwin.mvp.IView
;
import
tech.starwin.mvp.presenter.UserPresenter
;
import
tech.starwin.utils.PreferencesManager
;
import
tech.starwin.utils.PresenterHoler
;
import
tech.starwin.utils.ui_utils.UIHelper
;
/**
* Created by SiKang on 2018/9/27.
*/
public
class
MsgHandleService
extends
FirebaseMessagingService
{
public
static
final
String
TAG
=
"MsgHandleService"
;
public
static
final
String
RECEIVED_FIREBASE_MESSAGE
=
"action.receivedFireBaseMessage"
;
@Override
public
void
onNewToken
(
String
token
)
{
PreferencesManager
.
get
().
saveFireBaseMessagingToken
(
token
);
new
UserPresenter
().
uploadFirebaseToken
(
token
);
}
@Override
public
void
onMessageReceived
(
RemoteMessage
remoteMessage
)
{
handleMsg
(
this
,
remoteMessage
);
if
(
remoteMessage
.
getNotification
()
!=
null
)
{
RemoteMessage
.
Notification
notificationInfo
=
remoteMessage
.
getNotification
();
NotificationCompat
.
Builder
builder
=
new
NotificationCompat
.
Builder
(
this
,
"default"
)
.
setContentTitle
(
notificationInfo
.
getTitle
())
.
setContentText
(
notificationInfo
.
getBody
())
.
setSmallIcon
(
LibConfig
.
APP_ICON
)
.
setWhen
(
System
.
currentTimeMillis
())
.
setTicker
(
notificationInfo
.
getTitle
())
.
setVisibility
(
NotificationCompat
.
VISIBILITY_PUBLIC
)
.
setAutoCancel
(
true
);
UIHelper
.
notifyNotification
(
getBaseContext
(),
builder
);
}
}
@Override
public
void
onDeletedMessages
()
{
}
/**
* 处理推送内容
*/
public
static
void
handleMsg
(
Context
context
,
RemoteMessage
remoteMessage
)
{
if
(
remoteMessage
!=
null
)
{
//EventBus 通知
EventBus
.
getDefault
().
post
(
remoteMessage
);
//广播 通知
Intent
intent
=
remoteMessage
.
toIntent
();
intent
.
setAction
(
RECEIVED_FIREBASE_MESSAGE
);
context
.
sendBroadcast
(
intent
);
}
}
}
//package com.common.service;
//
//
//import android.content.Context;
//import android.content.Intent;
//import android.support.v4.app.NotificationCompat;
//
//import com.google.firebase.messaging.FirebaseMessagingService;
//import com.google.firebase.messaging.RemoteMessage;
//
//import org.greenrobot.eventbus.EventBus;
//
//import tech.starwin.LibConfig;
//import tech.starwin.mvp.presenter.UserPresenter;
//import tech.starwin.utils.PreferencesManager;
//import tech.starwin.utils.ui_utils.UIHelper;
//
//// TODO - Firebase配置
///**
// * Created by SiKang on 2018/9/27.
// */
//public class MsgHandleService extends FirebaseMessagingService {
// public static final String TAG = "MsgHandleService";
// public static final String RECEIVED_FIREBASE_MESSAGE = "action.receivedFireBaseMessage";
//
// @Override
// public void onNewToken(String token) {
// PreferencesManager.get().saveFireBaseMessagingToken(token);
// new UserPresenter().uploadFirebaseToken(token);
// }
//
// @Override
// public void onMessageReceived(RemoteMessage remoteMessage) {
// handleMsg(this, remoteMessage);
//
// if (remoteMessage.getNotification() != null) {
// RemoteMessage.Notification notificationInfo = remoteMessage.getNotification();
// NotificationCompat.Builder builder = new NotificationCompat.Builder(this, "default")
// .setContentTitle(notificationInfo.getTitle())
// .setContentText(notificationInfo.getBody())
// .setSmallIcon(LibConfig.APP_ICON)
// .setWhen(System.currentTimeMillis())
// .setTicker(notificationInfo.getTitle())
// .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
// .setAutoCancel(true);
// UIHelper.notifyNotification(getBaseContext(), builder);
// }
// }
//
// @Override
// public void onDeletedMessages() {
// }
//
// /**
// * 处理推送内容
// */
// public static void handleMsg(Context context, RemoteMessage remoteMessage) {
// if (remoteMessage != null) {
// //EventBus 通知
// EventBus.getDefault().post(remoteMessage);
// //广播 通知
// Intent intent = remoteMessage.toIntent();
// intent.setAction(RECEIVED_FIREBASE_MESSAGE);
// context.sendBroadcast(intent);
// }
//
// }
//
//}
src/main/java/com/common/service/MsgInstanceIdService.java
View file @
c0f39ef6
package
com
.
common
.
service
;
import
com.google.firebase.iid.FirebaseInstanceId
;
import
com.google.firebase.iid.FirebaseInstanceIdService
;
import
tech.starwin.utils.LogUtils
;
/**
* Created by SiKang on 2018/9/27.
*/
public
class
MsgInstanceIdService
extends
FirebaseInstanceIdService
{
public
static
final
String
TAG
=
"MsgInstanceIdService"
;
@Override
public
void
onTokenRefresh
()
{
String
refreshedToken
=
FirebaseInstanceId
.
getInstance
().
getToken
();
LogUtils
.
d
(
TAG
,
"message token:"
+
refreshedToken
);
}
}
//package com.common.service;
//
//import com.google.firebase.iid.FirebaseInstanceId;
//import com.google.firebase.iid.FirebaseInstanceIdService;
//
//import tech.starwin.utils.LogUtils;
//
///**
// * Created by SiKang on 2018/9/27.
// */
//// TODO - FireBase配置
//public class MsgInstanceIdService extends FirebaseInstanceIdService {
// public static final String TAG = "MsgInstanceIdService";
// @Override
// public void onTokenRefresh() {
// String refreshedToken = FirebaseInstanceId.getInstance().getToken();
// LogUtils.d(TAG, "message token:" + refreshedToken);
// }
//}
src/main/java/tech/starwin/LibConfig.java
View file @
c0f39ef6
...
...
@@ -6,7 +6,6 @@ import android.database.sqlite.SQLiteDatabase;
import
android.text.TextUtils
;
import
android.view.View
;
import
com.google.firebase.FirebaseApp
;
import
com.scwang.smartrefresh.layout.SmartRefreshLayout
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshFooterCreator
;
import
com.scwang.smartrefresh.layout.api.DefaultRefreshHeaderCreator
;
...
...
@@ -102,11 +101,10 @@ public class LibConfig {
//上传工具
UploadManager
.
init
(
CONTEXT
);
//TODO - FireBase配置
//init FireBase
FirebaseApp
.
initializeApp
(
CONTEXT
);
//
FirebaseApp.initializeApp(CONTEXT);
//RemoteConfig
// initFirebaseRemoteConfig();
//init SharePreferences
PreferencesManager
.
get
().
init
(
CONTEXT
);
...
...
src/main/java/tech/starwin/network/DefaultHeaderAddInterceptor.java
View file @
c0f39ef6
...
...
@@ -16,9 +16,7 @@ import okhttp3.RequestBody;
import
okhttp3.Response
;
import
okhttp3.internal.Util
;
import
tech.starwin.LibConfig
;
import
tech.starwin.R
;
import
tech.starwin.utils.LoginManager
;
import
tech.starwin.utils.PreferencesManager
;
/**
* Created by XLEO on 2018/1/30.
...
...
src/main/java/tech/starwin/utils/LogUtils.java
View file @
c0f39ef6
...
...
@@ -3,7 +3,6 @@ package tech.starwin.utils;
import
android.util.Log
;
import
com.google.firebase.analytics.FirebaseAnalytics
;
import
tech.starwin.BuildConfig
;
...
...
src/main/java/tech/starwin/utils/TrackEventHelper.java
View file @
c0f39ef6
...
...
@@ -7,7 +7,6 @@ import android.view.View;
import
android.widget.Button
;
import
android.widget.TextView
;
import
com.google.firebase.analytics.FirebaseAnalytics
;
import
tech.starwin.LibConfig
;
...
...
@@ -50,9 +49,10 @@ public class TrackEventHelper {
public
static
void
logClickEventByName
(
Context
context
,
String
itemName
)
{
Bundle
bundle
=
new
Bundle
();
String
eventName
=
"click_"
+
itemName
;
bundle
.
putString
(
FirebaseAnalytics
.
Param
.
CONTENT_TYPE
,
eventName
);
//TODO - FireBase配置
// bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, eventName);
//FireBase 埋点
FirebaseAnalytics
.
getInstance
(
context
).
logEvent
(
FirebaseAnalytics
.
Event
.
SELECT_CONTENT
,
bundle
);
//
FirebaseAnalytics.getInstance(context).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
if
(
onTrackEventListener
!=
null
)
{
onTrackEventListener
.
onActionClick
(
eventName
);
}
...
...
@@ -62,8 +62,9 @@ public class TrackEventHelper {
* 行为埋点
*/
public
static
void
logEvent
(
String
eventName
)
{
//TODO - FireBase配置
//FireBase 埋点
FirebaseAnalytics
.
getInstance
(
LibConfig
.
getContext
()).
logEvent
(
eventName
,
null
);
//
FirebaseAnalytics.getInstance(LibConfig.getContext()).logEvent(eventName, null);
if
(
onTrackEventListener
!=
null
)
{
onTrackEventListener
.
onActionEvent
(
eventName
);
}
...
...
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