|
@@ -1,279 +0,0 @@
|
|
|
-package com.edufound.android.xyyf.activity;
|
|
|
-
|
|
|
-import android.app.Activity;
|
|
|
-import android.graphics.Color;
|
|
|
-import android.os.Bundle;
|
|
|
-import android.support.annotation.NonNull;
|
|
|
-import android.support.annotation.Nullable;
|
|
|
-import android.text.Editable;
|
|
|
-import android.text.Spannable;
|
|
|
-import android.text.SpannableStringBuilder;
|
|
|
-import android.text.TextPaint;
|
|
|
-import android.text.TextWatcher;
|
|
|
-import android.text.method.LinkMovementMethod;
|
|
|
-import android.text.style.ClickableSpan;
|
|
|
-import android.view.KeyEvent;
|
|
|
-import android.view.MotionEvent;
|
|
|
-import android.view.View;
|
|
|
-import android.view.ViewGroup;
|
|
|
-import android.webkit.WebView;
|
|
|
-import android.widget.CheckBox;
|
|
|
-import android.widget.CompoundButton;
|
|
|
-import android.widget.EditText;
|
|
|
-import android.widget.FrameLayout;
|
|
|
-import android.widget.ImageView;
|
|
|
-import android.widget.LinearLayout;
|
|
|
-import android.widget.TextView;
|
|
|
-
|
|
|
-import com.edufound.android.xyyf.R;
|
|
|
-import com.edufound.android.xyyf.base.BaseActivity;
|
|
|
-import com.edufound.android.xyyf.phonelogin.PhoneLoginPersenter;
|
|
|
-import com.edufound.android.xyyf.phonelogin.PhoneLoginView;
|
|
|
-import com.edufound.android.xyyf.util.ContextUtil;
|
|
|
-import com.edufound.android.xyyf.util.DeviceUtil;
|
|
|
-import com.edufound.android.xyyf.util.LiuHaiScreenUtil;
|
|
|
-import com.edufound.android.xyyf.util.Logger;
|
|
|
-import com.edufound.android.xyyf.util.ToastUtil;
|
|
|
-
|
|
|
-import org.json.JSONException;
|
|
|
-
|
|
|
-import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
-public class PhoneNumLoginActivityLandscape extends BaseActivity implements PhoneLoginView {
|
|
|
-
|
|
|
- PhoneNumLoginActivityLandscape mIntences;
|
|
|
- PhoneLoginPersenter mPersenter;
|
|
|
- DeviceUtil mDeviceUtil;
|
|
|
- LinearLayout mClose;
|
|
|
- TextView mGetVetVer;
|
|
|
- EditText mPhoneNumber;
|
|
|
- EditText mInputVer;
|
|
|
- LinearLayout mFrameLayout;
|
|
|
- CheckBox mPrivacyCheckBox;
|
|
|
- TextView mPrivacyContext;
|
|
|
- boolean isShowWeb = false;
|
|
|
- WebView mWebView;
|
|
|
-
|
|
|
- @Override
|
|
|
- protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
- super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_login_phone_landscape);
|
|
|
- if (mIntences == null) {
|
|
|
- mIntences = this;
|
|
|
- }
|
|
|
- mDeviceUtil = new DeviceUtil();
|
|
|
- mPersenter = new PhoneLoginPersenter(this);
|
|
|
- mFrameLayout = findViewById(R.id.phonenumber_login_l_frame);
|
|
|
- int window_height = mDeviceUtil.getHeight(this);
|
|
|
- int dialog_width = mDeviceUtil.getWidth(this) / 2;
|
|
|
- int dialog_height = mDeviceUtil.getHeight(this) / 2;
|
|
|
- Logger.e("window_height:" + window_height / 720f);
|
|
|
- if ((window_height / 720f >= 1.4f) && (window_height / 720f <= 1.5f)) {
|
|
|
-
|
|
|
- } else {
|
|
|
- mFrameLayout.setLayoutParams(new LinearLayout.LayoutParams(dialog_width, dialog_height));
|
|
|
- }
|
|
|
-
|
|
|
- init();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- void init() {
|
|
|
- mClose = findViewById(R.id.login_phone_landscape_close);
|
|
|
- mGetVetVer = findViewById(R.id.phonenumber_getverifcation);
|
|
|
- mPhoneNumber = findViewById(R.id.phonenumber_login_number);
|
|
|
- mInputVer = findViewById(R.id.phonenumber_login_ver);
|
|
|
- mPersenter.setVerText(mGetVetVer);
|
|
|
- mPrivacyCheckBox = findViewById(R.id.privacy_context_check);
|
|
|
- mPrivacyContext = findViewById(R.id.privacy_context);
|
|
|
- setContext();
|
|
|
- initListener();
|
|
|
- }
|
|
|
-
|
|
|
- void initListener() {
|
|
|
- mClose.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- MainActivity.getInstance().loadJSMehtodPost("closeLogin('700000')");
|
|
|
- finish();
|
|
|
- }
|
|
|
- });
|
|
|
- mGetVetVer.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- }
|
|
|
- });
|
|
|
- mGetVetVer.setOnTouchListener(new View.OnTouchListener() {
|
|
|
- @Override
|
|
|
- public boolean onTouch(View v, MotionEvent event) {
|
|
|
- switch (event.getAction()) {
|
|
|
- case MotionEvent.ACTION_DOWN:
|
|
|
- mGetVetVer.setBackgroundResource(R.drawable.shape_login_phonenumber_getverification_selected);
|
|
|
- mGetVetVer.setTextColor(Color.WHITE);
|
|
|
- break;
|
|
|
- case MotionEvent.ACTION_CANCEL:
|
|
|
- case MotionEvent.ACTION_UP:
|
|
|
- try {
|
|
|
- mPersenter.getVCode(mPhoneNumber.getText().toString());
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- return false;
|
|
|
- }
|
|
|
- });
|
|
|
- mInputVer.addTextChangedListener(new TextWatcher() {
|
|
|
- @Override
|
|
|
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
- if (s.toString().length() == 4) {
|
|
|
- Logger.e("检查验证码并且登录");
|
|
|
- try {
|
|
|
- if (!mPrivacyCheckBox.isChecked()) {
|
|
|
- ToastUtil.showToast("请同意服务条款");
|
|
|
- return;
|
|
|
- }
|
|
|
- mPersenter.LoginByVCode(mPhoneNumber.getText().toString(), s.toString());
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void afterTextChanged(Editable s) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
- mPrivacyCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
|
|
- @Override
|
|
|
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
- if (mInputVer.getText().toString().length() == 4 && isChecked) {
|
|
|
- try {
|
|
|
- mPersenter.LoginByVCode(mPhoneNumber.getText().toString(), mInputVer.getText().toString());
|
|
|
- } catch (JSONException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- List<Integer> leftBrackets = new ArrayList<>();
|
|
|
- List<Integer> rightBrackets = new ArrayList<>();
|
|
|
- String text = "我已阅读并同意《服务协议》和《隐私政策》";
|
|
|
-
|
|
|
- void setContext() {
|
|
|
- leftBrackets = getChildIndexFromString(text, "《");
|
|
|
- rightBrackets = getChildIndexFromString(text, "》");
|
|
|
- SpannableStringBuilder style = new SpannableStringBuilder();
|
|
|
- style.append(text);
|
|
|
- for (int i = 0; i < leftBrackets.size(); i++) {
|
|
|
- final int finalI = i;
|
|
|
- style.setSpan(new ClickableSpan() {
|
|
|
- @Override
|
|
|
- public void onClick(@NonNull View widget) {
|
|
|
- lookPrivacy(finalI);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void updateDrawState(@NonNull TextPaint ds) {
|
|
|
- ds.setUnderlineText(false);
|
|
|
- ds.setColor(Color.parseColor("#68a5dc"));
|
|
|
- }
|
|
|
-
|
|
|
- }, leftBrackets.get(i), rightBrackets.get(i) + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
|
|
-
|
|
|
- }
|
|
|
- mPrivacyContext.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
- mPrivacyContext.setHighlightColor(Color.BLACK);
|
|
|
- mPrivacyContext.setText(style);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @param parent
|
|
|
- * @param child
|
|
|
- * @return
|
|
|
- */
|
|
|
- private List<Integer> getChildIndexFromString(String parent, String child) {
|
|
|
- int startIndex = 0;
|
|
|
- List<Integer> ids = new ArrayList<>();
|
|
|
- while (parent.indexOf(child, startIndex) != -1) {
|
|
|
- //ids.add(startIndex);
|
|
|
- startIndex = parent.indexOf(child, startIndex);
|
|
|
- ids.add(startIndex);
|
|
|
- startIndex = startIndex + child.length();
|
|
|
- }
|
|
|
- return ids;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- void lookPrivacy(int index) {
|
|
|
- if (mWebView == null) {
|
|
|
- mWebView = new WebView(ContextUtil.getContext());
|
|
|
- mWebView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
|
|
- }
|
|
|
- String url = "";
|
|
|
- switch (index) {
|
|
|
- case 0:
|
|
|
- url = "http://m-xyyf-web.ai160.com/res/protocol/service.htm";
|
|
|
- break;
|
|
|
- case 1:
|
|
|
- url = "http://m-xyyf-web.ai160.com/res/protocol/private.htm";
|
|
|
- break;
|
|
|
- }
|
|
|
- mWebView.getSettings().setUseWideViewPort(true);
|
|
|
- mWebView.getSettings().setLoadWithOverviewMode(true);
|
|
|
- mWebView.getSettings().setJavaScriptEnabled(true);
|
|
|
- mWebView.getSettings().setDomStorageEnabled(true);
|
|
|
- mWebView.loadUrl(url);
|
|
|
-// mFrameLayout.addView(webview);
|
|
|
- ((FrameLayout) getWindow().getDecorView()).addView(mWebView);
|
|
|
- isShowWeb = true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void changeVText(int type) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public Activity getActivity() {
|
|
|
- return mIntences;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
- switch (keyCode) {
|
|
|
- case KeyEvent.KEYCODE_ESCAPE:
|
|
|
- case KeyEvent.KEYCODE_BACK:
|
|
|
- if (isShowWeb) {
|
|
|
- isShowWeb = false;
|
|
|
- ((FrameLayout) getWindow().getDecorView()).removeView(mWebView);
|
|
|
- mWebView.loadUrl("");
|
|
|
- mWebView.clearCache(true);
|
|
|
-// if (mPrivacyContext.isChecked()) {
|
|
|
-// mPrivacyContext.setChecked(true);
|
|
|
-// } else {
|
|
|
-// mPrivacyContext.setChecked(false);
|
|
|
-// }
|
|
|
- } else {
|
|
|
- MainActivity.getInstance().loadJSMehtodPost("closeLogin('700000')");
|
|
|
- finish();
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- return super.onKeyDown(keyCode, event);
|
|
|
- }
|
|
|
-}
|