fix
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.host900.goproxy;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
@@ -10,6 +12,8 @@ import android.net.Uri;
|
||||
import android.net.wifi.WifiInfo;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
@@ -35,12 +39,24 @@ public class MainActivity extends AppCompatActivity {
|
||||
String serviceID = "srv";
|
||||
int log_line_cnt = 0;
|
||||
|
||||
EditText log ;
|
||||
|
||||
Handler handler=new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
String line=msg.getData().getString("line");
|
||||
if (++log_line_cnt > 100) {
|
||||
log.setText("");
|
||||
}
|
||||
log.append(line + "\n");
|
||||
}
|
||||
};
|
||||
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
final EditText editText = findViewById(R.id.input);
|
||||
|
||||
SharedPreferences config = getSharedPreferences("config", Context.MODE_PRIVATE);
|
||||
final SharedPreferences.Editor editor = config.edit();
|
||||
|
||||
@@ -49,13 +65,32 @@ public class MainActivity extends AppCompatActivity {
|
||||
editText.addTextChangedListener(watcher(editor, editText));
|
||||
|
||||
TextView status = findViewById(R.id.tv_status);
|
||||
EditText log = (EditText)findViewById(R.id.log_output);
|
||||
log = (EditText) findViewById(R.id.log_output);
|
||||
TextView tip = findViewById(R.id.tip);
|
||||
TextView ipaddrs = findViewById(R.id.ip_addrs);
|
||||
String sdkVersion = Proxysdk.version();
|
||||
TextView viewManual = findViewById(R.id.view_manual);
|
||||
TextView joinQQ = findViewById(R.id.join_qq_group);
|
||||
|
||||
ipaddrs.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData mClipData = ClipData.newPlainText("ip", ((TextView)view).getText());
|
||||
cm.setPrimaryClip(mClipData);
|
||||
Toast.makeText(view.getContext(), "IP已经复制", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
joinQQ.setOnLongClickListener(new View.OnLongClickListener() {
|
||||
@Override
|
||||
public boolean onLongClick(View view) {
|
||||
ClipboardManager cm = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
ClipData mClipData = ClipData.newPlainText("qq", ((TextView)view).getText());
|
||||
cm.setPrimaryClip(mClipData);
|
||||
Toast.makeText(view.getContext(), "QQ群号码已复制", Toast.LENGTH_LONG).show();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
//ui
|
||||
viewManual.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG); //下划线
|
||||
viewManual.getPaint().setAntiAlias(true);//抗锯齿
|
||||
@@ -73,7 +108,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
findViewById(R.id.btn_start).setOnClickListener(start(log, status, editText, this));
|
||||
findViewById(R.id.btn_stop).setOnClickListener(stop(status, editText));
|
||||
viewManual.setOnClickListener(openURL("https://snail007.github.io/goproxy/manual/zh/#/"));
|
||||
joinQQ.setOnClickListener(openURL("https://jq.qq.com/?_wv=1027&k=5G2EwxR"));
|
||||
// joinQQ.setOnClickListener(openURL("https://jq.qq.com/?_wv=1027&k=5G2EwxR"));
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -95,16 +130,22 @@ public class MainActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
String args = editText.getText().toString().trim();
|
||||
if(args.indexOf("proxy")==0&&args.length()>=5){
|
||||
args=args.substring(5);
|
||||
if (args.indexOf("proxy") == 0 && args.length() >= 5) {
|
||||
args = args.substring(5);
|
||||
}
|
||||
if (args.replaceAll("\n","").length() == 0) {
|
||||
Toast.makeText(ctx, "参数不能为空", Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
String err = Proxysdk.startWithLog(serviceID, args, "", new LogCallback() {
|
||||
@Override
|
||||
public void write(String line) {
|
||||
if (++log_line_cnt > 100) {
|
||||
log.setText("");
|
||||
}
|
||||
log.append(line + "\n");
|
||||
Message msg=Message.obtain();
|
||||
msg.what=1;
|
||||
Bundle bundle=new Bundle();
|
||||
bundle.putString("line", line);
|
||||
msg.setData(bundle);
|
||||
handler.sendMessage(msg);
|
||||
}
|
||||
});
|
||||
if (!err.isEmpty()) {
|
||||
@@ -118,7 +159,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
};
|
||||
}
|
||||
|
||||
public View.OnClickListener openURL(final String u) {
|
||||
public View.OnClickListener openURL(final String u) {
|
||||
|
||||
return new View.OnClickListener() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<solid android:color="#FFFFFF"/>
|
||||
|
||||
<stroke
|
||||
android:width="0.5dp"
|
||||
android:color="#dddddd"/>
|
||||
|
||||
<padding
|
||||
android:bottom="10dp"
|
||||
android:left="10dp"
|
||||
android:right="10dp"
|
||||
android:top="10dp"/>
|
||||
|
||||
<corners android:radius="10dp"/>
|
||||
|
||||
</shape>
|
||||
@@ -26,20 +26,15 @@
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="39dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="不会用?点击:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_manual"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="all"
|
||||
android:paddingLeft="10px"
|
||||
android:text="使用手册"
|
||||
android:textColor="#2D40AD"
|
||||
android:textStyle="bold" />
|
||||
@@ -48,13 +43,13 @@
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="欢迎加官方QQ交流群:" />
|
||||
android:text="官方QQ群:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/join_qq_group"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="all"
|
||||
android:autoLink="none"
|
||||
android:text="42805407"
|
||||
android:textColor="#F00"
|
||||
android:textStyle="bold" />
|
||||
@@ -69,9 +64,9 @@
|
||||
|
||||
<EditText
|
||||
android:id="@+id/input"
|
||||
style="@style/Base.Widget.MaterialComponents.TextInputEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:background="@drawable/log_shape"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
@@ -90,7 +85,7 @@
|
||||
style="@style/Widget.AppCompat.Button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:background="#66cc66"
|
||||
android:onClick="start"
|
||||
android:text="启动"
|
||||
@@ -102,27 +97,36 @@
|
||||
style="@style/Widget.AppCompat.Button"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="10dp"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:background="#e6e6e6"
|
||||
android:text="停止"
|
||||
android:textColor="#777"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="状态:" />
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:text="已停止"
|
||||
android:textColor=" #ff1a1a"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:text="状态:" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="已停止"
|
||||
android:textColor=" #ff1a1a"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
@@ -133,15 +137,13 @@
|
||||
<TextView
|
||||
android:id="@+id/ip_addrs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="20dp"
|
||||
android:paddingLeft="10dp" />
|
||||
|
||||
android:layout_height="wrap_content"/>
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="10dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:text="日志:" />
|
||||
|
||||
<EditText
|
||||
@@ -149,14 +151,12 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/log_shape"
|
||||
android:clickable="true"
|
||||
android:focusable="false"
|
||||
android:gravity="top"
|
||||
android:inputType="textMultiLine"
|
||||
android:lines="8"
|
||||
android:lines="5"
|
||||
android:scrollbars="vertical"
|
||||
android:singleLine="false"
|
||||
android:text="" />
|
||||
android:singleLine="false" />
|
||||
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
||||
Reference in New Issue
Block a user