From b60fffd055b4f90a9b3214ce0f9c8e5910f95fff Mon Sep 17 00:00:00 2001 From: pengfeizhou Date: Thu, 25 Feb 2021 12:43:22 +0800 Subject: [PATCH] feat:update assets and set ip for input --- .../app/src/main/java/pub/doric/demo/MainActivity.java | 2 +- .../devkit/src/main/java/pub/doric/devkit/DoricDev.java | 2 +- .../src/main/java/pub/doric/devkit/ui/DoricDevActivity.java | 6 ++++++ doric-demo/.vscode/tasks.json | 6 +++--- doric-demo/src/Counter.ts | 6 +++--- doric-iOS/Devkit/Classes/DoricDevViewController.m | 3 +++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java index fcfed697..8dc1ed2a 100644 --- a/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java +++ b/doric-android/app/src/main/java/pub/doric/demo/MainActivity.java @@ -120,7 +120,7 @@ public class MainActivity extends AppCompatActivity { public void onClick(View v) { Intent intent = new Intent(tv.getContext(), DoricActivity.class); intent.putExtra("source", "assets://src/" + data[position - 1]); - intent.putExtra("alias", data[position - 1]); + intent.putExtra("alias", data[position - 1].replace(".js", "")); tv.getContext().startActivity(intent); } }); diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index 576658f4..e4a4a33b 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -101,7 +101,7 @@ public class DoricDev { } public String getIP() { - if (wsClient != null) { + if (url != null) { return url.replace("ws://", "").replace(":7777", ""); } else { return "0.0.0.0"; diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java index 373cabae..7cc5003e 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/ui/DoricDevActivity.java @@ -10,6 +10,7 @@ import android.graphics.BitmapFactory; import android.graphics.Color; import android.graphics.drawable.BitmapDrawable; import android.os.Bundle; +import android.text.TextUtils; import android.util.Base64; import android.view.LayoutInflater; import android.view.View; @@ -152,6 +153,11 @@ public class DoricDevActivity extends AppCompatActivity implements DoricDev.Stat View v = LayoutInflater.from(DoricDevActivity.this).inflate(R.layout.doric_modal_prompt, null); final EditText editText = v.findViewById(R.id.edit_input); editText.setHint("192.168.1.1"); + String ip = DoricDev.getInstance().getIP(); + if (!TextUtils.isEmpty(ip)) { + editText.setText(ip); + editText.setSelection(ip.length()); + } builder.setView(v); builder .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { diff --git a/doric-demo/.vscode/tasks.json b/doric-demo/.vscode/tasks.json index d51f6710..da0e1c93 100644 --- a/doric-demo/.vscode/tasks.json +++ b/doric-demo/.vscode/tasks.json @@ -6,21 +6,21 @@ { "label": "Doric Build", "type": "shell", - "command": "doric build", + "command": "npm run build", "group": "build", "problemMatcher": [] }, { "label": "Doric Clean", "type": "shell", - "command": "doric clean", + "command": "npm run clean", "group": "build", "problemMatcher": [] }, { "label": "Doric Dev", "type": "shell", - "command": "doric dev", + "command": "npm run dev", "group": "build", "problemMatcher": [] } diff --git a/doric-demo/src/Counter.ts b/doric-demo/src/Counter.ts index 13235e56..8a50e7f5 100644 --- a/doric-demo/src/Counter.ts +++ b/doric-demo/src/Counter.ts @@ -59,9 +59,9 @@ class CounterVM extends ViewModel { } onBind(s: CountModel, vh: CounterView) { vh.number.text = `${s.count}`; - log("onBind"); - logw("onBind"); - loge("onBind"); + log(`Current count is ${s.count}`); + logw(`Current count is ${s.count}`); + loge(`Current count is ${s.count}`); } } diff --git a/doric-iOS/Devkit/Classes/DoricDevViewController.m b/doric-iOS/Devkit/Classes/DoricDevViewController.m index 97e88f2e..e2f71df3 100644 --- a/doric-iOS/Devkit/Classes/DoricDevViewController.m +++ b/doric-iOS/Devkit/Classes/DoricDevViewController.m @@ -194,6 +194,9 @@ - (void)input { preferredStyle:UIAlertControllerStyleAlert]; [alert addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) { textField.placeholder = @"192.168.1.1"; + if (DoricDev.instance.ip) { + textField.text = DoricDev.instance.ip; + } }]; __weak typeof(alert) _alert = alert;