PasteFerry (隔空贴): clipboard and file sync across macOS, Windows and Linux. Direct-first, end-to-end encrypted. Optional official access: no server to host. Independent self-hosting remains available.
Dart airdrop-alternativeclipboardclipboard-sharingclipboard-synccopy-pastecross-platformend-to-end-encryptionfile-syncfile-transferfluttergolanglinuxmacosnat-traversalp2pself-hostedtailscaleuniversal-clipboardwebrtcwindows
feat(android): let the sent records window be configured
baiyuze282c43732f25
diff --git a/client-core/internal/config/config.go b/client-core/internal/config/config.goindex a6a9162..a567d4e 100644--- a/client-core/internal/config/config.go+++ b/client-core/internal/config/config.go@@ -80,6 +80,8 @@ type Config struct {// QuickPasteIndexModifier 是快捷窗口里按住它再按 1–9 粘贴对应那一条的修饰键:"alt"、"meta"、"ctrl"。// 空字符串表示默认的 alt(Mac 上是 ⌥)QuickPasteIndexModifier string `json:"quick_paste_index_modifier,omitempty"`+ // SentRetentionDays 是手机上「发送记录」显示最近几天的发出内容;0 或负表示默认 3 天+ SentRetentionDays int `json:"sent_retention_days,omitempty"`// ReceiveDir 是隔空传送收到的文件存放的位置,空字符串表示系统的「下载」文件夹(见 DownloadsDir)ReceiveDir string `json:"receive_dir,omitempty"`diff --git a/client-core/internal/rpc/convert.go b/client-core/internal/rpc/convert.goindex d221a7f..a963217 100644--- a/client-core/internal/rpc/convert.go+++ b/client-core/internal/rpc/convert.go@@ -87,6 +87,7 @@ func configToProto(c config.Config) *pb.Config {QuickPasteHotkey: c.QuickPasteHotkey,QuickPasteCopyOnly: c.QuickPasteCopyOnly,QuickPasteIndexModifier: c.QuickPasteIndexModifier,+ SentRetentionDays: int32(c.SentRetentionDays),ReceiveDir: c.ReceiveDir,ReceiveDisabled: c.ReceiveDisabled,ReceiveNotifyDisabled: c.ReceiveNotifyDisabled,@@ -179,6 +180,9 @@ func configFromProto(in *pb.Config, base config.Config) config.Config {if m := in.GetQuickPasteIndexModifier(); m != "" {c.QuickPasteIndexModifier = m}+ if d := in.GetSentRetentionDays(); d > 0 {+ c.SentRetentionDays = int(d)+ }// 空字符串就是系统的「下载」文件夹c.ReceiveDir = in.GetReceiveDir()c.ReceiveDisabled = in.GetReceiveDisabled()diff --git a/proto/gen/pasteferry/v1/daemon.pb.go b/proto/gen/pasteferry/v1/daemon.pb.goindex abd1036..7abb629 100644--- a/proto/gen/pasteferry/v1/daemon.pb.go+++ b/proto/gen/pasteferry/v1/daemon.pb.go@@ -3708,8 +3708,10 @@ type Config struct {// 快捷粘贴窗口里按住哪个修饰键再按 1–9 粘贴对应的那一条(2.6.3):"alt"、"meta"、"ctrl"。// 空字符串表示默认:各平台都是 alt(Mac 上是 ⌥)QuickPasteIndexModifier string `protobuf:"bytes,33,opt,name=quick_paste_index_modifier,json=quickPasteIndexModifier,proto3" json:"quick_paste_index_modifier,omitempty"`- unknownFields protoimpl.UnknownFields- sizeCache protoimpl.SizeCache+ // 手机上「发送记录」显示最近几天的发出内容(2.7.2):0 或空表示默认 3 天+ SentRetentionDays int32 `protobuf:"varint,34,opt,name=sent_retention_days,json=sentRetentionDays,proto3" json:"sent_retention_days,omitempty"`+ unknownFields protoimpl.UnknownFields+ sizeCache protoimpl.SizeCache}func (x *Config) Reset() {@@ -3973,6 +3975,13 @@ func (x *Config) GetQuickPasteIndexModifier() string {return ""}+func (x *Config) GetSentRetentionDays() int32 {+ if x != nil {+ return x.SentRetentionDays+ }+ return 0+}+type OfficialUsage struct {state protoimpl.MessageState `protogen:"open.v1"`Available bool `protobuf:"varint,1,opt,name=available,proto3" json:"available,omitempty"`@@ -6750,7 +6759,7 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +"\x04kind\x18\x01 \x01(\x0e2\x1d.pasteferry.v1.ConnectionKindR\x04kind\"P\n" +"\x17SetDeviceAddressRequest\x12\x1b\n" +"\tdevice_id\x18\x01 \x01(\tR\bdeviceId\x12\x18\n" +- "\aaddress\x18\x02 \x01(\tR\aaddress\"\xa5\v\n" ++ "\aaddress\x18\x02 \x01(\tR\aaddress\"\xd5\v\n" +"\x06Config\x129\n" +"\x19auto_sync_threshold_bytes\x18\x01 \x01(\x03R\x16autoSyncThresholdBytes\x12.\n" +"\x13history_ttl_seconds\x18\x02 \x01(\x03R\x11historyTtlSeconds\x12*\n" +@@ -6788,7 +6797,8 @@ const file_pasteferry_v1_daemon_proto_rawDesc = "" +"\freceive_from\x18\x1e \x01(\tR\vreceiveFrom\x12.\n" +"\x13everyone_until_unix\x18\x1f \x01(\x03R\x11everyoneUntilUnix\x12!\n" +"\fdisplay_name\x18 \x01(\tR\vdisplayName\x12;\n" +- "\x1aquick_paste_index_modifier\x18! \x01(\tR\x17quickPasteIndexModifier\"\xd8\x02\n" ++ "\x1aquick_paste_index_modifier\x18! \x01(\tR\x17quickPasteIndexModifier\x12.\n" ++ "\x13sent_retention_days\x18\" \x01(\x05R\x11sentRetentionDays\"\xd8\x02\n" +"\rOfficialUsage\x12\x1c\n" +"\tavailable\x18\x01 \x01(\bR\tavailable\x12\x10\n" +"\x03day\x18\x02 \x01(\tR\x03day\x12\x1f\n" +diff --git a/proto/pasteferry/v1/daemon.proto b/proto/pasteferry/v1/daemon.protoindex 82bfeab..9d538a2 100644--- a/proto/pasteferry/v1/daemon.proto+++ b/proto/pasteferry/v1/daemon.proto@@ -661,6 +661,8 @@ message Config {// 快捷粘贴窗口里按住哪个修饰键再按 1–9 粘贴对应的那一条(2.6.3):"alt"、"meta"、"ctrl"。// 空字符串表示默认:各平台都是 alt(Mac 上是 ⌥)string quick_paste_index_modifier = 33;+ // 手机上「发送记录」显示最近几天的发出内容(2.7.2):0 或空表示默认 3 天+ int32 sent_retention_days = 34;}enum ServiceMode {diff --git a/ui/lib/gen/pasteferry/v1/daemon.pb.dart b/ui/lib/gen/pasteferry/v1/daemon.pb.dartindex 0bd79eb..1180b87 100644--- a/ui/lib/gen/pasteferry/v1/daemon.pb.dart+++ b/ui/lib/gen/pasteferry/v1/daemon.pb.dart@@ -4321,6 +4321,7 @@ class Config extends $pb.GeneratedMessage {$fixnum.Int64? everyoneUntilUnix,$core.String? displayName,$core.String? quickPasteIndexModifier,+ $core.int? sentRetentionDays,}) {final result = Config._();if (autoSyncThresholdBytes != null)@@ -4366,6 +4367,7 @@ class Config extends $pb.GeneratedMessage {if (displayName != null) result.displayName = displayName;if (quickPasteIndexModifier != null)result.quickPasteIndexModifier = quickPasteIndexModifier;+ if (sentRetentionDays != null) result.sentRetentionDays = sentRetentionDays;return result;}@@ -4416,6 +4418,7 @@ class Config extends $pb.GeneratedMessage {..aInt64(31, _omitFieldNames ? '' : 'everyoneUntilUnix')..aOS(32, _omitFieldNames ? '' : 'displayName')..aOS(33, _omitFieldNames ? '' : 'quickPasteIndexModifier')+ ..aI(34, _omitFieldNames ? '' : 'sentRetentionDays')..hasRequiredFields = false;@$core.Deprecated('See https://github.com/google/protobuf.dart/issues/998.')@@ -4753,6 +4756,16 @@ class Config extends $pb.GeneratedMessage {$core.bool hasQuickPasteIndexModifier() => $_has(32);@$pb.TagNumber(33)void clearQuickPasteIndexModifier() => $_clearField(33);++ /// 手机上「发送记录」显示最近几天的发出内容(2.7.2):0 或空表示默认 3 天+ @$pb.TagNumber(34)+ $core.int get sentRetentionDays => $_getIZ(33);+ @$pb.TagNumber(34)+ set sentRetentionDays($core.int value) => $_setSignedInt32(33, value);+ @$pb.TagNumber(34)+ $core.bool hasSentRetentionDays() => $_has(33);+ @$pb.TagNumber(34)+ void clearSentRetentionDays() => $_clearField(34);}class OfficialUsage extends $pb.GeneratedMessage {diff --git a/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart b/ui/lib/gen/pasteferry/v1/daemon.pbjson.dartindex 1d3d683..4e4e2a0 100644--- a/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart+++ b/ui/lib/gen/pasteferry/v1/daemon.pbjson.dart@@ -1336,6 +1336,13 @@ const Config$json = {'5': 9,'10': 'quickPasteIndexModifier'},+ {+ '1': 'sent_retention_days',+ '3': 34,+ '4': 1,+ '5': 5,+ '10': 'sentRetentionDays'+ },],};@@ -1367,7 +1374,7 @@ final $typed_data.Uint8List configDescriptor = $convert.base64Decode('VfZnJvbRgeIAEoCVILcmVjZWl2ZUZyb20SLgoTZXZlcnlvbmVfdW50aWxfdW5peBgfIAEoA1IR''ZXZlcnlvbmVVbnRpbFVuaXgSIQoMZGlzcGxheV9uYW1lGCAgASgJUgtkaXNwbGF5TmFtZRI7Ch''pxdWlja19wYXN0ZV9pbmRleF9tb2RpZmllchghIAEoCVIXcXVpY2tQYXN0ZUluZGV4TW9kaWZp'- 'ZXI=');+ 'ZXISLgoTc2VudF9yZXRlbnRpb25fZGF5cxgiIAEoBVIRc2VudFJldGVudGlvbkRheXM=');@$core.Deprecated('Use officialUsageDescriptor instead')const OfficialUsage$json = {diff --git a/ui/lib/l10n/app_en.arb b/ui/lib/l10n/app_en.arbindex 271ba1d..78df8a7 100644--- a/ui/lib/l10n/app_en.arb+++ b/ui/lib/l10n/app_en.arb@@ -1676,6 +1676,9 @@"mSent": "Sent","mSendFootnote": "Text and files go into the records on the computer and, by its setting, into its clipboard. What you copy on the phone is not sent by itself.","mSentRecords": "Sent",+ "mSentRetention": "Keep sent records",+ "mSentRetentionDesc": "Sent shows what this phone sent in the last {d} days",+ "mSentRetentionDays": "{d} days","mViewAll": "View all","mClearCache": "Clear","mCheckUpdate": "Check for updates",diff --git a/ui/lib/l10n/app_ja.arb b/ui/lib/l10n/app_ja.arbindex b8e0152..c00661e 100644--- a/ui/lib/l10n/app_ja.arb+++ b/ui/lib/l10n/app_ja.arb@@ -657,6 +657,9 @@"mSent": "送信しました","mSendFootnote": "テキストとファイルはパソコンの履歴に入り、設定に従ってクリップボードにも入ります。スマホでコピーした内容は自動では送られません。","mSentRecords": "送信履歴",+ "mSentRetention": "送信履歴の保持",+ "mSentRetentionDesc": "「送信履歴」には直近 {d} 日に送った内容を表示します",+ "mSentRetentionDays": "{d} 日","mViewAll": "すべて見る","mClearCache": "キャッシュを消去","mCheckUpdate": "アップデートを確認",diff --git a/ui/lib/l10n/app_localizations.dart b/ui/lib/l10n/app_localizations.dartindex ba6e8bd..4a07b8a 100644--- a/ui/lib/l10n/app_localizations.dart+++ b/ui/lib/l10n/app_localizations.dart@@ -4052,6 +4052,24 @@ abstract class AppLocalizations {/// **'Sent'**String get mSentRecords;+ /// No description provided for @mSentRetention.+ ///+ /// In en, this message translates to:+ /// **'Keep sent records'**+ String get mSentRetention;++ /// No description provided for @mSentRetentionDesc.+ ///+ /// In en, this message translates to:+ /// **'Sent shows what this phone sent in the last {d} days'**+ String mSentRetentionDesc(Object d);++ /// No description provided for @mSentRetentionDays.+ ///+ /// In en, this message translates to:+ /// **'{d} days'**+ String mSentRetentionDays(Object d);+/// No description provided for @mViewAll.////// In en, this message translates to:diff --git a/ui/lib/l10n/app_localizations_en.dart b/ui/lib/l10n/app_localizations_en.dartindex c548194..5734e8f 100644--- a/ui/lib/l10n/app_localizations_en.dart+++ b/ui/lib/l10n/app_localizations_en.dart@@ -2481,6 +2481,19 @@ class AppLocalizationsEn extends AppLocalizations {@overrideString get mSentRecords => 'Sent';+ @override+ String get mSentRetention => 'Keep sent records';++ @override+ String mSentRetentionDesc(Object d) {+ return 'Sent shows what this phone sent in the last $d days';+ }++ @override+ String mSentRetentionDays(Object d) {+ return '$d days';+ }+@overrideString get mViewAll => 'View all';diff --git a/ui/lib/l10n/app_localizations_ja.dart b/ui/lib/l10n/app_localizations_ja.dartindex 2498ef6..2e7a2f9 100644--- a/ui/lib/l10n/app_localizations_ja.dart+++ b/ui/lib/l10n/app_localizations_ja.dart@@ -2302,6 +2302,19 @@ class AppLocalizationsJa extends AppLocalizations {@overrideString get mSentRecords => '送信履歴';+ @override+ String get mSentRetention => '送信履歴の保持';++ @override+ String mSentRetentionDesc(Object d) {+ return '「送信履歴」には直近 $d 日に送った内容を表示します';+ }++ @override+ String mSentRetentionDays(Object d) {+ return '$d 日';+ }+@overrideString get mViewAll => 'すべて見る';diff --git a/ui/lib/l10n/app_localizations_zh.dart b/ui/lib/l10n/app_localizations_zh.dartindex 52dc360..6645c57 100644--- a/ui/lib/l10n/app_localizations_zh.dart+++ b/ui/lib/l10n/app_localizations_zh.dart@@ -2276,6 +2276,19 @@ class AppLocalizationsZh extends AppLocalizations {@overrideString get mSentRecords => '发送记录';+ @override+ String get mSentRetention => '发送记录保留';++ @override+ String mSentRetentionDesc(Object d) {+ return '「发送记录」显示最近 $d 天发出去的内容';+ }++ @override+ String mSentRetentionDays(Object d) {+ return '$d 天';+ }+@overrideString get mViewAll => '查看全部';@@ -4671,6 +4684,19 @@ class AppLocalizationsZhHantHk extends AppLocalizationsZh {@overrideString get mSentRecords => '傳送記錄';+ @override+ String get mSentRetention => '傳送記錄保留';++ @override+ String mSentRetentionDesc(Object d) {+ return '「傳送記錄」顯示最近 $d 天送出的內容';+ }++ @override+ String mSentRetentionDays(Object d) {+ return '$d 天';+ }+@overrideString get mViewAll => '查看全部';@@ -7066,6 +7092,19 @@ class AppLocalizationsZhHantTw extends AppLocalizationsZh {@overrideString get mSentRecords => '傳送記錄';+ @override+ String get mSentRetention => '傳送記錄保留';++ @override+ String mSentRetentionDesc(Object d) {+ return '「傳送記錄」顯示最近 $d 天送出的內容';+ }++ @override+ String mSentRetentionDays(Object d) {+ return '$d 天';+ }+@overrideString get mViewAll => '查看全部';diff --git a/ui/lib/l10n/app_zh.arb b/ui/lib/l10n/app_zh.arbindex 109310e..5a026d8 100644--- a/ui/lib/l10n/app_zh.arb+++ b/ui/lib/l10n/app_zh.arb@@ -657,6 +657,9 @@"mSent": "已发送","mSendFootnote": "文字和文件会进电脑的复制记录,并按电脑的设置写入剪贴板。手机上复制的内容不会自动发出,粘贴到这里再发送。","mSentRecords": "发送记录",+ "mSentRetention": "发送记录保留",+ "mSentRetentionDesc": "「发送记录」显示最近 {d} 天发出去的内容",+ "mSentRetentionDays": "{d} 天","mViewAll": "查看全部","mClearCache": "清除缓存","mCheckUpdate": "检查更新",diff --git a/ui/lib/l10n/app_zh_Hant_HK.arb b/ui/lib/l10n/app_zh_Hant_HK.arbindex bf290dd..238fc47 100644--- a/ui/lib/l10n/app_zh_Hant_HK.arb+++ b/ui/lib/l10n/app_zh_Hant_HK.arb@@ -657,6 +657,9 @@"mSent": "已傳送","mSendFootnote": "文字和檔案會進電腦的複製記錄,並按電腦的設定寫入剪貼簿。手機上複製的內容不會自動發出,貼到這裏再傳送。","mSentRecords": "傳送記錄",+ "mSentRetention": "傳送記錄保留",+ "mSentRetentionDesc": "「傳送記錄」顯示最近 {d} 天送出的內容",+ "mSentRetentionDays": "{d} 天","mViewAll": "查看全部","mClearCache": "清除快取","mCheckUpdate": "檢查更新",diff --git a/ui/lib/l10n/app_zh_Hant_TW.arb b/ui/lib/l10n/app_zh_Hant_TW.arbindex 87aaabe..afc45cd 100644--- a/ui/lib/l10n/app_zh_Hant_TW.arb+++ b/ui/lib/l10n/app_zh_Hant_TW.arb@@ -657,6 +657,9 @@"mSent": "已傳送","mSendFootnote": "文字和檔案會進電腦的複製記錄,並按電腦的設定寫入剪貼簿。手機上複製的內容不會自動發出,貼到這裡再傳送。","mSentRecords": "傳送記錄",+ "mSentRetention": "傳送記錄保留",+ "mSentRetentionDesc": "「傳送記錄」顯示最近 {d} 天送出的內容",+ "mSentRetentionDays": "{d} 天","mViewAll": "查看全部","mClearCache": "清除快取","mCheckUpdate": "檢查更新",diff --git a/ui/lib/mobile/send_tab.dart b/ui/lib/mobile/send_tab.dartindex 07293b8..2d33e90 100644--- a/ui/lib/mobile/send_tab.dart+++ b/ui/lib/mobile/send_tab.dart@@ -332,15 +332,19 @@ Future<bool?> showFileConfirmSheet(BuildContext context, List<(String, String, i}/// 发送记录:本机发出去的内容,只显示最近 3 天,高度固定,不挤压上面的发送区。-class _SentRecords extends StatelessWidget {- static const _days = 3;+/// 「发送记录」保留几天:配置里没设或为 0 时默认 3 天。设置页可改。+int sentRetentionDays(dynamic cfg) {+ final d = cfg?.sentRetentionDays ?? 0;+ return d > 0 ? d : 3;+}+class _SentRecords extends StatelessWidget {@overrideWidget build(BuildContext context) {final state = AppScope.of(context);final l = context.l10n;final p = context.palette;- final since = DateTime.now().subtract(const Duration(days: _days));+ final since = DateTime.now().subtract(Duration(days: sentRetentionDays(state.config)));final sent = state.records.where((r) => r.outgoing && recordTime(r).isAfter(since)).toList();diff --git a/ui/lib/mobile/settings_tab.dart b/ui/lib/mobile/settings_tab.dartindex 47fe4cc..73fb135 100644--- a/ui/lib/mobile/settings_tab.dart+++ b/ui/lib/mobile/settings_tab.dart@@ -9,6 +9,7 @@ import '../theme.dart';import '../widgets/common.dart';import 'host.dart';import 'update_check.dart';+import 'send_tab.dart' show sentRetentionDays;import 'ui.dart';/// 设置页:本机名称、收到文字后写不写剪贴板、后台保持连接与相关的系统权限、版本。@@ -115,6 +116,17 @@ class _SettingsTabState extends State<SettingsTab> with WidgetsBindingObserver {),],),+ MobileGroup(+ title: l.mSectionSync,+ children: [+ MobileTile(+ title: l.mSentRetention,+ subtitle: l.mSentRetentionDesc('${sentRetentionDays(cfg)}'),+ trailing: Icon(Icons.chevron_right, color: p.textFaint),+ onTap: () => _pickRetention(context),+ ),+ ],+ ),MobileGroup(title: l.mSectionSync,children: [@@ -263,3 +275,30 @@ class _UpdateTileState extends State<_UpdateTile> {);}}++/// 选「发送记录」保留几天:1、3、7、30 天+Future<void> _pickRetention(BuildContext context) async {+ final l = context.l10n;+ final state = AppScope.read(context);+ final cfg = state.config;+ if (cfg == null) return;+ final days = await showModalBottomSheet<int>(+ context: context,+ useSafeArea: true,+ builder: (ctx) => Column(+ mainAxisSize: MainAxisSize.min,+ children: [+ for (final d in const [1, 3, 7, 30])+ ListTile(+ title: Text(l.mSentRetentionDays(d)),+ trailing: sentRetentionDays(cfg) == d ? const Icon(Icons.check) : null,+ onTap: () => Navigator.pop(ctx, d),+ ),+ ],+ ),+ );+ if (days == null) return;+ try {+ await state.updateConfig(cfg.deepCopy()..sentRetentionDays = days);+ } catch (_) {}+}