Skip to content

Commit c0374a6

Browse files
committed
1.完成启动页添加隐私弹窗
1 parent c115820 commit c0374a6

File tree

15 files changed

+303
-12
lines changed

15 files changed

+303
-12
lines changed
Lines changed: 109 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,132 @@
11
package org.qpython.qpy.main.activity;
22

33
import android.content.Intent;
4+
import android.databinding.DataBindingUtil;
5+
import android.graphics.Color;
46
import android.os.Bundle;
57
import android.support.annotation.Nullable;
8+
import android.support.constraint.ConstraintLayout;
69
import android.support.v7.app.AppCompatActivity;
10+
import android.support.v7.widget.AppCompatTextView;
11+
import android.text.SpannableString;
12+
import android.text.Spanned;
13+
import android.text.method.LinkMovementMethod;
14+
import android.util.Log;
15+
import android.view.View;
716

817
import org.qpython.qpy.R;
18+
import org.qpython.qpy.databinding.ActivitySplashBinding;
19+
import org.qpython.qpy.main.app.App;
20+
import org.qpython.qpy.main.widget.MyCheckTextView;
921

1022
import java.util.Timer;
1123
import java.util.TimerTask;
1224

13-
public class SplashActivity extends AppCompatActivity {
25+
public class SplashActivity extends AppCompatActivity implements View.OnClickListener, MyCheckTextView.ClickListener {
26+
27+
ActivitySplashBinding binding;
28+
1429

1530
@Override
1631
public void onCreate(@Nullable Bundle savedInstanceState) {
1732
super.onCreate(savedInstanceState);
18-
setContentView(R.layout.activity_splash);
33+
binding = DataBindingUtil.setContentView(this, R.layout.activity_splash);
34+
// setContentView(R.layout.activity_splash);
35+
initClick();
36+
initData();
37+
}
38+
39+
private void initClick() {
40+
binding.tvPositive.setOnClickListener(this);
41+
binding.tvNegative.setOnClickListener(this);
42+
}
43+
44+
private void initData() {
45+
setContent();
46+
setAgreeContent();
47+
judgeAgreementStatus();
48+
}
49+
50+
private void setAgreeContent() {
51+
String one = "您可以阅读完整版";
52+
String two = "《服务协议》";
53+
String three = "和";
54+
String four = "《隐私政策》";
55+
56+
String content = one + two + three + four;
57+
SpannableString str = new SpannableString(content);
58+
str.setSpan(new MyCheckTextView(getApplicationContext(), 0, R.color.color_498fdd, this), one.length(), one.length() + two.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
59+
str.setSpan(new MyCheckTextView(getApplicationContext(), 1, R.color.color_498fdd, this), one.length() + two.length() + three.length(), one.length() + two.length() + three.length() + four.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
60+
61+
binding.tvAgreeContent.setText(str);
62+
63+
//不设置 没有点击事件
64+
binding.tvAgreeContent.setMovementMethod(LinkMovementMethod.getInstance());
65+
//设置点击后的颜色为透明
66+
binding.tvAgreeContent.setHighlightColor(Color.TRANSPARENT);
67+
}
68+
69+
private void setContent() {
70+
StringBuffer buffer = new StringBuffer();
71+
buffer.append("1.为了给您提供发布服务,我们可能会向您申请摄像头权限、麦克风权限、收集存储权限;\n");
72+
buffer.append("2.为了向您推荐您附近的村庄,我们会向您申请位置权限;\n");
73+
buffer.append("3.为了账号安全,我们会向您申请系统设备权限收集设备信息、日志信息;\n");
74+
buffer.append("4.我们会努力采取各种安全技术保护您的个人信息。未经您同意,我们不会从第三方获取、共享或对外提供您的信息;\n");
75+
buffer.append("5.您还可以访问、更正、删除您的个人信息,我们为您提供了注销、投诉等多种不同方式。");
76+
binding.tvContent.setText(buffer.toString());
77+
}
78+
79+
private void judgeAgreementStatus() {
80+
if (App.getAgreementStatus()){
81+
delayJumpToMain();
82+
}else{
83+
binding.clAgreeLayout.setVisibility(View.VISIBLE);
84+
}
85+
}
86+
87+
private void delayJumpToMain() {
1988
new Timer().schedule(new TimerTask() {
2089
@Override
2190
public void run() {
22-
Intent intent = new Intent(SplashActivity.this,HomeMainActivity.class);
23-
intent.setAction(getIntent().getAction());
24-
startActivity(intent);
25-
finish();
91+
jumpToMain();
2692
}
27-
},1000);
93+
}, 1000);
94+
}
95+
96+
private void jumpToMain(){
97+
Intent intent = new Intent(SplashActivity.this, HomeMainActivity.class);
98+
intent.setAction(getIntent().getAction());
99+
startActivity(intent);
100+
finish();
101+
}
102+
103+
@Override
104+
public void onClick(View v) {
105+
int id = v.getId();
106+
if (id == R.id.tv_positive){
107+
App.setAgreementStatus(true);
108+
jumpToMain();
109+
return;
110+
}
111+
if (id == R.id.tv_negative){
112+
finish();
113+
}
114+
}
115+
116+
@Override
117+
public void click(int mark) {
118+
if (mark == 0) {
119+
goServiceAgreement();
120+
}else{
121+
goPrivacyAgreement();
122+
}
28123
}
29124

125+
private void goPrivacyAgreement() {
126+
QWebViewActivity.start(this, getString(R.string.privacy_agreement), "https://www.qpython.org/privacy-cn.html");
127+
}
128+
129+
private void goServiceAgreement() {
130+
QWebViewActivity.start(this, getString(R.string.service_agreement), "https://www.qpython.org/agreement-cn.html");
131+
}
30132
}

qpython/src/main/java/org/qpython/qpy/main/app/App.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ public static User getUser() {
118118
return user;
119119
}
120120

121+
public static boolean getAgreementStatus(){
122+
return mPreferences.getBoolean("user_agree_status",false);
123+
}
124+
125+
public static void setAgreementStatus(boolean status){
126+
SharedPreferences.Editor editor = mPreferences.edit();
127+
editor.putBoolean("user_agree_status",status);
128+
if (!editor.commit()) {
129+
editor.apply();
130+
}
131+
}
132+
121133
public static DefaultDownloader getDownloader() {
122134
return downloader;
123135
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package org.qpython.qpy.main.widget;
2+
3+
import android.content.Context;
4+
import android.support.annotation.NonNull;
5+
import android.support.v4.content.ContextCompat;
6+
import android.text.TextPaint;
7+
import android.text.style.ClickableSpan;
8+
import android.view.View;
9+
10+
11+
public class MyCheckTextView extends ClickableSpan {
12+
private Context mContext;
13+
private int mark;
14+
private int color;
15+
private ClickListener listener;
16+
17+
public MyCheckTextView(Context mContext, int mark, int color, ClickListener listener) {
18+
this.mContext = mContext;
19+
this.mark = mark;
20+
this.color = color;
21+
this.listener = listener;
22+
}
23+
24+
25+
@Override
26+
public void onClick(@NonNull View widget) {
27+
if (listener != null) {
28+
listener.click(mark);
29+
}
30+
}
31+
32+
@Override
33+
public void updateDrawState(@NonNull TextPaint ds) {
34+
super.updateDrawState(ds);
35+
// 设置文本颜色
36+
ds.setColor(ContextCompat.getColor(mContext, color));
37+
// 超链接形式的下划线,false 表示不显示下划
38+
ds.setUnderlineText(false);
39+
40+
}
41+
42+
public interface ClickListener {
43+
void click(int mark);
44+
}
45+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:shape="rectangle">
4+
5+
<corners android:radius="100dp" />
6+
7+
<solid android:color="#009639" />
8+
9+
</shape>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<shape
3+
android:shape="rectangle"
4+
xmlns:android="http://schemas.android.com/apk/res/android">
5+
6+
<corners android:topLeftRadius="10dp" android:topRightRadius="10dp" />
7+
8+
<solid android:color="#ffffff" />
9+
10+
</shape>
Lines changed: 98 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,109 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<layout>
2+
<layout xmlns:tools="http://schemas.android.com/tools"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
34

4-
<RelativeLayout
5+
<FrameLayout
56
xmlns:android="http://schemas.android.com/apk/res/android"
67
android:layout_width="match_parent"
78
android:background="#103606"
89
android:layout_height="match_parent">
910

10-
<ImageView
11+
<android.support.v7.widget.AppCompatImageView
1112
android:layout_width="70dp"
1213
android:layout_height="50dp"
13-
android:layout_centerInParent="true"
14+
android:layout_gravity="center"
1415
android:src="@drawable/img_home_logo"/>
15-
</RelativeLayout>
16+
17+
<android.support.constraint.ConstraintLayout
18+
android:id="@+id/cl_agree_layout"
19+
android:layout_width="match_parent"
20+
android:layout_height="wrap_content"
21+
android:visibility="gone"
22+
android:background="@drawable/top_white_r10"
23+
android:layout_gravity="bottom"
24+
android:paddingBottom="6dp">
25+
26+
<android.support.v7.widget.AppCompatImageView
27+
android:id="@+id/iv_icon"
28+
android:layout_width="50dp"
29+
android:layout_height="50dp"
30+
android:layout_marginLeft="15dp"
31+
android:layout_marginTop="15dp"
32+
android:src="@drawable/img_home_logo"
33+
app:layout_constraintStart_toStartOf="parent"
34+
app:layout_constraintTop_toTopOf="parent" />
35+
36+
<android.support.v7.widget.AppCompatTextView
37+
android:id="@+id/tv_title"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:textSize="20dp"
41+
android:layout_marginTop="12dp"
42+
android:gravity="center"
43+
android:text="Welcome To Python"
44+
android:textColor="#333333"
45+
android:textStyle="bold"
46+
app:layout_constraintStart_toStartOf="@+id/iv_icon"
47+
app:layout_constraintTop_toBottomOf="@+id/iv_icon" />
48+
49+
<android.support.v7.widget.AppCompatTextView
50+
android:id="@+id/tv_content"
51+
android:layout_width="0dp"
52+
android:layout_height="wrap_content"
53+
android:textSize="12dp"
54+
android:layout_marginTop="12dp"
55+
android:layout_marginRight="15dp"
56+
app:layout_constraintEnd_toEndOf="parent"
57+
android:textColor="#333333"
58+
app:layout_constraintStart_toStartOf="@+id/iv_icon"
59+
app:layout_constraintTop_toBottomOf="@+id/tv_title" />
60+
61+
<android.support.v7.widget.AppCompatTextView
62+
android:id="@+id/tv_agree_content"
63+
android:layout_width="0dp"
64+
android:layout_height="wrap_content"
65+
android:textSize="12dp"
66+
android:layout_marginTop="12dp"
67+
android:layout_marginRight="15dp"
68+
android:textColor="#333333"
69+
app:layout_constraintEnd_toEndOf="parent"
70+
app:layout_constraintStart_toStartOf="@+id/iv_icon"
71+
app:layout_constraintTop_toBottomOf="@+id/tv_content" />
72+
73+
74+
<android.support.v7.widget.AppCompatTextView
75+
android:id="@+id/tv_positive"
76+
android:textSize="15dp"
77+
android:textStyle="bold"
78+
android:layout_width="0dp"
79+
android:layout_height="35dp"
80+
android:layout_marginTop="30dp"
81+
android:layout_marginRight="15dp"
82+
android:layout_marginLeft="15dp"
83+
android:background="@drawable/agree_confirm_btn"
84+
android:gravity="center"
85+
android:text="同意并继续"
86+
android:textColor="#ffffff"
87+
app:layout_constraintEnd_toEndOf="parent"
88+
app:layout_constraintStart_toStartOf="parent"
89+
app:layout_constraintTop_toBottomOf="@+id/tv_agree_content" />
90+
91+
<android.support.v7.widget.AppCompatTextView
92+
android:id="@+id/tv_negative"
93+
android:layout_width="0dp"
94+
android:textSize="12dp"
95+
android:layout_height="35dp"
96+
android:layout_marginLeft="15dp"
97+
android:layout_marginTop="6dp"
98+
android:layout_marginRight="15dp"
99+
android:gravity="center"
100+
android:text="退出并关闭 Python"
101+
android:textColor="#999999"
102+
app:layout_constraintEnd_toEndOf="parent"
103+
app:layout_constraintStart_toStartOf="parent"
104+
app:layout_constraintTop_toBottomOf="@+id/tv_positive" />
105+
106+
</android.support.constraint.ConstraintLayout>
107+
108+
</FrameLayout>
16109
</layout>

qpython/src/main/res/values-ja/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,6 @@
490490
<string name="disable_keep_alive">Disable</string>
491491
<string name="keep_alive_tips">QPython will restart to apply changes.</string>
492492
<string name="shortcut_create_fail">"Please grant the creat shortcut permission. "</string>
493+
<string name="privacy_agreement">服务协议</string>
494+
<string name="service_agreement">隐私政策</string>
493495
</resources>

qpython/src/main/res/values-ru/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,6 @@ w <string name="confirm">Подтвердить</string>
434434
<string name="disable_keep_alive">Disable</string>
435435
<string name="keep_alive_tips">QPython will restart to apply changes.</string>
436436
<string name="shortcut_create_fail">"Please grant the creat shortcut permission. "</string>
437+
<string name="privacy_agreement">服务协议</string>
438+
<string name="service_agreement">隐私政策</string>
437439
</resources>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
</resources>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
</resources>

0 commit comments

Comments
 (0)