Fix inert ToolApp UI actions
This commit is contained in:
@@ -237,14 +237,46 @@ FloatBallAppWM.prototype.createSettingItemView = function(item, parent, needDivi
|
||||
// 透明波纹背景
|
||||
btn.setBackground(self.ui.createTransparentRippleDrawable(primary, self.dp(16)));
|
||||
|
||||
function runSettingAction() {
|
||||
try {
|
||||
self.touchActivity();
|
||||
var action = String(item.action || "");
|
||||
if (action === "open_btn_mgr") {
|
||||
self.showPanelAvoidBall("btn_editor");
|
||||
return;
|
||||
}
|
||||
if (action === "open_schema_editor") {
|
||||
self.showPanelAvoidBall("schema_editor");
|
||||
return;
|
||||
}
|
||||
if (action === "open_settings") {
|
||||
self.showPanelAvoidBall("settings");
|
||||
return;
|
||||
}
|
||||
if (action === "open_manual" || action === "open_doc") {
|
||||
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
|
||||
intent.setData(android.net.Uri.parse("https://xin-blog.com/114.html"));
|
||||
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
return;
|
||||
}
|
||||
if (action && (action.indexOf("http://") === 0 || action.indexOf("https://") === 0)) {
|
||||
var urlIntent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
|
||||
urlIntent.setData(android.net.Uri.parse(action));
|
||||
urlIntent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(urlIntent);
|
||||
return;
|
||||
}
|
||||
self.toast(action ? ("暂不支持动作: " + action) : "动作未配置");
|
||||
} catch(e) {
|
||||
try { self.toast("动作执行失败: " + String(e)); } catch(eToast) {}
|
||||
safeLog(null, 'e', "setting action fail " + String(e));
|
||||
}
|
||||
}
|
||||
|
||||
btn.setOnClickListener(new android.view.View.OnClickListener({
|
||||
onClick: function(v) {
|
||||
try {
|
||||
self.touchActivity();
|
||||
if (item.action === "open_btn_mgr") {
|
||||
self.showPanelAvoidBall("btn_editor");
|
||||
}
|
||||
} catch(e) { safeLog(null, 'e', "catch " + String(e)); }
|
||||
runSettingAction();
|
||||
}
|
||||
}));
|
||||
row.addView(btn);
|
||||
@@ -252,12 +284,7 @@ FloatBallAppWM.prototype.createSettingItemView = function(item, parent, needDivi
|
||||
// 行点击也触发
|
||||
row.setOnClickListener(new android.view.View.OnClickListener({
|
||||
onClick: function(v) {
|
||||
try {
|
||||
self.touchActivity();
|
||||
if (item.action === "open_btn_mgr") {
|
||||
self.showPanelAvoidBall("btn_editor");
|
||||
}
|
||||
} catch(e) { safeLog(null, 'e', "catch " + String(e)); }
|
||||
runSettingAction();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
@@ -614,6 +614,7 @@ FloatBallAppWM.prototype.makeToolAppStackEntry = function(route) {
|
||||
};
|
||||
|
||||
FloatBallAppWM.prototype.buildToolAppPreviewBody = function(entry) {
|
||||
var self = this;
|
||||
var oldGroupKey = null;
|
||||
var hasOldGroupKey = false;
|
||||
var r = "settings";
|
||||
@@ -650,10 +651,13 @@ FloatBallAppWM.prototype.buildToolAppPreviewBody = function(entry) {
|
||||
bar.setBackground(this.ui.createStrokeDrawable(T.card, this.withAlpha(T.stroke, isDark ? 0.30 : 0.45), this.dp(1), this.dp(20)));
|
||||
try { bar.setElevation(this.dp((spec && (spec.isExpandedWidth || spec.isWideWidth)) ? 1 : 2)); } catch(eBarElev) {}
|
||||
|
||||
var btnBack = this.ui.createFlatButton(this, "‹", T.brown, function() {});
|
||||
function handlePreviewBackClick() {
|
||||
try { self.toast("这是返回预览,松手后才会返回"); } catch(eToast) {}
|
||||
}
|
||||
var btnBack = this.ui.createFlatButton(this, "‹", T.brown, handlePreviewBackClick);
|
||||
btnBack.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, 24);
|
||||
btnBack.setPadding(this.dp(8), 0, this.dp(8), 0);
|
||||
try { btnBack.setClickable(false); btnBack.setAlpha(0.45); } catch(eBackClick) {}
|
||||
try { btnBack.setAlpha(0.62); } catch(eBackClick) {}
|
||||
try { btnBack.setBackground(this.ui.createStrokeDrawable(T.primarySoft, this.withAlpha(T.primaryDeep, isDark ? 0.30 : 0.22), this.dp(1), this.dp(18))); } catch(eBackBg) {}
|
||||
bar.addView(btnBack, new android.widget.LinearLayout.LayoutParams(this.dp(42), this.dp(38)));
|
||||
|
||||
@@ -670,11 +674,23 @@ FloatBallAppWM.prototype.buildToolAppPreviewBody = function(entry) {
|
||||
bar.addView(tvTitle, titleLp);
|
||||
|
||||
var rightText = r === "settings" ? "📖 岛务手册" : "✕";
|
||||
var btnClose = this.ui.createFlatButton(this, rightText, T.primaryDeep, function() {});
|
||||
function handlePreviewRightClick() {
|
||||
try {
|
||||
if (r === "settings") {
|
||||
var intent = new android.content.Intent(android.content.Intent.ACTION_VIEW);
|
||||
intent.setData(android.net.Uri.parse("https://xin-blog.com/114.html"));
|
||||
intent.setFlags(android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
context.startActivity(intent);
|
||||
return;
|
||||
}
|
||||
self.toast("这是返回预览,松手后才会返回");
|
||||
} catch(eDoc) { try { self.toast("无法打开文档链接"); } catch(eToast) {} }
|
||||
}
|
||||
var btnClose = this.ui.createFlatButton(this, rightText, T.primaryDeep, handlePreviewRightClick);
|
||||
btnClose.setTextSize(android.util.TypedValue.COMPLEX_UNIT_SP, r === "settings" ? 12 : 18);
|
||||
btnClose.setTypeface(null, android.graphics.Typeface.BOLD);
|
||||
btnClose.setPadding(this.dp(10), 0, this.dp(10), 0);
|
||||
try { btnClose.setClickable(false); btnClose.setAlpha(0.45); } catch(eRightClick) {}
|
||||
try { btnClose.setAlpha(0.62); } catch(eRightClick) {}
|
||||
try { btnClose.setBackground(this.ui.createStrokeDrawable(T.primarySoft, this.withAlpha(T.primaryDeep, isDark ? 0.30 : 0.22), this.dp(1), this.dp(18))); } catch(eRightBg) {}
|
||||
bar.addView(btnClose, new android.widget.LinearLayout.LayoutParams(this.dp(104), this.dp(38)));
|
||||
var barLp = new android.widget.LinearLayout.LayoutParams(-1, topBarHeight);
|
||||
|
||||
Reference in New Issue
Block a user