android: devkit support add port

This commit is contained in:
pengfei.zhou 2023-08-11 16:25:07 +08:00 committed by jingpeng
parent b61699a450
commit aa7820a3b3
3 changed files with 100 additions and 46 deletions

View File

@ -85,8 +85,8 @@ public class DoricDev {
} }
public void closeDevMode() { public void closeDevMode() {
stopDebugging(true);
if (wsClient != null) { if (wsClient != null) {
stopDebugging(true);
wsClient.close(); wsClient.close();
wsClient = null; wsClient = null;
} }
@ -172,9 +172,11 @@ public class DoricDev {
} }
public void stopDebugging(final boolean resume) { public void stopDebugging(final boolean resume) {
if (wsClient != null) {
wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder() wsClient.sendToDebugger("DEBUG_STOP", new JSONBuilder()
.put("msg", "Stop debugging") .put("msg", "Stop debugging")
.toJSONObject()); .toJSONObject());
}
if (debuggable != null) { if (debuggable != null) {
uiHandler.post(new Runnable() { uiHandler.post(new Runnable() {
@Override @Override

View File

@ -122,7 +122,13 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
} }
if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) { if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
String result = bundle.getString(CodeUtils.RESULT_STRING); String result = bundle.getString(CodeUtils.RESULT_STRING);
DoricDev.getInstance().connectDevKit("ws://" + result + ":7777"); if (!result.contains(":")) {
result = result + ":7777";
}
if (!result.contains("://")) {
result = "ws://" + result;
}
DoricDev.getInstance().connectDevKit(result);
} }
} }
} }
@ -187,8 +193,14 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
String ip = editText.getText().toString(); String url = editText.getText().toString();
DoricDev.getInstance().connectDevKit("ws://" + ip + ":7777"); if (!url.contains(":")) {
url = url + ":7777";
}
if (!url.contains("://")) {
url = "ws://" + url;
}
DoricDev.getInstance().connectDevKit(url);
} }
}) })
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { .setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

View File

@ -14,6 +14,7 @@
android:paddingRight="15dp" android:paddingRight="15dp"
android:paddingBottom="5dp"> android:paddingBottom="5dp">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -24,7 +25,8 @@
android:textSize="30dp" /> android:textSize="30dp" />
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="vertical"> android:orientation="vertical">
@ -47,11 +49,6 @@
android:textColor="#dfe4ea" android:textColor="#dfe4ea"
android:textSize="12dp" /> android:textSize="12dp" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView <TextView
android:id="@+id/tv_input" android:id="@+id/tv_input"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -97,8 +94,23 @@
android:textColor="#dfe4ea" android:textColor="#dfe4ea"
android:textSize="15dp" android:textSize="15dp"
android:visibility="visible" /> android:visibility="visible" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout> </LinearLayout>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollIndicators="none">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -121,6 +133,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_marginLeft="20dp"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
@ -140,7 +153,34 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="10dp" /> android:layout_marginLeft="10dp" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_marginLeft="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Mask"
android:textColor="#dfe4ea"
android:textSize="15dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch_mask"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
</LinearLayout> </LinearLayout>
</LinearLayout>
</HorizontalScrollView>
</LinearLayout>
</LinearLayout> </LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView