Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit f113ac39
authored
2026-06-24 21:01:41 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整原生的隐私政策界面
1 parent
366f13c2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
39 deletions
android/app/src/main/java/cn/banxe/bxe/PrivacyActivity.java
android/app/src/main/java/cn/banxe/bxe/PrivacyActivity.java
View file @
f113ac3
...
...
@@ -5,6 +5,7 @@ import android.app.AlertDialog;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.graphics.drawable.GradientDrawable
;
import
android.graphics.Typeface
;
import
android.net.Uri
;
import
android.os.Bundle
;
...
...
@@ -16,6 +17,7 @@ import android.text.style.ClickableSpan;
import
android.view.Gravity
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
...
...
@@ -62,30 +64,37 @@ public class PrivacyActivity extends Activity {
}
private
View
createContentView
()
{
// 根布局
LinearLayout
rootLayout
=
new
LinearLayout
(
this
);
rootLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
rootLayout
.
setGravity
(
Gravity
.
CENTER_VERTICAL
);
rootLayout
.
setPadding
(
dpToPx
(
32
),
dpToPx
(
48
),
dpToPx
(
32
),
dpToPx
(
48
));
// 外层根布局(浅灰色背景,垂直居中)
FrameLayout
rootLayout
=
new
FrameLayout
(
this
);
rootLayout
.
setBackgroundColor
(
0xFFFFFFFF
);
// 内容容器
LinearLayout
contentLayout
=
new
LinearLayout
(
this
);
contentLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
LinearLayout
.
LayoutParams
contentLayoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
rootLayout
.
addView
(
contentLayout
,
contentLayoutParams
);
// 卡片容器(白色圆角卡片)
LinearLayout
cardLayout
=
new
LinearLayout
(
this
);
cardLayout
.
setOrientation
(
LinearLayout
.
VERTICAL
);
cardLayout
.
setPadding
(
dpToPx
(
28
),
dpToPx
(
36
),
dpToPx
(
28
),
dpToPx
(
36
));
GradientDrawable
cardBg
=
new
GradientDrawable
();
cardBg
.
setColor
(
0xFFFFFFFF
);
cardBg
.
setCornerRadius
(
dpToPx
(
16
));
cardLayout
.
setBackground
(
cardBg
);
FrameLayout
.
LayoutParams
cardParams
=
new
FrameLayout
.
LayoutParams
(
FrameLayout
.
LayoutParams
.
MATCH_PARENT
,
FrameLayout
.
LayoutParams
.
WRAP_CONTENT
);
int
cardMarginH
=
dpToPx
(
24
);
int
cardMarginV
=
dpToPx
(
80
);
cardParams
.
setMargins
(
cardMarginH
,
cardMarginV
,
cardMarginH
,
cardMarginV
);
cardParams
.
gravity
=
Gravity
.
CENTER_VERTICAL
;
rootLayout
.
addView
(
cardLayout
,
cardParams
);
// 标题
TextView
titleView
=
new
TextView
(
this
);
titleView
.
setText
(
"用户协议与隐私政策"
);
titleView
.
setTextSize
(
2
2
);
titleView
.
setTextSize
(
2
3
);
titleView
.
setTextColor
(
0xFF333333
);
titleView
.
setTypeface
(
null
,
Typeface
.
BOLD
);
titleView
.
setGravity
(
Gravity
.
CENTER
);
titleView
.
setPadding
(
0
,
0
,
0
,
dpToPx
(
32
));
c
ontent
Layout
.
addView
(
titleView
);
titleView
.
setPadding
(
0
,
0
,
0
,
dpToPx
(
28
));
c
ard
Layout
.
addView
(
titleView
);
// 内容(带可点击链接)
TextView
contentView
=
new
TextView
(
this
);
...
...
@@ -93,10 +102,10 @@ public class PrivacyActivity extends Activity {
contentView
.
setMovementMethod
(
LinkMovementMethod
.
getInstance
());
contentView
.
setHighlightColor
(
0x00000000
);
contentView
.
setTextSize
(
17
);
contentView
.
setTextColor
(
0xFF
666666
);
contentView
.
setTextColor
(
0xFF
555555
);
contentView
.
setLineSpacing
(
dpToPx
(
6
),
1.0f
);
contentView
.
setGravity
(
Gravity
.
START
);
c
ontent
Layout
.
addView
(
contentView
);
c
ard
Layout
.
addView
(
contentView
);
// 按钮容器
LinearLayout
buttonLayout
=
new
LinearLayout
(
this
);
...
...
@@ -105,45 +114,51 @@ public class PrivacyActivity extends Activity {
LinearLayout
.
LayoutParams
buttonLayoutParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
MATCH_PARENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
buttonLayoutParams
.
topMargin
=
dpToPx
(
48
);
contentLayout
.
addView
(
buttonLayout
,
buttonLayoutParams
);
buttonLayoutParams
.
topMargin
=
dpToPx
(
32
);
cardLayout
.
addView
(
buttonLayout
,
buttonLayoutParams
);
int
btnHeight
=
dpToPx
(
44
);
int
btnRadius
=
dpToPx
(
22
);
// 同意按钮
// 同意按钮
(蓝紫色填充,大圆角)
Button
agreeButton
=
new
Button
(
this
);
agreeButton
.
setText
(
"同意"
);
agreeButton
.
setTextColor
(
0xFFFFFFFF
);
agreeButton
.
setBackgroundColor
(
0xFF4CAF50
);
agreeButton
.
setTextSize
(
16
);
agreeButton
.
setTypeface
(
null
,
Typeface
.
BOLD
);
agreeButton
.
setGravity
(
Gravity
.
CENTER
);
agreeButton
.
setSingleLine
(
true
);
agreeButton
.
set
MinWidth
(
dpToPx
(
120
)
);
agreeButton
.
setMinHeight
(
dpToPx
(
48
)
);
int
btnPaddingH
=
dpToPx
(
24
);
int
btnPaddingV
=
dpToPx
(
12
);
agreeButton
.
set
Padding
(
btnPaddingH
,
btnPaddingV
,
btnPaddingH
,
btnPaddingV
);
agreeButton
.
set
Padding
(
0
,
0
,
0
,
0
);
GradientDrawable
agreeBg
=
new
GradientDrawable
(
);
agreeBg
.
setColor
(
0xFF7691FA
);
agreeBg
.
setCornerRadius
(
btnRadius
);
agreeButton
.
set
Background
(
agreeBg
);
agreeButton
.
setOnClickListener
(
v
->
onAgreeClicked
());
LinearLayout
.
LayoutParams
agreeParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
agreeParams
.
setMargins
(
dpToPx
(
16
),
0
,
dpToPx
(
16
),
0
);
0
,
btnHeight
,
1.0f
);
agreeParams
.
setMargins
(
0
,
0
,
dpToPx
(
8
),
0
);
buttonLayout
.
addView
(
agreeButton
,
agreeParams
);
// 不同意按钮
// 不同意按钮
(灰色描边,大圆角)
Button
disagreeButton
=
new
Button
(
this
);
disagreeButton
.
setText
(
"不同意"
);
disagreeButton
.
setTextColor
(
0xFF666666
);
disagreeButton
.
setBackgroundColor
(
0xFFEEEEEE
);
disagreeButton
.
setTextSize
(
16
);
disagreeButton
.
setGravity
(
Gravity
.
CENTER
);
disagreeButton
.
setSingleLine
(
true
);
disagreeButton
.
setMinWidth
(
dpToPx
(
120
));
disagreeButton
.
setMinHeight
(
dpToPx
(
48
));
disagreeButton
.
setPadding
(
btnPaddingH
,
btnPaddingV
,
btnPaddingH
,
btnPaddingV
);
disagreeButton
.
setPadding
(
0
,
0
,
0
,
0
);
GradientDrawable
disagreeBg
=
new
GradientDrawable
();
disagreeBg
.
setColor
(
0xFFF5F6FA
);
disagreeBg
.
setCornerRadius
(
btnRadius
);
disagreeButton
.
setBackground
(
disagreeBg
);
disagreeButton
.
setOnClickListener
(
v
->
onDisagreeClicked
());
LinearLayout
.
LayoutParams
disagreeParams
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
disagreeParams
.
setMargins
(
dpToPx
(
16
),
0
,
dpToPx
(
16
),
0
);
0
,
btnHeight
,
1.0f
);
disagreeParams
.
setMargins
(
dpToPx
(
8
),
0
,
0
,
0
);
buttonLayout
.
addView
(
disagreeButton
,
disagreeParams
);
return
rootLayout
;
...
...
@@ -172,7 +187,7 @@ public class PrivacyActivity extends Activity {
@Override
public
void
updateDrawState
(
TextPaint
ds
)
{
super
.
updateDrawState
(
ds
);
ds
.
setColor
(
0xFF
4CAF50
);
ds
.
setColor
(
0xFF
7691FA
);
ds
.
setUnderlineText
(
true
);
}
},
userAgreementStart
,
userAgreementEnd
,
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
...
...
@@ -188,7 +203,7 @@ public class PrivacyActivity extends Activity {
@Override
public
void
updateDrawState
(
TextPaint
ds
)
{
super
.
updateDrawState
(
ds
);
ds
.
setColor
(
0xFF
4CAF50
);
ds
.
setColor
(
0xFF
7691FA
);
ds
.
setUnderlineText
(
true
);
}
},
privacyPolicyStart
,
privacyPolicyEnd
,
Spanned
.
SPAN_EXCLUSIVE_EXCLUSIVE
);
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment