From 3ae14ed506501b6d18a215d909577e3db354c31f Mon Sep 17 00:00:00 2001
From: 18142669586 <1669783059@qq.com>
Date: Sat, 20 Aug 2022 14:48:09 +0800
Subject: [PATCH] 111
---
app/src/main/AndroidManifest.xml | 15 +-
.../utils/MyNotificationService.java | 70 ++++++
.../com/yunbao/common/http/HttpCallback.java | 6 +-
.../main/res/layout/notification_message.xml | 53 +++++
config.gradle | 5 +-
.../yunbao/live/adapter/ImListAdapter.java | 2 +-
.../live/presenter/LiveLinkMicPresenter.java | 8 +-
.../yunbao/live/views/LiveRoomViewHolder.java | 2 +-
main/build.gradle | 2 +
main/src/main/AndroidManifest.xml | 14 +-
.../yunbao/main/activity/MainActivity.java | 35 +--
.../yunbao/main/activity/MsgSettActivity.java | 23 ++
.../yunbao/main/activity/SettingActivity.java | 4 +-
.../PDLiveCustomConversationProvider.java | 2 +-
.../yunbao/main/views/MainHomeViewHolder.java | 2 +-
.../src/main/res/layout/activity_msg_sett.xml | 221 ++++++++++++++++++
16 files changed, 422 insertions(+), 42 deletions(-)
create mode 100644 app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
create mode 100644 common/src/main/res/layout/notification_message.xml
create mode 100644 main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java
create mode 100644 main/src/main/res/layout/activity_msg_sett.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 441c442ba..fa8da8be4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -92,13 +92,19 @@
android:usesCleartextTraffic="true"
tools:replace="theme,label,icon,allowBackup">
+ android:name="com.shayu.phonelive.utils.MyNotificationService">
-
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
new file mode 100644
index 000000000..c8d229464
--- /dev/null
+++ b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
@@ -0,0 +1,70 @@
+package com.shayu.phonelive.utils;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.media.RingtoneManager;
+import android.net.Uri;
+import android.util.Log;
+import android.widget.RemoteViews;
+
+import androidx.core.app.NotificationCompat;
+import androidx.core.app.NotificationManagerCompat;
+
+import com.google.android.gms.common.internal.zzm;
+import com.google.firebase.messaging.FirebaseMessagingService;
+import com.google.firebase.messaging.RemoteMessage;
+import com.yunbao.common.utils.ToastUtil;
+import com.yunbao.main.activity.MainActivity;
+
+import myname.pdlive.shayu.R;
+
+public class MyNotificationService extends FirebaseMessagingService {
+ private String createNotificationChannel(String channelID, String channelNAME, int level) {
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
+ NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
+ NotificationChannel channel = new NotificationChannel(channelID, channelNAME, level);
+ manager.createNotificationChannel(channel);
+ return channelID;
+ } else {
+ return null;
+ }
+ }
+ public void onMessageReceived(RemoteMessage remoteMessage) {
+ Log.e("gmc","remoteMessage");
+ // do nothing
+ sendNotification("remoteMessage");
+ }
+
+
+
+ private void sendNotification(String messageBody) {
+
+ // 设置通知的点击行为:这里启动一个 Activity
+ Intent intent = new Intent(this, MainActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
+ String channelId = createNotificationChannel("my_channel_ID", "my_channel_NAME", NotificationManager.IMPORTANCE_HIGH);
+ // 构建 remoteView
+ RemoteViews remoteView = new RemoteViews(getPackageName(), R.layout.notification_message);
+// remoteView.setTextViewText(R.id.tvMsg, "RemoteViews");
+// remoteView.setImageViewResource(R.id.ivIcon, R.mipmap.ic_launcher_round);
+ NotificationCompat.Builder builder = new NotificationCompat.Builder(this,channelId);
+ // 设置自定义 RemoteViews
+ builder.setContent(remoteView).setSmallIcon(R.mipmap.ic_launcher);
+ // 设置通知的优先级(悬浮通知)
+ builder.setPriority(NotificationCompat.PRIORITY_MAX);
+ builder.setContentIntent(pendingIntent);
+ builder.setAutoCancel(true);
+ Notification notification = builder.build();
+ NotificationManager manager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
+ manager.notify(0, notification);
+
+ }
+
+}
diff --git a/common/src/main/java/com/yunbao/common/http/HttpCallback.java b/common/src/main/java/com/yunbao/common/http/HttpCallback.java
index dc31bfdea..11637be1a 100644
--- a/common/src/main/java/com/yunbao/common/http/HttpCallback.java
+++ b/common/src/main/java/com/yunbao/common/http/HttpCallback.java
@@ -45,11 +45,7 @@ public abstract class HttpCallback extends AbsCallback {
//token过期,重新登录
RouteUtil.forwardLoginInvalid(data.getMsg());
} else {
- if(data.getInfo().length==0){
- onSuccess(data.getCode(), data.getMsg(), new String[]{data.getData()});
- }else {
- onSuccess(data.getCode(), data.getMsg(), data.getInfo());
- }
+ onSuccess(data.getCode(), data.getMsg(), data.getInfo());
}
} else {
L.e("服务器返回值异常--->ret: " + bean.getRet() + " msg: " + bean.getMsg());
diff --git a/common/src/main/res/layout/notification_message.xml b/common/src/main/res/layout/notification_message.xml
new file mode 100644
index 000000000..0939da377
--- /dev/null
+++ b/common/src/main/res/layout/notification_message.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/config.gradle b/config.gradle
index 3f66756b1..d733c9c09 100644
--- a/config.gradle
+++ b/config.gradle
@@ -9,9 +9,10 @@ ext {
]
manifestPlaceholders = [
//正式
-// serverHost : "https://napi.yaoulive.com",
+
+ serverHost : "https://napi.yaoulive.com",
//測試
- serverHost : "https://ceshi.yaoulive.com",
+// serverHost : "https://ceshi.yaoulive.com",
//腾讯地图
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",
diff --git a/live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java b/live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java
index 417f3a25b..1abf88b9a 100644
--- a/live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java
+++ b/live/src/main/java/com/yunbao/live/adapter/ImListAdapter.java
@@ -290,7 +290,7 @@ public class ImListAdapter extends RecyclerView.Adapter
}
if ("1".equals(bean.getIs_admin())) {
- ImgLoader.display(mContext, "https://qny.shayucm.com/Instructors.png", img_new);
+ ImgLoader.display(mContext, "https://downs.yaoulive.com/Instructors.png", img_new);
img_new.setVisibility(View.VISIBLE);
} else {
img_new.setVisibility(View.GONE);
diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
index 3edffa9a8..87846ad27 100644
--- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
+++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPresenter.java
@@ -326,7 +326,7 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
});
//周星
BannerBean bannerBean = new BannerBean();
- bannerBean.setImageUrl("https://qny.shayucm.com/img/BTN_WEEKSTAR%20%281%29.png");
+ bannerBean.setImageUrl("https://downs.yaoulive.com/img/BTN_WEEKSTAR%20%281%29.png");
bannerBean.setLink("zxb");
mBannerList1.add(bannerBean);
@@ -358,18 +358,18 @@ public class LiveLinkMicPresenter implements View.OnClickListener {
}
}
BannerBean banner3Bean = new BannerBean();
- banner3Bean.setImageUrl("https://qny.shayucm.com/live_Mission_box.png");
+ banner3Bean.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
banner3Bean.setLink(obj.getString("sendgift"));
mBannerList3.add(banner3Bean);
BannerBean banner3Bean1 = new BannerBean();
- banner3Bean1.setImageUrl("https://qny.shayucm.com/live_Mission_box.png");
+ banner3Bean1.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
banner3Bean1.setLink(obj.getString("attent"));
mBannerList3.add(banner3Bean1);
BannerBean banner3Bean2 = new BannerBean();
- banner3Bean2.setImageUrl("https://qny.shayucm.com/live_Mission_box.png");
+ banner3Bean2.setImageUrl("https://downs.yaoulive.com/live_Mission_box.png");
banner3Bean2.setLink(obj.getString("illumine"));
mBannerList3.add(banner3Bean2);
diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
index c81d168ca..94986da77 100644
--- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
+++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java
@@ -1773,7 +1773,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
* 获取是否有热度卡加成
*/
public static void getIsHot() {
- ImgLoader.display(Contexts, "https://qny.shayucm.com/img_hot_gif.gif", img_hot_gif);
+ ImgLoader.display(Contexts, "https://downs.yaoulive.com/img_hot_gif.gif", img_hot_gif);
LiveHttpUtil.isHotCard(mLiveUid, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
diff --git a/main/build.gradle b/main/build.gradle
index 45faf87ee..5664cbc1c 100644
--- a/main/build.gradle
+++ b/main/build.gradle
@@ -70,6 +70,8 @@ dependencies {
//短视频
api project(':video')
api project(':common')
+ implementation 'androidx.appcompat:appcompat:1.3.0'
+ implementation 'com.google.android.material:material:1.4.0'
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
api files('libs/OpenInstall_v2.3.0.jar')
implementation project(path: ':lib_country_code')
diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml
index f83b60038..e1790638b 100644
--- a/main/src/main/AndroidManifest.xml
+++ b/main/src/main/AndroidManifest.xml
@@ -5,7 +5,10 @@
-
+
+
@@ -56,7 +59,7 @@
+ android:theme="@style/CAppTheme" />
@@ -122,8 +125,7 @@
android:screenOrientation="portrait" />
-
+ android:screenOrientation="portrait" />
-
+
\ No newline at end of file
diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
index 9f2fc8e66..fb048fbc9 100644
--- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
@@ -277,23 +277,23 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
// RTCLib 初始化
RCRTCConfig.Builder config = RCRTCConfig.Builder.create();
RCRTCEngine.getInstance().init(MainActivity.this, config.build());
-// FirebaseMessaging.getInstance().getToken()
-// .addOnCompleteListener(new OnCompleteListener() {
-// @Override
-// public void onComplete(@NonNull Task task) {
-// if (!task.isSuccessful()) {
-// Log.w(TAG, "Fetching FCM registration token failed", task.getException());
-// return;
-// }
-//
-// // Get new FCM registration token
-// String token = task.getResult();
-//
-// // Log and toast
-// Log.d(TAG, token);
-// Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
-// }
-// });
+ FirebaseMessaging.getInstance().getToken()
+ .addOnCompleteListener(new OnCompleteListener() {
+ @Override
+ public void onComplete(@NonNull Task task) {
+ if (!task.isSuccessful()) {
+ Log.w(TAG, "Fetching FCM registration token failed", task.getException());
+ return;
+ }
+
+ // Get new FCM registration token
+ String token = task.getResult();
+
+ // Log and toast
+ Log.d(TAG, token);
+ Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
+ }
+ });
boolean showInvite = getIntent().getBooleanExtra(Constants.SHOW_INVITE, false);
mRootView = (ViewGroup) findViewById(R.id.rootView);
floatBanner = findViewById(R.id.float_banner_home);
@@ -379,6 +379,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
if (showInvite) {
showInvitationCode();
}
+
checkVersion();
loginIM();
CommonAppConfig.getInstance().setLaunched(true);
diff --git a/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java
new file mode 100644
index 000000000..d33226cb4
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/activity/MsgSettActivity.java
@@ -0,0 +1,23 @@
+package com.yunbao.main.activity;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+import com.yunbao.common.activity.AbsActivity;
+import com.yunbao.main.R;
+
+public class MsgSettActivity extends AbsActivity {
+
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.activity_msg_sett;
+ }
+
+ @Override
+ protected void main() {
+ super.main();
+ setTitle("消息通知");
+ }
+}
\ No newline at end of file
diff --git a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java
index 3812f05d6..575a5cab6 100644
--- a/main/src/main/java/com/yunbao/main/activity/SettingActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/SettingActivity.java
@@ -96,7 +96,9 @@ public class SettingActivity extends AbsActivity implements OnItemClickListener<
FollowActivity.forward(mContext, CommonAppConfig.getInstance().getUid(),1);
} else if (bean.getId() == SETTING_CLEAR_CACHE) {//清除缓存
clearCache(position);
- }
+ }else if (bean.getId() == 21) {//清除缓存
+ startActivity(new Intent(SettingActivity.this,MsgSettActivity.class));
+ }
} else {
if (bean.getId() == 17) {//意见反馈要在url上加版本号和设备号
href += "&version=" + android.os.Build.VERSION.RELEASE + "&model=" + android.os.Build.MODEL;
diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java
index 78480bbfb..b0afb8644 100644
--- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java
+++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java
@@ -60,7 +60,7 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider {
if (userInfo != null && !TextUtils.isEmpty(userInfo.getExtra())) {
IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class);
if (model != null && TextUtils.equals(model.getIsAdmin(), "1"))
- Glide.with(holder.getContext()).asDrawable().load("https://qny.shayucm.com/Instructors.png").into(imgNew);
+ Glide.with(holder.getContext()).asDrawable().load("https://downs.yaoulive.com/Instructors.png").into(imgNew);
}
}
diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
index 834025436..4e4e1eeec 100644
--- a/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainHomeViewHolder.java
@@ -35,7 +35,7 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
super.init();
img_trophy = (ImageView) findViewById(R.id.img_trophy);
- ImgLoader.display(mContext, "https://qny.shayucm.com/gif_trophy.gif", img_trophy);
+ ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
}
@Override
diff --git a/main/src/main/res/layout/activity_msg_sett.xml b/main/src/main/res/layout/activity_msg_sett.xml
new file mode 100644
index 000000000..794671e14
--- /dev/null
+++ b/main/src/main/res/layout/activity_msg_sett.xml
@@ -0,0 +1,221 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file