chore: 迁移依赖、移除sqlite3_flutter_libs并新增功能
1. 替换hive_flutter为hive_ce_flutter依赖 2. 从各平台插件列表移除sqlite3_flutter_libs 3. 重构API请求体格式,优化历史记录去重逻辑 4. 新增CTC笔记相关功能:桌面小部件、模板模型、本地存储 5. 新增表单收集服务和后台管理接口 6. 优化缓存配置、多语言文案和UI细节 7. 重构首页状态监听组件
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* CtcLatestNoteProvider.kt
|
||||
* 创建时间: 2026-06-15
|
||||
* 更新时间: 2026-06-15
|
||||
* 名称: CTC最新笔记桌面小部件Provider
|
||||
* 作用: 在Android桌面展示CTC最新笔记的钥匙名和内容预览,支持深色主题
|
||||
* 上次更新内容: 初始创建,支持light/dark双主题布局,点击跳转/ctc路由
|
||||
*/
|
||||
package apps.xy.xianyan.widget
|
||||
|
||||
import android.appwidget.AppWidgetManager
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.widget.RemoteViews
|
||||
import apps.xy.xianyan.R
|
||||
import apps.xy.xianyan.MainActivity
|
||||
import es.antonborri.home_widget.HomeWidgetLaunchIntent
|
||||
import es.antonborri.home_widget.HomeWidgetProvider
|
||||
|
||||
class CtcLatestNoteProvider : HomeWidgetProvider() {
|
||||
override fun onUpdate(
|
||||
context: Context,
|
||||
appWidgetManager: AppWidgetManager,
|
||||
appWidgetIds: IntArray,
|
||||
widgetData: SharedPreferences
|
||||
) {
|
||||
val isDark = widgetData.getString("widget_theme_mode", "light") == "dark"
|
||||
appWidgetIds.forEach { widgetId ->
|
||||
val layoutId = if (isDark) R.layout.widget_ctc_latest_note_dark else R.layout.widget_ctc_latest_note
|
||||
val views = RemoteViews(context.packageName, layoutId).apply {
|
||||
// 读取SharedPreferences中的笔记数据
|
||||
val noteKey = widgetData.getString("ctc_latest_note_key", null) ?: ""
|
||||
val noteContent = widgetData.getString("ctc_latest_note_content", null) ?: ""
|
||||
val noteTime = widgetData.getString("ctc_latest_note_time", null) ?: ""
|
||||
|
||||
// 更新UI
|
||||
setTextViewText(R.id.widget_ctc_note_key, if (noteKey.isNotEmpty()) "🔑 $noteKey" else "📝 暂无笔记")
|
||||
setTextViewText(R.id.widget_ctc_note_content, if (noteContent.isNotEmpty()) noteContent else "点击查看CTC笔记")
|
||||
setTextViewText(R.id.widget_ctc_note_time, noteTime)
|
||||
|
||||
// 点击跳转到 /ctc 路由
|
||||
val pendingIntent = HomeWidgetLaunchIntent.getActivity(context, MainActivity::class.java)
|
||||
setOnClickPendingIntent(R.id.widget_ctc_note_container, pendingIntent)
|
||||
}
|
||||
appWidgetManager.updateAppWidget(widgetId, views)
|
||||
}
|
||||
}
|
||||
}
|
||||
53
android/app/src/main/res/layout/widget_ctc_latest_note.xml
Normal file
53
android/app/src/main/res/layout/widget_ctc_latest_note.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_ctc_note_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/widget_background"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<!-- 笔记图标 + 钥匙名 -->
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="📝 暂无笔记"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#333333"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<!-- 内容预览 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点击查看CTC笔记"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#888888"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:lineSpacingMultiplier="1.2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textSize="10sp"
|
||||
android:textColor="#BBBBBB"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/widget_ctc_note_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:padding="12dp"
|
||||
android:background="@drawable/widget_background_dark"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<!-- 笔记图标 + 钥匙名 -->
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="📝 暂无笔记"
|
||||
android:textSize="14sp"
|
||||
android:textColor="#E0E0E0"
|
||||
android:textStyle="bold"
|
||||
android:maxLines="1"
|
||||
android:ellipsize="end"
|
||||
android:layout_marginEnd="8dp" />
|
||||
|
||||
<!-- 内容预览 -->
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="点击查看CTC笔记"
|
||||
android:textSize="12sp"
|
||||
android:textColor="#AAAAAA"
|
||||
android:maxLines="2"
|
||||
android:ellipsize="end"
|
||||
android:lineSpacingMultiplier="1.2" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/widget_ctc_note_time"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=""
|
||||
android:textSize="10sp"
|
||||
android:textColor="#777777"
|
||||
android:layout_marginTop="2dp"
|
||||
android:maxLines="1" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
12
android/app/src/main/res/xml/ctc_latest_note_info.xml
Normal file
12
android/app/src/main/res/xml/ctc_latest_note_info.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:initialLayout="@layout/widget_ctc_latest_note"
|
||||
android:minWidth="250dp"
|
||||
android:minHeight="40dp"
|
||||
android:previewLayout="@layout/widget_ctc_latest_note"
|
||||
android:resizeMode="horizontal|vertical"
|
||||
android:targetCellWidth="4"
|
||||
android:targetCellHeight="1"
|
||||
android:updatePeriodMillis="1800000"
|
||||
android:widgetCategory="home_screen"
|
||||
android:description="@string/widget_ctc_latest_note_desc" />
|
||||
Reference in New Issue
Block a user