From 820d71fb07065e56b3f66b54758f8e22650a5cb3 Mon Sep 17 00:00:00 2001 From: Mygod Date: Tue, 16 Aug 2016 22:07:01 +0800 Subject: [PATCH] Add help for kcpcli (#811) * Add help for kcpcli * Filter useless parameters --- src/main/res/xml/pref_all.xml | 2 +- .../preferences/KcpCliPreference.scala | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/scala/com/github/shadowsocks/preferences/KcpCliPreference.scala diff --git a/src/main/res/xml/pref_all.xml b/src/main/res/xml/pref_all.xml index 25cbd4a0..befdccf0 100644 --- a/src/main/res/xml/pref_all.xml +++ b/src/main/res/xml/pref_all.xml @@ -94,7 +94,7 @@ android:summary="@string/kcp_port_summary" android:title="@string/kcp_port"/> - { + val dialog = new AlertDialog.Builder(context) + .setTitle("?") + .setMessage(asScalaBuffer(Shell.SH.run(context.getApplicationInfo.dataDir + "/kcptun --help")) + .dropWhile(line => line != "GLOBAL OPTIONS:") + .drop(1) + .takeWhile(line => line.length() > 3) + .filter(line => + !line.startsWith(" --localaddr ") && + !line.startsWith(" --remoteaddr ") && + !line.startsWith(" --path ") && + !line.startsWith(" --help,") && + !line.startsWith(" --version,")) + .mkString("\n")) + .show() + val window = dialog.getWindow + val attrs = window.getAttributes + attrs.width = ViewGroup.LayoutParams.MATCH_PARENT + window.setAttributes(attrs) + }): DialogInterface.OnClickListener) + } +}