添加完整的隐私政策功能:1. 创建PrivacyPolicyActivity显示隐私政策 2. 修改MainActivity在首次启动时显示隐私政策 3. 添加必要的资源和布局文件 4. 实现隐私政策同意机制
This commit is contained in:
@@ -36,6 +36,11 @@
|
||||
android:name=".SettingsActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".PrivacyPolicyActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.LogCam" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -1,16 +1,41 @@
|
||||
package com.example.app
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_main)
|
||||
|
||||
// 启动综合相机Activity
|
||||
startActivity(Intent(this, CameraActivity::class.java))
|
||||
|
||||
sharedPreferences = getSharedPreferences("app_preferences", MODE_PRIVATE)
|
||||
|
||||
// 检查用户是否已同意隐私政策
|
||||
val privacyAccepted = sharedPreferences.getBoolean("privacy_accepted", false)
|
||||
|
||||
if (privacyAccepted) {
|
||||
// 已同意,直接进入相机界面
|
||||
startCameraActivity()
|
||||
} else {
|
||||
// 未同意,显示隐私政策
|
||||
showPrivacyPolicy()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startCameraActivity() {
|
||||
val intent = Intent(this, CameraActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish() // 关闭MainActivity,避免返回键回到空白页面
|
||||
}
|
||||
|
||||
private fun showPrivacyPolicy() {
|
||||
val intent = Intent(this, PrivacyPolicyActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish() // 关闭MainActivity,隐私政策页面会处理后续流程
|
||||
}
|
||||
}
|
||||
|
||||
267
app/src/main/java/com/example/app/PrivacyPolicyActivity.kt
Normal file
267
app/src/main/java/com/example/app/PrivacyPolicyActivity.kt
Normal file
@@ -0,0 +1,267 @@
|
||||
package com.example.app
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebView
|
||||
import android.widget.Button
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
|
||||
class PrivacyPolicyActivity : AppCompatActivity() {
|
||||
|
||||
private lateinit var sharedPreferences: SharedPreferences
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_privacy_policy)
|
||||
|
||||
sharedPreferences = getSharedPreferences("app_preferences", MODE_PRIVATE)
|
||||
|
||||
// 设置Toolbar
|
||||
val toolbar: Toolbar = findViewById(R.id.toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(true)
|
||||
toolbar.setNavigationOnClickListener {
|
||||
onBackPressed()
|
||||
}
|
||||
|
||||
val webView: WebView = findViewById(R.id.privacyWebView)
|
||||
val agreeButton: Button = findViewById(R.id.agreeButton)
|
||||
val disagreeButton: Button = findViewById(R.id.disagreeButton)
|
||||
|
||||
// 设置按钮点击事件
|
||||
agreeButton.setOnClickListener {
|
||||
savePrivacyAcceptance(true)
|
||||
startCameraActivity()
|
||||
}
|
||||
|
||||
disagreeButton.setOnClickListener {
|
||||
savePrivacyAcceptance(false)
|
||||
finish() // 不同意则退出应用
|
||||
}
|
||||
|
||||
// 加载隐私政策HTML内容
|
||||
val privacyPolicyHtml = """
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
background-color: #f9f9f9;
|
||||
}
|
||||
h1 {
|
||||
color: #2c3e50;
|
||||
border-bottom: 2px solid #3498db;
|
||||
padding-bottom: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
h2 {
|
||||
color: #34495e;
|
||||
margin-top: 30px;
|
||||
padding-bottom: 5px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
h3 {
|
||||
color: #7f8c8d;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.section {
|
||||
background: white;
|
||||
padding: 20px;
|
||||
margin: 20px 0;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||
}
|
||||
.highlight {
|
||||
background-color: #fffde7;
|
||||
padding: 15px;
|
||||
border-left: 4px solid #ffd600;
|
||||
margin: 15px 0;
|
||||
}
|
||||
.contact {
|
||||
background-color: #e8f4fd;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
margin-top: 30px;
|
||||
}
|
||||
.update-date {
|
||||
text-align: right;
|
||||
color: #7f8c8d;
|
||||
font-style: italic;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="update-date">最后更新日期:2025年2月11日</div>
|
||||
|
||||
<h1>LogCam 隐私政策</h1>
|
||||
|
||||
<div class="section">
|
||||
<p>欢迎使用 LogCam(以下简称"本应用")。我们高度重视您的隐私保护,并致力于保护您的个人信息安全。本隐私政策旨在说明我们如何收集、使用、存储和保护您的个人信息。</p>
|
||||
|
||||
<div class="highlight">
|
||||
<p><strong>重要提示:</strong>请仔细阅读本隐私政策。使用本应用即表示您同意本隐私政策的条款。如果您不同意本政策,请停止使用本应用。</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>1. 信息收集</h2>
|
||||
<p>本应用在以下情况下会收集信息:</p>
|
||||
|
||||
<h3>1.1 相机权限</h3>
|
||||
<p>当您使用拍照功能时,本应用需要访问您的设备相机。我们仅使用相机权限来:</p>
|
||||
<ul>
|
||||
<li>预览相机画面</li>
|
||||
<li>拍摄照片</li>
|
||||
<li>添加水印(如选择水印模式)</li>
|
||||
</ul>
|
||||
<p><strong>我们不会:</strong>通过相机权限录制视频、进行人脸识别或收集任何生物特征信息。</p>
|
||||
|
||||
<h3>1.2 存储权限</h3>
|
||||
<p>当您保存照片时,本应用需要访问设备存储。我们仅使用存储权限来:</p>
|
||||
<ul>
|
||||
<li>将拍摄的照片保存到您的设备相册</li>
|
||||
<li>读取已保存的照片进行合成处理(如选择合成模式)</li>
|
||||
</ul>
|
||||
<p>所有照片都保存在您的设备本地,我们不会将您的照片上传到任何服务器。</p>
|
||||
|
||||
<h3>1.3 设备信息</h3>
|
||||
<p>我们可能会收集以下匿名设备信息用于应用优化:</p>
|
||||
<ul>
|
||||
<li>设备型号</li>
|
||||
<li>Android 版本</li>
|
||||
<li>应用使用情况统计(功能使用频率)</li>
|
||||
</ul>
|
||||
<p>这些信息都是匿名的,无法识别您的个人身份。</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>2. 信息使用</h2>
|
||||
<p>我们收集的信息仅用于以下目的:</p>
|
||||
<ul>
|
||||
<li>提供核心拍照功能</li>
|
||||
<li>改进应用性能和用户体验</li>
|
||||
<li>修复应用错误和问题</li>
|
||||
<li>统计分析应用使用情况</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>3. 信息存储</h2>
|
||||
<h3>3.1 本地存储</h3>
|
||||
<p>所有拍摄的照片都存储在您的设备本地,具体位置为:</p>
|
||||
<ul>
|
||||
<li>内部存储 → Pictures/LogCam 目录</li>
|
||||
<li>或您选择的其他位置</li>
|
||||
</ul>
|
||||
|
||||
<h3>3.2 数据安全</h3>
|
||||
<p>我们采取合理的技术措施保护您的信息:</p>
|
||||
<ul>
|
||||
<li>照片仅存储在设备本地</li>
|
||||
<li>不收集敏感个人信息</li>
|
||||
<li>遵循最小必要原则收集信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>4. 信息共享</h2>
|
||||
<p><strong>我们不会与任何第三方共享您的个人信息或照片。</strong>具体包括:</p>
|
||||
<ul>
|
||||
<li>不将照片上传到云端</li>
|
||||
<li>不向广告商提供个人信息</li>
|
||||
<li>不与第三方分析工具共享可识别信息</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>5. 第三方服务</h2>
|
||||
<p>本应用使用了以下第三方库,这些库可能会收集匿名信息:</p>
|
||||
<ul>
|
||||
<li><strong>CameraX</strong>:Google提供的相机库,用于相机功能</li>
|
||||
<li><strong>AndroidX</strong>:Google提供的Android扩展库</li>
|
||||
</ul>
|
||||
<p>这些库的使用遵循其各自的隐私政策,但我们确保它们不会收集您的个人照片或可识别信息。</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>6. 儿童隐私</h2>
|
||||
<p>本应用不面向13岁以下儿童设计。我们不会有意收集儿童的个人信息。如果您是家长或监护人,并发现您的孩子向我们提供了个人信息,请通过以下联系方式与我们联系,我们将尽快删除这些信息。</p>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>7. 权限管理</h2>
|
||||
<p>您可以在设备的设置中随时管理本应用的权限:</p>
|
||||
<ul>
|
||||
<li>前往"设置" → "应用" → "LogCam" → "权限"</li>
|
||||
<li>您可以随时授予或撤销相机、存储等权限</li>
|
||||
<li>撤销权限可能会影响部分功能的正常使用</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="section">
|
||||
<h2>8. 隐私政策更新</h2>
|
||||
<p>我们可能会不时更新本隐私政策。更新后的隐私政策将在本页面发布,并在应用内通知您。建议您定期查看本隐私政策以了解任何更改。</p>
|
||||
</div>
|
||||
|
||||
<div class="section contact">
|
||||
<h2>9. 联系我们</h2>
|
||||
<p>如果您对本隐私政策有任何疑问、意见或建议,请通过以下方式联系我们:</p>
|
||||
<ul>
|
||||
<li>邮箱:privacy@example.com</li>
|
||||
<li>反馈时间:工作日 9:00-18:00</li>
|
||||
<li>我们将在15个工作日内回复您的咨询</li>
|
||||
</ul>
|
||||
|
||||
<p style="margin-top: 20px;"><strong>再次感谢您使用 LogCam!</strong></p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
""".trimIndent()
|
||||
|
||||
webView.loadDataWithBaseURL(
|
||||
null,
|
||||
privacyPolicyHtml,
|
||||
"text/html",
|
||||
"UTF-8",
|
||||
null
|
||||
)
|
||||
|
||||
// 自动滚动到底部,确保用户看到同意按钮
|
||||
webView.postDelayed({
|
||||
webView.scrollTo(0, webView.contentHeight)
|
||||
}, 500)
|
||||
}
|
||||
|
||||
private fun savePrivacyAcceptance(accepted: Boolean) {
|
||||
val editor = sharedPreferences.edit()
|
||||
editor.putBoolean("privacy_accepted", accepted)
|
||||
editor.apply()
|
||||
}
|
||||
|
||||
private fun startCameraActivity() {
|
||||
val intent = Intent(this, CameraActivity::class.java)
|
||||
startActivity(intent)
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
// 不允许通过返回键跳过隐私政策
|
||||
// 显示提示信息
|
||||
android.app.AlertDialog.Builder(this)
|
||||
.setTitle("提示")
|
||||
.setMessage("您需要同意隐私政策才能使用本应用")
|
||||
.setPositiveButton("确定", null)
|
||||
.show()
|
||||
}
|
||||
}
|
||||
10
app/src/main/res/drawable/ic_arrow_back.xml
Normal file
10
app/src/main/res/drawable/ic_arrow_back.xml
Normal file
@@ -0,0 +1,10 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="@color/white">
|
||||
<path
|
||||
android:fillColor="@android:color/white"
|
||||
android:pathData="M20,11H7.83l5.59,-5.59L12,4l-8,8 8,8 1.41,-1.41L7.83,13H20v-2z"/>
|
||||
</vector>
|
||||
61
app/src/main/res/layout/activity_privacy_policy.xml
Normal file
61
app/src/main/res/layout/activity_privacy_policy.xml
Normal file
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:background="@color/white"
|
||||
tools:context=".PrivacyPolicyActivity">
|
||||
|
||||
<!-- 标题栏 -->
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="?attr/colorPrimary"
|
||||
android:theme="?attr/actionBarTheme"
|
||||
app:title="隐私政策"
|
||||
app:titleTextColor="@color/white"
|
||||
app:navigationIcon="@drawable/ic_arrow_back"
|
||||
app:navigationContentDescription="返回" />
|
||||
|
||||
<!-- WebView显示隐私政策内容 -->
|
||||
<WebView
|
||||
android:id="@+id/privacyWebView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:padding="8dp" />
|
||||
|
||||
<!-- 底部确认按钮 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:padding="16dp"
|
||||
android:background="@color/white"
|
||||
android:elevation="4dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/agreeButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="同意并继续"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:textColor="@color/white"
|
||||
android:textStyle="bold"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/disagreeButton"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="不同意"
|
||||
android:backgroundTint="@color/gray"
|
||||
android:textColor="@color/white" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -8,4 +8,6 @@
|
||||
<color name="black">#FF000000</color>
|
||||
<color name="white">#FFFFFFFF</color>
|
||||
<color name="primary">#FF6200EE</color>
|
||||
<color name="gray">#FF9E9E9E</color>
|
||||
<color name="colorPrimary">#FF6200EE</color>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user