Commit 91b4b0d5c59abf426cef25a94b3389fceb803a6d
1 parent
5149c7ad
添加三方登录手机号码绑定页面逻辑并测试
Showing
7 changed files
with
575 additions
and
52 deletions
cloud/user/src/main/AndroidManifest.xml
| 1 | +<?xml version="1.0" encoding="utf-8"?> | |
| 1 | 2 | <manifest xmlns:android="http://schemas.android.com/apk/res/android" |
| 2 | 3 | xmlns:tools="http://schemas.android.com/tools" |
| 3 | 4 | package="com.cnlive.cloud.user"> |
| 4 | 5 | |
| 5 | - <uses-permission android:name="android.permission.INTERNET" /> | |
| 6 | - | |
| 7 | - <!-- for mta statistics, not necessary--> | |
| 6 | + <uses-permission android:name="android.permission.INTERNET" /> <!-- for mta statistics, not necessary --> | |
| 8 | 7 | <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> |
| 9 | 8 | <uses-permission android:name="android.permission.READ_PHONE_STATE" /> |
| 10 | 9 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| ... | ... | @@ -32,44 +31,42 @@ |
| 32 | 31 | <uses-permission android:name="android.permission.INTERNET" /> |
| 33 | 32 | |
| 34 | 33 | <application android:largeHeap="true"> |
| 34 | + <activity android:name=".ui.activity.BindPhoneNumberActivity"></activity> | |
| 35 | + | |
| 35 | 36 | <meta-data |
| 36 | 37 | android:name="WEIBO_APPKEY" |
| 37 | 38 | android:value="3884700821" /> |
| 38 | 39 | <meta-data |
| 39 | 40 | android:name="WEIBO_CHANNEL" |
| 40 | - android:value="weibo" /> | |
| 41 | - <!-- 个人签名--> | |
| 41 | + android:value="weibo" /> <!-- 个人签名 --> | |
| 42 | 42 | <activity |
| 43 | - android:name="com.cnlive.cloud.user.ui.activity.SignatureActivity" | |
| 43 | + android:name=".ui.activity.SignatureActivity" | |
| 44 | 44 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
| 45 | 45 | android:launchMode="singleTop" |
| 46 | 46 | android:screenOrientation="portrait" |
| 47 | - android:windowSoftInputMode="stateVisible|adjustPan" /> | |
| 48 | - <!-- 个人资料姓名--> | |
| 47 | + android:windowSoftInputMode="stateVisible|adjustPan" /> <!-- 个人资料姓名 --> | |
| 49 | 48 | <activity |
| 50 | - android:name="com.cnlive.cloud.user.ui.activity.UpdateContentActivity" | |
| 49 | + android:name=".ui.activity.UpdateContentActivity" | |
| 51 | 50 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
| 52 | 51 | android:launchMode="singleTop" |
| 53 | - android:screenOrientation="portrait" /> | |
| 54 | - <!--预览头像--> | |
| 52 | + android:screenOrientation="portrait" /> <!-- 预览头像 --> | |
| 55 | 53 | <activity |
| 56 | - android:name="com.cnlive.cloud.user.ui.activity.PersonalImageActivity" | |
| 54 | + android:name=".ui.activity.PersonalImageActivity" | |
| 57 | 55 | android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" |
| 58 | 56 | android:launchMode="singleTop" |
| 59 | - android:screenOrientation="portrait" /> | |
| 60 | - <!-- 个人资料页--> | |
| 57 | + android:screenOrientation="portrait" /> <!-- 个人资料页 --> | |
| 61 | 58 | <activity |
| 62 | - android:name="com.cnlive.cloud.user.ui.activity.PersonalDataActivity" | |
| 59 | + android:name=".ui.activity.PersonalDataActivity" | |
| 63 | 60 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
| 64 | 61 | android:launchMode="singleTop" |
| 65 | 62 | android:screenOrientation="portrait" /> |
| 66 | 63 | <activity |
| 67 | - android:name="com.cnlive.cloud.user.ui.activity.LoginDialogActivity" | |
| 64 | + android:name=".ui.activity.LoginDialogActivity" | |
| 68 | 65 | android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" |
| 69 | 66 | android:launchMode="singleTop" |
| 70 | 67 | android:theme="@style/ProcessHtmlDialogActivityTheme" /> |
| 71 | 68 | <activity |
| 72 | - android:name="com.cnlive.cloud.user.ui.activity.LoginActivity" | |
| 69 | + android:name=".ui.activity.LoginActivity" | |
| 73 | 70 | android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout" |
| 74 | 71 | android:launchMode="singleTop" |
| 75 | 72 | android:screenOrientation="portrait" |
| ... | ... | @@ -79,19 +76,19 @@ |
| 79 | 76 | </intent-filter> |
| 80 | 77 | </activity> |
| 81 | 78 | <activity |
| 82 | - android:name="com.cnlive.cloud.user.ui.activity.FirstLoginActivity" | |
| 79 | + android:name=".ui.activity.FirstLoginActivity" | |
| 83 | 80 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
| 84 | 81 | android:launchMode="singleTop" |
| 85 | 82 | android:screenOrientation="portrait" /> |
| 86 | 83 | <activity |
| 87 | - android:name="com.cnlive.cloud.user.ui.activity.SelectCountryActivity" | |
| 84 | + android:name=".ui.activity.SelectCountryActivity" | |
| 88 | 85 | android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation" |
| 89 | 86 | android:launchMode="singleTask" |
| 90 | 87 | android:screenOrientation="portrait" |
| 91 | 88 | android:windowSoftInputMode="adjustResize" /> |
| 92 | 89 | |
| 93 | 90 | <service |
| 94 | - android:name="com.cnlive.cloud.user.auth.UserAccountService" | |
| 91 | + android:name=".auth.UserAccountService" | |
| 95 | 92 | tools:ignore="ExportedService"> |
| 96 | 93 | <intent-filter> |
| 97 | 94 | <action android:name="android.accounts.AccountAuthenticator" /> |
| ... | ... | @@ -101,9 +98,8 @@ |
| 101 | 98 | android:name="android.accounts.AccountAuthenticator" |
| 102 | 99 | android:resource="@xml/authenticator" /> |
| 103 | 100 | </service> |
| 104 | - | |
| 105 | 101 | <service |
| 106 | - android:name="com.cnlive.cloud.user.auth.UserSyncService" | |
| 102 | + android:name=".auth.UserSyncService" | |
| 107 | 103 | android:exported="true"> |
| 108 | 104 | <intent-filter> |
| 109 | 105 | <action android:name="android.content.SyncAdapter" /> |
| ... | ... | @@ -115,9 +111,10 @@ |
| 115 | 111 | </service> |
| 116 | 112 | |
| 117 | 113 | <provider |
| 118 | - android:name="com.cnlive.cloud.user.auth.UserAccountProvider" | |
| 114 | + android:name=".auth.UserAccountProvider" | |
| 119 | 115 | android:authorities="@string/ACCOUNT_PROVIDE" |
| 120 | 116 | android:exported="false" |
| 121 | 117 | android:syncable="true" /> |
| 122 | 118 | </application> |
| 123 | -</manifest> | |
| 119 | + | |
| 120 | +</manifest> | |
| 124 | 121 | \ No newline at end of file | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/frame/presenter/BindPhoneNumberPresenter.java
0 → 100644
| 1 | +package com.cnlive.cloud.user.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.text.TextUtils; | |
| 5 | + | |
| 6 | +import com.cnlive.cloud.user.R; | |
| 7 | +import com.cnlive.cloud.user.UserUtilAction; | |
| 8 | +import com.cnlive.cloud.user.auth.UserService; | |
| 9 | +import com.cnlive.cloud.user.frame.view.BindPhoneNumberView; | |
| 10 | +import com.cnlive.cloud.user.model.CNLiveUserInfo; | |
| 11 | +import com.cnlive.cloud.user.router.user.UserAction; | |
| 12 | +import com.cnlive.cloud.user.ui.activity.BindPhoneNumberActivity; | |
| 13 | +import com.cnlive.cloud.user.util.RegexUtils; | |
| 14 | +import com.cnlive.cloud.user.util.TimeEvent; | |
| 15 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 16 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | |
| 17 | +import com.cnlive.core.libs.base.util.TimerWaitUtil; | |
| 18 | +import com.cnlive.core.network.HttpConn; | |
| 19 | +import com.cnlive.core.network.NetCallBack; | |
| 20 | +import com.cnlive.core.network.model.BaseResult; | |
| 21 | +import com.cnlive.login.model.OtherUserInfo; | |
| 22 | + | |
| 23 | +import java.util.HashMap; | |
| 24 | + | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * 作者: 吴奎庆 | |
| 28 | + * <p> | |
| 29 | + * 时间: 2019/9/9 | |
| 30 | + * <p> | |
| 31 | + * 简介: | |
| 32 | + */ | |
| 33 | +public class BindPhoneNumberPresenter extends BasePresenter<BindPhoneNumberView> { | |
| 34 | + | |
| 35 | + private TimerWaitUtil timerUtil; | |
| 36 | + private long currentTime = 0; | |
| 37 | + | |
| 38 | + private void startTimer() { | |
| 39 | + if (timerUtil != null) timerUtil.cancel(); | |
| 40 | + | |
| 41 | + timerUtil = new TimerWaitUtil(); | |
| 42 | + timerUtil.setTotalTime(60_000);//设置毫秒数 | |
| 43 | + timerUtil.setIntervalTime(500);//设置间隔数 | |
| 44 | + timerUtil.start(); | |
| 45 | + timerUtil.setTimerLiener(new TimerWaitUtil.TimeListener() { | |
| 46 | + @Override | |
| 47 | + public void onFinish() { | |
| 48 | + currentTime = 0; | |
| 49 | + ifViewAttached(view -> view.onTimerFinish()); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Override | |
| 53 | + public void onInterval(long remainTime) { | |
| 54 | + currentTime = remainTime; | |
| 55 | + ifViewAttached(view -> view.onTimerInterval(remainTime / 1000)); | |
| 56 | + } | |
| 57 | + }); | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void sendCode(Context context, String phone, String countryCode) { | |
| 61 | + if (getView() == null) return; | |
| 62 | + if (TimeEvent.debounce(2_000)) return; | |
| 63 | + if (TextUtils.isEmpty(phone)) { | |
| 64 | + getView().showMessage(context.getString(R.string.user_toast_quick_login_empty_phone)); | |
| 65 | + return; | |
| 66 | + } | |
| 67 | + if ("86".equals(countryCode) && !RegexUtils.isMobileSimple(phone)) { | |
| 68 | + getView().showMessage(context.getString(R.string.user_toast_quick_login_error_phone)); | |
| 69 | + return; | |
| 70 | + } | |
| 71 | + if (currentTime != 0) { | |
| 72 | + ifViewAttached(view -> view.showMessage("处理中请稍后...")); | |
| 73 | + return; | |
| 74 | + } | |
| 75 | + HttpConn.action(UserUtilAction.sendMsgBefQuickLoginAction(context, phone, countryCode), new NetCallBack<BaseResult>() { | |
| 76 | + @Override | |
| 77 | + public void onRequestState(int state) { | |
| 78 | + | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public void onSuccess(BaseResult data) { | |
| 83 | + startTimer(); | |
| 84 | + ifViewAttached(view -> view.showMessage("验证码已发送")); | |
| 85 | + } | |
| 86 | + | |
| 87 | + @Override | |
| 88 | + public void onFailure(String errCode, String errMsg, Exception e) { | |
| 89 | + ifViewAttached(view -> { | |
| 90 | + view.cancelLoading(); | |
| 91 | + view.showMessage(errMsg); | |
| 92 | + } | |
| 93 | + ); | |
| 94 | + } | |
| 95 | + }); | |
| 96 | + } | |
| 97 | + | |
| 98 | + public void cancle() { | |
| 99 | + if (timerUtil != null) { | |
| 100 | + timerUtil.cancel(); | |
| 101 | + } | |
| 102 | + } | |
| 103 | + | |
| 104 | + public void bindOther(BindPhoneNumberActivity activity, OtherUserInfo otherUserInfo, String phone, String ems) { | |
| 105 | + HashMap<String, String> requestMap = new HashMap<>(); | |
| 106 | + requestMap.put("appId", AppConfig.getAppId()); | |
| 107 | + requestMap.put("mobile", phone); | |
| 108 | + requestMap.put("countryCode", activity.countryCode); | |
| 109 | + requestMap.put("frmId", AppConfig.getAppChannel()); | |
| 110 | + requestMap.put("verificationCode", ems); | |
| 111 | + | |
| 112 | + requestMap.put("thirdPartyPlat", otherUserInfo.getLoginType()); | |
| 113 | + requestMap.put("thirdPartyId", otherUserInfo.getThirdPartyId()); | |
| 114 | + requestMap.put("uuid", AppConfig.getAppUUID()); | |
| 115 | + requestMap.put("clientPlat", "a"); | |
| 116 | + requestMap.put("nickName", otherUserInfo.getNickName()); | |
| 117 | + requestMap.put("gender", otherUserInfo.getGender()); | |
| 118 | + requestMap.put("location", otherUserInfo.getLocation()); | |
| 119 | + requestMap.put("faceUrl", otherUserInfo.getFaceUrl()); | |
| 120 | + UserAction.otherLoginBindMobile(activity, phone, activity.countryCode, ems, | |
| 121 | + otherUserInfo.getLoginType(), otherUserInfo.getThirdPartyId(), | |
| 122 | + otherUserInfo.getNickName(), otherUserInfo.getGender(), otherUserInfo.getLocation(), | |
| 123 | + otherUserInfo.getFaceUrl(), new UserAction.CallBack() { | |
| 124 | + @Override | |
| 125 | + public void callback(int state, String msg, Object object) { | |
| 126 | + initLoginEvent(activity, state, msg, false, otherUserInfo); | |
| 127 | + } | |
| 128 | + }); | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void initLoginEvent(BindPhoneNumberActivity context, int state, String message, Boolean retry, OtherUserInfo otherUserInfo) { | |
| 132 | + switch (state) { | |
| 133 | + case 0: | |
| 134 | + CNLiveUserInfo user = UserService.getInstance(context).getAppAccount(); | |
| 135 | + if (user == null || (user != null && TextUtils.isEmpty(user.getToken()))) { | |
| 136 | + ifViewAttached(view -> view.showMessage("用户登陆失败,再试一次吧.")); | |
| 137 | + } else if (user.isNewUser()) { | |
| 138 | + //TODO 必须设置用户头像 | |
| 139 | + //OpenInstall用户注册统计 | |
| 140 | +// OpenInstall.reportRegister(); | |
| 141 | + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 142 | +// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 143 | + if (otherUserInfo != null) { | |
| 144 | + ifViewAttached(view -> view.showMainView()); | |
| 145 | + } else { | |
| 146 | + ifViewAttached(view -> view.showEditView()); | |
| 147 | + } | |
| 148 | + } else { | |
| 149 | + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 150 | +// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 151 | + ifViewAttached(view -> view.showMainView()); | |
| 152 | + } | |
| 153 | + AppConfig.setCountryCode(""); | |
| 154 | + AppConfig.setCountryName(""); | |
| 155 | + AppConfig.setVerificationCode(""); | |
| 156 | + AppConfig.setUserPhone(""); | |
| 157 | + break; | |
| 158 | + case HttpConn.ON_START: | |
| 159 | + ifViewAttached(view -> view.showLoading()); | |
| 160 | + break; | |
| 161 | + case HttpConn.ON_END: | |
| 162 | + ifViewAttached(view -> view.cancelLoading()); | |
| 163 | + break; | |
| 164 | + case 41010: //手机号无效 | |
| 165 | + ifViewAttached(view -> view.showMessage(message)); | |
| 166 | + break; | |
| 167 | + case 41002: //验证码为6位数字 | |
| 168 | + ifViewAttached(view -> view.showMessage(message)); | |
| 169 | + break; | |
| 170 | + case 41009: //验证码错误 | |
| 171 | + ifViewAttached(view -> view.showMessage(message)); | |
| 172 | + break; | |
| 173 | + case 41006: //手机号已存在 | |
| 174 | + ifViewAttached(view -> view.showMessage(message)); | |
| 175 | + break; | |
| 176 | + case 6208: //当前用户在其他地点登陆 | |
| 177 | + if (retry) { | |
| 178 | + UserAction.otherLoginBindMobile(context, context.phoneNum, context.countryCode, context.phoneEms, | |
| 179 | + otherUserInfo.getLoginType(), otherUserInfo.getThirdPartyId(), | |
| 180 | + otherUserInfo.getNickName(), otherUserInfo.getGender(), otherUserInfo.getLocation(), | |
| 181 | + otherUserInfo.getFaceUrl(), new UserAction.CallBack() { | |
| 182 | + @Override | |
| 183 | + public void callback(int state, String msg, Object object) { | |
| 184 | + initLoginEvent(context, state, msg, false, otherUserInfo); | |
| 185 | + } | |
| 186 | + } | |
| 187 | + ); | |
| 188 | + return; | |
| 189 | + } else { | |
| 190 | + ifViewAttached(view -> view.showMessage("用户登录失败,再试一次吧.")); | |
| 191 | + } | |
| 192 | + break; | |
| 193 | + default: //其他错误 | |
| 194 | + ifViewAttached(view -> view.showMessage(message)); | |
| 195 | + break; | |
| 196 | + } | |
| 197 | + } | |
| 198 | + | |
| 199 | +} | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/frame/view/BindPhoneNumberView.java
0 → 100644
| 1 | +package com.cnlive.cloud.user.frame.view; | |
| 2 | + | |
| 3 | +import android.app.Dialog; | |
| 4 | +import android.content.Intent; | |
| 5 | +import android.net.Uri; | |
| 6 | +import android.text.Spannable; | |
| 7 | +import android.text.SpannableStringBuilder; | |
| 8 | +import android.text.TextPaint; | |
| 9 | +import android.text.TextUtils; | |
| 10 | +import android.text.method.LinkMovementMethod; | |
| 11 | +import android.text.style.ClickableSpan; | |
| 12 | +import android.text.style.ForegroundColorSpan; | |
| 13 | +import android.view.View; | |
| 14 | + | |
| 15 | +import com.cnlive.cloud.user.R; | |
| 16 | +import com.cnlive.cloud.user.router.user.UserAction; | |
| 17 | +import com.cnlive.cloud.user.ui.activity.BindPhoneNumberActivity; | |
| 18 | +import com.cnlive.cloud.user.ui.activity.FirstLoginActivity; | |
| 19 | +import com.cnlive.cloud.user.ui.activity.LoginActivity; | |
| 20 | +import com.cnlive.core.libs.base.frame.view.BaseView; | |
| 21 | +import com.cnlive.core.libs.base.util.AlertUtil; | |
| 22 | +import com.cnlive.core.libs.base.util.DoublePressed; | |
| 23 | +import com.qmuiteam.qmui.widget.QMUITopBar; | |
| 24 | +import com.qmuiteam.qmui.widget.dialog.QMUITipDialog; | |
| 25 | + | |
| 26 | +/** | |
| 27 | + * 作者: 吴奎庆 | |
| 28 | + * <p> | |
| 29 | + * 时间: 2019/9/9 | |
| 30 | + * <p> | |
| 31 | + * 简介: | |
| 32 | + */ | |
| 33 | +public class BindPhoneNumberView extends BaseView { | |
| 34 | + BindPhoneNumberActivity mActivity; | |
| 35 | + private Dialog loadingDiaog; | |
| 36 | + | |
| 37 | + public BindPhoneNumberView(BindPhoneNumberActivity activity) { | |
| 38 | + mActivity = activity; | |
| 39 | + } | |
| 40 | + | |
| 41 | + String al = "确定后,此%s将与网家家账号绑定"; | |
| 42 | + | |
| 43 | + public void initViews() { | |
| 44 | + QMUITopBar toolbar = (QMUITopBar) mActivity.binding.includeToolbar; | |
| 45 | + toolbar.setTitle("绑定手机号"); | |
| 46 | + toolbar.setBackgroundColor(mActivity.getResources().getColor(R.color.white)); | |
| 47 | + toolbar.addLeftImageButton(R.drawable.back_black, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() { | |
| 48 | + @Override | |
| 49 | + public void onClick(View v) { | |
| 50 | + mActivity.finish(); | |
| 51 | + } | |
| 52 | + }); | |
| 53 | + switch (mActivity.otherUserInfo.getLoginType()) { | |
| 54 | + | |
| 55 | + case "1": | |
| 56 | + //sina | |
| 57 | + mActivity.binding.ivThree.setBackgroundResource(R.drawable.iv_bind_wb); | |
| 58 | + mActivity.binding.tvThree.setText("微博"); | |
| 59 | + | |
| 60 | + String weibos = String.format(al, "微博账号"); | |
| 61 | + mActivity.binding.tvBind.setText(weibos); | |
| 62 | + | |
| 63 | +// 微博账号 | |
| 64 | + break; | |
| 65 | + case "2": | |
| 66 | ||
| 67 | + mActivity.binding.ivThree.setBackgroundResource(R.drawable.iv_bind_qq); | |
| 68 | + mActivity.binding.tvThree.setText("QQ"); | |
| 69 | + String qqs = String.format(al, "QQ账号"); | |
| 70 | + mActivity.binding.tvBind.setText(qqs); | |
| 71 | + break; | |
| 72 | + case "3": | |
| 73 | ||
| 74 | + mActivity.binding.ivThree.setBackgroundResource(R.drawable.iv_bind_wechat); | |
| 75 | + mActivity.binding.tvThree.setText("微信"); | |
| 76 | + | |
| 77 | + String wechats = String.format(al, "微信账号"); | |
| 78 | + mActivity.binding.tvBind.setText(wechats); | |
| 79 | + break; | |
| 80 | + | |
| 81 | + } | |
| 82 | + String textContent = "已阅读并同意《账户绑定确认书(网家家)》"; | |
| 83 | + SpannableStringBuilder ssb = new SpannableStringBuilder(textContent); | |
| 84 | + ssb.setSpan(new ClickableSpan() { | |
| 85 | + @Override | |
| 86 | + public void onClick(View widget) { | |
| 87 | + if (DoublePressed.onDoublePressed())return; | |
| 88 | + if (mActivity != null ) { | |
| 89 | + startWebView("sfdlxy"); | |
| 90 | + } | |
| 91 | + } | |
| 92 | + | |
| 93 | + @Override | |
| 94 | + public void updateDrawState(TextPaint ds) { | |
| 95 | + ds.setUnderlineText(false); | |
| 96 | + } | |
| 97 | + }, 7, 19, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | |
| 98 | + | |
| 99 | + ssb.setSpan(new ForegroundColorSpan(mActivity.getResources().getColor(R.color.color_23d41e)), 7, 19, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); | |
| 100 | + mActivity.binding.tvAgreement.setMovementMethod(LinkMovementMethod.getInstance()); | |
| 101 | + mActivity.binding.tvAgreement.setText(ssb); | |
| 102 | + mActivity.binding.tvVc.setOnClickListener(mActivity); | |
| 103 | + mActivity.binding.llCountry.setOnClickListener(mActivity); | |
| 104 | + mActivity.binding.login.setOnClickListener(mActivity); | |
| 105 | + mActivity.binding.tvCountry.setText("+ " + mActivity.countryCode); | |
| 106 | + mActivity.binding.tvCountryName.setText(mActivity.countryName); | |
| 107 | + } | |
| 108 | + | |
| 109 | + private void startWebView(String type) { | |
| 110 | +// WWebView wWebView = new WWebView.Builder() | |
| 111 | +// .urlType(type) | |
| 112 | +// .isOther(false) | |
| 113 | +// .enableTitle(false) | |
| 114 | +// .enableJump(true) | |
| 115 | +// .enableRefresh(false) | |
| 116 | +// .enableImageLongClick(false) | |
| 117 | +// .builder(); | |
| 118 | +// wWebView.startWebViewActivity(mActivity); | |
| 119 | + } | |
| 120 | + | |
| 121 | + | |
| 122 | + public void showMessage(String message) { | |
| 123 | + if (mActivity == null || TextUtils.isEmpty(message)) return; | |
| 124 | + AlertUtil.showDeftToast(mActivity, message); | |
| 125 | + } | |
| 126 | + | |
| 127 | + public void onTimerFinish() { | |
| 128 | + mActivity.binding.tvVc.setText("获取验证码"); | |
| 129 | + mActivity.binding.tvVc.setTextColor(mActivity.getResources().getColor(R.color.color_23d41e)); | |
| 130 | + } | |
| 131 | + | |
| 132 | + private static final String time_format = "已发送 | %ss"; | |
| 133 | + | |
| 134 | + public void onTimerInterval(long l) { | |
| 135 | + String text = String.format(time_format, (int) l); | |
| 136 | + mActivity.binding.tvVc.setText(text); | |
| 137 | + mActivity.binding.tvVc.setTextColor(mActivity.getResources().getColor(R.color.color_999)); | |
| 138 | + } | |
| 139 | + | |
| 140 | + public void showEditView() { | |
| 141 | + if (mActivity == null) return; | |
| 142 | + Intent intent = new Intent(mActivity, FirstLoginActivity.class); | |
| 143 | + intent.putExtra(mActivity.TAG_CLICK_AD, mActivity.clickAd); | |
| 144 | + intent.putExtra(LoginActivity.TAG_MSG, TextUtils.isEmpty(mActivity.tagMsg) ? "" : mActivity.tagMsg); | |
| 145 | + mActivity.startActivity(intent); | |
| 146 | + mActivity.finish(); | |
| 147 | + } | |
| 148 | + | |
| 149 | + public void showMainView() { | |
| 150 | + //TODO 记得放开首页 | |
| 151 | +// if (mActivity == null) return; | |
| 152 | +// //判断如果是因为token为空跳转到的登录页面则不需要跳转到MainActivity,直接关闭登录页面即可 | |
| 153 | +// if (mActivity.fromTokenError) { | |
| 154 | +// mActivity.finish(); | |
| 155 | +// return; | |
| 156 | +// } | |
| 157 | +// Uri uri = UserAction.getUri(mActivity); | |
| 158 | +// Intent intent = new Intent(mActivity, MainActivity.class); | |
| 159 | +// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 160 | +// intent.putExtra("type", "login"); | |
| 161 | +// intent.putExtra("uri", uri); | |
| 162 | +// intent.putExtra("sharetype", mActivity.tagShare); | |
| 163 | +// intent.putExtra(mActivity.TAG_CLICK_AD, mActivity.clickAd); | |
| 164 | +// if (!TextUtils.isEmpty(mActivity.tagMsg)) | |
| 165 | +// intent.putExtra("classifyTagMsg", mActivity.tagMsg); | |
| 166 | +// mActivity.startActivity(intent); | |
| 167 | + } | |
| 168 | + | |
| 169 | + public void showLoading() { | |
| 170 | + if (mActivity == null) return; | |
| 171 | + if (loadingDiaog == null) { | |
| 172 | + loadingDiaog = new QMUITipDialog.Builder(mActivity) | |
| 173 | + .setIconType(QMUITipDialog.Builder.ICON_TYPE_LOADING) | |
| 174 | + .setTipWord("请稍后") | |
| 175 | + .create(); | |
| 176 | + } | |
| 177 | + loadingDiaog.show(); | |
| 178 | + } | |
| 179 | + | |
| 180 | + public void cancelLoading() { | |
| 181 | + if (mActivity == null) return; | |
| 182 | + if (loadingDiaog != null) { | |
| 183 | + loadingDiaog.dismiss(); | |
| 184 | + } | |
| 185 | + } | |
| 186 | +} | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/frame/view/LoginDialogView.java
| ... | ... | @@ -14,6 +14,7 @@ import android.text.style.ClickableSpan; |
| 14 | 14 | import android.text.style.ForegroundColorSpan; |
| 15 | 15 | import android.view.View; |
| 16 | 16 | |
| 17 | +import com.cnlive.cloud.user.ui.activity.BindPhoneNumberActivity; | |
| 17 | 18 | import com.cnlive.core.libs.base.application.AppConfig; |
| 18 | 19 | import com.cnlive.core.libs.base.frame.view.BaseView; |
| 19 | 20 | import com.cnlive.core.libs.base.util.AlertUtil; |
| ... | ... | @@ -307,7 +308,7 @@ public class LoginDialogView extends BaseView { |
| 307 | 308 | |
| 308 | 309 | public void bindPhone(OtherUserInfo otherUserInfo) { |
| 309 | 310 | if (mActivity == null) return; |
| 310 | -// BindPhoneNumberActivity.startActivity(mActivity, | |
| 311 | -// otherUserInfo, mActivity.fromTokenError, mActivity.tagMsg, mActivity.tagShare, mActivity.clickAd); | |
| 311 | + BindPhoneNumberActivity.startActivity(mActivity, | |
| 312 | + otherUserInfo, mActivity.fromTokenError, mActivity.tagMsg, mActivity.tagShare, mActivity.clickAd); | |
| 312 | 313 | } |
| 313 | 314 | } | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/frame/view/QuickLoginView.java
| ... | ... | @@ -20,6 +20,7 @@ import com.cnlive.cloud.user.R; |
| 20 | 20 | import com.cnlive.cloud.user.model.LoginSuccessInfo; |
| 21 | 21 | import com.cnlive.cloud.user.sms.OnSmsCatchListener; |
| 22 | 22 | import com.cnlive.cloud.user.sms.SmsVerifyCatcher; |
| 23 | +import com.cnlive.cloud.user.ui.activity.BindPhoneNumberActivity; | |
| 23 | 24 | import com.cnlive.cloud.user.ui.activity.FirstLoginActivity; |
| 24 | 25 | import com.cnlive.cloud.user.ui.activity.LoginActivity; |
| 25 | 26 | import com.cnlive.cloud.user.ui.fragment.QuickLoginFragment; |
| ... | ... | @@ -351,8 +352,8 @@ public class QuickLoginView extends BaseView { |
| 351 | 352 | |
| 352 | 353 | public void bindPhone(OtherUserInfo otherUserInfo) { |
| 353 | 354 | if (fragment == null) return; |
| 354 | -// BindPhoneNumberActivity.startActivity(fragment.getActivity(), | |
| 355 | -// otherUserInfo, fragment.fromTokenError, fragment.tagMsg, fragment.tagShare, fragment.clickAd); | |
| 355 | + BindPhoneNumberActivity.startActivity(fragment.getActivity(), | |
| 356 | + otherUserInfo, fragment.fromTokenError, fragment.tagMsg, fragment.tagShare, fragment.clickAd); | |
| 356 | 357 | } |
| 357 | 358 | |
| 358 | 359 | } | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/ui/activity/BindPhoneNumberActivity.java
0 → 100644
| 1 | +package com.cnlive.cloud.user.ui.activity; | |
| 2 | + | |
| 3 | + | |
| 4 | +import android.app.Activity; | |
| 5 | +import android.content.Intent; | |
| 6 | +import android.text.TextUtils; | |
| 7 | +import android.view.View; | |
| 8 | + | |
| 9 | +import com.cnlive.cloud.user.R; | |
| 10 | +import com.cnlive.cloud.user.databinding.ActivityBindPhoneNumberBinding; | |
| 11 | +import com.cnlive.cloud.user.frame.presenter.BindPhoneNumberPresenter; | |
| 12 | +import com.cnlive.cloud.user.frame.view.BindPhoneNumberView; | |
| 13 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 14 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | |
| 15 | +import com.cnlive.core.libs.base.util.DoublePressed; | |
| 16 | +import com.cnlive.login.model.OtherUserInfo; | |
| 17 | + | |
| 18 | +import androidx.databinding.ViewDataBinding; | |
| 19 | + | |
| 20 | +public class BindPhoneNumberActivity extends BaseActivity<BindPhoneNumberView, BindPhoneNumberPresenter> implements View.OnClickListener { | |
| 21 | + public OtherUserInfo otherUserInfo; | |
| 22 | + public String countryCode = "86"; | |
| 23 | + public String countryName = "中国"; | |
| 24 | + public String phoneNum; | |
| 25 | + public String phoneEms; | |
| 26 | + public static String FROM_TOKEN_ERROR = "from_token_error"; | |
| 27 | + public static String TAG_MSG = "tagMsg"; | |
| 28 | + public static String TAG_SHARE = ""; | |
| 29 | + public static String TAG_CLICK_AD = "clickAd"; | |
| 30 | + | |
| 31 | + public String tagMsg; | |
| 32 | + public String tagShare; | |
| 33 | + public boolean fromTokenError; | |
| 34 | + public boolean clickAd; | |
| 35 | + public ActivityBindPhoneNumberBinding binding; | |
| 36 | + | |
| 37 | + public static void startActivity(Activity context, OtherUserInfo info, boolean fromTokenError, String tagMsg, String shareType, boolean clickAd) { | |
| 38 | + Intent intent = new Intent(); | |
| 39 | + intent.putExtra(FROM_TOKEN_ERROR, fromTokenError); | |
| 40 | + intent.putExtra(TAG_MSG, tagMsg); | |
| 41 | + intent.putExtra(TAG_SHARE, shareType); | |
| 42 | + intent.putExtra(TAG_CLICK_AD, clickAd); | |
| 43 | + intent.setClass(context, BindPhoneNumberActivity.class); | |
| 44 | + intent.putExtra("info", info); | |
| 45 | + context.startActivity(intent); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + protected int getBindLayoutId() { | |
| 50 | + return R.layout.activity_bind_phone_number; | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + protected void initBindingLayoutData(ViewDataBinding baseBinding) { | |
| 55 | + super.initBindingLayoutData(baseBinding); | |
| 56 | + binding = (ActivityBindPhoneNumberBinding) baseBinding; | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + protected void initView() { | |
| 61 | + showDefaultWhiteStatusBar(); | |
| 62 | + otherUserInfo = (OtherUserInfo) getIntent().getSerializableExtra("info"); | |
| 63 | + fromTokenError = (boolean) getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false); | |
| 64 | + tagMsg = (String) getIntent().getStringExtra(TAG_MSG); | |
| 65 | + tagShare = (String) getIntent().getStringExtra(TAG_SHARE); | |
| 66 | + clickAd = getIntent().getBooleanExtra(TAG_CLICK_AD, false); | |
| 67 | + if (!TextUtils.isEmpty(AppConfig.getCountryCode())) { | |
| 68 | + countryCode = AppConfig.getCountryCode(); | |
| 69 | + } | |
| 70 | + if (!TextUtils.isEmpty(AppConfig.getCountryName())) { | |
| 71 | + countryName = AppConfig.getCountryName(); | |
| 72 | + } | |
| 73 | + if (otherUserInfo == null) { | |
| 74 | + getMvpView().showMessage("数据异常"); | |
| 75 | + finish(); | |
| 76 | + } | |
| 77 | + if (getMvpView() != null) getMvpView().initViews(); | |
| 78 | + } | |
| 79 | + | |
| 80 | + @Override | |
| 81 | + public void onClick(View view) { | |
| 82 | + if (view.getId() == R.id.tv_vc) { | |
| 83 | + if (DoublePressed.onDoublePressed()) return; | |
| 84 | + if (!TextUtils.isEmpty(binding.etPhone.getText())) { | |
| 85 | + phoneNum = binding.etPhone.getText().toString(); | |
| 86 | + if (getPresenter() != null) | |
| 87 | + getPresenter().sendCode(this, phoneNum, countryCode); | |
| 88 | + } else { | |
| 89 | + if (getMvpView() != null) getMvpView().showMessage("请输入手机号"); | |
| 90 | + } | |
| 91 | + | |
| 92 | + } else if (view.getId() == R.id.login) { | |
| 93 | + if (DoublePressed.onDoublePressed()) return; | |
| 94 | + if (!TextUtils.isEmpty(binding.etPhone.getText()) && !TextUtils.isEmpty(binding.etEms.getText()) && getPresenter() != null) { | |
| 95 | + phoneNum = binding.etPhone.getText().toString(); | |
| 96 | + phoneEms = binding.etEms.getText().toString(); | |
| 97 | + getPresenter().bindOther(this, otherUserInfo, phoneNum, phoneEms); | |
| 98 | + } else { | |
| 99 | + if (getMvpView() != null) getMvpView().showMessage("请输入手机号和验证码"); | |
| 100 | + } | |
| 101 | + } else if (view.getId() == R.id.ll_country) { | |
| 102 | + if (DoublePressed.onDoublePressed()) return; | |
| 103 | + if (AppConfig.getCountryCode() != null) { | |
| 104 | + SelectCountryActivity.startSelectCountryActivity(this, SelectCountryActivity.ACTIVITY_RESULT_CODE, AppConfig.getCountryCode()); | |
| 105 | + } else { | |
| 106 | + SelectCountryActivity.startSelectCountryActivity(this, SelectCountryActivity.ACTIVITY_RESULT_CODE, countryCode); | |
| 107 | + } | |
| 108 | + } | |
| 109 | + } | |
| 110 | + | |
| 111 | + @Override | |
| 112 | + protected void onResume() { | |
| 113 | + super.onResume(); | |
| 114 | + showDefaultWhiteStatusBar(); | |
| 115 | + } | |
| 116 | + | |
| 117 | + @Override | |
| 118 | + public void onActivityResult(int requestCode, int resultCode, Intent data) { | |
| 119 | + super.onActivityResult(requestCode, resultCode, data); | |
| 120 | + if (resultCode == SelectCountryActivity.ACTIVITY_RESULT_CODE) { | |
| 121 | + countryCode = data.getStringExtra("countryCode"); | |
| 122 | + countryName = data.getStringExtra("country"); | |
| 123 | + if (!TextUtils.isEmpty(countryCode)) { | |
| 124 | + AppConfig.setCountryCode(countryCode); | |
| 125 | + binding.tvCountry.setText("+ " + countryCode); | |
| 126 | + } | |
| 127 | + if (!TextUtils.isEmpty(countryName)) { | |
| 128 | + AppConfig.setCountryName(countryName); | |
| 129 | + binding.tvCountryName.setText(countryName); | |
| 130 | + } | |
| 131 | + } | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + protected void onDestroy() { | |
| 136 | + super.onDestroy(); | |
| 137 | + if (getMvpView() != null) getMvpView().cancelLoading(); | |
| 138 | + } | |
| 139 | +} | ... | ... |
cloud/user/src/main/res/layout/activity_bind_phone_number.xml
| ... | ... | @@ -118,38 +118,38 @@ |
| 118 | 118 | android:layout_height="wrap_content"> |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - <TextView | |
| 122 | - android:layout_marginLeft="15dp" | |
| 123 | - android:id="@+id/tv_country_name" | |
| 124 | - android:layout_width="wrap_content" | |
| 125 | - android:layout_height="wrap_content" | |
| 126 | - android:layout_centerVertical="true" | |
| 127 | - android:text="手机号归属地" | |
| 128 | - android:textColor="@color/color_333" | |
| 129 | - android:textSize="14sp" /> | |
| 130 | - | |
| 131 | - <LinearLayout | |
| 132 | - android:layout_marginRight="12dp" | |
| 133 | - android:id="@+id/ll_country" | |
| 134 | - android:layout_width="wrap_content" | |
| 135 | - android:layout_height="wrap_content" | |
| 136 | - android:layout_alignParentRight="true" | |
| 137 | - android:padding="13dp"> | |
| 138 | - | |
| 139 | 121 | <TextView |
| 140 | - android:id="@+id/tv_country" | |
| 122 | + android:layout_marginLeft="15dp" | |
| 123 | + android:id="@+id/tv_country_name" | |
| 141 | 124 | android:layout_width="wrap_content" |
| 142 | 125 | android:layout_height="wrap_content" |
| 126 | + android:layout_centerVertical="true" | |
| 127 | + android:text="手机号归属地" | |
| 143 | 128 | android:textColor="@color/color_333" |
| 144 | 129 | android:textSize="14sp" /> |
| 145 | 130 | |
| 146 | - <ImageView | |
| 131 | + <LinearLayout | |
| 132 | + android:layout_marginRight="12dp" | |
| 133 | + android:id="@+id/ll_country" | |
| 147 | 134 | android:layout_width="wrap_content" |
| 148 | 135 | android:layout_height="wrap_content" |
| 149 | - android:layout_gravity="center_vertical" | |
| 150 | - android:layout_marginLeft="9dp" | |
| 151 | - android:background="@drawable/dl_xl" /> | |
| 152 | - </LinearLayout> | |
| 136 | + android:layout_alignParentRight="true" | |
| 137 | + android:padding="13dp"> | |
| 138 | + | |
| 139 | + <TextView | |
| 140 | + android:id="@+id/tv_country" | |
| 141 | + android:layout_width="wrap_content" | |
| 142 | + android:layout_height="wrap_content" | |
| 143 | + android:textColor="@color/color_333" | |
| 144 | + android:textSize="14sp" /> | |
| 145 | + | |
| 146 | + <ImageView | |
| 147 | + android:layout_width="wrap_content" | |
| 148 | + android:layout_height="wrap_content" | |
| 149 | + android:layout_gravity="center_vertical" | |
| 150 | + android:layout_marginLeft="9dp" | |
| 151 | + android:background="@drawable/dl_xl" /> | |
| 152 | + </LinearLayout> | |
| 153 | 153 | </RelativeLayout> |
| 154 | 154 | <LinearLayout |
| 155 | 155 | android:layout_width="match_parent" | ... | ... |