diff --git a/bluetooth/BluetoothAdapter.md b/bluetooth/BluetoothAdapter.md new file mode 100644 index 0000000000000000000000000000000000000000..3e01684680a7a714399c31f552fdf90a049419d9 --- /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 f2dd6989f8358d07f0accee6132d729ca6bc911e..677138676802674582c520485becd7c603379289 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 0000000000000000000000000000000000000000..86952d80d9efef40386d30b862b63fa80eadc89f --- /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 0000000000000000000000000000000000000000..4fad0227fca1ae5c62e6e1a27ab508ff9da53859 --- /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 0000000000000000000000000000000000000000..e283e0639acbaa8f86a9009ea2518b831e961c08 --- /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 0000000000000000000000000000000000000000..c86fe75b200e8c3c08983d44db1db8b2bd8b5d55 --- /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 0000000000000000000000000000000000000000..637ee65ae66923ea9cf5b1eebc5c7e280a49b9d8 --- /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 0000000000000000000000000000000000000000..c533379bb5d8869443eead907c783777e6021d0f --- /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 0000000000000000000000000000000000000000..fe142bf3751223480979e5ca0adb2908c3a85ebc --- /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 0000000000000000000000000000000000000000..6717f08d2e815fa2d98ddbdc99bc8bf83de09b86 --- /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 0000000000000000000000000000000000000000..ac6cb10c39b43cd113d1df8fc543a28d13913523 --- /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