Commit 149c7a66b92d87242bc587a8ce7bc1ebab02dc14
1 parent
6c56b92a
6.0聊天室权限认证,添加签名信息,更新Jar
Showing
6 changed files
with
40 additions
and
7 deletions
app/build.gradle
| ... | ... | @@ -11,13 +11,28 @@ android { |
| 11 | 11 | versionName "1.0" |
| 12 | 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
| 13 | 13 | } |
| 14 | + | |
| 14 | 15 | dataBinding { |
| 15 | 16 | enabled true |
| 16 | 17 | } |
| 18 | + | |
| 19 | + signingConfigs { | |
| 20 | + myConfig { | |
| 21 | + storeFile file("cnlive_app.jks") | |
| 22 | + storePassword "000000" | |
| 23 | + keyAlias "CNliveApp" | |
| 24 | + keyPassword "000000" | |
| 25 | + } | |
| 26 | + } | |
| 27 | + | |
| 17 | 28 | buildTypes { |
| 29 | + debug{ | |
| 30 | + signingConfig signingConfigs.myConfig | |
| 31 | + } | |
| 18 | 32 | release { |
| 19 | 33 | minifyEnabled false |
| 20 | 34 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 35 | + signingConfig signingConfigs.myConfig | |
| 21 | 36 | } |
| 22 | 37 | } |
| 23 | 38 | } | ... | ... |
app/cnlive_app.jks
0 → 100644
No preview for this file type
app/libs/libcnlivelive.jar
No preview for this file type
app/libs/libcnliveutil.jar
No preview for this file type
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
| 1 | 1 | package com.cnlive.gundam.video.fragment.chat; |
| 2 | 2 | |
| 3 | +import android.Manifest; | |
| 4 | +import android.content.pm.PackageManager; | |
| 3 | 5 | import android.databinding.BindingAdapter; |
| 4 | 6 | import android.databinding.DataBindingUtil; |
| 5 | 7 | import android.os.Bundle; |
| 8 | +import android.support.annotation.NonNull; | |
| 6 | 9 | import android.support.annotation.Nullable; |
| 7 | 10 | import android.support.v4.app.Fragment; |
| 11 | +import android.support.v4.content.ContextCompat; | |
| 8 | 12 | import android.support.v7.widget.GridLayoutManager; |
| 9 | 13 | import android.support.v7.widget.SwitchCompat; |
| 10 | 14 | import android.view.LayoutInflater; |
| ... | ... | @@ -20,6 +24,7 @@ import com.cnlive.gundam.databinding.FragmentChatBinding; |
| 20 | 24 | import com.cnlive.gundam.user.auth.UserService; |
| 21 | 25 | import com.cnlive.gundam.user.model.User; |
| 22 | 26 | import com.cnlive.gundam.user.util.InputUtil; |
| 27 | +import com.cnlive.gundam.user.util.ToastUtil; | |
| 23 | 28 | import com.cnlive.gundam.video.adpter.CommonAdapter; |
| 24 | 29 | import com.cnlive.gundam.video.adpter.GiftAdapter; |
| 25 | 30 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; |
| ... | ... | @@ -42,6 +47,8 @@ import java.util.ArrayList; |
| 42 | 47 | */ |
| 43 | 48 | public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback, MessageContentInfo.OnChatListener { |
| 44 | 49 | |
| 50 | + private final int PERMISSION_REQUEST_CODE = 0x1001; | |
| 51 | + | |
| 45 | 52 | private FragmentChatBinding fragmentChatBinding; |
| 46 | 53 | private ArrayList<GiftModle> giftArray; |
| 47 | 54 | private CommonAdapter<MessageContent> messageContentCommonAdapter; |
| ... | ... | @@ -77,9 +84,24 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 77 | 84 | initListener(); |
| 78 | 85 | initDate(); |
| 79 | 86 | initGift(); |
| 80 | - initChat(); | |
| 87 | + int checkCallPhonePermission = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.READ_PHONE_STATE); | |
| 88 | + if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) { | |
| 89 | + requestPermissions(new String[]{Manifest.permission.READ_PHONE_STATE}, PERMISSION_REQUEST_CODE); | |
| 90 | + }else{ | |
| 91 | + initChat(); | |
| 92 | + } | |
| 93 | + } | |
| 94 | + @Override | |
| 95 | + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |
| 96 | + super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |
| 97 | + if(requestCode == PERMISSION_REQUEST_CODE){ | |
| 98 | + if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |
| 99 | + initChat(); | |
| 100 | + } else { | |
| 101 | + ToastUtil.show(getActivity(),"使用聊天功能,请通过权限审核"); | |
| 102 | + } | |
| 103 | + } | |
| 81 | 104 | } |
| 82 | - | |
| 83 | 105 | |
| 84 | 106 | private void barrageBottom() { |
| 85 | 107 | switchCompatBottom = fragmentChatBinding.barrage; |
| ... | ... | @@ -135,15 +157,11 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 135 | 157 | final int uid = activeAccountInfo.getUid(); |
| 136 | 158 | |
| 137 | 159 | if (uid != 0) { |
| 138 | - | |
| 139 | 160 | ChatUtil.connect(new CNUserInfo(uid + "", nickname, faceurl), messageContentInfo.onConnectListener); |
| 140 | 161 | } else { |
| 141 | - | |
| 142 | 162 | ChatUtil.connect(messageContentInfo.onConnectListener); |
| 143 | - | |
| 144 | 163 | } |
| 145 | 164 | |
| 146 | - | |
| 147 | 165 | ChatUtil.setOnReceiveMessageListener(messageContentInfo.onReceiveMessageListener); |
| 148 | 166 | |
| 149 | 167 | } | ... | ... |
app/src/main/res/layout/fragment_player_ugc_live.xml