Release v0.1.55: Bootstrap-style phone interface and full-screen settings

This commit is contained in:
Codex
2026-10-19 08:19:10 +08:00
parent 4dc3e2fb9f
commit 5b99a7e9fc
13 changed files with 121 additions and 48 deletions
+4
View File
@@ -1,5 +1,9 @@
# 赵府智家 · 视觉系统
## v0.1.55 · 手机 Bootstrap 视觉规范
「位置 / 沟通 / 我的」统一浅灰底、白色描边卡片、青绿色主按钮、分组列表与导航选中态。设置详情全屏打开,表单加入统一下拉框、输入框、焦点和禁用状态,适配窄屏及大字体。安卓使用本地原生组件实现 Bootstrap 风格,未引入远程样式或字体。[本版说明](RELEASE-v0.1.55.md)。
## v0.1.54 · 定时定位与沟通状态
手机新增「定时采集 / 实时共享」。定时模式每次取得新位置或 30 秒超时后释放定位,上传周期单独配置;后台由系统调度,省电限制可能延迟。沟通列表首次加载最近 10 条,分开显示传输、送达、播放和网盘保存状态。[本版说明](RELEASE-v0.1.54.md)。
+25
View File
@@ -0,0 +1,25 @@
# V0.1.55 · 手机 Bootstrap 风格
## 界面
- 「位置 / 沟通 / 我的」采用浅灰背景、白色描边卡片、青绿色主按钮与描边次按钮,统一文字层次、间距和圆角。
- 底部导航明确标示当前页面;设置使用分组列表及分隔线。
- 位置页保持系统状态、地图、按采集时间排序的位置列表。沟通页保持接收对象、双方记录和大号按住说话按钮。
- 设置详情全屏打开,固定标题和完成按钮,正文独立滚动。输入框、下拉选择、复选框统一样式,区分聚焦、选中和禁用状态。
- 自定义时间输入与单位选择保留独立间距,修复横向表单的基线对齐导致单位框被裁切。窄屏沟通页调整间距与话筒尺寸,保留聊天滚动区和大触控目标。
## 使用与实现
在平台「配套 App 下载」下载新版家人位置手机版,覆盖安装;不要卸载旧版,以保留配对和本机待同步队列。
安卓界面由本地原生组件实现 Bootstrap 的视觉规范,图标为内置矢量,不加载远程 CSS、字体或脚本。网页端继续使用本地打包的 Vue 与 Bootstrap。显示终端与手机版安装包分别提供。
本版不改变定位采集、授权名单、语音传输、最近十条分页或网盘保存规则。打开设置不会开启共享;实时共享与定时采集仍由本人选择和确认。
## 验证边界
界面检查使用独立测试包与合成数据,在安卓设备上限制为手机尺寸,包含 320 dp 窄屏与 135% 字体。测试包没有联网、定位和麦克风权限,结束后卸载并恢复原前台应用。真实用户手机尚未连接,本版没有安装到用户手机;厂商锁屏、省电及真实音频效果仍需手机验证。
已通过 20 种安卓隔离场景:位置、设置、沟通、录音、取消、窄屏、大字体、未配对、离线、配对过期、聊天分页、定位模式、定位周期、加密队列,以及常规/窄屏/大字体设置表单、上传表单、配对表单、大字体沟通。重点检查按钮高度、聊天区域、表单不裁切、导航状态和设置控件归属。
Python 全量 345 项、JavaScript 192 项检查通过,网页构建、手机与显示终端 APK 构建及签名校验通过。日采集调度的测试改为固定启动时钟,消除多个取时调用之间的亚毫秒误差,生产调度逻辑不变。
+1 -1
View File
@@ -1 +1 @@
0.1.54
0.1.55
+1 -1
View File
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.ucvl.zhaodisplay" android:versionCode="10" android:versionName="0.1.54">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.ucvl.zhaodisplay" android:versionCode="11" android:versionName="0.1.55">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="30" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
+1 -1
View File
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.ucvl.zhaodisplay" android:versionCode="10" android:versionName="0.1.54">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="cn.ucvl.zhaodisplay" android:versionCode="11" android:versionName="0.1.55">
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="30"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
@@ -29,7 +29,7 @@ public class LocationActivity extends Activity {
android.content.SharedPreferences prefs;
final Handler ui=new Handler();
final Runnable refresh=new Runnable(){public void run(){if(!visible)return;render();if(SystemClock.elapsedRealtime()-lastList>15000)loadFamily();ui.postDelayed(this,2000);}};
TextView text(String value,int size,LinearLayout parent){TextView t=style.label(value,size,PhoneStyle.INK);t.setPadding(0,style.dp(10),0,style.dp(10));parent.addView(t);return t;}
TextView text(String value,int size,LinearLayout parent){TextView t=style.label(value,size,size<16?PhoneStyle.MUTED:PhoneStyle.INK);t.setPadding(0,style.dp(10),0,style.dp(10));parent.addView(t);return t;}
Button button(String label,LinearLayout parent){Button b=style.button(label,false);LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(-1,-2);lp.topMargin=style.dp(8);parent.addView(b,lp);return b;}
public void onCreate(Bundle state){
super.onCreate(state);prefs=getSharedPreferences("location",0);
@@ -61,11 +61,11 @@ public class LocationActivity extends Activity {
text("锁屏、省电或系统限制可能延后定时任务,不能保证精确到秒。手机重启后需要本人重新开启共享。",14,sampleSection);
sharingMode.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){public void onItemSelected(AdapterView<?> p,View v,int i,long id){if(sampleCadence!=null&&cadence!=null)render();}public void onNothingSelected(AdapterView<?> p){}});
text("定时采集频率",16,sampleSection);sampleCadence=new Spinner(this);sampleCadence.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"每 10 秒(较耗电)","每 1 分钟(默认)","每 5 分钟","每 15 分钟","每 30 分钟","每 1 小时","每 2 小时","每 3 小时","每 4 小时","每 5 小时","每 6 小时","每 12 小时","每 1 天","自定义采集间隔"}));sampleCadence.setSelection(1);sampleSection.addView(sampleCadence);
samplePeriod=new LinearLayout(this);samplePeriod.setOrientation(LinearLayout.HORIZONTAL);sampleAmount=new EditText(this);sampleAmount.setInputType(InputType.TYPE_CLASS_NUMBER);sampleAmount.setHint("正整数");sampleAmount.setText("2");sampleAmount.setFilters(new android.text.InputFilter[]{new android.text.InputFilter.LengthFilter(5)});samplePeriod.addView(sampleAmount,new LinearLayout.LayoutParams(0,-2,1));sampleUnit=new Spinner(this);sampleUnit.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"秒","分钟","小时","天"}));sampleUnit.setSelection(2);samplePeriod.addView(sampleUnit);sampleSection.addView(samplePeriod);samplePeriod.setVisibility(View.GONE);
samplePeriod=new LinearLayout(this);samplePeriod.setOrientation(LinearLayout.HORIZONTAL);samplePeriod.setBaselineAligned(false);samplePeriod.setGravity(Gravity.CENTER_VERTICAL);sampleAmount=new EditText(this);sampleAmount.setInputType(InputType.TYPE_CLASS_NUMBER);sampleAmount.setHint("正整数");sampleAmount.setText("2");sampleAmount.setFilters(new android.text.InputFilter[]{new android.text.InputFilter.LengthFilter(5)});samplePeriod.addView(sampleAmount,new LinearLayout.LayoutParams(0,-2,1));sampleUnit=new Spinner(this);sampleUnit.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"秒","分钟","小时","天"}));sampleUnit.setSelection(2);LinearLayout.LayoutParams sampleUnitParams=new LinearLayout.LayoutParams(-2,-2);sampleUnitParams.leftMargin=style.dp(8);samplePeriod.addView(sampleUnit,sampleUnitParams);LinearLayout.LayoutParams samplePeriodParams=new LinearLayout.LayoutParams(-1,-2);samplePeriodParams.topMargin=style.dp(8);sampleSection.addView(samplePeriod,samplePeriodParams);samplePeriod.setVisibility(View.GONE);
sampleCadence.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){public void onItemSelected(AdapterView<?> p,View v,int position,long id){samplePeriod.setVisibility(position==sampleIntervals.length-1?View.VISIBLE:View.GONE);}public void onNothingSelected(AdapterView<?> p){}});
text("每次采集留下一个定位点。可自定义 10 秒至 24 小时,最长每天一次,不设一周。采集越稀疏越省电,但无法还原期间的完整路线。",14,sampleSection);
text("集中上传周期",16,uploadSection);cadence=new Spinner(this);cadence.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"每 10 秒","每 1 分钟","每 5 分钟(默认)","每 1 小时","每 2 小时","每 3 小时","每 4 小时","每 5 小时","每 1 天","每 2 天","每 3 天","自定义小时 / 天"}));cadence.setSelection(2);uploadSection.addView(cadence);
customPeriod=new LinearLayout(this);customPeriod.setOrientation(0);customAmount=new EditText(this);customAmount.setInputType(InputType.TYPE_CLASS_NUMBER);customAmount.setHint("正整数");customAmount.setText("6");customAmount.setFilters(new android.text.InputFilter[]{new android.text.InputFilter.LengthFilter(3)});customPeriod.addView(customAmount,new LinearLayout.LayoutParams(0,-2,1));customUnit=new Spinner(this);customUnit.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"小时","天"}));customPeriod.addView(customUnit);uploadSection.addView(customPeriod);customPeriod.setVisibility(View.GONE);
customPeriod=new LinearLayout(this);customPeriod.setOrientation(0);customPeriod.setBaselineAligned(false);customPeriod.setGravity(Gravity.CENTER_VERTICAL);customAmount=new EditText(this);customAmount.setInputType(InputType.TYPE_CLASS_NUMBER);customAmount.setHint("正整数");customAmount.setText("6");customAmount.setFilters(new android.text.InputFilter[]{new android.text.InputFilter.LengthFilter(3)});customPeriod.addView(customAmount,new LinearLayout.LayoutParams(0,-2,1));customUnit=new Spinner(this);customUnit.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_spinner_dropdown_item,new String[]{"小时","天"}));LinearLayout.LayoutParams customUnitParams=new LinearLayout.LayoutParams(-2,-2);customUnitParams.leftMargin=style.dp(8);customPeriod.addView(customUnit,customUnitParams);LinearLayout.LayoutParams customPeriodParams=new LinearLayout.LayoutParams(-1,-2);customPeriodParams.topMargin=style.dp(8);uploadSection.addView(customPeriod,customPeriodParams);customPeriod.setVisibility(View.GONE);
cadence.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){public void onItemSelected(AdapterView<?> p,View v,int position,long id){customPeriod.setVisibility(position==uploadIntervals.length-1?View.VISIBLE:View.GONE);}public void onNothingSelected(AdapterView<?> p){}});
text("采集与上传分开:例如每分钟采集、每天集中上传。自定义 1—720 小时或 1—30 天。断网时本地暂存,恢复后自动补传;长周期期间家人无法看到实时移动。调整名单或频率前,先关闭共享。",14,uploadSection);
historyConsent=new CheckBox(this);historyConsent.setText("另行同意保存我的历史轨迹到家庭网盘,长期保留至我手动删除;共享期间允许所选查看人读取其获授权期间的记录。");historySection.addView(historyConsent);
@@ -103,10 +103,10 @@ public class LocationActivity extends Activity {
void selectTab(int tab){voice.finish(false);phone.select(tab);voice.communication(tab==1);if(tab==2&&!settingsReady)loadSettings();}
void showDetail(String title,LinearLayout content){
if(detailDialog!=null)detailDialog.dismiss();voice.finish(false);if(content.getParent()!=null)((android.view.ViewGroup)content.getParent()).removeView(content);
LinearLayout frame=style.column();frame.setPadding(style.dp(20),style.dp(16),style.dp(20),style.dp(16));frame.setBackgroundColor(PhoneStyle.PAPER);
LinearLayout header=style.line();Button back=style.button("返回",false);header.addView(back);TextView heading=style.bold(title,22);heading.setPadding(style.dp(14),0,0,0);header.addView(heading,new LinearLayout.LayoutParams(0,-2,1));frame.addView(header);style.gap(frame,18);
ScrollView scroll=new ScrollView(this);scroll.setFillViewport(true);scroll.addView(content);frame.addView(scroll,new LinearLayout.LayoutParams(-1,0,1));
Button done=style.button("完成",true);frame.addView(done);Dialog shown=new Dialog(this,android.R.style.Theme_Material_Light_NoActionBar);detailDialog=shown;shown.setContentView(frame);
LinearLayout frame=style.column();frame.setBackgroundColor(PhoneStyle.PAPER);
LinearLayout header=style.line();header.setPadding(style.dp(16),style.dp(12),style.dp(16),style.dp(12));header.setBackground(style.bordered(PhoneStyle.CARD,PhoneStyle.LINE,0));Button back=style.button("返回",false);header.addView(back);TextView heading=style.bold(title,20);heading.setPadding(style.dp(12),0,0,0);header.addView(heading,new LinearLayout.LayoutParams(0,-2,1));frame.addView(header);
style.form(content);style.card(content);ScrollView scroll=new ScrollView(this);scroll.setFillViewport(true);scroll.setClipToPadding(false);scroll.setPadding(style.dp(16),style.dp(16),style.dp(16),style.dp(16));scroll.addView(content);frame.addView(scroll,new LinearLayout.LayoutParams(-1,0,1));
LinearLayout footer=style.column();footer.setPadding(style.dp(16),style.dp(12),style.dp(16),style.dp(12));footer.setBackground(style.bordered(PhoneStyle.CARD,PhoneStyle.LINE,0));Button done=style.button("完成",true);footer.addView(done,new LinearLayout.LayoutParams(-1,-2));frame.addView(footer);Dialog shown=new Dialog(this,android.R.style.Theme_Material_Light_NoActionBar);detailDialog=shown;shown.setContentView(frame);
Runnable close=()->{if(content==sampleSection||content==uploadSection){try{if(content==sampleSection)samplePeriodSeconds();else uploadPeriod();}catch(Exception e){Toast.makeText(this,"请填写有效的自定义间隔",1).show();return;}}shown.dismiss();};back.setOnClickListener(v->close.run());done.setOnClickListener(v->close.run());
shown.setOnDismissListener(d->{if(content.getParent()==scroll)scroll.removeView(content);if(content.getParent()==null)settings.addView(content);if(detailDialog==shown)detailDialog=null;if(!isDestroyed())render();});shown.show();shown.getWindow().setLayout(-1,-1);shown.getWindow().setStatusBarColor(PhoneStyle.PAPER);shown.getWindow().setNavigationBarColor(PhoneStyle.PAPER);shown.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR|View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR);render();
}
@@ -182,7 +182,7 @@ public class LocationActivity extends Activity {
JSONObject result=DisplayApi.call("/api/location/update",token,new JSONObject().put("action","settings"));
runOnUiThread(()->{if(!visible||g!=generation||request!=settingsRequest)return;settingsReceipt=result.optString("receipt");recipients.removeAllViews();choices.clear();
for(String type:new String[]{"viewers","phones","displays"}){String key=type.equals("viewers")?"viewerIds":type.equals("phones")?"phoneIds":"displayIds";text(type.equals("viewers")?"平台查看账号":type.equals("phones")?"已配对的家人手机":"公共显示终端",16,recipients);JSONArray options=result.optJSONArray(type),selected=result.optJSONArray(key);Set<String> ids=new HashSet<>();if(selected!=null)for(int i=0;i<selected.length();i++)ids.add(selected.optString(i));List<CheckBox> list=new ArrayList<>();choices.put(key,list);if(options!=null)for(int i=0;i<options.length();i++){JSONObject item=options.optJSONObject(i);CheckBox c=new CheckBox(this);c.setText(item.optString("name"));c.setTag(item.optString("id"));c.setChecked(ids.contains(item.optString("id")));recipients.addView(c);list.add(c);}if(list.isEmpty())text("暂无可选对象",14,recipients);}
sharingMode.setSelection("realtime".equals(result.optString("sharingMode","scheduled"))?1:0);int seconds=result.optInt("intervalSeconds",300);setUploadPeriod(seconds);setSamplePeriod(result.optInt("sampleIntervalSeconds",60));historyAcknowledged=result.optBoolean("historyEnabled",false);historyConsent.setChecked(historyAcknowledged||result.optBoolean("historyDefault",false));JSONObject h=result.optJSONObject("history");if(h!=null)historyStatus.setText("待归档 "+h.optInt("pending")+" 个定位点 · 已归档 "+h.optInt("archived")+" 段 · 待删除 "+h.optInt("deleting")+" 段\n"+h.optString("error")+"\n长期保留,由本人手动删除。修改设置前先关闭共享。");settingsReady=true;render();});
style.form(recipients);sharingMode.setSelection("realtime".equals(result.optString("sharingMode","scheduled"))?1:0);int seconds=result.optInt("intervalSeconds",300);setUploadPeriod(seconds);setSamplePeriod(result.optInt("sampleIntervalSeconds",60));historyAcknowledged=result.optBoolean("historyEnabled",false);historyConsent.setChecked(historyAcknowledged||result.optBoolean("historyDefault",false));JSONObject h=result.optJSONObject("history");if(h!=null)historyStatus.setText("待归档 "+h.optInt("pending")+" 个定位点 · 已归档 "+h.optInt("archived")+" 段 · 待删除 "+h.optInt("deleting")+" 段\n"+h.optString("error")+"\n长期保留,由本人手动删除。修改设置前先关闭共享。");settingsReady=true;render();});
}catch(Exception e){runOnUiThread(()->{if(visible&&g==generation&&request==settingsRequest){settingsReady=false;if(e instanceof DisplayApi.ApiError&&(((DisplayApi.ApiError)e).status==401||((DisplayApi.ApiError)e).status==403))bindingRejected=true;settingsError="无法读取我的位置设置,请检查网络或配对有效期,重新打开设置重试。";render();}});}},"location-settings").start();
}
void start(){
@@ -22,14 +22,14 @@ final class PhoneLayout extends LinearLayout {
scrolls[1].removeView(pages[1]);content.removeView(scrolls[1]);content.addView(pages[1],new FrameLayout.LayoutParams(-1,-1));
LinearLayout heading=s.line();TextView title=s.bold("位置",28);heading.addView(title,new LayoutParams(0,-2,1));settingsButton=s.iconButton("settings","打开我的设置");heading.addView(settingsButton,new LayoutParams(s.dp(48),s.dp(48)));pages[0].addView(heading);
homeName=s.label("配对后查看家人",16,PhoneStyle.MUTED);pages[0].addView(homeName);s.gap(pages[0],16);
LinearLayout banner=s.line();banner.setPadding(s.dp(14),s.dp(8),s.dp(8),s.dp(8));banner.setBackground(s.shape(0xfffff1d6,16));
homeStatus=s.label("尚未配对本人",14,0xff805c23);banner.addView(homeStatus,new LayoutParams(0,-2,1));check=s.button("检查",false);banner.addView(check);pages[0].addView(banner);s.gap(pages[0],12);
LinearLayout banner=s.line();banner.setPadding(s.dp(12),s.dp(10),s.dp(10),s.dp(10));banner.setBackground(s.bordered(PhoneStyle.WARNING,PhoneStyle.WARNING_BORDER,8));
homeStatus=s.label("尚未配对本人",14,PhoneStyle.WARNING_INK);homeStatus.setPadding(0,0,s.dp(8),0);banner.addView(homeStatus,new LayoutParams(0,-2,1));check=s.button("检查",false);banner.addView(check);pages[0].addView(banner);s.gap(pages[0],16);
homeContent=s.column();pages[0].addView(homeContent);
mapSlot=new FrameLayout(app);mapSlot.setBackground(s.shape(0xffe5ede5,22));mapSlot.setClipToOutline(true);homeContent.addView(mapSlot,new LayoutParams(-1,s.dp(330)));
mapSlot=new FrameLayout(app);mapSlot.setBackground(s.bordered(PhoneStyle.PALE,PhoneStyle.LINE,8));mapSlot.setClipToOutline(true);homeContent.addView(mapSlot,new LayoutParams(-1,s.dp(330)));
fit=s.iconButton("location","在地图上查看全部家人");FrameLayout.LayoutParams fitParams=new FrameLayout.LayoutParams(s.dp(48),s.dp(48),Gravity.RIGHT|Gravity.CENTER_VERTICAL);fitParams.setMargins(0,0,s.dp(12),0);mapSlot.addView(fit,fitParams);
TextView privacy=s.label("仅显示已授权的位置",11,PhoneStyle.GREEN);privacy.setPadding(s.dp(10),s.dp(7),s.dp(10),s.dp(7));privacy.setBackground(s.shape(PhoneStyle.CARD,20));FrameLayout.LayoutParams pp=new FrameLayout.LayoutParams(-2,-2,Gravity.LEFT|Gravity.TOP);pp.setMargins(s.dp(10),s.dp(12),s.dp(64),0);mapSlot.addView(privacy,pp);
s.gap(homeContent,14);LinearLayout recent=s.column();s.card(recent);homeContent.addView(recent);LinearLayout recentHead=s.line();recentHead.addView(s.bold("位置列表",17),new LayoutParams(0,-2,1));refresh=s.iconButton("refresh","刷新家人位置");recentHead.addView(refresh,new LayoutParams(s.dp(48),s.dp(48)));recent.addView(recentHead);
viewStatus=s.label("正在读取家人授权…",13,PhoneStyle.MUTED);viewStatus.setPadding(0,0,0,s.dp(8));recent.addView(viewStatus);familyList=s.column();recent.addView(familyList);s.gap(homeContent,10);
viewStatus=s.label("正在读取家人授权…",13,PhoneStyle.MUTED);viewStatus.setPadding(0,s.dp(8),0,s.dp(12));recent.addView(viewStatus);familyList=s.column();s.divided(familyList);recent.addView(familyList);s.gap(homeContent,10);
pairIntro=s.column();s.card(pairIntro);pages[0].addView(pairIntro);pairIntro.addView(s.bold("与家人连接",23));s.gap(pairIntro,12);pairIntro.addView(s.label("使用手机配对码关联自己的成员档案,无需注册。配对后就能查看已授权给你的家人。",16,PhoneStyle.MUTED));s.gap(pairIntro,20);pairNow=s.button("去配对我的手机",true);pairIntro.addView(pairNow);
// The voice page is populated with the same production VoiceSurface used by the controller.
pages[1].setPadding(0,0,0,s.dp(8));
@@ -37,17 +37,18 @@ final class PhoneLayout extends LinearLayout {
profile=s.line();avatar=s.avatar("我",54);profile.addView(avatar);LinearLayout words=s.column();words.setPadding(s.dp(14),0,0,0);identity=s.bold("尚未配对本人",19);pairSummary=s.label("无需注册 · 使用手机配对码",13,PhoneStyle.MUTED);words.addView(identity);s.gap(words,5);words.addView(pairSummary);profile.addView(words,new LayoutParams(0,-2,1));TextView chevron=s.label("›",28,PhoneStyle.MUTED);profile.addView(chevron);profile.setMinimumHeight(s.dp(64));profile.setFocusable(true);profile.setClickable(true);pages[2].addView(profile);s.gap(pages[2],18);
mineContent=s.column();pages[2].addView(mineContent);
shareCard=s.column();s.card(shareCard);mineContent.addView(shareCard);sharing=new Switch(app);sharing.setText("共享我的位置");sharing.setTextSize(19);sharing.setTypeface(null,Typeface.BOLD);sharing.setTextColor(PhoneStyle.INK);sharing.setMinHeight(s.dp(50));sharing.setThumbTintList(new android.content.res.ColorStateList(new int[][]{new int[]{android.R.attr.state_checked},new int[]{}},new int[]{PhoneStyle.GREEN,0xffb5bcb6}));shareCard.addView(sharing);
LinearLayout state=s.line();state.setPadding(s.dp(10),s.dp(6),s.dp(4),s.dp(6));state.setBackground(s.shape(0xfffff4de,12));myStatus=s.label("共享关闭",13,0xff805c23);state.addView(myStatus,new LayoutParams(0,-2,1));myCheck=s.button("检查权限",false);state.addView(myCheck);shareCard.addView(state);s.gap(shareCard,10);shareCard.addView(s.label("查看家人位置,无需开启自己的共享。",12,PhoneStyle.MUTED));
LinearLayout state=s.line();state.setPadding(s.dp(10),s.dp(6),s.dp(4),s.dp(6));state.setBackground(s.bordered(PhoneStyle.WARNING,PhoneStyle.WARNING_BORDER,6));myStatus=s.label("共享关闭",13,PhoneStyle.WARNING_INK);state.addView(myStatus,new LayoutParams(0,-2,1));myCheck=s.button("检查权限",false);state.addView(myCheck);shareCard.addView(state);s.gap(shareCard,10);shareCard.addView(s.label("查看家人位置,无需开启自己的共享。",12,PhoneStyle.MUTED));
section(mineContent,"允许谁查看");LinearLayout access=s.column();s.card(access);mineContent.addView(access);viewers=s.row("family","查看人名单","读取中");access.addView(viewers);expiry=s.row("clock","共享有效期","跟随本机配对有效期");access.addView(expiry);
section(mineContent,"定位与轨迹");LinearLayout location=s.column();s.card(location);mineContent.addView(location);sampling=s.row("location","共享模式与采集频率","定时采集 · 每 1 分钟");upload=s.row("cloud","集中上传周期","每 5 分钟");history=s.row("track","我的历史轨迹","每天、每周、每月、每年、一生");permissions=s.row("shield","定位权限与系统设置","本人开启共享后才采集");for(View row:new View[]{sampling,upload,history,permissions})location.addView(row);
section(mineContent,"沟通与声音");voiceSettings=s.column();s.card(voiceSettings);mineContent.addView(voiceSettings);
section(pages[2],"设备与系统");LinearLayout device=s.column();s.card(device);pages[2].addView(device);pairing=s.row("phone","配对与设备","查看或更换手机配对");device.addView(pairing);
nav=s.line();nav.setBackgroundColor(PhoneStyle.CARD);nav.setPadding(s.dp(8),s.dp(4),s.dp(8),s.dp(6));addView(nav,new LayoutParams(-1,-2));String[] names={"位置","沟通","我的"},icons={"location","mic","person"};
s.card(profile);s.divided(access);s.divided(location);s.divided(device);
nav=s.line();nav.setBackground(s.bordered(PhoneStyle.CARD,PhoneStyle.LINE,0));nav.setPadding(s.dp(8),s.dp(6),s.dp(8),s.dp(6));addView(nav,new LayoutParams(-1,-2));String[] names={"位置","沟通","我的"},icons={"location","mic","person"};
for(int i=0;i<3;i++){final int index=i;LinearLayout item=s.column();item.setGravity(Gravity.CENTER);item.setMinimumHeight(s.dp(64));item.setPadding(0,s.dp(6),0,s.dp(6));navIcons[i]=new ImageView(app);item.addView(navIcons[i],new LayoutParams(s.dp(25),s.dp(25)));s.gap(item,5);navLabels[i]=s.label(names[i],12,PhoneStyle.MUTED);navLabels[i].setGravity(Gravity.CENTER);item.addView(navLabels[i]);item.setContentDescription(names[i]);item.setFocusable(true);item.setClickable(true);item.setOnClickListener(v->{select(index);if(onTab!=null)onTab.accept(index);});nav.addView(item,new LayoutParams(0,-2,1));}
select(0);
}
void section(LinearLayout parent,String title){s.gap(parent,22);parent.addView(s.bold(title,17));s.gap(parent,10);}
void select(int next){tab=next;pages[1].setVisibility(next==1?VISIBLE:GONE);for(int i=0;i<3;i++){scrolls[i].setVisibility(i==next?VISIBLE:GONE);nav.getChildAt(i).setSelected(i==next);navLabels[i].setTextColor(i==next?PhoneStyle.GREEN:PhoneStyle.MUTED);navLabels[i].setTypeface(null,i==next?Typeface.BOLD:Typeface.NORMAL);navIcons[i].setImageDrawable(new PhoneStyle.Icon(new String[]{"location","mic","person"}[i],i==next?PhoneStyle.GREEN:PhoneStyle.MUTED,s.dp(25)));}}
void select(int next){tab=next;pages[1].setVisibility(next==1?VISIBLE:GONE);for(int i=0;i<3;i++){scrolls[i].setVisibility(i==next?VISIBLE:GONE);nav.getChildAt(i).setSelected(i==next);nav.getChildAt(i).setBackground(s.shape(i==next?PhoneStyle.PALE:PhoneStyle.CARD,6));navLabels[i].setTextColor(i==next?PhoneStyle.GREEN:PhoneStyle.MUTED);navLabels[i].setTypeface(null,i==next?Typeface.BOLD:Typeface.NORMAL);navIcons[i].setImageDrawable(new PhoneStyle.Icon(new String[]{"location","mic","person"}[i],i==next?PhoneStyle.GREEN:PhoneStyle.MUTED,s.dp(25)));}}
void family(String name,String detail,boolean position,Runnable focus,Runnable history){
LinearLayout row=s.line();row.setPadding(0,s.dp(10),0,s.dp(10));TextView avatar=s.avatar(name,42);row.addView(avatar);LinearLayout words=s.column();words.setPadding(s.dp(12),0,s.dp(6),0);TextView title=s.bold(name,17);words.addView(title);s.gap(words,5);words.addView(s.label(detail,12,PhoneStyle.MUTED));words.setMinimumHeight(s.dp(48));words.setFocusable(true);words.setClickable(true);words.setOnClickListener(v->focus.run());words.setContentDescription(name+","+detail+(position?",在地图上查看":""));row.addView(words,new LayoutParams(0,-2,1));Button more=s.button("轨迹",false);more.setContentDescription("查看 "+name+" 的已授权历史轨迹");more.setOnClickListener(v->history.run());row.addView(more);familyList.addView(row);
}
@@ -7,9 +7,10 @@ import android.graphics.drawable.*;
import android.view.*;
import android.widget.*;
/** Small native design system. Icons are bundled vector paths; no remote fonts or artwork. */
/** Bootstrap-inspired native controls: local tokens, bordered cards and accessible touch targets. */
final class PhoneStyle {
static final int PAPER=0xfff8f7ef,CARD=0xfffffefa,INK=0xff193d35,MUTED=0xff718078,GREEN=0xff177363,LINE=0xffe8ebe3,PALE=0xffe8f2e9;
static final int PAPER=0xfff8f9fa,CARD=0xffffffff,INK=0xff212529,MUTED=0xff5c636a,GREEN=0xff146c55,LINE=0xffdee2e6,PALE=0xffe4f1ec;
static final int WARNING=0xfffff3cd,WARNING_INK=0xff664d03,WARNING_BORDER=0xffffe69c,RADIUS=8;
final Context context;
PhoneStyle(Context context){this.context=context;}
int dp(float value){return Math.round(value*context.getResources().getDisplayMetrics().density);}
@@ -18,19 +19,45 @@ final class PhoneStyle {
TextView label(String text,int size,int color){TextView v=new TextView(context);v.setText(text);v.setTextSize(size);v.setTextColor(color);v.setIncludeFontPadding(false);return v;}
TextView bold(String text,int size){TextView v=label(text,size,INK);v.setTypeface(null,Typeface.BOLD);return v;}
GradientDrawable shape(int color,int radius){GradientDrawable v=new GradientDrawable();v.setColor(color);v.setCornerRadius(dp(radius));return v;}
void card(View v){v.setBackground(shape(CARD,20));v.setPadding(dp(16),dp(16),dp(16),dp(16));v.setClipToOutline(true);}
GradientDrawable bordered(int fill,int stroke,int radius){GradientDrawable v=shape(fill,radius);v.setStroke(dp(1),stroke);return v;}
ColorStateList enabledColors(int normal,int disabled){return new ColorStateList(new int[][]{new int[]{-android.R.attr.state_enabled},new int[]{}},new int[]{disabled,normal});}
void card(View v){v.setBackground(bordered(CARD,LINE,RADIUS));v.setPadding(dp(16),dp(16),dp(16),dp(16));v.setClipToOutline(true);}
void divided(LinearLayout v){GradientDrawable line=shape(LINE,0);line.setSize(dp(1),dp(1));v.setDividerDrawable(line);v.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);}
void gap(LinearLayout parent,int height){parent.addView(new View(context),new LinearLayout.LayoutParams(1,dp(height)));}
Button button(String text,boolean primary){Button b=new Button(context);b.setText(text);b.setTextSize(15);b.setAllCaps(false);b.setMinWidth(0);b.setMinimumWidth(0);b.setMinHeight(dp(48));b.setMinimumHeight(dp(48));b.setTextColor(primary?Color.WHITE:GREEN);b.setPadding(dp(14),dp(9),dp(14),dp(9));b.setStateListAnimator(null);b.setBackground(new RippleDrawable(ColorStateList.valueOf(0x1a177363),shape(primary?GREEN:PALE,14),null));return b;}
Button iconButton(String icon,String description){Button b=button("",false);b.setBackground(new RippleDrawable(ColorStateList.valueOf(0x22177363),shape(CARD,14),null));Icon d=new Icon(icon,GREEN,dp(22));d.setBounds(0,0,dp(22),dp(22));b.setCompoundDrawables(d,null,null,null);b.setPadding(dp(13),dp(12),dp(13),dp(12));b.setContentDescription(description);return b;}
void buttonStyle(Button b,boolean primary){
b.setTextColor(enabledColors(primary?Color.WHITE:GREEN,0xff868e96));StateListDrawable states=new StateListDrawable();
states.addState(new int[]{-android.R.attr.state_enabled},bordered(0xffe9ecef,LINE,6));
states.addState(new int[]{android.R.attr.state_focused},bordered(primary?GREEN:PALE,GREEN,6));
states.addState(new int[]{},bordered(primary?GREEN:CARD,primary?GREEN:LINE,6));
b.setBackground(new RippleDrawable(ColorStateList.valueOf(0x24146c55),states,null));
}
Button button(String text,boolean primary){Button b=new Button(context);b.setText(text);b.setTextSize(15);b.setAllCaps(false);b.setMinWidth(0);b.setMinimumWidth(0);b.setMinHeight(dp(48));b.setMinimumHeight(dp(48));b.setPadding(dp(14),dp(9),dp(14),dp(9));b.setStateListAnimator(null);buttonStyle(b,primary);return b;}
Button iconButton(String icon,String description){Button b=button("",false);Icon d=new Icon(icon,GREEN,dp(22));d.setBounds(0,0,dp(22),dp(22));b.setCompoundDrawables(d,null,null,null);b.setPadding(dp(13),dp(12),dp(13),dp(12));b.setContentDescription(description);return b;}
void form(View v){
if(v instanceof EditText||v instanceof Spinner){
StateListDrawable background=new StateListDrawable();background.addState(new int[]{-android.R.attr.state_enabled},bordered(0xffe9ecef,LINE,6));
background.addState(new int[]{android.R.attr.state_focused},bordered(CARD,GREEN,6));background.addState(new int[]{},bordered(CARD,0xffadb5bd,6));
v.setBackground(background);v.setMinimumHeight(dp(52));
if(v instanceof EditText){EditText field=(EditText)v;field.setPadding(dp(12),dp(12),dp(12),dp(12));field.setTextSize(16);field.setTextColor(enabledColors(INK,0xff868e96));field.setHintTextColor(MUTED);}
else{Spinner field=(Spinner)v;field.setPadding(dp(4),dp(2),dp(4),dp(2));SpinnerAdapter previous=field.getAdapter();int selected=field.getSelectedItemPosition();
if(!(previous instanceof FormAdapter)){String[] values=new String[previous.getCount()];for(int i=0;i<values.length;i++)values[i]=String.valueOf(previous.getItem(i));field.setAdapter(new FormAdapter(values,field));field.setSelection(selected);}}
}else if(v instanceof CheckBox){CheckBox field=(CheckBox)v;field.setTextSize(16);field.setTextColor(enabledColors(INK,0xff868e96));field.setMinHeight(dp(48));field.setPadding(dp(4),dp(10),dp(4),dp(10));field.setButtonTintList(new ColorStateList(new int[][]{new int[]{-android.R.attr.state_enabled},new int[]{android.R.attr.state_checked},new int[]{}},new int[]{0xffadb5bd,GREEN,MUTED}));}
else if(v instanceof ViewGroup){ViewGroup group=(ViewGroup)v;for(int i=0;i<group.getChildCount();i++)form(group.getChildAt(i));}
}
final class FormAdapter extends ArrayAdapter<String>{
final Spinner owner;FormAdapter(String[] values,Spinner owner){super(context,android.R.layout.simple_spinner_item,values);this.owner=owner;}
public View getView(int position,View convert,ViewGroup parent){TextView v=label(getItem(position),16,INK);v.setTextColor(enabledColors(INK,0xff868e96));v.setDuplicateParentStateEnabled(true);v.setMinHeight(dp(48));v.setGravity(Gravity.CENTER_VERTICAL);v.setPadding(dp(8),dp(8),dp(8),dp(8));Icon arrow=new Icon("chevron",MUTED,dp(18));arrow.setBounds(0,0,dp(18),dp(18));v.setCompoundDrawables(null,null,arrow,null);v.setCompoundDrawablePadding(dp(8));return v;}
public View getDropDownView(int position,View convert,ViewGroup parent){TextView v=label(getItem(position),16,INK);v.setMinHeight(dp(52));v.setGravity(Gravity.CENTER_VERTICAL);v.setPadding(dp(16),dp(12),dp(16),dp(12));v.setBackgroundColor(position==owner.getSelectedItemPosition()?PALE:CARD);return v;}
}
TextView avatar(String name,int size){TextView v=bold(name.isEmpty()?"家":name.substring(0,name.offsetByCodePoints(0,1)),size/3);v.setGravity(Gravity.CENTER);v.setBackground(shape(PALE,size/2));v.setContentDescription(name);v.setLayoutParams(new LinearLayout.LayoutParams(dp(size),dp(size)));return v;}
Row row(String icon,String title,String value){return new Row(icon,title,value);}
final class Row extends LinearLayout {
final TextView title,value;final LinearLayout words;
Row(String icon,String name,String detail){
super(context);setGravity(Gravity.CENTER_VERTICAL);setPadding(dp(4),dp(14),dp(4),dp(14));setMinimumHeight(dp(60));
super(context);setGravity(Gravity.CENTER_VERTICAL);setPadding(dp(0),dp(16),dp(0),dp(16));setMinimumHeight(dp(64));
ImageView mark=new ImageView(context);mark.setImageDrawable(new Icon(icon,INK,dp(23)));LayoutParams ip=new LayoutParams(dp(24),dp(24));ip.rightMargin=dp(13);addView(mark,ip);
words=column();title=label(name,16,INK);value=label(detail,13,MUTED);words.addView(title);gap(words,6);words.addView(value);addView(words,new LayoutParams(0,-2,1));
TextView next=label("›",26,MUTED);next.setPadding(dp(12),0,dp(2),0);addView(next);setBackground(new RippleDrawable(ColorStateList.valueOf(0x14177363),null,shape(Color.WHITE,10)));setFocusable(true);setClickable(true);
TextView next=label("›",26,MUTED);next.setPadding(dp(12),0,dp(2),0);addView(next);setBackground(new RippleDrawable(ColorStateList.valueOf(0x14177363),null,shape(Color.WHITE,6)));setFocusable(true);setClickable(true);
}
void value(String text){VoiceSurface.text(value,text);value.setVisibility(text.isEmpty()?GONE:VISIBLE);}
}
@@ -40,6 +67,7 @@ final class PhoneStyle {
public int getIntrinsicWidth(){return size;}public int getIntrinsicHeight(){return size;}
public void draw(Canvas c){Rect b=getBounds();c.save();c.translate(b.left,b.top);c.scale(b.width()/24f,b.height()/24f);p.setStyle(Paint.Style.STROKE);p.setStrokeWidth(1.7f);p.setStrokeCap(Paint.Cap.ROUND);p.setStrokeJoin(Paint.Join.ROUND);
switch(kind){
case "chevron":c.drawLine(6,9,12,15,p);c.drawLine(12,15,18,9,p);break;
case "mic":c.drawRoundRect(9,2,15,15,3,3,p);c.drawArc(5,5,19,20,0,180,false,p);c.drawLine(5,11,5,13,p);c.drawLine(19,11,19,13,p);c.drawLine(12,20,12,23,p);c.drawLine(8,23,16,23,p);break;
case "family":c.drawCircle(9,6,3,p);c.drawArc(3,11,15,23,180,180,false,p);c.drawLine(3,17,3,20,p);c.drawLine(3,20,15,20,p);c.drawLine(15,17,15,20,p);c.drawArc(13,3,19,9,-90,180,false,p);c.drawArc(13,11,22,23,-90,90,false,p);c.drawLine(21,17,21,20,p);c.drawLine(18,20,21,20,p);break;
case "person":c.drawCircle(12,7,4,p);c.drawArc(4,13,20,27,180,180,false,p);c.drawLine(4,20,20,20,p);break;
@@ -14,21 +14,21 @@ final class VoiceChat extends LinearLayout {
String signature="";Consumer<String> replay=id->{};LinearLayout transfer;
void transfer(String description,boolean failed,Runnable retry,Runnable discard){
if(transfer!=null){messages.removeView(transfer);transfer=null;}if(description.isEmpty())return;
transfer=s.column();transfer.setPadding(s.dp(12),s.dp(10),s.dp(12),s.dp(10));transfer.setBackground(s.shape(PhoneStyle.PALE,14));
transfer.addView(s.label(description,13,PhoneStyle.INK));
transfer=s.column();transfer.setPadding(s.dp(12),s.dp(10),s.dp(12),s.dp(10));transfer.setBackground(s.bordered(failed?PhoneStyle.WARNING:PhoneStyle.PALE,failed?PhoneStyle.WARNING_BORDER:PhoneStyle.LINE,6));
transfer.addView(s.label(description,13,failed?PhoneStyle.WARNING_INK:PhoneStyle.INK));
if(failed){LinearLayout actions=s.line();Button again=s.button("重试发送",true),cancel=s.button("放弃本次",false);actions.addView(again);actions.addView(cancel);again.setOnClickListener(v->retry.run());cancel.setOnClickListener(v->discard.run());transfer.addView(actions);}
messages.addView(transfer);scroll.post(()->scroll.fullScroll(FOCUS_DOWN));
}
VoiceChat(Activity app){
super(app);s=new PhoneStyle(app);setOrientation(VERTICAL);s.card(this);
LinearLayout head=s.line();heading=s.bold("聊天记录",18);head.addView(heading,new LayoutParams(0,-2,1));older=s.button("更早",false);latest=s.button("最近",false);head.addView(older);head.addView(latest);addView(head);
notice=s.label("选择沟通对象后查看记录",12,PhoneStyle.MUTED);addView(notice);
LinearLayout head=s.line();heading=s.bold("聊天记录",18);head.addView(heading,new LayoutParams(0,-2,1));older=s.button("更早",false);latest=s.button("最近",false);head.addView(older);LayoutParams lp=new LayoutParams(-2,-2);lp.leftMargin=s.dp(6);head.addView(latest,lp);addView(head);
notice=s.label("选择沟通对象后查看记录",12,PhoneStyle.MUTED);notice.setPadding(0,s.dp(8),0,s.dp(8));addView(notice);
scroll=new ScrollView(app);scroll.setFillViewport(true);messages=s.column();scroll.addView(messages);addView(scroll,new LayoutParams(-1,s.dp(218)));
scroll.setOnTouchListener((v,e)->{if(e.getActionMasked()==MotionEvent.ACTION_DOWN)v.getParent().requestDisallowInterceptTouchEvent(true);if(e.getActionMasked()==MotionEvent.ACTION_UP||e.getActionMasked()==MotionEvent.ACTION_CANCEL)v.getParent().requestDisallowInterceptTouchEvent(false);return false;});
older.setEnabled(false);
}
void clear(String text){signature="";saved=new JSONArray();messages.removeAllViews();notice.setText(text);older.setEnabled(false);}
void theme(boolean value){if(night==value)return;night=value;setBackground(s.shape(night?0xff21372d:PhoneStyle.CARD,20));heading.setTextColor(night?0xffc8d5cd:PhoneStyle.INK);notice.setTextColor(night?0xff96aaa0:PhoneStyle.MUTED);for(Button b:new Button[]{older,latest}){b.setTextColor(night?0xffc8d5cd:PhoneStyle.GREEN);b.setBackground(s.shape(night?0xff2d4439:PhoneStyle.PALE,14));}if(saved.length()>0){signature="";show(saved,savedMore,savedPast,replay);}}
void theme(boolean value){if(night==value)return;night=value;setBackground(s.bordered(night?0xff21372d:PhoneStyle.CARD,night?0xff345043:PhoneStyle.LINE,8));heading.setTextColor(night?0xffc8d5cd:PhoneStyle.INK);notice.setTextColor(night?0xff96aaa0:PhoneStyle.MUTED);for(Button b:new Button[]{older,latest}){if(night){b.setTextColor(0xffc8d5cd);b.setBackground(s.bordered(0xff2d4439,0xff345043,6));}else s.buttonStyle(b,false);}if(saved.length()>0){signature="";show(saved,savedMore,savedPast,replay);}}
void show(JSONArray items,boolean hasMore,boolean past,Consumer<String> play){
replay=play;saved=items;savedMore=hasMore;savedPast=past;older.setEnabled(hasMore);notice.setText(past?"较早的 10 条 · 可继续向前翻阅":"最近 10 条 · 点语音回听 · 更早记录按需加载");
String next=items.toString();if(next.equals(signature))return;boolean follow=signature.isEmpty()||scroll.getScrollY()+scroll.getHeight()>=messages.getHeight()-s.dp(32);int oldScroll=scroll.getScrollY();signature=next;messages.removeAllViews();
@@ -36,14 +36,14 @@ final class VoiceChat extends LinearLayout {
for(int i=0;i<items.length();i++){
JSONObject item=items.optJSONObject(i);if(item==null)continue;boolean mine=item.optBoolean("mine");
int ink=night?0xffc8d5cd:PhoneStyle.INK,muted=night?0xff96aaa0:PhoneStyle.MUTED;
LinearLayout row=s.column();row.setPadding(s.dp(12),s.dp(10),s.dp(12),s.dp(10));row.setBackground(s.shape(night?(mine?0xff2e4d40:0xff2a3d33):mine?PhoneStyle.PALE:0xfff1f0e9,14));LayoutParams lp=new LayoutParams(-1,-2);lp.topMargin=s.dp(9);lp.leftMargin=s.dp(mine?22:0);lp.rightMargin=s.dp(mine?0:22);messages.addView(row,lp);
LinearLayout row=s.column();row.setPadding(s.dp(12),s.dp(10),s.dp(12),s.dp(10));row.setBackground(s.bordered(night?(mine?0xff2e4d40:0xff2a3d33):mine?PhoneStyle.PALE:PhoneStyle.PAPER,night?0xff345043:PhoneStyle.LINE,6));LayoutParams lp=new LayoutParams(-1,-2);lp.topMargin=s.dp(10);lp.leftMargin=s.dp(mine?18:0);lp.rightMargin=s.dp(mine?0:18);messages.addView(row,lp);
String name=(mine?"我 · ":"")+item.optString("senderName","设备");TextView author=s.bold(name,14);author.setTextColor(ink);row.addView(author);
row.addView(s.label(new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss",Locale.CHINA).format(new Date((long)(item.optDouble("at")*1000))),11,muted));
Button voice=s.button("▶ 语音 · "+String.format(Locale.CHINA,"%.1f",item.optDouble("seconds"))+" 秒",mine);if(night){voice.setTextColor(ink);voice.setBackground(s.shape(0xff355549,14));}voice.setContentDescription("播放 "+name+" 的语音");voice.setOnClickListener(v->replay.accept(item.optString("id")));row.addView(voice,new LayoutParams(-1,-2));
String delivery=item.optString("delivery"),archive=item.optString("archive");
String state=delivery.equals("played")?"已送达 · 已播放":delivery.equals("received")?"已送达 · 尚未完整播放":delivery.equals("queued")?"已发送 · 等待送达":delivery.equals("rejected")?"未完整播放 · 可回听":"自动播放已过期 · 可回听";
if(delivery.equals("transferring"))state="传输中 · 等待对方确认接收";
row.addView(s.label(state,12,muted));
TextView stateLabel=s.label(state,12,night?muted:delivery.equals("played")||delivery.equals("received")?PhoneStyle.GREEN:PhoneStyle.MUTED);stateLabel.setPadding(0,s.dp(8),0,s.dp(4));row.addView(stateLabel);
row.addView(s.label(archive.equals("cloud")?"✓ 已存网盘 · 校验完成":archive.equals("retry")?"网盘归档待重试 · 临时副本保留":archive.equals("uploading")?"↑ 正在传输到网盘":"等待存入网盘",11,muted));
}
if(!past&&follow)scroll.post(()->scroll.fullScroll(FOCUS_DOWN));else scroll.post(()->scroll.scrollTo(0,past?0:oldScroll));
@@ -16,9 +16,9 @@ final class VoiceSurface extends LinearLayout {
final VoiceArt art;final Switch receiver;final LinearLayout destinationCard,receiverCard,playbackCard;final TextView availability;final ImageView destinationIcon;
final VoiceChat chat;
boolean night=false,communicationPage=false,compact=false;String targetSignature="",controlSignature="";
int ink(){return night?0xffc8d5cd:0xff29443c;}int muted(){return night?0xff96aaa0:0xff65766d;}
int accent(){return night?0xff456b5e:0xff17695e;}int paper(){return night?0xff172820:0xfff8f5ed;}
int card(){return night?0xff21372d:0xfffffefa;}
int ink(){return night?0xffc8d5cd:PhoneStyle.INK;}int muted(){return night?0xff96aaa0:PhoneStyle.MUTED;}
int accent(){return night?0xff456b5e:PhoneStyle.GREEN;}int paper(){return night?0xff172820:PhoneStyle.PAPER;}
int card(){return night?0xff21372d:PhoneStyle.CARD;}
int dp(float n){return Math.round(n*getResources().getDisplayMetrics().density);}
VoiceSurface(Activity activity,boolean expanded){
super(activity);full=expanded;setOrientation(VERTICAL);setPadding(dp(full?20:12),dp(full?20:8),dp(full?20:12),dp(full?22:8));
@@ -61,10 +61,10 @@ final class VoiceSurface extends LinearLayout {
protected void onMeasure(int width,int height){
int available=View.MeasureSpec.getSize(height);boolean small=available>0&&available<dp(680);
if(communicationPage&&available>0&&small!=compact){compact=small;
title.setTextSize(small?23:28);recipient.setTextSize(small?18:21);speak.setLayoutParams(new LayoutParams(dp(small?120:150),dp(small?120:150)));clock.setLayoutParams(new LayoutParams(-1,dp(small?32:42)));art.setLayoutParams(new LayoutParams(-1,dp(small?12:18)));
title.setTextSize(small?23:28);recipient.setTextSize(small?18:21);speak.setLayoutParams(new LayoutParams(dp(small?112:150),dp(small?112:150)));clock.setLayoutParams(new LayoutParams(-1,dp(small?28:42)));art.setLayoutParams(new LayoutParams(-1,dp(small?12:18)));
for(int i=0;i<getChildCount();i++){View child=getChildAt(i);if(child.getClass()==View.class)child.setLayoutParams(new LayoutParams(1,dp(small?4:12)));}
destinationIcon.setLayoutParams(new LayoutParams(dp(small?38:52),dp(small?38:52)));destinationCard.setPadding(dp(12),dp(small?5:10),dp(12),dp(small?5:10));
chat.setPadding(dp(small?12:16),dp(small?10:16),dp(small?12:16),dp(small?10:16));
chat.setPadding(dp(small?12:16),dp(small?8:16),dp(small?12:16),dp(small?8:16));
}
super.onMeasure(width,height);
}
@@ -75,13 +75,15 @@ final class VoiceSurface extends LinearLayout {
status.setTextSize(11);status.setMaxLines(2);status.setEllipsize(android.text.TextUtils.TruncateAt.END);LinearLayout feedback=new LinearLayout(getContext());feedback.setGravity(Gravity.CENTER_VERTICAL);feedback.addView(status,new LayoutParams(0,-2,1));feedback.addView(stop);addView(feedback);
}
static void text(TextView view,CharSequence value){if(!android.text.TextUtils.equals(view.getText(),value))view.setText(value);}
Button button(String text,int size){Button b=new Button(getContext());b.setText(text);b.setTextSize(size);b.setAllCaps(false);b.setMinHeight(dp(44));b.setMinimumHeight(dp(44));b.setMinWidth(0);b.setMinimumWidth(0);b.setPadding(dp(12),dp(8),dp(12),dp(8));b.setStateListAnimator(null);return b;}
Button button(String text,int size){Button b=new PhoneStyle(getContext()).button(text,false);b.setTextSize(size);return b;}
void space(int amount){spaceIn(this,amount);}void spaceIn(LinearLayout parent,int amount){parent.addView(new View(getContext()),new LayoutParams(1,dp(amount)));}
GradientDrawable shape(int color,int border,int radius){GradientDrawable d=new GradientDrawable();d.setColor(color);d.setCornerRadius(dp(radius));if(border!=0)d.setStroke(dp(1),border);return d;}
void applyTheme(boolean value){
night=value;chat.theme(value);setBackgroundColor(paper());for(TextView t:new TextView[]{title,recipient,clock})t.setTextColor(ink());for(TextView t:new TextView[]{subtitle,status,hint,receive})t.setTextColor(muted());
compose.setBackground(null);for(View v:new View[]{destinationCard,receiverCard,playbackCard})v.setBackground(full?shape(card(),0,20):null);receiver.setTextColor(ink());availability.setTextColor(muted());
for(Button b:new Button[]{settings,stop,expand}){b.setTextColor(ink());b.setBackground(shape(night?0xff2d4439:0xffefeee6,0,18));}
compose.setBackground(null);for(View v:new View[]{destinationCard,receiverCard,playbackCard})v.setBackground(full?shape(card(),night?0xff345043:PhoneStyle.LINE,8):null);receiver.setTextColor(ink());availability.setTextColor(muted());
if(communicationPage)playbackCard.setBackground(null);
for(Button b:new Button[]{settings,stop,expand}){if(night){b.setTextColor(ink());b.setBackground(shape(0xff2d4439,0xff345043,6));}else new PhoneStyle(getContext()).buttonStyle(b,false);}
receiver.setThumbTintList(new ColorStateList(new int[][]{new int[]{android.R.attr.state_checked},new int[]{}},new int[]{accent(),0xffadb5bd}));
art.night=value;art.invalidate();targetSignature="";controlSignature="";
}
void destination(JSONObject selected,boolean ready){
@@ -96,7 +98,7 @@ final class VoiceSurface extends LinearLayout {
for(int i=0;i<values.length();i++){
JSONObject item=values.optJSONObject(i);if(item==null)continue;String id=item.optString("id"),name=item.optString("name","家人");boolean chosen=id.equals(selected),online=item.optBoolean("online");
LinearLayout tile=new LinearLayout(getContext());tile.setOrientation(VERTICAL);tile.setGravity(Gravity.CENTER);tile.setPadding(dp(8),dp(12),dp(8),dp(10));
tile.setBackground(shape(chosen?(night?0xff304f40:0xffeaf3ec):card(),chosen?accent():night?0xff345043:0xffe5e6dc,20));tile.setFocusable(true);tile.setClickable(true);tile.setSelected(chosen);tile.setContentDescription(name+","+(online?"已打开 App":"未打开 App")+(chosen?",已选中":",点按选择"));tile.setOnClickListener(v->choose.accept(id));
tile.setBackground(shape(chosen?(night?0xff304f40:PhoneStyle.PALE):card(),chosen?accent():night?0xff345043:PhoneStyle.LINE,8));tile.setFocusable(true);tile.setClickable(true);tile.setSelected(chosen);tile.setContentDescription(name+","+(online?"已打开 App":"未打开 App")+(chosen?",已选中":",点按选择"));tile.setOnClickListener(v->choose.accept(id));
TextView avatar=label(name.isEmpty()?"家":name.substring(0,name.offsetByCodePoints(0,1)),28);avatar.setGravity(Gravity.CENTER);avatar.setTypeface(null,Typeface.BOLD);avatar.setTextColor(chosen?Color.WHITE:ink());avatar.setBackground(shape(chosen?accent():night?0xff375547:0xffe2e9dc,0,30));tile.addView(avatar,new LayoutParams(dp(54),dp(54)));
TextView caption=label(name+(chosen?" ✓":""),17);caption.setGravity(Gravity.CENTER);caption.setTypeface(null,Typeface.BOLD);caption.setMaxLines(2);caption.setTextColor(ink());tile.addView(caption);
TextView availability=label(online?"● 已打开 App":"○ 未打开 App",12);availability.setGravity(Gravity.CENTER);availability.setTextColor(online?(night?0xff9bbfab:accent()):muted());tile.addView(availability);
@@ -117,7 +119,7 @@ final class VoiceSurface extends LinearLayout {
static final class VoiceCircle extends Drawable {
final Paint p=new Paint(Paint.ANTI_ALIAS_FLAG);final int color;final boolean night;
VoiceCircle(int color,boolean night){this.color=color;this.night=night;}
public void draw(Canvas c){Rect b=getBounds();float x=b.exactCenterX(),y=b.exactCenterY(),r=Math.min(b.width(),b.height())/2f;p.setColor(night?0xff223c31:0xffe5f0e6);c.drawCircle(x,y,r,p);p.setColor(night?0xff2e4d40:0xffcfe5d8);c.drawCircle(x,y,r*.88f,p);p.setShader(new LinearGradient(x-r,y-r,x+r,y+r,new int[]{color,night?0xff355549:0xff095747},null,Shader.TileMode.CLAMP));c.drawCircle(x,y,r*.81f,p);p.setShader(null);MicIcon mic=new MicIcon(night?0xffcfdfd5:Color.WHITE,64);int half=Math.round(r*.27f);mic.setBounds(Math.round(x)-half,Math.round(y)-half,Math.round(x)+half,Math.round(y)+half);mic.draw(c);}
public void draw(Canvas c){Rect b=getBounds();float x=b.exactCenterX(),y=b.exactCenterY(),r=Math.min(b.width(),b.height())/2f;p.setColor(night?0xff223c31:PhoneStyle.PALE);c.drawCircle(x,y,r,p);p.setColor(color);c.drawCircle(x,y,r*.88f,p);MicIcon mic=new MicIcon(night?0xffcfdfd5:Color.WHITE,64);int half=Math.round(r*.29f);mic.setBounds(Math.round(x)-half,Math.round(y)-half,Math.round(x)+half,Math.round(y)+half);mic.draw(c);}
public void setAlpha(int a){p.setAlpha(a);}public void setColorFilter(ColorFilter f){p.setColorFilter(f);}public int getOpacity(){return PixelFormat.TRANSLUCENT;}
}
static final class MicIcon extends Drawable {
@@ -11,13 +11,13 @@ public class PhonePreviewActivity extends LocationActivity {
protected void attachBaseContext(android.content.Context base){android.content.res.Configuration c=new android.content.res.Configuration(base.getResources().getConfiguration());c.densityDpi=420;super.attachBaseContext(base.createConfigurationContext(c));}
public void onCreate(Bundle state){
mode=getIntent().getStringExtra("mode");if(mode==null)mode="family";
if(mode.equals("large")){android.content.res.Configuration cfg=new android.content.res.Configuration(getResources().getConfiguration());cfg.fontScale=1.35f;getResources().updateConfiguration(cfg,getResources().getDisplayMetrics());}
if(mode.equals("large")||mode.equals("settings-large")||mode.equals("voice-large")){android.content.res.Configuration cfg=new android.content.res.Configuration(getResources().getConfiguration());cfg.fontScale=1.35f;getResources().updateConfiguration(cfg,getResources().getDisplayMetrics());}
DisplayApi.offline="offline".equals(mode);DisplayApi.expired="expired".equals(mode);
getSharedPreferences("location",0).edit().clear().putString("token","unpaired".equals(mode)?"":"synthetic-token").putString("memberName","示例成员").putString("home","我的家 · 演示家庭").putLong("expires",System.currentTimeMillis()+86400000L).putString("status","共享关闭 · 可以查看已授权的家人").apply();
super.onCreate(state);
// Limit the actual Activity layout to a phone viewport without changing display configuration.
((android.view.ViewGroup)phone.getParent()).removeView(phone);FrameLayout outer=new FrameLayout(this);outer.setBackgroundColor(PhoneStyle.PAPER);
int width="narrow".equals(mode)||"large".equals(mode)?320:390;outer.addView(phone,new FrameLayout.LayoutParams(style.dp(width),style.dp("narrow".equals(mode)?640:844),Gravity.TOP|Gravity.CENTER_HORIZONTAL));previewRoot=phone;setContentView(outer);
int width="narrow".equals(mode)||"large".equals(mode)||"voice-large".equals(mode)?320:390;outer.addView(phone,new FrameLayout.LayoutParams(style.dp(width),style.dp("narrow".equals(mode)?640:844),Gravity.TOP|Gravity.CENTER_HORIZONTAL));previewRoot=phone;setContentView(outer);
new Handler().postDelayed(()->{try{exercise();if(mode.equals("history"))exerciseHistory();else if(mode.equals("cycles"))LocationCycleChecks.run(this,this::save);else if(mode.equals("storage")){QueueStorageChecks.run(this);save();}else save();}catch(Exception e){throw new RuntimeException(e);}},1800);
}
void check(boolean condition,String message){if(!condition)throw new AssertionError(message);}
@@ -40,7 +40,7 @@ public class PhonePreviewActivity extends LocationActivity {
check(!prefs.getBoolean("active",false),"choosing a mode never enables sharing");
}
if(mode.equals("mine")||mode.equals("large"))selectTab(2);
else if(mode.equals("voice")||mode.equals("recording")||mode.equals("cancel")||mode.equals("narrow")||mode.equals("history")){
else if(mode.equals("voice")||mode.equals("voice-large")||mode.equals("recording")||mode.equals("cancel")||mode.equals("narrow")||mode.equals("history")){
selectTab(1);voice.ui.removeCallbacks(voice.visual);VoiceSurface v=voice.page();v.expand.setVisibility(View.GONE);v.destination(new JSONObject("{\"name\":\"家庭显示终端\",\"kind\":\"display\",\"online\":true}"),true);v.recipient.setText("家庭显示终端");v.status.setText("界面验收 · 不录音、不发送语音");
boolean recording=mode.equals("recording")||mode.equals("cancel");for(int i=0;i<31;i++)v.recording(recording,mode.equals("cancel"),8000,(int)(9000*Math.abs(Math.sin(i))),false,true);
}
@@ -50,9 +50,18 @@ public class PhonePreviewActivity extends LocationActivity {
if(mode.equals("offline")){check(familyList.getChildCount()==0,"offline stale positions removed");check(!sharing.isEnabled(),"offline cannot start sharing");}
check(phone.nav.getChildCount()==3,"exactly three tabs");check(phone.navLabels[0].getText().toString().equals("位置")&&phone.navLabels[1].getText().toString().equals("沟通"),"requested navigation names");
check(voice.page().receiverCard.getParent()==null,"communication page does not duplicate settings");
check(phone.nav.getChildAt(phone.tab).isSelected(),"active Bootstrap navigation state");
Button disabled=style.button("测试",false);disabled.setEnabled(false);check(disabled.getCurrentTextColor()==0xff868e96,"disabled button has distinct text color");
if(mode.startsWith("settings")||mode.equals("upload-settings")||mode.equals("pair-settings")){
selectTab(2);boolean upload=mode.equals("upload-settings"),pair=mode.equals("pair-settings");showDetail(pair?"配对与设备":upload?"集中上传与离线暂存":"共享模式与采集频率",pair?pairSection:upload?uploadSection:sampleSection);
if(upload){cadence.setSelection(uploadIntervals.length-1);}else if(!pair){sampleCadence.setSelection(sampleIntervals.length-1);}
detailDialog.getWindow().setLayout(style.dp(mode.equals("settings-narrow")||mode.equals("settings-large")?320:390),style.dp(720));previewRoot=detailDialog.getWindow().getDecorView();
check(pair||((upload?cadence:sampleCadence).getAdapter() instanceof PhoneStyle.FormAdapter),"native Bootstrap select adapter installed");
check(!prefs.getBoolean("active",false),"styling and custom cadence selection never enable location");
}
}
void exerciseHistory(){
new Handler().postDelayed(()->{check(voice.nextBefore==12,"history initial page");voice.page().chat.older.performClick();new Handler().postDelayed(()->{check(voice.historyBefore==12&&voice.nextBefore==0,"older page loaded");check(!voice.page().chat.older.isEnabled(),"end of history disables older");voice.page().chat.latest.performClick();new Handler().postDelayed(()->{check(voice.historyBefore==0&&voice.nextBefore==12,"return to latest page");check(!voice.enabled,"reading history does not enable reception");save();},250);},250);},250);
}
void save(){previewRoot.postDelayed(()->{try{check(sampleSection.getParent()==settings&&uploadSection.getParent()==settings,"dismissed forms safely returned after queued dialog callbacks");if(phone.tab==1){check(voice.page().chat.messages.getChildCount()==3,"real controller loads chat history");check(voice.nextBefore==12,"older history cursor available");check(voice.page().chat.scroll.getHeight()>=style.dp(90),"chat viewport="+voice.page().chat.scroll.getHeight()+", root="+voice.page().getHeight()+", chat="+voice.page().chat.getHeight()+", compose="+voice.page().compose.getHeight()+", compact="+voice.page().compact);check(voice.page().speak.getHeight()>=style.dp(110),"microphone remains a large target");}android.graphics.Bitmap b=android.graphics.Bitmap.createBitmap(previewRoot.getWidth(),previewRoot.getHeight(),android.graphics.Bitmap.Config.ARGB_8888);previewRoot.draw(new android.graphics.Canvas(b));try(java.io.FileOutputStream f=new java.io.FileOutputStream(new java.io.File(getExternalFilesDir(null),"preview.png"))){b.compress(android.graphics.Bitmap.CompressFormat.PNG,100,f);}b.recycle();try(java.io.FileWriter f=new java.io.FileWriter(new java.io.File(getExternalFilesDir(null),"checks.txt"))){f.write("PASS "+mode+" production navigation, chronological list, focus, chat visibility and settings ownership");}}catch(Exception e){throw new RuntimeException(e);}},600);}
void save(){previewRoot.postDelayed(()->{try{if(detailDialog==null)check(sampleSection.getParent()==settings&&uploadSection.getParent()==settings,"dismissed forms safely returned after queued dialog callbacks");else{EditText field=mode.equals("pair-settings")?code:mode.equals("upload-settings")?customAmount:sampleAmount;check(field.getHeight()>=style.dp(48),"form fields retain accessible touch height");check(field.getWidth()>style.dp(60),"custom amount retains usable width");if(!mode.equals("pair-settings")){LinearLayout period=mode.equals("upload-settings")?customPeriod:samplePeriod;View unit=mode.equals("upload-settings")?customUnit:sampleUnit;check(unit.getBottom()<=period.getHeight(),"unit selector is not clipped by baseline alignment");}}if(phone.tab==1){check(voice.page().chat.messages.getChildCount()==3,"real controller loads chat history");check(voice.nextBefore==12,"older history cursor available");check(voice.page().chat.scroll.getHeight()>=style.dp(90),"chat viewport="+voice.page().chat.scroll.getHeight()+", root="+voice.page().getHeight()+", chat="+voice.page().chat.getHeight()+", compose="+voice.page().compose.getHeight()+", compact="+voice.page().compact);check(voice.page().speak.getHeight()>=style.dp(110),"microphone remains a large target");}android.graphics.Bitmap b=android.graphics.Bitmap.createBitmap(previewRoot.getWidth(),previewRoot.getHeight(),android.graphics.Bitmap.Config.ARGB_8888);previewRoot.draw(new android.graphics.Canvas(b));try(java.io.FileOutputStream f=new java.io.FileOutputStream(new java.io.File(getExternalFilesDir(null),"preview.png"))){b.compress(android.graphics.Bitmap.CompressFormat.PNG,100,f);}b.recycle();try(java.io.FileWriter f=new java.io.FileWriter(new java.io.File(getExternalFilesDir(null),"checks.txt"))){f.write("PASS "+mode+" production navigation, chronological list, focus, chat visibility and settings ownership");}}catch(Exception e){throw new RuntimeException(e);}},600);}
}
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "zhao-steward-ui",
"private": true,
"version": "0.1.54",
"version": "0.1.55",
"type": "module",
"scripts": {
"build": "vite build",
+5 -1
View File
@@ -155,7 +155,11 @@ class LocationSyncTests(unittest.TestCase):
with self.assertRaises(app.Problem):self.configure(phone,viewerIds=[self.owner['id']],sampleIntervalSeconds=invalid)
def test_daily_sampling_wait_and_overdue_are_distinct_from_upload(self):
phone=self.enabled(intervalSeconds=300,sampleIntervalSeconds=86400);started=phone['collectionStartedAt']
# Scheduling and history create their timestamps separately. Freeze this
# logical start event so sub-millisecond wall-clock drift cannot fail it.
with patch('member_locations.time.time',return_value=time.time()):
phone=self.enabled(intervalSeconds=300,sampleIntervalSeconds=86400)
started=phone['collectionStartedAt']
with patch('member_locations.time.time',return_value=started+3600):
row=app.LOCATIONS.listing(self.aid,user=self.owner)[0]
self.assertEqual(row['status'],'scheduled');self.assertEqual(row['scheduleReason'],'sampling')