fix: TV RTSP compatibility and adaptive colorful day-night clock
This commit is contained in:
@@ -24,6 +24,8 @@ public class MainActivity extends Activity {
|
||||
static volatile MainActivity active;
|
||||
WebView web;
|
||||
CameraStrip cameras;
|
||||
final Handler themeHandler=new Handler();
|
||||
final Runnable themeTick=new Runnable(){public void run(){applyTimeMode();themeHandler.postDelayed(this,60000);}};
|
||||
@Override public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
@@ -34,7 +36,8 @@ public class MainActivity extends Activity {
|
||||
web.getSettings().setDomStorageEnabled(true);
|
||||
web.getSettings().setAllowFileAccess(false);
|
||||
web.getSettings().setAllowContentAccess(false);
|
||||
web.getSettings().setMixedContentMode(0);
|
||||
// Plain RTSP is allowed only by the native player's same-network check.
|
||||
web.getSettings().setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_NEVER_ALLOW);
|
||||
web.setWebViewClient(new WebViewClient(){
|
||||
@Override public boolean shouldOverrideUrlLoading(WebView view,WebResourceRequest request){
|
||||
return !"https".equals(request.getUrl().getScheme()) || !"zhao.ucvl.cn".equals(request.getUrl().getHost()) || !request.getUrl().getPath().startsWith("/tv");
|
||||
@@ -44,6 +47,7 @@ public class MainActivity extends Activity {
|
||||
layout.addView(web,new LinearLayout.LayoutParams(-1,0,88));
|
||||
cameras=new CameraStrip(this);layout.addView(cameras,new LinearLayout.LayoutParams(-1,0,12));
|
||||
setContentView(layout);
|
||||
themeHandler.post(themeTick);
|
||||
configure(getIntent());
|
||||
}
|
||||
void configure(Intent intent){
|
||||
@@ -73,7 +77,13 @@ public class MainActivity extends Activity {
|
||||
@Override public void onNewIntent(Intent intent){super.onNewIntent(intent);setIntent(intent);configure(intent);}
|
||||
@Override public void onResume(){super.onResume();active=this;immersive();if(cameras!=null)cameras.foreground(true);}
|
||||
@Override public void onPause(){if(active==this)active=null;if(cameras!=null)cameras.foreground(false);super.onPause();}
|
||||
@Override public void onDestroy(){if(active==this)active=null;if(cameras!=null)cameras.close();web.destroy();super.onDestroy();}
|
||||
@Override public void onDestroy(){if(active==this)active=null;themeHandler.removeCallbacksAndMessages(null);if(cameras!=null)cameras.close();web.destroy();super.onDestroy();}
|
||||
void applyTimeMode(){
|
||||
java.util.Calendar cal=java.util.Calendar.getInstance(java.util.TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
int hour=cal.get(java.util.Calendar.HOUR_OF_DAY);boolean night=hour>=20||hour<7;
|
||||
WindowManager.LayoutParams params=getWindow().getAttributes();params.screenBrightness=night?.12f:.75f;getWindow().setAttributes(params);
|
||||
if(cameras!=null){cameras.setBackgroundColor(night?0xff18221b:0xffe8e5db);cameras.title.setTextColor(night?0xff98a48c:0xff57634e);}
|
||||
}
|
||||
@Override public void onWindowFocusChanged(boolean hasFocus){super.onWindowFocusChanged(hasFocus);if(hasFocus)immersive();}
|
||||
void immersive(){getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN|View.SYSTEM_UI_FLAG_HIDE_NAVIGATION|View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY|View.SYSTEM_UI_FLAG_LAYOUT_STABLE|View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);}
|
||||
static void capture(Consumer<byte[]> callback){
|
||||
|
||||
Reference in New Issue
Block a user