[leanback] support config name

pull/297/head^2
FongMi 2 years ago
parent 4abf6446ef
commit 028dfdff3d
  1. 5
      app/src/leanback/java/com/fongmi/android/tv/ui/dialog/ConfigDialog.java
  2. 6
      app/src/leanback/res/layout/dialog_config.xml
  3. 39
      app/src/main/assets/index.html
  4. 2
      app/src/main/assets/js/script.js
  5. 14
      app/src/main/java/com/fongmi/android/tv/event/ServerEvent.java
  6. 3
      app/src/main/java/com/fongmi/android/tv/server/process/Action.java

@ -139,10 +139,12 @@ public class ConfigDialog implements DialogInterface.OnDismissListener {
}
private void onPositive(View view) {
String name = binding.name.getText().toString().trim();
String text = binding.text.getText().toString().trim();
if (edit) Config.find(url, type).url(text).update();
if (text.isEmpty()) Config.delete(url, type);
callback.setConfig(Config.find(text, type));
if (name.isEmpty()) callback.setConfig(Config.find(text, type));
else callback.setConfig(Config.find(text, name, type));
dialog.dismiss();
}
@ -153,6 +155,7 @@ public class ConfigDialog implements DialogInterface.OnDismissListener {
@Subscribe(threadMode = ThreadMode.MAIN)
public void onServerEvent(ServerEvent event) {
if (event.getType() != ServerEvent.Type.SETTING) return;
binding.name.setText(event.getName());
binding.text.setText(event.getText());
binding.text.setSelection(binding.text.getText().length());
}

@ -27,6 +27,12 @@
android:textSize="18sp"
tools:text="@string/push_info" />
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<EditText
android:id="@+id/text"
android:layout_width="match_parent"

@ -28,10 +28,12 @@
<div class="weui-cell weui-cell_active weui-cell_vcode weui-cell_wrap">
<div class="weui-cell__bd weui-flex">
<input id="keyword" class="weui-input weui-cell__control weui-cell__control_flex" type="text" value="" placeholder="請輸入關鍵字..." />
<button onclick="search(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
</div>
</div>
</div>
<div style="text-align: center;margin-top: 10px;">
<button onclick="search(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
</div>
</div>
</div>
</div>
@ -47,10 +49,12 @@
<div class="weui-cell weui-cell_active weui-cell_vcode weui-cell_wrap">
<div class="weui-cell__bd weui-flex">
<input id="push_url" class="weui-input weui-cell__control weui-cell__control_flex" type="text" value="" placeholder="請輸入播放網址..." />
<button onclick="push(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
</div>
</div>
</div>
<div style="text-align: center;margin-top: 10px;">
<button onclick="push(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
</div>
</div>
</div>
</div>
@ -60,16 +64,19 @@
<div class="weui-form__text-area">
<h2 class="weui-form__title">接口/Proxy/User-Agent</h2>
</div>
<div class="weui-form__control-area" style="margin-bottom: 0px !important;">
<div class="weui-form__control-area">
<div class="weui-cells__group weui-cells__group_form">
<div class="weui-cells">
<div class="weui-cell weui-cell_active weui-cell_vcode weui-cell_wrap">
<div class="weui-cell__bd weui-flex">
<input id="setting_text" class="weui-input weui-cell__control weui-cell__control_flex" type="text" value="" placeholder="請輸入..." />
<button onclick="setting(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
<input id="setting_name" class="weui-input weui-cell__control" type="text" value="" placeholder="請輸入名稱" />
<input id="setting_text" class="weui-input weui-cell__control weui-cell__control_flex" type="text" value="" placeholder="請輸入接口/Proxy/User-Agent..." />
</div>
</div>
</div>
<div style="text-align: center;margin-top: 10px;">
<button onclick="setting(); return false;" class="weui-cell__control weui-btn weui-btn_default weui-vcode-btn">確定</button>
</div>
</div>
</div>
</div>
@ -81,7 +88,7 @@
</div>
<input type="file" id="file_uploader" style="display:none;" onchange="uploadTip()" multiple />
<div class="weui-form__control-area" style="text-align: center;margin-bottom: 10px !important;">
<div class="button-sp-area" style="margin-top: 10px;">
<div class="button-sp-area">
<a href="javascript:void(0)" role="button" class="weui-btn weui-btn_mini weui-btn_default weui-wa-hotarea" href="javascript:void(0)" onclick="uploadFile()">上傳檔案</a>&nbsp;
<a href="javascript:void(0)" role="button" class="weui-btn weui-btn_mini weui-btn_default weui-wa-hotarea" href="javascript:void(0)" onclick="newFolder()">新增資料夾</a>&nbsp;
<a id="delCurFolder" href="javascript:void(0)" role="button" class="weui-btn weui-btn_mini weui-btn_warn weui-wa-hotarea" href="javascript:void(0)" onclick="delFolder()" style="display: none;">刪除資料夾</a>
@ -94,25 +101,37 @@
<div role="tablist" class="weui-tabbar">
<div id="tab1" role="tab" aria-labelledby="t1_title" aria-selected="true" aria-controls="panel1" class="weui-tabbar__item weui-bar__item_on">
<div class="weui-tabbar__icon">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" />
</svg>
</div>
<p id="t1_title" aria-hidden="true" class="weui-tabbar__label">搜尋</p>
</div>
<div id="tab2" role="tab" aria-labelledby="t2_title" aria-selected="false" aria-controls="panel2" class="weui-tabbar__item">
<div class="weui-tabbar__icon">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3zM8 13h2.55v3h2.9v-3H16l-4-4z" />
</svg>
</div>
<p id="t2_title" aria-hidden="true" class="weui-tabbar__label">推送</p>
</div>
<div id="tab3" role="tab" aria-labelledby="t3_title" aria-selected="false" aria-controls="panel3" class="weui-tabbar__item">
<div class="weui-tabbar__icon">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7.14 1.13zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M19.43 12.98c.04-.32.07-.64.07-.98 0-.34-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.09-.16-.26-.25-.44-.25-.06 0-.12.01-.17.03l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.06-.02-.12-.03-.18-.03-.17 0-.34.09-.43.25l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98 0 .33.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.09.16.26.25.44.25.06 0 .12-.01.17-.03l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.06.02.12.03.18.03.17 0 .34-.09.43-.25l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zm-1.98-1.71c.04.31.05.52.05.73 0 .21-.02.43-.05.73l-.14 1.13.89.7 1.08.84-.7 1.21-1.27-.51-1.04-.42-.9.68c-.43.32-.84.56-1.25.73l-1.06.43-.16 1.13-.2 1.35h-1.4l-.19-1.35-.16-1.13-1.06-.43c-.43-.18-.83-.41-1.23-.71l-.91-.7-1.06.43-1.27.51-.7-1.21 1.08-.84.89-.7-.14-1.13c-.03-.31-.05-.54-.05-.74s.02-.43.05-.73l.14-1.13-.89-.7-1.08-.84.7-1.21 1.27.51 1.04.42.9-.68c.43-.32.84-.56 1.25-.73l1.06-.43.16-1.13.2-1.35h1.39l.19 1.35.16 1.13 1.06.43c.43.18.83.41 1.23.71l.91.7 1.06-.43 1.27-.51.7 1.21-1.07.85-.89.7.14 1.13zM12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z" />
</svg>
</div>
<p id="t3_title" aria-hidden="true" class="weui-tabbar__label">設定</p>
</div>
<div id="tab4" role="tab" aria-labelledby="t4_title" aria-selected="false" aria-controls="panel4" class="weui-tabbar__item">
<div class="weui-tabbar__icon">
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M9.17 6l2 2H20v10H4V6h5.17M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000">
<path d="M0 0h24v24H0V0z" fill="none" />
<path d="M9.17 6l2 2H20v10H4V6h5.17M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z" />
</svg>
</div>
<p id="t4_title" aria-hidden="true" class="weui-tabbar__label">本地</p>
</div>

@ -13,7 +13,7 @@ function push() {
}
function setting() {
doAction('setting', { text: $('#setting_text').val() });
doAction('setting', { text: $('#setting_text').val(), name: $('#setting_name').val() });
}
function file(path) {

@ -6,6 +6,7 @@ public class ServerEvent {
private final Type type;
private final String text;
private final String name;
public static void search(String text) {
EventBus.getDefault().post(new ServerEvent(Type.SEARCH, text));
@ -19,9 +20,18 @@ public class ServerEvent {
EventBus.getDefault().post(new ServerEvent(Type.SETTING, text));
}
public static void setting(String text, String name) {
EventBus.getDefault().post(new ServerEvent(Type.SETTING, text, name));
}
private ServerEvent(Type type, String text) {
this(type, text, "");
}
private ServerEvent(Type type, String text, String name) {
this.type = type;
this.text = text;
this.name = name;
}
public Type getType() {
@ -32,6 +42,10 @@ public class ServerEvent {
return text;
}
public String getName() {
return name;
}
public enum Type {
SEARCH, PUSH, SETTING
}

@ -77,8 +77,9 @@ public class Action implements Process {
private void onSetting(Map<String, String> params) {
String text = params.get("text");
String name = params.get("name");
if (TextUtils.isEmpty(text)) return;
ServerEvent.setting(text);
ServerEvent.setting(text, name);
}
private void onFile(Map<String, String> params) {

Loading…
Cancel
Save