修复一些列bug
This commit is contained in:
41
android/app/src/main/AndroidManifest.xml
Normal file
41
android/app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:dataExtractionRules="@xml/data_extraction_rules"
|
||||
android:fullBackupContent="@xml/backup_rules"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:roundIcon="@drawable/ic_launcher"
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/Theme.XQKQueue"
|
||||
android:usesCleartextTraffic="false"
|
||||
tools:targetApi="s">
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|screenSize|smallestScreenSize|uiMode"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTask">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
<intent-filter android:autoVerify="false">
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
<data android:scheme="https" />
|
||||
<data android:host="queue.nianxx.cn" />
|
||||
<data android:path="/admin/display" />
|
||||
<data android:pathPrefix="/display/" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
@@ -0,0 +1,403 @@
|
||||
package cn.nianxx.queue.display;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ApplicationInfo;
|
||||
import android.graphics.Color;
|
||||
import android.net.http.SslError;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowInsets;
|
||||
import android.view.WindowInsetsController;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.PermissionRequest;
|
||||
import android.webkit.SslErrorHandler;
|
||||
import android.webkit.WebChromeClient;
|
||||
import android.webkit.WebResourceError;
|
||||
import android.webkit.WebResourceRequest;
|
||||
import android.webkit.WebResourceResponse;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Button;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
public final class MainActivity extends Activity {
|
||||
private FrameLayout root;
|
||||
private WebView webView;
|
||||
private ProgressBar progressBar;
|
||||
private LinearLayout errorView;
|
||||
private TextView errorDetail;
|
||||
private View customView;
|
||||
private WebChromeClient.CustomViewCallback customViewCallback;
|
||||
private String lastAllowedUrl = NavigationPolicy.START_URL;
|
||||
private boolean mainFrameFailed;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
configureWindow();
|
||||
buildContentView();
|
||||
setContentView(root);
|
||||
registerPredictiveBackCallback();
|
||||
|
||||
String initialUrl = NavigationPolicy.initialUrlOrStart(getIntent().getDataString());
|
||||
lastAllowedUrl = initialUrl;
|
||||
webView.loadUrl(initialUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
setIntent(intent);
|
||||
String target = NavigationPolicy.initialUrlOrStart(intent.getDataString());
|
||||
exitWebFullscreen();
|
||||
if (!target.equals(webView.getUrl())) {
|
||||
webView.loadUrl(target);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
webView.onResume();
|
||||
enterImmersiveMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
webView.onPause();
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
if (hasFocus) {
|
||||
enterImmersiveMode();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressLint("GestureBackNavigation")
|
||||
@SuppressWarnings("deprecation")
|
||||
public void onBackPressed() {
|
||||
handleBackNavigation();
|
||||
}
|
||||
|
||||
private void handleBackNavigation() {
|
||||
if (customView != null) {
|
||||
exitWebFullscreen();
|
||||
return;
|
||||
}
|
||||
if (webView.canGoBack()) {
|
||||
webView.goBack();
|
||||
return;
|
||||
}
|
||||
if (NavigationPolicy.isProjectDisplay(lastAllowedUrl)) {
|
||||
webView.loadUrl(NavigationPolicy.START_URL);
|
||||
return;
|
||||
}
|
||||
finishAfterTransition();
|
||||
}
|
||||
|
||||
private void registerPredictiveBackCallback() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
|
||||
android.window.OnBackInvokedDispatcher.PRIORITY_DEFAULT,
|
||||
this::handleBackNavigation);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (customView != null) {
|
||||
root.removeView(customView);
|
||||
customView = null;
|
||||
if (customViewCallback != null) {
|
||||
customViewCallback.onCustomViewHidden();
|
||||
customViewCallback = null;
|
||||
}
|
||||
}
|
||||
root.removeView(webView);
|
||||
webView.stopLoading();
|
||||
webView.setWebChromeClient(null);
|
||||
webView.setWebViewClient(null);
|
||||
webView.destroy();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void configureWindow() {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
enterImmersiveMode();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void enterImmersiveMode() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
||||
getWindow().setDecorFitsSystemWindows(false);
|
||||
WindowInsetsController controller = getWindow().getInsetsController();
|
||||
if (controller != null) {
|
||||
controller.hide(WindowInsets.Type.systemBars());
|
||||
controller.setSystemBarsBehavior(
|
||||
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
|
||||
}
|
||||
return;
|
||||
}
|
||||
getWindow().getDecorView().setSystemUiVisibility(
|
||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
|
||||
}
|
||||
|
||||
private void buildContentView() {
|
||||
root = new FrameLayout(this);
|
||||
root.setBackgroundColor(Color.BLACK);
|
||||
|
||||
webView = createWebView();
|
||||
root.addView(webView, matchParent());
|
||||
|
||||
progressBar = new ProgressBar(this);
|
||||
FrameLayout.LayoutParams progressLayout = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER);
|
||||
root.addView(progressBar, progressLayout);
|
||||
|
||||
errorView = createErrorView();
|
||||
errorView.setVisibility(View.GONE);
|
||||
root.addView(errorView, matchParent());
|
||||
}
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@SuppressWarnings("deprecation")
|
||||
private WebView createWebView() {
|
||||
WebView view = new WebView(this);
|
||||
view.setBackgroundColor(Color.BLACK);
|
||||
view.setOverScrollMode(View.OVER_SCROLL_NEVER);
|
||||
view.setLongClickable(false);
|
||||
view.setOnLongClickListener(ignored -> true);
|
||||
|
||||
boolean debuggable = (getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
|
||||
WebView.setWebContentsDebuggingEnabled(debuggable);
|
||||
|
||||
WebSettings settings = view.getSettings();
|
||||
settings.setJavaScriptEnabled(true);
|
||||
settings.setDomStorageEnabled(true);
|
||||
settings.setMediaPlaybackRequiresUserGesture(false);
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(false);
|
||||
settings.setSupportMultipleWindows(false);
|
||||
settings.setAllowFileAccess(false);
|
||||
settings.setAllowContentAccess(false);
|
||||
settings.setGeolocationEnabled(false);
|
||||
settings.setMixedContentMode(WebSettings.MIXED_CONTENT_NEVER_ALLOW);
|
||||
settings.setCacheMode(WebSettings.LOAD_DEFAULT);
|
||||
settings.setUserAgentString(settings.getUserAgentString() + " XQKQueueDisplay/1.0");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
settings.setSafeBrowsingEnabled(true);
|
||||
}
|
||||
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
cookieManager.setAcceptCookie(true);
|
||||
cookieManager.setAcceptThirdPartyCookies(view, false);
|
||||
|
||||
view.setWebViewClient(new DisplayWebViewClient());
|
||||
view.setWebChromeClient(new DisplayWebChromeClient());
|
||||
return view;
|
||||
}
|
||||
|
||||
private LinearLayout createErrorView() {
|
||||
LinearLayout panel = new LinearLayout(this);
|
||||
panel.setOrientation(LinearLayout.VERTICAL);
|
||||
panel.setGravity(Gravity.CENTER);
|
||||
panel.setPadding(dp(32), dp(32), dp(32), dp(32));
|
||||
panel.setBackgroundColor(Color.rgb(245, 248, 246));
|
||||
|
||||
TextView title = new TextView(this);
|
||||
title.setText(R.string.page_unavailable_title);
|
||||
title.setTextColor(Color.rgb(24, 54, 44));
|
||||
title.setTextSize(24);
|
||||
title.setGravity(Gravity.CENTER);
|
||||
title.setTypeface(title.getTypeface(), android.graphics.Typeface.BOLD);
|
||||
panel.addView(title, wrapContentWithBottomMargin(dp(12)));
|
||||
|
||||
errorDetail = new TextView(this);
|
||||
errorDetail.setText(R.string.page_unavailable_detail);
|
||||
errorDetail.setTextColor(Color.rgb(67, 88, 81));
|
||||
errorDetail.setTextSize(16);
|
||||
errorDetail.setGravity(Gravity.CENTER);
|
||||
panel.addView(errorDetail, wrapContentWithBottomMargin(dp(24)));
|
||||
|
||||
Button retry = new Button(this);
|
||||
retry.setText(R.string.retry);
|
||||
retry.setTextColor(Color.WHITE);
|
||||
retry.setBackgroundColor(Color.rgb(15, 107, 77));
|
||||
retry.setOnClickListener(ignored -> {
|
||||
showLoading();
|
||||
webView.loadUrl(NavigationPolicy.initialUrlOrStart(lastAllowedUrl));
|
||||
});
|
||||
panel.addView(retry, new LinearLayout.LayoutParams(dp(160), dp(52)));
|
||||
return panel;
|
||||
}
|
||||
|
||||
private void showLoading() {
|
||||
mainFrameFailed = false;
|
||||
errorView.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void showError(int messageResource) {
|
||||
mainFrameFailed = true;
|
||||
progressBar.setVisibility(View.GONE);
|
||||
errorDetail.setText(messageResource);
|
||||
errorView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void exitWebFullscreen() {
|
||||
if (customView == null) {
|
||||
return;
|
||||
}
|
||||
root.removeView(customView);
|
||||
customView = null;
|
||||
webView.setVisibility(View.VISIBLE);
|
||||
if (customViewCallback != null) {
|
||||
WebChromeClient.CustomViewCallback callback = customViewCallback;
|
||||
customViewCallback = null;
|
||||
callback.onCustomViewHidden();
|
||||
}
|
||||
enterImmersiveMode();
|
||||
}
|
||||
|
||||
private FrameLayout.LayoutParams matchParent() {
|
||||
return new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
}
|
||||
|
||||
private LinearLayout.LayoutParams wrapContentWithBottomMargin(int bottomMargin) {
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
params.bottomMargin = bottomMargin;
|
||||
return params;
|
||||
}
|
||||
|
||||
private int dp(int value) {
|
||||
return Math.round(value * getResources().getDisplayMetrics().density);
|
||||
}
|
||||
|
||||
private final class DisplayWebViewClient extends WebViewClient {
|
||||
@Override
|
||||
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
|
||||
if (!request.isForMainFrame()) {
|
||||
return false;
|
||||
}
|
||||
return blockIfOutsideApp(request.getUrl().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public boolean shouldOverrideUrlLoading(WebView view, String url) {
|
||||
return blockIfOutsideApp(url);
|
||||
}
|
||||
|
||||
private boolean blockIfOutsideApp(String url) {
|
||||
if (NavigationPolicy.isAllowed(url)) {
|
||||
return false;
|
||||
}
|
||||
Toast.makeText(MainActivity.this, R.string.blocked_navigation, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageStarted(WebView view, String url, android.graphics.Bitmap favicon) {
|
||||
if (NavigationPolicy.isAllowed(url)) {
|
||||
lastAllowedUrl = url;
|
||||
}
|
||||
showLoading();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageFinished(WebView view, String url) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
if (!mainFrameFailed) {
|
||||
errorView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedError(
|
||||
WebView view,
|
||||
WebResourceRequest request,
|
||||
WebResourceError error) {
|
||||
if (request.isForMainFrame()) {
|
||||
showError(R.string.page_unavailable_detail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedHttpError(
|
||||
WebView view,
|
||||
WebResourceRequest request,
|
||||
WebResourceResponse errorResponse) {
|
||||
if (request.isForMainFrame() && errorResponse.getStatusCode() >= 400) {
|
||||
showError(R.string.page_unavailable_detail);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
|
||||
handler.cancel();
|
||||
showError(R.string.ssl_error);
|
||||
}
|
||||
}
|
||||
|
||||
private final class DisplayWebChromeClient extends WebChromeClient {
|
||||
@Override
|
||||
public void onProgressChanged(WebView view, int newProgress) {
|
||||
if (!mainFrameFailed && newProgress < 100 && customView == null) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
} else if (newProgress == 100) {
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShowCustomView(View view, CustomViewCallback callback) {
|
||||
if (customView != null) {
|
||||
callback.onCustomViewHidden();
|
||||
return;
|
||||
}
|
||||
customView = view;
|
||||
customViewCallback = callback;
|
||||
webView.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
errorView.setVisibility(View.GONE);
|
||||
root.addView(customView, matchParent());
|
||||
enterImmersiveMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHideCustomView() {
|
||||
exitWebFullscreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPermissionRequest(PermissionRequest request) {
|
||||
request.deny();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package cn.nianxx.queue.display;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
final class NavigationPolicy {
|
||||
static final String START_URL = "https://queue.nianxx.cn/admin/display";
|
||||
|
||||
private static final String HOST = "queue.nianxx.cn";
|
||||
private static final String DISPLAY_PREFIX = "/display/";
|
||||
private static final Pattern DISPLAY_IDENTIFIER = Pattern.compile("[A-Za-z0-9_-]{2,128}");
|
||||
|
||||
private NavigationPolicy() {
|
||||
}
|
||||
|
||||
static String initialUrlOrStart(String candidate) {
|
||||
return isAllowed(candidate) ? candidate : START_URL;
|
||||
}
|
||||
|
||||
static boolean isAllowed(String candidate) {
|
||||
URI uri = parse(candidate);
|
||||
if (uri == null
|
||||
|| !"https".equalsIgnoreCase(uri.getScheme())
|
||||
|| !HOST.equalsIgnoreCase(uri.getHost())
|
||||
|| uri.getRawUserInfo() != null
|
||||
|| (uri.getPort() != -1 && uri.getPort() != 443)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String path = uri.getRawPath();
|
||||
if ("/admin/display".equals(path)) {
|
||||
return true;
|
||||
}
|
||||
if (path == null || !path.startsWith(DISPLAY_PREFIX)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
String identifier = path.substring(DISPLAY_PREFIX.length());
|
||||
return DISPLAY_IDENTIFIER.matcher(identifier).matches();
|
||||
}
|
||||
|
||||
static boolean isProjectDisplay(String candidate) {
|
||||
URI uri = parse(candidate);
|
||||
return isAllowed(candidate)
|
||||
&& uri != null
|
||||
&& uri.getRawPath() != null
|
||||
&& uri.getRawPath().startsWith(DISPLAY_PREFIX);
|
||||
}
|
||||
|
||||
private static URI parse(String candidate) {
|
||||
if (candidate == null || candidate.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new URI(candidate);
|
||||
} catch (URISyntaxException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
22
android/app/src/main/res/drawable/ic_launcher.xml
Normal file
22
android/app/src/main/res/drawable/ic_launcher.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path
|
||||
android:fillColor="#0F6B4D"
|
||||
android:pathData="M0,0h108v108h-108z" />
|
||||
<path
|
||||
android:fillColor="#D8F0E6"
|
||||
android:pathData="M16,73L36,42L48,57L63,33L93,73Z" />
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:pathData="M16,74L39,54L50,65L65,48L94,74Z" />
|
||||
<path
|
||||
android:fillColor="@android:color/transparent"
|
||||
android:pathData="M18,82C32,75 43,88 57,81C70,75 80,86 92,79"
|
||||
android:strokeColor="#D8F0E6"
|
||||
android:strokeLineCap="round"
|
||||
android:strokeWidth="5" />
|
||||
</vector>
|
||||
9
android/app/src/main/res/values/strings.xml
Normal file
9
android/app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">景区排队叫号大屏</string>
|
||||
<string name="page_unavailable_title">页面暂时无法连接</string>
|
||||
<string name="page_unavailable_detail">请检查网络连接后重试</string>
|
||||
<string name="retry">重新加载</string>
|
||||
<string name="blocked_navigation">已阻止离开公示页面</string>
|
||||
<string name="ssl_error">安全连接校验失败,请联系管理员</string>
|
||||
</resources>
|
||||
13
android/app/src/main/res/values/styles.xml
Normal file
13
android/app/src/main/res/values/styles.xml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<style name="Theme.XQKQueue" parent="android:style/Theme.Material.Light.NoActionBar">
|
||||
<item name="android:fontFamily">sans</item>
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<item name="android:windowFullscreen">true</item>
|
||||
<item name="android:windowNoTitle">true</item>
|
||||
<item name="android:colorAccent">#0F6B4D</item>
|
||||
<item name="android:navigationBarColor">#000000</item>
|
||||
<item name="android:statusBarColor">@android:color/transparent</item>
|
||||
<item name="android:windowLightStatusBar">false</item>
|
||||
</style>
|
||||
</resources>
|
||||
7
android/app/src/main/res/xml/backup_rules.xml
Normal file
7
android/app/src/main/res/xml/backup_rules.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<full-backup-content>
|
||||
<exclude domain="root" path="." />
|
||||
<exclude domain="file" path="." />
|
||||
<exclude domain="database" path="." />
|
||||
<exclude domain="sharedpref" path="." />
|
||||
</full-backup-content>
|
||||
15
android/app/src/main/res/xml/data_extraction_rules.xml
Normal file
15
android/app/src/main/res/xml/data_extraction_rules.xml
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<data-extraction-rules>
|
||||
<cloud-backup>
|
||||
<exclude domain="root" path="." />
|
||||
<exclude domain="file" path="." />
|
||||
<exclude domain="database" path="." />
|
||||
<exclude domain="sharedpref" path="." />
|
||||
</cloud-backup>
|
||||
<device-transfer>
|
||||
<exclude domain="root" path="." />
|
||||
<exclude domain="file" path="." />
|
||||
<exclude domain="database" path="." />
|
||||
<exclude domain="sharedpref" path="." />
|
||||
</device-transfer>
|
||||
</data-extraction-rules>
|
||||
8
android/app/src/main/res/xml/network_security_config.xml
Normal file
8
android/app/src/main/res/xml/network_security_config.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<network-security-config>
|
||||
<base-config cleartextTrafficPermitted="false">
|
||||
<trust-anchors>
|
||||
<certificates src="system" />
|
||||
</trust-anchors>
|
||||
</base-config>
|
||||
</network-security-config>
|
||||
@@ -0,0 +1,50 @@
|
||||
package cn.nianxx.queue.display;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public final class NavigationPolicyTest {
|
||||
@Test
|
||||
public void allowsOnlyTheTwoPublicPageFamilies() {
|
||||
assertTrue(NavigationPolicy.isAllowed("https://queue.nianxx.cn/admin/display"));
|
||||
assertTrue(NavigationPolicy.isAllowed("https://queue.nianxx.cn:443/admin/display"));
|
||||
assertTrue(NavigationPolicy.isAllowed("https://queue.nianxx.cn/display/YYHHC"));
|
||||
assertTrue(NavigationPolicy.isAllowed(
|
||||
"https://queue.nianxx.cn/display/0123456789abcdef0123456789abcdef01234567"));
|
||||
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn/admin"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn/staff"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn/display/YYHHC/extra"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn/display/X"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rejectsUntrustedOrAmbiguousUrls() {
|
||||
assertFalse(NavigationPolicy.isAllowed("http://queue.nianxx.cn/admin/display"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn.evil.test/display/YYHHC"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn@evil.test/display/YYHHC"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn:444/display/YYHHC"));
|
||||
assertFalse(NavigationPolicy.isAllowed("https://queue.nianxx.cn/display/YY%2FHHC"));
|
||||
assertFalse(NavigationPolicy.isAllowed("not a url"));
|
||||
assertFalse(NavigationPolicy.isAllowed(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fallsBackToTheProjectListForInvalidDeepLinks() {
|
||||
assertEquals(
|
||||
NavigationPolicy.START_URL,
|
||||
NavigationPolicy.initialUrlOrStart("https://example.com/display/YYHHC"));
|
||||
assertEquals(
|
||||
"https://queue.nianxx.cn/display/YYHHC",
|
||||
NavigationPolicy.initialUrlOrStart("https://queue.nianxx.cn/display/YYHHC"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void identifiesDirectProjectDisplaysForBackNavigation() {
|
||||
assertTrue(NavigationPolicy.isProjectDisplay("https://queue.nianxx.cn/display/YYHHC"));
|
||||
assertFalse(NavigationPolicy.isProjectDisplay(NavigationPolicy.START_URL));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user