Add help for kcpcli (#811)
* Add help for kcpcli * Filter useless parameters
This commit is contained in:
@@ -94,7 +94,7 @@
|
||||
android:summary="@string/kcp_port_summary"
|
||||
android:title="@string/kcp_port"/>
|
||||
|
||||
<com.github.shadowsocks.preferences.SummaryEditTextPreference
|
||||
<com.github.shadowsocks.preferences.KcpCliPreference
|
||||
android:key="kcpcli"
|
||||
android:persistent="false"
|
||||
android:summary="@string/kcpcli_summary"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.github.shadowsocks.preferences
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.content.{Context, DialogInterface}
|
||||
import android.util.AttributeSet
|
||||
import android.view.ViewGroup
|
||||
import eu.chainfire.libsuperuser.Shell
|
||||
|
||||
import scala.collection.JavaConversions._
|
||||
|
||||
/**
|
||||
* @author Mygod
|
||||
*/
|
||||
class KcpCliPreference(context: Context, attrs: AttributeSet) extends SummaryEditTextPreference(context, attrs) {
|
||||
override def onPrepareDialogBuilder(builder: AlertDialog.Builder) {
|
||||
super.onPrepareDialogBuilder(builder)
|
||||
builder.setNeutralButton("?", ((_, _) => {
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user