Release v0.1.55: Bootstrap-style phone interface and full-screen settings
This commit is contained in:
@@ -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);}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user