|
@@ -0,0 +1,180 @@
|
|
|
|
+package com.edufound.android.xyyf.activity;
|
|
|
|
+
|
|
|
|
+import android.content.Intent;
|
|
|
|
+import android.graphics.Color;
|
|
|
|
+import android.os.Bundle;
|
|
|
|
+import android.support.annotation.NonNull;
|
|
|
|
+import android.support.annotation.Nullable;
|
|
|
|
+import android.text.Spannable;
|
|
|
|
+import android.text.SpannableStringBuilder;
|
|
|
|
+import android.text.TextPaint;
|
|
|
|
+import android.text.method.LinkMovementMethod;
|
|
|
|
+import android.text.style.ClickableSpan;
|
|
|
|
+import android.view.KeyEvent;
|
|
|
|
+import android.view.View;
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
+import android.webkit.WebSettings;
|
|
|
|
+import android.webkit.WebView;
|
|
|
|
+import android.widget.FrameLayout;
|
|
|
|
+import android.widget.LinearLayout;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
+
|
|
|
|
+import com.edufound.android.xyyf.R;
|
|
|
|
+import com.edufound.android.xyyf.application.EApplication;
|
|
|
|
+import com.edufound.android.xyyf.base.BaseActivity;
|
|
|
|
+import com.edufound.android.xyyf.useragreement.UserAgreementPersenter;
|
|
|
|
+import com.edufound.android.xyyf.useragreement.UserAgreementView;
|
|
|
|
+import com.edufound.android.xyyf.util.ContextUtil;
|
|
|
|
+import com.edufound.android.xyyf.util.Logger;
|
|
|
|
+import com.edufound.android.xyyf.util.SPutil;
|
|
|
|
+import com.edufound.android.xyyf.util.ToastUtil;
|
|
|
|
+import com.mobile.auth.gatewayauth.activity.AuthWebVeiwActivity;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+public class AgreementActivity extends BaseActivity implements UserAgreementView {
|
|
|
|
+
|
|
|
|
+ UserAgreementPersenter mPersenter;
|
|
|
|
+ FrameLayout mRoot;
|
|
|
|
+ TextView mTextContext;
|
|
|
|
+ TextView mCancel;
|
|
|
|
+ TextView mAgree;
|
|
|
|
+ LinearLayout mPrivacFrame;
|
|
|
|
+ String spKey = "privacy";
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
+ setContentView(R.layout.activity_privacypolicy);
|
|
|
|
+ if (EApplication.getAppCode().equals("2001")) {
|
|
|
|
+ if (SPutil.getPrefBoolean(this, spKey, false)) {
|
|
|
|
+ toMain();
|
|
|
|
+ } else {
|
|
|
|
+ init();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ toMain();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void init() {
|
|
|
|
+ mPersenter = new UserAgreementPersenter(this);
|
|
|
|
+ mRoot = findViewById(R.id.privacy_root);
|
|
|
|
+ mPrivacFrame = findViewById(R.id.privacy_text_frame);
|
|
|
|
+ mTextContext = findViewById(R.id.privacy_context);
|
|
|
|
+ setContext();
|
|
|
|
+ mCancel = findViewById(R.id.privacy_cancel);
|
|
|
|
+ mAgree = findViewById(R.id.privacy_ok);
|
|
|
|
+ mCancel.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ mAgree.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ setSP();
|
|
|
|
+ toMain();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ List<Integer> leftBrackets = new ArrayList<>();
|
|
|
|
+ List<Integer> rightBrackets = new ArrayList<>();
|
|
|
|
+ String text = "请你务必审慎阅读、充分理解“服务协议”和“隐私政策”各条款,包括但不限于:为了向你提供内容等服务,我们需要收集你的设备信息、操作日志等个人信息。" +
|
|
|
|
+ "\n你可以阅读《服务协议》和《隐私政策》了解详细信息。如你同意,请点击“同意”开始接受我们的服务。";
|
|
|
|
+
|
|
|
|
+ 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);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ mTextContext.setMovementMethod(LinkMovementMethod.getInstance());
|
|
|
|
+ mTextContext.setHighlightColor(Color.parseColor("#ffffff"));
|
|
|
|
+ mTextContext.setText(style);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void toMain() {
|
|
|
|
+ Intent intent = new Intent(this, MainActivity.class);
|
|
|
|
+ startActivity(intent);
|
|
|
|
+ finish();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @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) {
|
|
|
|
+ WebView webview = new WebView(ContextUtil.getContext());
|
|
|
|
+ webview.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;
|
|
|
|
+ }
|
|
|
|
+ webview.getSettings().setUseWideViewPort(true);
|
|
|
|
+ webview.getSettings().setLoadWithOverviewMode(true);
|
|
|
|
+ webview.getSettings().setJavaScriptEnabled(true);
|
|
|
|
+ webview.getSettings().setDomStorageEnabled(true);
|
|
|
|
+ webview.loadUrl(url);
|
|
|
|
+ mRoot.addView(webview);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void setSP() {
|
|
|
|
+ SPutil.setPrefBoolean(this, spKey, true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
|
|
|
|
+ switch (keyCode) {
|
|
|
|
+ case KeyEvent.KEYCODE_ESCAPE:
|
|
|
|
+ case KeyEvent.KEYCODE_BACK:
|
|
|
|
+ if (mRoot.getChildAt(1) != null) {
|
|
|
|
+ mRoot.removeViewAt(1);
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return super.onKeyDown(keyCode, event);
|
|
|
|
+ }
|
|
|
|
+}
|