From 292410895d276fbf1eaf013412301192265c89cb Mon Sep 17 00:00:00 2001 From: litongzhou Date: Thu, 17 Jun 2021 14:58:35 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bluetooth/BluetoothAdapter.md | 45 +++++++++++++++++ graphics/drawable/GradientDrawable.md | 10 ++++ graphics/drawable/StateListDrawable.md | 44 ++++++++++++++++ os/Looper.md | 42 ++++++++++++++++ view/LayoutInflater.md | 5 ++ view/MotionEvent.md | 12 +++++ view/VelocityTracker.md | 70 ++++++++++++++++++++++++++ view/View.MeasureSpec.md | 47 +++++++++++++++++ view/ViewTreeObserver.md | 28 +++++++++++ widget/FrameLayout.md | 13 +++++ widget/ImageView.md | 17 +++++++ 11 files changed, 333 insertions(+) create mode 100644 bluetooth/BluetoothAdapter.md create mode 100644 graphics/drawable/StateListDrawable.md create mode 100644 os/Looper.md create mode 100644 view/LayoutInflater.md create mode 100644 view/MotionEvent.md create mode 100644 view/VelocityTracker.md create mode 100644 view/View.MeasureSpec.md create mode 100644 view/ViewTreeObserver.md create mode 100644 widget/FrameLayout.md create mode 100644 widget/ImageView.md diff --git a/bluetooth/BluetoothAdapter.md b/bluetooth/BluetoothAdapter.md new file mode 100644 index 0000000..3e01684 --- /dev/null +++ b/bluetooth/BluetoothAdapter.md @@ -0,0 +1,45 @@ +### **disable** +>+ openharmony API:ohos.bluetooth.BluetoothHost.disableBt +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:BluetoothHost.disableBt() + +### **enable** +>+ openharmony API:ohos.bluetooth.BluetoothHost.enableBt +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:BluetoothHost.enableBt() + +>+ 补充说明:调用enableBt()前需要判断蓝牙状态,直接调用hui会弹出蓝牙开关的对话框 + if (bluetoothHost.getBtState()== BluetoothHost.STATE_OFF){ + //此API会弹出蓝牙开关的对话框,需要配置"ohos.permission.DISCOVER_BLUETOOTH"权限 + bluetoothHost.enableBt(); + } + +### **cancelDiscovery** +>+ openharmony API:ohos.bluetooth.BluetoothHost.cancelBtDiscovery +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:bluetoothHost.cancelBtDiscovery() + +### **checkBluetoothAddress** +>+ openharmony API:ohos.bluetooth.BluetoothHost.isValidBluetoothAddr +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:bluetoothHost.isValidBluetoothAddr(String) + +### **isEnabled** +>+ openharmony API:ohos.bluetooth.BluetoothHost.getBtState +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:使用bluetoothHost.getBtState()获取蓝牙状态,再调用enableBt()方法 + +### **getName** +>+ openharmony API:ohos.bluetooth.BluetoothHost.getLocalName +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:bluetoothHost.getLocalName() + + + + diff --git a/graphics/drawable/GradientDrawable.md b/graphics/drawable/GradientDrawable.md index f2dd698..6771386 100644 --- a/graphics/drawable/GradientDrawable.md +++ b/graphics/drawable/GradientDrawable.md @@ -31,4 +31,14 @@ ```java shapeElement.setRgbColor(new RgbColor(color)); shapeElement.setAlpha(alpha); + ``` + +### **setCornerRadii** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + ShapeElement leftItemPressedDrawable = new ShapeElement(); + leftItemPressedDrawable.setCornerRadiiArray(new float[]{}); ``` \ No newline at end of file diff --git a/graphics/drawable/StateListDrawable.md b/graphics/drawable/StateListDrawable.md new file mode 100644 index 0000000..86952d8 --- /dev/null +++ b/graphics/drawable/StateListDrawable.md @@ -0,0 +1,44 @@ +### **GradientDrawable()** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + ShapeElement shapeElement = new ShapeElement(); + ``` +### **setCornerRadius(float radius)** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + shapeElement.setShape(ShapeElement.RECTANGLE);//根据不同的形状传不同的参数 + shapeElement.setCornerRadius(raduis); + ``` +### **setStroke(int width, int color)** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + shapeElement.setStroke(strokeWidth, new RgbColor(strokeColor)); + ``` +### **setColor(int argb)** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + shapeElement.setRgbColor(new RgbColor(color)); + shapeElement.setAlpha(alpha); + ``` + +### **setCornerRadii** +>+ openharmony API: `ohos.agp.components.element.ShapeElement` +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + ```java + ShapeElement leftItemPressedDrawable = new ShapeElement(); + leftItemPressedDrawable.setCornerRadiiArray(new float[]{}); + ``` \ No newline at end of file diff --git a/os/Looper.md b/os/Looper.md new file mode 100644 index 0000000..4fad022 --- /dev/null +++ b/os/Looper.md @@ -0,0 +1,42 @@ +### **prepare** +>+ openharmony API:ohos.eventhandler.EventRunner.create +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **prepareMainLooper** +>+ openharmony API:ohos.eventhandler.EventRunner.create +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **myLooper** +>+ openharmony API:ohos.eventhandler.EventRunner.current +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **isCurrentThread** +>+ openharmony API:ohos.eventhandler.EventRunner.isCurrentRunnerThread +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **getMainLooper** +>+ openharmony API:ohos.eventhandler.EventRunner.getMainEventRunner +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **loop** +>+ openharmony API:ohos.eventhandler.EventRunner.run +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **quit** +>+ openharmony API:ohos.eventhandler.EventRunner.stop +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + diff --git a/view/LayoutInflater.md b/view/LayoutInflater.md new file mode 100644 index 0000000..e283e06 --- /dev/null +++ b/view/LayoutInflater.md @@ -0,0 +1,5 @@ +### **inflate** +>+ openharmony API:ohos.agp.components.LayoutScatter.parse +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 \ No newline at end of file diff --git a/view/MotionEvent.md b/view/MotionEvent.md new file mode 100644 index 0000000..c86fe75 --- /dev/null +++ b/view/MotionEvent.md @@ -0,0 +1,12 @@ +### **getActionIndex** +>+ openharmony API: ohos.multimodalinput.event.TouchEvent.getIndex +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + +### **getActionMasked** +>+ openharmony API: ohos.multimodalinput.event.TouchEvent.getAction +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + diff --git a/view/VelocityTracker.md b/view/VelocityTracker.md new file mode 100644 index 0000000..637ee65 --- /dev/null +++ b/view/VelocityTracker.md @@ -0,0 +1,70 @@ + +### **obtain** +>+ openharmony API: ohos.agp.components.VelocityDetector.obtainInstance +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:直接替换 + + +### **addMovement** +>+ openharmony API: ohos.agp.components.VelocityDetector.addEvent +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: +```java +VelocityDetector detector = VelocityDetector.obtainInstance(); +detector.addEvent(touchEvent); +``` + +### **computeCurrentVelocity** +>+ openharmony API: ohos.agp.components.VelocityDetector.calculateCurrentVelocity +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: +```java +VelocityDetector detector = VelocityDetector.obtainInstance(); +detector.calculateCurrentVelocity(units, maxVxVelocity, maxVyVelocity); +``` +>+ 注意事项:给TouchEvent事件添加惯性(VelocityDetector)的时候必须要按如下顺序才可以正常获取到VelocityDetector的数值,否则数值会一直是0 +顺序如下: +VelocityDetector detector = VelocityDetector.obtainInstance(); +detector.addEvent(touchEvent); +detector.calculateCurrentVelocity(1000, 10000, 10000); +float velocity = detector.getVerticalVelocity(); + + +### **getXVelocity** +>+ openharmony API: ohos.agp.components.VelocityDetector.getHorizontalVelocity +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + +```java +VelocityDetector detector = VelocityDetector.obtainInstance(); +// 必须先调用computeCurrentVelocity方法 +detector.getHorizontalVelocity(); +``` + + +### **getYVelocity** +>+ openharmony API: ohos.agp.components.VelocityDetector.getVerticalVelocity +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + +```java +VelocityDetector detector = VelocityDetector.obtainInstance(); +// 必须先调用computeCurrentVelocity方法 +detector.getVerticalVelocity(); +``` + +### **clear** +>+ openharmony API: ohos.agp.components.VelocityDetector.clear +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:替换使用,使用方法如下: + +```java +VelocityDetector detector = VelocityDetector.obtainInstance(); +detector.clear(); +``` \ No newline at end of file diff --git a/view/View.MeasureSpec.md b/view/View.MeasureSpec.md new file mode 100644 index 0000000..c533379 --- /dev/null +++ b/view/View.MeasureSpec.md @@ -0,0 +1,47 @@ +### **UNSPECIFIED** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.UNCONSTRAINT +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + + +### **EXACTLY** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.PRECISE +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + + +### **AT_MOST** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.NOT_EXCEED +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + + +### **MODE_MASK** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.ESTIMATED_STATE_BIT_MASK +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + + +### **makeMeasureSpec** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.getSizeWithMode +>+ openharmony SDK版本:2.1.0.17 +>+ IDE版本:2.1.0.141 +>+ 实现方案:直接替换 + + +### **getMode** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.getMode +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 + + +### **getSize** +>+ openharmony API: ohos.agp.components.Component$EstimateSpec.getSize +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:直接替换 diff --git a/view/ViewTreeObserver.md b/view/ViewTreeObserver.md new file mode 100644 index 0000000..fe142bf --- /dev/null +++ b/view/ViewTreeObserver.md @@ -0,0 +1,28 @@ +### **OnGlobalLayoutListener** +>+ openharmony API: ohos.agp.components.ComponentTreeObserver.WindowBoundListener +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +使用addTreeLayoutChangedListener调用,监听没有回调,故使用addWindowBoundListener来进行替换,需要注意,该替换只会在首次Window添加Components后调用,不会像原库一样,Layout变化后,每次都会调用,需要自己具体情况自行考虑,手动触发监听。手动调用如下: ComponentTreeObserver.WindowBoundListener.onWindowBound(); + +``` +componentView.getComponentTreeObserver().addWindowBoundListener( + new ComponentTreeObserver.WindowBoundListener() { + + @Override + public void onWindowBound() { + componentView.this.layout.onWindowBound(); + } + + @Override + public void onWindowUnbound() { + try { + componentView.getComponentTreeObserver().removeWindowBoundListener(this); + }catch (Exception e){ + e.printStackTrace(); + } + } + + }); + +``` \ No newline at end of file diff --git a/widget/FrameLayout.md b/widget/FrameLayout.md new file mode 100644 index 0000000..6717f08 --- /dev/null +++ b/widget/FrameLayout.md @@ -0,0 +1,13 @@ +### **LayoutParams** +>+ openharmony API:ohos.agp.components.StackLayout.LayoutConfig +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java + StackLayout.LayoutConfig layoutParams = new StackLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT); + layoutParams.setMarginLeft(borderMargin); + layoutParams.setMarginTop(topMargin); + layoutParams.setMarginRight(borderMargin); + layoutParams.setMarginBottom(bottomMargin); + view.setLayoutConfig(layoutParams); +``` \ No newline at end of file diff --git a/widget/ImageView.md b/widget/ImageView.md new file mode 100644 index 0000000..ac6cb10 --- /dev/null +++ b/widget/ImageView.md @@ -0,0 +1,17 @@ +### **setColorFilter** +>+ openharmony API:暂无 +>+ openharmony SDK版本:2.1.1.21 +>+ IDE版本:2.1.0.501 +>+ 实现方案:自行实现,使用方法如下: +```java +public static void setImageTint(Element element, int intColor, BlendMode mode, Image image) { + int[] colors = new int[]{intColor, intColor}; + int[][] states = new int[2][]; + states[0] = new int[]{0}; + states[1] = new int[]{0}; + element.setStateColorList(states, colors); + element.setStateColorMode(mode); + image.setImageElement(element); + } + +``` \ No newline at end of file -- Gitee From dc34a56316c625ef4dff152189b197c3563d0773 Mon Sep 17 00:00:00 2001 From: litongzhou Date: Thu, 17 Jun 2021 15:07:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A7=BB=E6=A4=8D?= =?UTF-8?q?=E5=8C=96=E6=96=B9=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view/View.MeasureSpec.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/view/View.MeasureSpec.md b/view/View.MeasureSpec.md index c533379..c731e75 100644 --- a/view/View.MeasureSpec.md +++ b/view/View.MeasureSpec.md @@ -27,10 +27,16 @@ ### **makeMeasureSpec** ->+ openharmony API: ohos.agp.components.Component$EstimateSpec.getSizeWithMode +>+ openharmony API: 暂无 >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 ->+ 实现方案:直接替换 +>+ 实现方案:暂无相关替换,可以自行实现。 + +```java +public static int makeEstimateSpec(int size, int mode) { + return (size & ~EstimateSpec.ESTIMATED_STATE_BIT_MASK) | (mode & EstimateSpec.ESTIMATED_STATE_BIT_MASK); +} +``` ### **getMode** -- Gitee