MM内地版本
This commit is contained in:
@@ -223,18 +223,18 @@ public class IMApplication extends MultiDexApplication {
|
||||
private void initLang() {
|
||||
if (DataUtils.get(getAppContext(), "locale", -1) == -1) {//如果一次都没有设置,则需要默认设置一次,以便Activity中生效
|
||||
// PreferencesToolkits.getNew(getAppContext(),"locale",0);
|
||||
if (Locale.getDefault().getCountry().equals(Locale.CHINA.getCountry())) {
|
||||
DataUtils.set(getAppContext(), "locale", 1);
|
||||
if (Locale.getDefault().getCountry().equals(Locale.TAIWAN.getCountry())) {
|
||||
DataUtils.set(getAppContext(), "locale", 0);
|
||||
} else if (Locale.getDefault().equals(Locale.ENGLISH)) {
|
||||
DataUtils.set(getAppContext(), "locale", 2);
|
||||
} else if (Locale.getDefault().equals(Locale.JAPANESE)) {
|
||||
DataUtils.set(getAppContext(), "locale", 3);
|
||||
} else {
|
||||
DataUtils.set(getAppContext(), "locale", 0);
|
||||
DataUtils.set(getAppContext(), "locale", 1);
|
||||
}
|
||||
|
||||
}
|
||||
int loc = DataUtils.get(getAppContext(), "locale", 3);
|
||||
int loc = DataUtils.get(getAppContext(), "locale", -1);
|
||||
ChatDataUtils.set(getAppContext(), "locale", loc);
|
||||
|
||||
LogUtils.i("下标:" + loc);
|
||||
|
||||
@@ -193,6 +193,7 @@ public class NimSDKOptionConfig {
|
||||
|
||||
/**
|
||||
* config app image/voice/file/log directory
|
||||
* /storage/emulated/0/Android/data/com.dskj.rbchat/cache
|
||||
*/
|
||||
static String getAppCacheDir(Context context) {
|
||||
String storageRootPath = null;
|
||||
|
||||
151
app/src/main/java/com/dskj/rbchat/NotificationMsgService.java
Normal file
151
app/src/main/java/com/dskj/rbchat/NotificationMsgService.java
Normal file
@@ -0,0 +1,151 @@
|
||||
package com.dskj.rbchat;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.IBinder;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.ServiceCompat;
|
||||
|
||||
import com.dskj.rbchat.utils.LogUtils;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.yunxin.kit.chatkit.model.IMMessageInfo;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ChatObserverRepo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.common.ChatDataUtils;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.model.EventObserver;
|
||||
import com.netease.yunxin.kit.corekit.im.provider.FriendProvider;
|
||||
import com.netease.yunxin.kit.corekit.im.repo.SettingRepo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NotificationMsgService extends Service {
|
||||
|
||||
//处理在线通知而已
|
||||
private final EventObserver<List<IMMessageInfo>> receiveMessageObserver =
|
||||
new EventObserver<>() {
|
||||
@Override
|
||||
public void onEvent(@Nullable List<IMMessageInfo> event) {
|
||||
if (IMApplication.getForegroundActCount() == 0) { //在前台不推送
|
||||
LogUtils.d("messagechat" + "收到通知收到通知");
|
||||
IMMessage messageInfo = event.get(0).getMessage();
|
||||
if (messageInfo.getMsgType() == MsgTypeEnum.tip && messageInfo.getPushPayload().containsKey("sound")) {
|
||||
return;
|
||||
}
|
||||
if (SettingRepo.isPushNotify() && messageInfo.getMsgType() != MsgTypeEnum.nrtc_netcall) { //音视频单话就结束后会发送一条信息
|
||||
//收到私聊消息通知
|
||||
if (messageInfo.getSessionType() == SessionTypeEnum.P2P && FriendProvider.INSTANCE.isNotify(messageInfo.getFromAccount())) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
setNotifications(messageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
LogUtils.d("messagechat" + "没有收到");
|
||||
LogUtils.d("不在前台");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
private void setNotifications(IMMessage messageInfo) {
|
||||
|
||||
Intent notifyIntent = new Intent();
|
||||
ComponentName launchComponent = getApplication()
|
||||
.getPackageManager()
|
||||
.getLaunchIntentForPackage(getApplication().getPackageName())
|
||||
.getComponent();
|
||||
notifyIntent.setComponent(launchComponent);
|
||||
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||
notifyIntent.setAction(Intent.ACTION_VIEW);
|
||||
notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // 必须
|
||||
|
||||
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notifyIntent, PendingIntent.FLAG_IMMUTABLE);
|
||||
//获取本地设置消息铃声
|
||||
NotificationManager notificationManager = (NotificationManager) IMApplication.getAppContext().getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
|
||||
String channelID = ChatDataUtils.getMessageBell(IMKitClient.getUserInfo());
|
||||
LogUtils.d("channelId==" + channelID);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
// IMMessage messageInfo = event.get(0).getMessage();
|
||||
String content = "";
|
||||
if (!isShowDetails) {
|
||||
content = messageInfo.getContent();
|
||||
} else {
|
||||
if (messageInfo.getSessionType() == SessionTypeEnum.Team) {
|
||||
content = getString(R.string.message_notifycontent_team);
|
||||
} else if (messageInfo.getSessionType() == SessionTypeEnum.P2P) {
|
||||
content = getString(R.string.message_notifycontent_friend);
|
||||
} else if (messageInfo.getMsgType() == MsgTypeEnum.avchat) {
|
||||
content = getString(R.string.message_notifycontent_friend);
|
||||
}
|
||||
}
|
||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelID)
|
||||
.setSmallIcon(R.mipmap.ic_launcher)
|
||||
.setContentTitle(messageInfo.getFromNick())
|
||||
.setContentText(content)
|
||||
.setContentIntent(pendingIntent)
|
||||
.setAutoCancel(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||
notificationManager.notify(0, builder.build());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isShowDetails = true;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
|
||||
isShowDetails = intent.getBooleanExtra("isShowDetails", true);
|
||||
//注册通知
|
||||
ChatObserverRepo.registerReceiveMessageObserve(receiveMessageObserver);
|
||||
return super.onStartCommand(intent, flags, startId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
NotificationChannel channel = null;
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
channel = new NotificationChannel("1","前台服务",
|
||||
NotificationManager.IMPORTANCE_HIGH);
|
||||
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
manager.createNotificationChannel(channel);
|
||||
|
||||
Notification notification = new Notification.Builder(getApplicationContext(),"1").build();
|
||||
startForeground(1, notification);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
ChatObserverRepo.unregisterReceiveMessageObserve(receiveMessageObserver);
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
@@ -95,22 +95,22 @@ public class PhoneLoginActivity extends BaseActivity {
|
||||
setPrivacyContent(activityWelcomeBinding.mobileTipsTv);
|
||||
|
||||
countryBean = DataUtils.getLocCountry(PhoneLoginActivity.this);
|
||||
changeArea();
|
||||
activityWelcomeBinding.areaTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
SelectCountryDialog selectCountryDialog = new SelectCountryDialog(PhoneLoginActivity.this);
|
||||
selectCountryDialog.setOnToVipListener(new SelectCountryDialog.OnToTypeListener() {
|
||||
@Override
|
||||
public void toType(CountryBean type) {
|
||||
countryBean = type;
|
||||
changeArea();
|
||||
DataUtils.set(PhoneLoginActivity.this, IMUIKitConfig.LOC_COUNTRY_CODE, type.getAreaCodeName());
|
||||
}
|
||||
});
|
||||
selectCountryDialog.show();
|
||||
}
|
||||
});
|
||||
// changeArea();
|
||||
// activityWelcomeBinding.areaTv.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// SelectCountryDialog selectCountryDialog = new SelectCountryDialog(PhoneLoginActivity.this);
|
||||
// selectCountryDialog.setOnToVipListener(new SelectCountryDialog.OnToTypeListener() {
|
||||
// @Override
|
||||
// public void toType(CountryBean type) {
|
||||
// countryBean = type;
|
||||
// changeArea();
|
||||
// DataUtils.set(PhoneLoginActivity.this, IMUIKitConfig.LOC_COUNTRY_CODE, type.getAreaCodeName());
|
||||
// }
|
||||
// });
|
||||
// selectCountryDialog.show();
|
||||
// }
|
||||
// });
|
||||
activityWelcomeBinding.nextIv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -157,19 +157,19 @@ public class RegisterActivity extends BaseActivity {
|
||||
setPrivacyContent(activityWelcomeBinding.mobileTipsTv);
|
||||
|
||||
countryBean = DataUtils.getLocCountry(RegisterActivity.this);
|
||||
changeArea();
|
||||
activityWelcomeBinding.areaTv.setOnClickListener(v -> {
|
||||
SelectCountryDialog selectCountryDialog = new SelectCountryDialog(RegisterActivity.this);
|
||||
selectCountryDialog.setOnToVipListener(new SelectCountryDialog.OnToTypeListener() {
|
||||
@Override
|
||||
public void toType(CountryBean type) {
|
||||
countryBean = type;
|
||||
changeArea();
|
||||
DataUtils.set(RegisterActivity.this, IMUIKitConfig.LOC_COUNTRY_CODE, type.getAreaCodeName());
|
||||
}
|
||||
});
|
||||
selectCountryDialog.show();
|
||||
});
|
||||
// changeArea();
|
||||
// activityWelcomeBinding.areaTv.setOnClickListener(v -> {
|
||||
// SelectCountryDialog selectCountryDialog = new SelectCountryDialog(RegisterActivity.this);
|
||||
// selectCountryDialog.setOnToVipListener(new SelectCountryDialog.OnToTypeListener() {
|
||||
// @Override
|
||||
// public void toType(CountryBean type) {
|
||||
// countryBean = type;
|
||||
// changeArea();
|
||||
// DataUtils.set(RegisterActivity.this, IMUIKitConfig.LOC_COUNTRY_CODE, type.getAreaCodeName());
|
||||
// }
|
||||
// });
|
||||
// selectCountryDialog.show();
|
||||
// });
|
||||
activityWelcomeBinding.nextIv.setOnClickListener(v -> {
|
||||
if(lastTime>0){
|
||||
if(System.currentTimeMillis()-lastTime<2000){
|
||||
|
||||
@@ -18,6 +18,7 @@ import android.app.PendingIntent;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
@@ -25,6 +26,8 @@ import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.PowerManager;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
@@ -44,6 +47,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.core.app.NotificationCompat;
|
||||
import androidx.core.app.ServiceCompat;
|
||||
import androidx.core.view.WindowCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
@@ -57,6 +61,7 @@ import com.dskj.rbchat.AppSkinConfig;
|
||||
import com.dskj.rbchat.CustomConfig;
|
||||
import com.dskj.rbchat.IMApplication;
|
||||
import com.dskj.rbchat.IMUIKitConfig;
|
||||
import com.dskj.rbchat.NotificationMsgService;
|
||||
import com.dskj.rbchat.R;
|
||||
import com.dskj.rbchat.adapter.CommonAdapter;
|
||||
import com.dskj.rbchat.adapter.ViewHolder;
|
||||
@@ -264,7 +269,9 @@ public class MainActivity extends BaseActivity {
|
||||
if (SettingRepo.isPushNotify() && messageInfo.getMsgType() != MsgTypeEnum.nrtc_netcall) { //音视频单话就结束后会发送一条信息
|
||||
//收到私聊消息通知
|
||||
if (messageInfo.getSessionType() == SessionTypeEnum.P2P && FriendProvider.INSTANCE.isNotify(messageInfo.getFromAccount())) {
|
||||
setNotifications(event);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
setNotifications(messageInfo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -277,7 +284,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.O)
|
||||
private void setNotifications(List<IMMessageInfo> event) {
|
||||
private void setNotifications(IMMessage messageInfo) {
|
||||
|
||||
Intent notifyIntent = new Intent();
|
||||
ComponentName launchComponent = getApplication()
|
||||
@@ -296,7 +303,7 @@ public class MainActivity extends BaseActivity {
|
||||
String channelID = ChatDataUtils.getMessageBell(IMKitClient.getUserInfo());
|
||||
LogUtils.d("channelId==" + channelID);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
IMMessage messageInfo = event.get(0).getMessage();
|
||||
// IMMessage messageInfo = event.get(0).getMessage();
|
||||
String content = "";
|
||||
if (!notifyViewModel.getPushShowNoDetail()) {
|
||||
content = messageInfo.getContent();
|
||||
@@ -317,6 +324,7 @@ public class MainActivity extends BaseActivity {
|
||||
.setAutoCancel(true)
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT);
|
||||
notificationManager.notify(0, builder.build());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -342,6 +350,7 @@ public class MainActivity extends BaseActivity {
|
||||
|
||||
private SettingNotifyViewModel notifyViewModel;
|
||||
private Subscription mEventSubscription;
|
||||
Intent notifyService;
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
@Override
|
||||
@@ -460,7 +469,6 @@ public class MainActivity extends BaseActivity {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public int getNavigationBarHeight(Context context) {
|
||||
@@ -645,13 +653,13 @@ public class MainActivity extends BaseActivity {
|
||||
shareDateUtils = new ShareDateUtils();
|
||||
shareDateUtils.getAllSessionList();
|
||||
shareDateUtils.getLocFriends();
|
||||
index2Fragment = new HomeFragment();
|
||||
// index2Fragment = new HomeFragment();
|
||||
chatTabFragment = new ChatTabFragment();
|
||||
voomFragment = new VoomFragment();
|
||||
// voomFragment = new VoomFragment();
|
||||
walletFragment = new MineFragment();
|
||||
fragments.add(index2Fragment);
|
||||
// fragments.add(index2Fragment);
|
||||
fragments.add(chatTabFragment);
|
||||
fragments.add(voomFragment);
|
||||
// fragments.add(voomFragment);
|
||||
fragments.add(walletFragment);
|
||||
|
||||
fragmentAdapter = new FragmentAdapter(this);
|
||||
@@ -660,7 +668,7 @@ public class MainActivity extends BaseActivity {
|
||||
activityMainBinding.viewPager.setAdapter(fragmentAdapter);
|
||||
activityMainBinding.viewPager.setCurrentItem(START_INDEX, false);
|
||||
activityMainBinding.viewPager.setOffscreenPageLimit(fragments.size());
|
||||
mCurrentTab = activityMainBinding.conversationBtnGroup;
|
||||
mCurrentTab = activityMainBinding.contactBtnGroup;
|
||||
resetTabSkin(isCommonSkin);
|
||||
checkZhiWen();
|
||||
}
|
||||
@@ -1360,6 +1368,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (bindBean == null || (!bindBean.getPhoneBind()) || (!bindBean.getPayPasswordSet())) {
|
||||
bindInfo();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void bindInfo() {
|
||||
@@ -1389,6 +1398,7 @@ public class MainActivity extends BaseActivity {
|
||||
if (mEventSubscription != null) {
|
||||
mEventSubscription.unsubscribe();
|
||||
}
|
||||
// stopService(notifyService);
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -1406,7 +1416,7 @@ public class MainActivity extends BaseActivity {
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
private void resetTabSkin(boolean isCommonSkin) {
|
||||
if (mCurrentTab == activityMainBinding.contactBtnGroup) {
|
||||
activityMainBinding.viewPager.setCurrentItem(1, false);
|
||||
activityMainBinding.viewPager.setCurrentItem(0, false);
|
||||
activityMainBinding.contact.setTextColor(
|
||||
getResources().getColor(R.color.color_fe6881));
|
||||
activityMainBinding.contact.setCompoundDrawablesWithIntrinsicBounds(
|
||||
@@ -1420,7 +1430,7 @@ public class MainActivity extends BaseActivity {
|
||||
null, getResources().getDrawable(R.mipmap.voom_img_t), null, null);
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
} else if (mCurrentTab == activityMainBinding.myselfBtnGroup) {
|
||||
activityMainBinding.viewPager.setCurrentItem(3, false);
|
||||
activityMainBinding.viewPager.setCurrentItem(1, false);
|
||||
activityMainBinding.mine.setTextColor(getResources().getColor(R.color.color_fe6881));
|
||||
activityMainBinding.mine.setCompoundDrawablesWithIntrinsicBounds(
|
||||
null, getResources().getDrawable(R.mipmap.wo_t), null, null);
|
||||
@@ -1434,6 +1444,35 @@ public class MainActivity extends BaseActivity {
|
||||
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
|
||||
}
|
||||
// if (mCurrentTab == activityMainBinding.contactBtnGroup) {
|
||||
// activityMainBinding.viewPager.setCurrentItem(1, false);
|
||||
// activityMainBinding.contact.setTextColor(
|
||||
// getResources().getColor(R.color.color_fe6881));
|
||||
// activityMainBinding.contact.setCompoundDrawablesWithIntrinsicBounds(
|
||||
// null, getResources().getDrawable(R.mipmap.chat_img_t), null, null);
|
||||
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
// } else if (mCurrentTab == activityMainBinding.liveBtnGroup) {
|
||||
// activityMainBinding.viewPager.setCurrentItem(2, false);
|
||||
// activityMainBinding.live.setTextColor(
|
||||
// getResources().getColor(R.color.color_fe6881));
|
||||
// activityMainBinding.live.setCompoundDrawablesWithIntrinsicBounds(
|
||||
// null, getResources().getDrawable(R.mipmap.voom_img_t), null, null);
|
||||
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
// } else if (mCurrentTab == activityMainBinding.myselfBtnGroup) {
|
||||
// activityMainBinding.viewPager.setCurrentItem(3, false);
|
||||
// activityMainBinding.mine.setTextColor(getResources().getColor(R.color.color_fe6881));
|
||||
// activityMainBinding.mine.setCompoundDrawablesWithIntrinsicBounds(
|
||||
// null, getResources().getDrawable(R.mipmap.wo_t), null, null);
|
||||
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
// } else if (mCurrentTab == activityMainBinding.conversationBtnGroup) {
|
||||
// activityMainBinding.viewPager.setCurrentItem(0, false);
|
||||
// activityMainBinding.conversation.setTextColor(
|
||||
// getResources().getColor(R.color.color_fe6881));
|
||||
// activityMainBinding.conversation.setCompoundDrawablesWithIntrinsicBounds(
|
||||
// null, getResources().getDrawable(R.mipmap.index_img_t), null, null);
|
||||
// getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,13 +27,21 @@ import com.dskj.rbchat.main.FragmentAdapter;
|
||||
import com.dskj.rbchat.main.MainActivity;
|
||||
import com.dskj.rbchat.main.index.add.AddFriendsActivity;
|
||||
import com.dskj.rbchat.event.ConversationEditEvent;
|
||||
import com.dskj.rbchat.main.message.NotifyMessageActivity;
|
||||
import com.dskj.rbchat.model.BindBean;
|
||||
import com.dskj.rbchat.model.NotifyCountBean;
|
||||
import com.dskj.rbchat.network.Api;
|
||||
import com.dskj.rbchat.network.BaseObserver;
|
||||
import com.dskj.rbchat.network.Result;
|
||||
import com.dskj.rbchat.utils.DataUtils;
|
||||
import com.dskj.rbchat.utils.GsonUtils;
|
||||
import com.dskj.rbchat.utils.LogUtils;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.yunxin.kit.alog.ALog;
|
||||
import com.netease.yunxin.kit.chatkit.model.ConversationInfo;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ContactRepo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.fun.FunChatForwardSelectDialog;
|
||||
import com.netease.yunxin.kit.common.ui.fragments.BaseFragment;
|
||||
import com.netease.yunxin.kit.common.utils.NetworkUtils;
|
||||
@@ -43,11 +51,15 @@ import com.netease.yunxin.kit.conversationkit.ui.model.ConversationBean;
|
||||
import com.netease.yunxin.kit.corekit.event.EventCenter;
|
||||
import com.netease.yunxin.kit.corekit.event.EventNotify;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.provider.FetchCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
//聊天会话View 把注册监听 放到childfragment 不然分屏之后不会更新数据
|
||||
public class ChatTabFragment extends BaseFragment {
|
||||
|
||||
@@ -147,6 +159,100 @@ public class ChatTabFragment extends BaseFragment {
|
||||
// initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
getNotifiesCount();
|
||||
if (verifyCount > 0) {
|
||||
getNotificationUnreadCount();
|
||||
}
|
||||
if (bindBean == null || (!bindBean.getPhoneBind()) || (!bindBean.getPayPasswordSet())) {
|
||||
bindInfo();
|
||||
}
|
||||
}
|
||||
|
||||
BindBean bindBean;
|
||||
private void bindInfo() {
|
||||
Api.getInstance().bindInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<BindBean>>() {
|
||||
@Override
|
||||
public void onSuccess(Result<BindBean> feedbackResp) {
|
||||
bindBean = feedbackResp.data;
|
||||
LogUtils.i("获取到的数据:" + GsonUtils.beanToJSONString(bindBean));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public void setNotifyTotalCount() {
|
||||
int notifyTotalCount = notifyCount + verifyCount;
|
||||
if (notifyTotalCount > 0) {
|
||||
viewBinding.viewChatfmNotifypoint.setVisibility(View.VISIBLE);
|
||||
viewBinding.viewChatfmNotifypoint.setText("" + notifyTotalCount);
|
||||
} else {
|
||||
viewBinding.viewChatfmNotifypoint.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void getNotificationUnreadCount() {
|
||||
ContactRepo.getNotificationUnreadCount(new FetchCallback<Integer>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Integer integer) {
|
||||
verifyCount = integer;
|
||||
setNotifyTotalCount();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int i) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(@Nullable Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int verifyCount = 0;
|
||||
int notifyCount = 0;
|
||||
private void getNotifiesCount() {
|
||||
notifyCount = 0;
|
||||
String time = DataUtils.getCurrentTimeType(DataUtils.get(getActivity(), "notify_message_time_" + IMKitClient.account(), IMUIKitConfig.NOTIFY_MESSAGE_START_TIME));
|
||||
Api.getInstance().notifiesmessageCountNew(IMKitClient.account(), time)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<NotifyCountBean> feedbackResp) {
|
||||
LogUtils.i("获取到的错误:" + feedbackResp + "" + feedbackResp.data);
|
||||
int count = feedbackResp.data.getSystemMsgCount();
|
||||
int activityMsgCount = feedbackResp.data.getActivityMsgCount();
|
||||
int msgcount = DataUtils.get(getActivity(), "activity_message_count", 0);
|
||||
if (activityMsgCount > msgcount) {
|
||||
DataUtils.set(getActivity(), "activity_message_count", activityMsgCount);
|
||||
}
|
||||
notifyCount = count + activityMsgCount;
|
||||
setNotifyTotalCount();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getServicesData() {
|
||||
String tagString = DataUtils.get(IMApplication.getAppContext(), IMUIKitConfig.SERVICES_IDS_TAG + "_" + IMKitClient.account(), "");
|
||||
@@ -209,6 +315,11 @@ public class ChatTabFragment extends BaseFragment {
|
||||
viewBinding.viewContactclick.setOnClickListener(view -> {
|
||||
startActivity(new Intent(getActivity(), ContactActivity.class));
|
||||
});
|
||||
viewBinding.ivIndexfmNotifytop.setOnClickListener(v -> {
|
||||
notifyCount = 0;
|
||||
setNotifyTotalCount();
|
||||
startActivity(new Intent(getActivity(), NotifyMessageActivity.class));
|
||||
});
|
||||
viewBinding.layoutChatfmCommonSearch.getRoot().setOnClickListener(view -> startActivity(new Intent(getActivity(), FunSearchActivity.class))
|
||||
);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ public class DataUtils {
|
||||
*/
|
||||
public static List<CountryBean> getCountry(Context context) {
|
||||
List<CountryBean> countryBeans = new ArrayList<>();
|
||||
int localeLan = DataUtils.get(context, "locale", 0);
|
||||
int localeLan = DataUtils.get(context, "locale", 1);
|
||||
String jsonStr = "";
|
||||
if (localeLan == 1) {
|
||||
jsonStr = getAssetsJson(context, "countrycn.json");
|
||||
@@ -152,9 +152,9 @@ public class DataUtils {
|
||||
public static CountryBean getLocCountry(Context context) {
|
||||
String areaCode;
|
||||
try {
|
||||
areaCode = DataUtils.get(context, IMUIKitConfig.LOC_COUNTRY_CODE, "+886");
|
||||
areaCode = DataUtils.get(context, IMUIKitConfig.LOC_COUNTRY_CODE, "+86");
|
||||
} catch (Exception e) {
|
||||
areaCode = "+" + DataUtils.get(context, IMUIKitConfig.LOC_COUNTRY_CODE, 886); //兼容老版本
|
||||
areaCode = "+" + DataUtils.get(context, IMUIKitConfig.LOC_COUNTRY_CODE, 86); //兼容老版本
|
||||
}
|
||||
List<CountryBean> countryBeans = getCountry(context);
|
||||
for (CountryBean country : countryBeans) {
|
||||
@@ -162,7 +162,7 @@ public class DataUtils {
|
||||
return country;
|
||||
}
|
||||
}
|
||||
return new CountryBean("+886", context.getString(R.string.taiwan_txt));
|
||||
return new CountryBean("+86", context.getString(R.string.zhongguo_txt));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -131,26 +131,31 @@ public class WelcomeActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
private void showIsLogin(boolean isLogin) {
|
||||
getWindow().setBackgroundDrawableResource(com.netease.yunxin.nertc.ui.R.color.white);
|
||||
// if (isLogin) {
|
||||
AnimationDrawable mLoadingAnimationDrawable = (AnimationDrawable) activityWelcomeBinding.appYunxinIcon.getDrawable();
|
||||
//直接就开始执行,性能不是最佳的。
|
||||
mLoadingAnimationDrawable.start();
|
||||
new Handler().postDelayed(() -> {
|
||||
getWindow().setBackgroundDrawableResource(R.color.transparent);
|
||||
}, 2800);
|
||||
if (!isLogin) {
|
||||
// 计算动画执行的时间
|
||||
int duration = 0;
|
||||
for (int i = 0; i < mLoadingAnimationDrawable.getNumberOfFrames(); i++) {
|
||||
duration += mLoadingAnimationDrawable.getDuration(i);
|
||||
}
|
||||
new Handler().postDelayed(() -> {
|
||||
activityWelcomeBinding.appYunxinIcon.setImageResource(R.drawable.kefu_loading2);
|
||||
AnimationDrawable mLoadingAnimationDrawable1 = (AnimationDrawable) activityWelcomeBinding.appYunxinIcon.getDrawable();
|
||||
mLoadingAnimationDrawable1.start();
|
||||
}, duration);
|
||||
}
|
||||
|
||||
//加载动画
|
||||
activityWelcomeBinding.lottieView.setAnimation(R.raw.loading);
|
||||
activityWelcomeBinding.lottieView.playAnimation();
|
||||
|
||||
// getWindow().setBackgroundDrawableResource(com.netease.yunxin.nertc.ui.R.color.white);
|
||||
//// if (isLogin) {
|
||||
// AnimationDrawable mLoadingAnimationDrawable = (AnimationDrawable) activityWelcomeBinding.appYunxinIcon.getDrawable();
|
||||
// //直接就开始执行,性能不是最佳的。
|
||||
// mLoadingAnimationDrawable.start();
|
||||
// new Handler().postDelayed(() -> {
|
||||
// getWindow().setBackgroundDrawableResource(R.color.transparent);
|
||||
// }, 2800);
|
||||
// if (!isLogin) {
|
||||
// // 计算动画执行的时间
|
||||
// int duration = 0;
|
||||
// for (int i = 0; i < mLoadingAnimationDrawable.getNumberOfFrames(); i++) {
|
||||
// duration += mLoadingAnimationDrawable.getDuration(i);
|
||||
// }
|
||||
// new Handler().postDelayed(() -> {
|
||||
// activityWelcomeBinding.appYunxinIcon.setImageResource(R.drawable.kefu_loading2);
|
||||
// AnimationDrawable mLoadingAnimationDrawable1 = (AnimationDrawable) activityWelcomeBinding.appYunxinIcon.getDrawable();
|
||||
// mLoadingAnimationDrawable1.start();
|
||||
// }, duration);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user