From 894302e52028aec21fa5d3cc40f6c12c593c7c80 Mon Sep 17 00:00:00 2001 From: zm <87072237@qq.com> Date: Fri, 25 Jun 2021 09:35:57 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- androidx/core/content/ContextCompat.md | 9 + .../recyclerview/widget/ItemTouchHelper.md | 65 ++++++ androidx/viewpager/widget/ViewPager.md | 78 +++++++ animation/Animator.md | 77 +++++++ animation/AnimatorListenerAdapter.md | 41 ++++ animation/AnimatorSet.md | 28 +++ animation/PropertyValuesHolder.md | 17 ++ animation/ValueAnimator.md | 38 +++ app/Activity.md | 15 ++ app/AlertDialog.md | 27 +++ app/Application.md | 12 + app/Builder.md | 46 ++++ app/Dialog.md | 46 ++++ app/usage/NetworkStatsManager.md | 11 + app/usage/UsageStatsManager.md | 10 + arch/persistence/room/RoomDatabase.md | 65 ++++++ content/BroadcastReceiver.md | 14 ++ content/ContentResolver.md | 10 + content/ContentValues.md | 54 +++++ content/Context.md | 14 +- content/Intent.md | 39 ++++ content/SharedPreferences.md | 69 ++++++ content/pm/ApplicationInfo.md | 15 ++ content/pm/PackageManager.md | 20 ++ content/res/Configuration.md | 10 + content/res/Resources.md | 9 + content/res/TypedArray.md | 12 +- database/sqlite/SQLiteOpenHelper.md | 19 ++ graphics/Bitmap.md | 15 +- graphics/BitmapFactory.md | 20 ++ graphics/Canvas.md | 63 ++++- graphics/Color.md | 18 ++ graphics/DashPathEffect.md | 11 + graphics/LinearGradient.md | 11 + graphics/Matrix.md | 38 +++ graphics/NinePatch.md | 18 ++ graphics/Paint.md | 19 ++ graphics/Path.md | 16 ++ graphics/PathMeasure.md | 38 +++ graphics/Rect.md | 34 +++ graphics/Shader.md | 9 + graphics/drawable/ColorDrawable.md | 10 + graphics/drawable/Drawable.md | 40 +++- hardware/Camera.md | 19 ++ hardware/Hardware.md | 13 ++ location/location.md | 64 ++++++ media/MediaPlayer.md | 132 +++++++++++ nekocode/camerafilter/NekoCode.md | 10 + net/ProxyInfo.md | 21 ++ net/Uri.md | 11 + net/wifi/WifiConfiguration.md | 9 + net/wifi/WifiManager.md | 20 ++ opengl/GLES11Ext.md | 12 + opengl/GLES20.md | 12 + org/org.md | 31 +++ os/Handler.md | 10 + os/Vibrator.md | 36 +++ provider/provider.md | 10 + support/design/widget/Snackbar.md | 12 + support/v4/app/FragmentActivity.md | 14 ++ support/v4/app/PagerAdapter.md | 9 + support/v4/view/ViewPager.md | 26 +++ support/v4/widget/ScrollerCompat.md | 73 ++++++ support/v7/app/AppCompatActivity.md | 10 + support/v7/widget/LinearLayoutManager.md | 11 + support/v7/widget/RecyclerView.md | 52 +++++ support/v7/widget/SwitchCompat.md | 42 ++++ .../v8/renderscript/ScriptIntrinsicBlur.md | 23 ++ support/wearable/view/WearableListView.md | 26 +++ telephony/TelephonyManager.md | 217 ++++++++++++++++++ telephony/telephony.md | 75 ++++++ text/Editable.md | 10 + text/TextPaint.md | 39 ++++ text/TextUtils.md | 4 +- util/AttributeSet.md | 10 + util/DisplayMetrics.md | 13 ++ util/Log.md | 12 + util/Pair.md | 10 + util/SparseArray.md | 11 + view/Display.md | 9 + view/Gravity.md | 10 + view/Menu.md | 19 ++ view/OnClickListener.md | 15 ++ view/SurfaceView.md | 9 + view/TextureView.md | 9 + view/VelocityTracker.md | 24 ++ view/ViewGroup.md | 21 ++ view/ViewParent.md | 55 +++++ view/Window.md | 32 +++ view/WindowManager.md | 14 +- view/animation/DecelerateInterpolator.md | 10 + widget/CompoundButton.md | 16 ++ widget/EditText.md | 9 + widget/ImageView.md | 2 +- widget/LinearLayout.md | 9 + widget/ProgressBar.md | 35 +++ widget/RadioButton.md | 13 ++ widget/RadioGroup.md | 12 + widget/RatingBar.md | 21 ++ widget/SeekBar.md | 13 ++ widget/Spinner.md | 31 +++ widget/Switch.md | 16 ++ widget/TextView.md | 50 ++++ widget/Toast.md | 18 ++ 104 files changed, 2801 insertions(+), 10 deletions(-) create mode 100644 androidx/core/content/ContextCompat.md create mode 100644 androidx/recyclerview/widget/ItemTouchHelper.md create mode 100644 androidx/viewpager/widget/ViewPager.md create mode 100644 animation/Animator.md create mode 100644 animation/AnimatorListenerAdapter.md create mode 100644 animation/AnimatorSet.md create mode 100644 animation/PropertyValuesHolder.md create mode 100644 app/AlertDialog.md create mode 100644 app/Application.md create mode 100644 app/Builder.md create mode 100644 app/Dialog.md create mode 100644 app/usage/NetworkStatsManager.md create mode 100644 app/usage/UsageStatsManager.md create mode 100644 arch/persistence/room/RoomDatabase.md create mode 100644 content/BroadcastReceiver.md create mode 100644 content/ContentValues.md create mode 100644 content/Intent.md create mode 100644 content/SharedPreferences.md create mode 100644 content/pm/ApplicationInfo.md create mode 100644 content/pm/PackageManager.md create mode 100644 content/res/Configuration.md create mode 100644 content/res/Resources.md create mode 100644 database/sqlite/SQLiteOpenHelper.md create mode 100644 graphics/Color.md create mode 100644 graphics/DashPathEffect.md create mode 100644 graphics/LinearGradient.md create mode 100644 graphics/NinePatch.md create mode 100644 graphics/PathMeasure.md create mode 100644 graphics/Rect.md create mode 100644 graphics/Shader.md create mode 100644 graphics/drawable/ColorDrawable.md create mode 100644 hardware/Camera.md create mode 100644 hardware/Hardware.md create mode 100644 location/location.md create mode 100644 media/MediaPlayer.md create mode 100644 nekocode/camerafilter/NekoCode.md create mode 100644 net/ProxyInfo.md create mode 100644 net/Uri.md create mode 100644 net/wifi/WifiConfiguration.md create mode 100644 net/wifi/WifiManager.md create mode 100644 opengl/GLES11Ext.md create mode 100644 opengl/GLES20.md create mode 100644 org/org.md create mode 100644 os/Vibrator.md create mode 100644 provider/provider.md create mode 100644 support/design/widget/Snackbar.md create mode 100644 support/v4/app/FragmentActivity.md create mode 100644 support/v4/app/PagerAdapter.md create mode 100644 support/v4/view/ViewPager.md create mode 100644 support/v4/widget/ScrollerCompat.md create mode 100644 support/v7/app/AppCompatActivity.md create mode 100644 support/v7/widget/LinearLayoutManager.md create mode 100644 support/v7/widget/RecyclerView.md create mode 100644 support/v7/widget/SwitchCompat.md create mode 100644 support/v8/renderscript/ScriptIntrinsicBlur.md create mode 100644 support/wearable/view/WearableListView.md create mode 100644 telephony/TelephonyManager.md create mode 100644 telephony/telephony.md create mode 100644 text/Editable.md create mode 100644 text/TextPaint.md create mode 100644 util/AttributeSet.md create mode 100644 util/DisplayMetrics.md create mode 100644 util/Log.md create mode 100644 util/Pair.md create mode 100644 view/Display.md create mode 100644 view/Gravity.md create mode 100644 view/Menu.md create mode 100644 view/OnClickListener.md create mode 100644 view/SurfaceView.md create mode 100644 view/TextureView.md create mode 100644 view/ViewGroup.md create mode 100644 view/ViewParent.md create mode 100644 view/Window.md create mode 100644 view/animation/DecelerateInterpolator.md create mode 100644 widget/CompoundButton.md create mode 100644 widget/EditText.md create mode 100644 widget/LinearLayout.md create mode 100644 widget/ProgressBar.md create mode 100644 widget/RadioButton.md create mode 100644 widget/RadioGroup.md create mode 100644 widget/RatingBar.md create mode 100644 widget/SeekBar.md create mode 100644 widget/Spinner.md create mode 100644 widget/Switch.md create mode 100644 widget/TextView.md create mode 100644 widget/Toast.md diff --git a/androidx/core/content/ContextCompat.md b/androidx/core/content/ContextCompat.md new file mode 100644 index 0000000..cea0cb8 --- /dev/null +++ b/androidx/core/content/ContextCompat.md @@ -0,0 +1,9 @@ +### **getColor()** +>+ openharmony API: ohos.global.resource.Element.getColor() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// AbilityContext直接获取ResourceManager +int color = getResourceManager().getElement(ResourceTable.Color_aqua).getColor(); +``` diff --git a/androidx/recyclerview/widget/ItemTouchHelper.md b/androidx/recyclerview/widget/ItemTouchHelper.md new file mode 100644 index 0000000..c6af64f --- /dev/null +++ b/androidx/recyclerview/widget/ItemTouchHelper.md @@ -0,0 +1,65 @@ +### **onSaveInstanceState(Bundle bundle))** +>+ openharmony API: ohos.aafwk.ability.onPostStart(PacMap pacMap); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 当前ability 复写即可 +@Override +protected void onPostStart(PacMap pacMap) { + super.onPostStart(pacMap); +} +``` + +### **vibrateOnce(context: Context, millisecond: Int)** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.startOnce(int duration) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.startOnce(200); +``` + +### **vibrateStop();** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.vibrateStop(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.vibrateStop(); +``` + +### **setOnDrawerOpenListener(SlidingDrawer.OnDrawerOpenListener listener)** +>+ openharmony API: ohos.agp.components.SlideDrawer.addSlideListener(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +SlideDrawer slideDrawer =new SlideDrawer(this); +slideDrawer.addSlideListener(new SlideDrawer.SlideListener() { + @Override + public void onOpen(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { + + } + + @Override + public void onMiddle(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, SlideDrawer.DrawerState drawerState) { + + } + + @Override + public void onClose(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { + + } + + @Override + public void onSlideChange(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, int i, int i1) { + + } +}); +``` \ No newline at end of file diff --git a/androidx/viewpager/widget/ViewPager.md b/androidx/viewpager/widget/ViewPager.md new file mode 100644 index 0000000..3ed0776 --- /dev/null +++ b/androidx/viewpager/widget/ViewPager.md @@ -0,0 +1,78 @@ +### **setAdapter(PagerAdapter)** +>+ openharmony API: ohos.agp.components.PageSlider.setProvider(ohos.agp.components.PageSliderProvider) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置提供当前页视图的寻呼机适配器。 +PageSlider pageSlider = new PageSlider(this); + pageSlider.setProvider(new PageSliderProvider() { + @Override + public int getCount() { + return 0; + } + + @Override + public Object createPageInContainer(ComponentContainer componentContainer, int i) { + return null; + } + + @Override + public void destroyPageFromContainer(ComponentContainer componentContainer, int i, Object o) { + + } + + @Override + public boolean isPageMatchToObject(Component component, Object o) { + return false; + } + }); +``` + +### **setOffscreenPageLimit(int)** +>+ openharmony API: ohos.agp.components.PageSlider.setPageCacheSize(int) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置要保留在当前页两侧的页数。 +PageSlider pageSlider = new PageSlider(this); +pageSlider.setPageCacheSize(2); +``` + +### **addOnPageChangeListener(OnPageChangeListener)** +>+ openharmony API: ohos.agp.components.PageSlider.addPageChangedListener(ohos.agp.components.PageSlider.PageChangedListener) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 注册一个侦听器,用于侦听页面更改事件。 +PageSlider pageSlider = new PageSlider(this); +pageSlider.addPageChangedListener(new PageSlider.PageChangedListener() { + @Override + public void onPageSliding(int i, float v, int i1) { + + } + + @Override + public void onPageSlideStateChanged(int i) { + + } + + @Override + public void onPageChosen(int i) { + + } +}); +``` + +### **setCurrentItem(int)** +>+ openharmony API: ohos.agp.components.PageSlider.setCurrentPage(int) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置所选页面。 +PageSlider pageSlider = new PageSlider(this); +pageSlider.setCurrentPage(0); +``` diff --git a/animation/Animator.md b/animation/Animator.md new file mode 100644 index 0000000..672a3ac --- /dev/null +++ b/animation/Animator.md @@ -0,0 +1,77 @@ +### **setInterpolator(value: TimeInterpolator!)** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setCurve(Animator.TimelineCurve curve) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +addAnimator.setCurve(new Animator.TimelineCurve() { + @Override + public float getCurvedTime(float input) { + return input * input; + } +}); +``` + +### **removeAllListeners()** +>+ openharmony API: ohos.agp.animation.AnimatorProperty.reset() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 重置 +addAnimator.reset(); +``` + +### **addListener(listener: Animator.AnimatorListener!)** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setStateChangedListener(Animator.StateChangedListener listener) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 为动画设置状态改变监听器 + addAnimator.setStateChangedListener(new Animator.StateChangedListener() { + @Override + public void onStart(Animator animator) { + + } + + @Override + public void onStop(Animator animator) { + + } + + @Override + public void onCancel(Animator animator) { + + } + + @Override + public void onEnd(Animator animator) { + destroy(); + } + + @Override + public void onPause(Animator animator) { + + } + + @Override + public void onResume(Animator animator) { + + } + }); +``` + + +### **start()** +>+ openharmony API: ohos.agp.animation.Animator.start(); +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 动画开始 +addAnimator.start(); +``` \ No newline at end of file diff --git a/animation/AnimatorListenerAdapter.md b/animation/AnimatorListenerAdapter.md new file mode 100644 index 0000000..f2265de --- /dev/null +++ b/animation/AnimatorListenerAdapter.md @@ -0,0 +1,41 @@ +### **addListener(new AnimatorListener(){})** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setStateChangedListener(Animator.StateChangedListener listener) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 为动画设置状态改变监听器 + addAnimator.setStateChangedListener(new Animator.StateChangedListener() { + @Override + public void onStart(Animator animator) { + + } + + @Override + public void onStop(Animator animator) { + + } + + @Override + public void onCancel(Animator animator) { + + } + + @Override + public void onEnd(Animator animator) { + destroy(); + } + + @Override + public void onPause(Animator animator) { + + } + + @Override + public void onResume(Animator animator) { + + } + }); +``` + diff --git a/animation/AnimatorSet.md b/animation/AnimatorSet.md new file mode 100644 index 0000000..ffd7825 --- /dev/null +++ b/animation/AnimatorSet.md @@ -0,0 +1,28 @@ +### **setDuration(long duration)** +>+ openharmony API: ohos.agp.animation.AnimatorProperty.setDuration(long duration) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +AnimatorProperty animatorProperty = pager.createAnimatorProperty(); +// 设置动画时长 +animatorProperty.setDuration(1000); +``` + +### **playTogether(Collection items)** +>+ openharmony API: ohos.agp.animation.AnimatorProperty.reset() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置动画属性,开始动画 +AnimatorProperty animatorProperty = pager.createAnimatorProperty() + .moveFromX(-160).moveToX(20) + .moveFromY(pointY).moveToY(100) + .scaleXFrom(0.2f).scaleX(0.4f) + .scaleYFrom(0.2f).scaleY(0.4f) + .setCurveType(CUBIC_BEZIER_SMOOTH) + .setDuration(1000); +animatorProperty.start(); +``` diff --git a/animation/PropertyValuesHolder.md b/animation/PropertyValuesHolder.md new file mode 100644 index 0000000..dfe9759 --- /dev/null +++ b/animation/PropertyValuesHolder.md @@ -0,0 +1,17 @@ +### **ofFloat()** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setCurve(Animator.TimelineCurve curve) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:无对应Api,使用ValueUpdateListener返回的v值进行计算: +```java +// 直接构建 +mAnimatorValue = new AnimatorValue(); +mAnimatorValue.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() { + @Override + public void onUpdate(AnimatorValue animatorValue, float v) { + wxa12 = x1 + (x2 - x1) * (float)Math.pow(v,3.6f); + wya12 = y1 + (y2 - y1) * (float)Math.pow(v,3.6f); + callback.onValueUpdated(); + } +}); +``` \ No newline at end of file diff --git a/animation/ValueAnimator.md b/animation/ValueAnimator.md index 6eca569..b6bff93 100644 --- a/animation/ValueAnimator.md +++ b/animation/ValueAnimator.md @@ -461,4 +461,42 @@ public class MainAbility extends Ability { } } +``` + +### **setDuration(long duration)** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setDuration(long duration) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +AnimatorProperty animatorProperty = pager.createAnimatorProperty(); +// 设置动画时长 +animatorProperty.setDuration(1000); +``` + +### **setInterpolator(value: TimeInterpolator!)** +>+ openharmony API: ohos.agp.animation.AnimatorValue.setCurve(Animator.TimelineCurve curve) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +addAnimator.setCurve(new Animator.TimelineCurve() { + @Override + public float getCurvedTime(float input) { + return input * input; + } +}); +```` + +### **start()** +>+ openharmony API: ohos.agp.animation.Animator.start(); +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 动画开始 +addAnimator.start(); ``` \ No newline at end of file diff --git a/app/Activity.md b/app/Activity.md index 5d7b9ce..cceeb69 100644 --- a/app/Activity.md +++ b/app/Activity.md @@ -27,3 +27,18 @@ protected void onOrientationChanged(AbilityInfo.DisplayOrientation displayOrient } ``` + +### **oncreate()** +>+ openharmony API: ohos.aafwk.ability.AbilitySlice.onstart() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 重写 +@Override +protected void onStart(Intent intent) { + super.onStart(intent); + setUIContentByRes(ResourceTable.Layout_activity_elme); + RxDeviceTool.setPortrait(this); +} +``` diff --git a/app/AlertDialog.md b/app/AlertDialog.md new file mode 100644 index 0000000..5b31bcb --- /dev/null +++ b/app/AlertDialog.md @@ -0,0 +1,27 @@ +### **Builder** +>+ openharmony API: ohos.agp.window.dialog.ListDialog +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +``` + +### **setTitle(title: CharSequence?)** +>+ openharmony API: ohos.agp.window.dialog.CommonDialog.setTitleText​(String text) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +// 设置标题 +listDialog.setTitleText("test"); +// 设置大小 +listDialog.setSize(400,600); +// 显示 +listDialog.show(); +// 从BaseDialog调用来销毁列表对话框 +listDialog.destroy(); +``` \ No newline at end of file diff --git a/app/Application.md b/app/Application.md new file mode 100644 index 0000000..c16cedc --- /dev/null +++ b/app/Application.md @@ -0,0 +1,12 @@ +### **oncreate()** +>+ openharmony API: ohos.aafwk.ability.AbilityPackage.onInitialize() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 重写,进行初始化操作 +@Override +public void onInitialize() { + super.onInitialize(); +} +``` \ No newline at end of file diff --git a/app/Builder.md b/app/Builder.md new file mode 100644 index 0000000..dfe8f8a --- /dev/null +++ b/app/Builder.md @@ -0,0 +1,46 @@ +### **setMultiChoiceItems(itemsId: Int, checkedItems: BooleanArray!, listener: DialogInterface.OnMultiChoiceClickListener!)** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +// 设置要在对话框中显示的项目列表作为内容 +listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); +// 设置确认按钮 +listDialog.setButton(1,"Ok",this); +// 设置取消按钮 +listDialog.setButton(2,"Cancel",this); +``` + +### **setPositiveButton(textId: Int, listener: DialogInterface.OnClickListener!)** +### **setNegativeButton(textId: Int, listener: DialogInterface.OnClickListener!)** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代使用,自定义使用方法如下: +```java +// 自定义确认,取消点击时间 +@Override +public void onClick(IDialog dialog ,int id){ + if(id == 1){ + //确定 + }else if(id == 2){ + //取消 + } +} +``` + +### **create()** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.show() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 从BaseDialog调用来显示列表对话框 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +listDialog.setTitleText("test"); +listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); +listDialog.show(); +``` diff --git a/app/Dialog.md b/app/Dialog.md new file mode 100644 index 0000000..4ead801 --- /dev/null +++ b/app/Dialog.md @@ -0,0 +1,46 @@ +### **setContentView(layoutResID: Int)** +>+ openharmony API: ohos.agp.window.dialog.CommonDialog +>+ openharmony API: ohos.agp.window.dialog.IDialog +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:组合使用,使用方法如下: +```java +// 重写,进行初始化操作 +CommonDialog commonDialog = new CommonDialog(this); +IDialog.ClickedListener myDialogClickListener = new IDialog.ClickedListener() { + @Override + public void onClick(IDialog iDialog, int i) { + switch (i) { + case 0: + RxLocationTool.openGpsSettings(ActivityLocation.this); + commonDialog.destroy(); + break; + case 1: + commonDialog.destroy(); + break; + default: + //do nothing + } + } + }; +commonDialog.setTitleText("GPS未打开") + .setContentText("您需要在系统设置中打开GPS方可采集数据") + .setButton(0, "去设置", myDialogClickListener) + .setButton(1, "取消", myDialogClickListener); +``` + +### **show()** +>+ openharmony API: ohos.agp.window.dialog.CommonDialog +>+ openharmony API: ohos.agp.window.dialog.IDialog +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:组合使用,使用方法如下: +```java +// 重写,进行初始化操作 +CommonDialog commonDialog = new CommonDialog(this); +commonDialog.setTitleText("GPS未打开") + .setContentText("您需要在系统设置中打开GPS方可采集数据") + .setButton(0, "去设置", myDialogClickListener) + .setButton(1, "取消", myDialogClickListener) + .show(); +``` \ No newline at end of file diff --git a/app/usage/NetworkStatsManager.md b/app/usage/NetworkStatsManager.md new file mode 100644 index 0000000..7d12200 --- /dev/null +++ b/app/usage/NetworkStatsManager.md @@ -0,0 +1,11 @@ +### **querySummary(networkType: Int, subscriberId: String!, startTime: Long, endTime: Long)** +>+ openharmony API: ohos.net.DataFlowStatistics.getUidTxBytes​(int uid) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 拿到应用UID +int uid = 12345; +// 查询指定应用发送的数据流量(包括所有TCP、UDP数据包) +long result = new DataFlowStatistics().getUidRxBytes(uid) + new DataFlowStatistics().getUidTxBytes(uid); +``` \ No newline at end of file diff --git a/app/usage/UsageStatsManager.md b/app/usage/UsageStatsManager.md new file mode 100644 index 0000000..877dc08 --- /dev/null +++ b/app/usage/UsageStatsManager.md @@ -0,0 +1,10 @@ +### **queryEvents(beginTime: Long, endTime: Long)** +>+ openharmony API: ohos.bundleactive.BundleActiveInfosMgr.queryBundleActiveStates() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 查询当前bundle在指定时间段内的状态数据 +BundleActiveInfosMgr bundleActiveInfosMgr = BundleActiveInfosMgr.newInstance(getContext()); +bundleActiveInfosMgr.queryCurrentBundleActiveStates(System.currentTimeMillis(),System.currentTimeMillis()); +``` \ No newline at end of file diff --git a/arch/persistence/room/RoomDatabase.md b/arch/persistence/room/RoomDatabase.md new file mode 100644 index 0000000..be109c3 --- /dev/null +++ b/arch/persistence/room/RoomDatabase.md @@ -0,0 +1,65 @@ +### **用对象的方式操作数据库中的数据,对象的成员变量与数据表的字段对应,一个对象可认为是一条数据** +>+ openharmony API: ohos.data.orm.OrmContext +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 建立一个辅助类,在构造方法中创建操作对象,并在该类中操作数据 +public class UserDBHelper { + + private final OrmContext appDatabase; + private final UserDaoImpl inMemoryAppDatabase; + + public UserDBHelper(Context context) { + DatabaseHelper databaseHelper = new DatabaseHelper(context); + appDatabase = databaseHelper.getOrmContext("User", "User.db", AppDatabase.class); + + StoreConfig storeConfig = StoreConfig.newMemoryConfig(); + RdbStore rdbStore = databaseHelper.getRdbStore(storeConfig, 1, new RdbOpenCallback() { + @Override + public void onCreate(RdbStore db) { + db.executeSql( + "create table users " + + "(id integer primary key, name text)" + ); + } + + @Override + public void onUpgrade(RdbStore db, int i, int i1) { + db.executeSql("DROP TABLE IF EXISTS users"); + onCreate(db); + } + }); + InMemoryDebugSQLiteDB inMemoryDebugSQLiteDB = new InMemoryDebugSQLiteDB(rdbStore); + inMemoryAppDatabase = new UserDaoImpl(inMemoryDebugSQLiteDB); + } + + public void insertUser(List userList) { + if (userList==null) + return; + appDatabase.beginTransaction(); + for (User user:userList) { + appDatabase.insert(user); + } + appDatabase.commit(); + } + + public void insertUserInMemory(List userList) { + inMemoryAppDatabase.insertAll(userList); + } + + public int count() { + OrmPredicates ormPredicates = new OrmPredicates(User.class); + return appDatabase.count(ormPredicates).intValue(); + } + + public int countInMemory() { + return inMemoryAppDatabase.loadAll().size(); + } + + public InMemoryDebugSQLiteDB getInMemoryDatabase() { + return inMemoryAppDatabase.getInMemoryDatabase(); + } +} + +``` \ No newline at end of file diff --git a/content/BroadcastReceiver.md b/content/BroadcastReceiver.md new file mode 100644 index 0000000..ebe1920 --- /dev/null +++ b/content/BroadcastReceiver.md @@ -0,0 +1,14 @@ +### **onReceive()** +>+ openharmony API: ohos.event.commonevent.CommonEventSubscriber.onReceiveEvent​(CommonEventData data) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 当应用程序接收到一个新的公共事件时回调 +@Override +public void onReceiveEvent(@NotNull CommonEventData commonEventData) { + if (commonEventData == null || commonEventData.getIntent() == null) { + return; + } +} +``` diff --git a/content/ContentResolver.md b/content/ContentResolver.md index a8c75f6..85b23ac 100644 --- a/content/ContentResolver.md +++ b/content/ContentResolver.md @@ -40,4 +40,14 @@ } return file; } +``` + +### **query(uri: Uri, projection: Array?, selection: String?, selectionArgs: Array?, sortOrder: String?)** +>+ openharmony API: ohos.aafwk.ability.DataAbilityHelper.query​(Uri uri, String[] columns, DataAbilityPredicates predicates) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 查询数据库中的数据 +ResultSet result = helper.query(AVStorage.Images.Media.EXTERNAL_DATA_ABILITY_URI, null, null); ``` \ No newline at end of file diff --git a/content/ContentValues.md b/content/ContentValues.md new file mode 100644 index 0000000..09c8ab3 --- /dev/null +++ b/content/ContentValues.md @@ -0,0 +1,54 @@ +### **put(key: String!, value: !)** +>+ openharmony API: ohos.data.rdb.ValuesBucket +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ValuesBucket valuesBucket = new ValuesBucket(); + +// 将一个String值放入当前ValuesBucket中,并将其与给定的列名关联 +valuesBucket.putString("name",name); + +将Short值放入当前ValuesBucket中,并将其与给定的列名关联 +valuesBucket.putShort("sex", sex); + +// 将空值放入当前ValuesBucket,并将其与给定的列名关联 +valuesBucket.putNull(""); + +// 将Long值放入当前ValuesBucket中,并将其与给定的列名关联 +valuesBucket.putLong​("phone", phone); + + +// 将Integer值放入当前ValuesBucket中,并将其与给定的列名关联 +valuesBucket.putInteger​("age", age); + +// 将Float值放入当前ValuesBucket中,并将其与给定的列名关联 +valuesBucket.putFloat("money",money); +``` + +### **get(key: String!)** +>+ openharmony API: ohos.data.rdb.ValuesBucket +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ValuesBucket valuesBucket = new ValuesBucket(); + +// 获取指定列名的String值 +valuesBucket.getString(String columnName); + +// 获取指定列名的Short值 +valuesBucket.getShort(String columnName); + +// 获取指定列名的Long值 +valuesBucket.getLong(String columnName); + +// 获取指定列名的Interger值 +valuesBucket.getInteger(String columnName); + +// 获取指定列名的Float值 +valuesBucket.getFloat(String columnName); + +``` \ No newline at end of file diff --git a/content/Context.md b/content/Context.md index 9faa86d..4bde402 100644 --- a/content/Context.md +++ b/content/Context.md @@ -1,5 +1,4 @@ - -# obtainStyledAttributes +# obtainStyledAttributes * openharmony API:ohos.agp.components.AttrSet * openharmony SDK版本:2.1.0.17 * IDE版本:2.1.0.141 @@ -9,4 +8,15 @@ if(attrSet.getAttr(customXmlName).isPresent()){ mCustomLength = attrSet.getAttr(customXmlName).get().getDimensionValue(); } +``` + +### **Context** +>+ openharmony API: ohos.app.Context +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +public void test(Context context){ + this.context = context; +} ``` \ No newline at end of file diff --git a/content/Intent.md b/content/Intent.md new file mode 100644 index 0000000..af65751 --- /dev/null +++ b/content/Intent.md @@ -0,0 +1,39 @@ +### **Intent(this, SecondActivity.class)** +>+ openharmony API: ohos.aafwk.content.Intent +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +Intent intent = new Intent(); +// 设置跳转链接 +intent.setUri(Uri.parse("package:" + "com.demo")); +// 设置处理标志 +intent.setFlags(Intent.FLAG_ABILITY_NEW_MISSION); +``` + +### **getStringExtra(name: String!)** +>+ openharmony API: ohos.aafwk.content.Intent.getStringParam​(String key) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +Intent intent = new Intent(); +// 检索意图中的扩展数据 +intent.getStringParam("1"); +``` + +### **setAction(action: String?)** +>+ openharmony API: ohos.aafwk.content.Intent.setAction​(String action) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +Intent intent = new Intent(); +// 检索意图中的扩展数据 +intent.getStringParam("1"); +// 设置要执行的常规操作 +intent.setAction("test"); +``` \ No newline at end of file diff --git a/content/SharedPreferences.md b/content/SharedPreferences.md new file mode 100644 index 0000000..a93fc68 --- /dev/null +++ b/content/SharedPreferences.md @@ -0,0 +1,69 @@ +### **getInt(key: String!, defValue: Int)** +>+ openharmony API: ohos.data.preferences.Preferences.getInt​(String key, int defValue) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取int格式首选项的值 +public static int getInt(Context context, String key) { + Preferences sp = new DatabaseHelper(context).getPreferences(key); + int value = sp.getInt(key, -1); + return value; + } +``` + +### **getString(key: String!, defValue: String?)** +>+ openharmony API: ohos.data.preferences.Preferences.getString(String key, String defValue) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取字符串格式的首选项的值 +public static String getString(Context context, String key) { + Preferences sp = new DatabaseHelper(context).getPreferences(key); + String value = sp.getString(key, ""); + return value; +} +``` + +### **getLong(key: String!, defValue: Long)** +>+ openharmony API: ohos.data.preferences.Preferences.getLong​(String key, long defValue) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取长格式首选项的值 +public static long getLong(Context context, String key) { + Preferences sp = new DatabaseHelper(context).getPreferences(key); + long value = sp.getLong(key, -1L); + return value; +} +``` + +### **getFloat(key: String!, defValue: Float)** +>+ openharmony API: ohos.data.preferences.Preferences.getFloat​(String key, float defValue) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取浮点格式首选项的值 + public static float getFloat(Context context, String key) { + Preferences sp = new DatabaseHelper(context).getPreferences(key); + float value = sp.getFloat(key, -1f); + return value; + } +``` + +### **getBoolean(key: String!, defValue: Boolean)** +>+ openharmony API: ohos.data.preferences.Preferences.getBoolean​(String key, boolean defValue) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取布尔格式首选项的值 +public static boolean getBoolean(Context context, String key) { + Preferences sp = new DatabaseHelper(context).getPreferences(key); + boolean value = sp.getBoolean(key, false); + return value; +} +``` diff --git a/content/pm/ApplicationInfo.md b/content/pm/ApplicationInfo.md new file mode 100644 index 0000000..8fbaf47 --- /dev/null +++ b/content/pm/ApplicationInfo.md @@ -0,0 +1,15 @@ +### **applicationInfo.flags** +### **applicationInfo.FLAG_SYSTEM** +### **applicationInfo.FLAG_UPDATED_SYSTEM_APP** +>+ openharmony API: ohos.bundle.ApplicationInfo.getSystemApp() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 通过packagename,直接判断应用是否为系统应用 +public boolean SystemApp(IBundleManager manager ,String packageName) throws RemoteException { + ApplicationInfo applicationInfo = manager.getApplicationInfo(packageName,0,0); + boolean isSystemApp = applicationInfo.getSystemApp(); + return isSystemApp; +} +``` \ No newline at end of file diff --git a/content/pm/PackageManager.md b/content/pm/PackageManager.md new file mode 100644 index 0000000..59fe854 --- /dev/null +++ b/content/pm/PackageManager.md @@ -0,0 +1,20 @@ +### **getApplicationInfo(packageName: String, flags: Int)** +>+ openharmony API: ohos.bundle. ApplicationInfo +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 判断应用是否已安装 +public boolean isInstalled(IBundleManager packageManager ,String packageName) throws RemoteException { + boolean isInstalled = false; + List infos = packageManager.getApplicationInfos(0,0); + for (ApplicationInfo info :infos){ + //获取应用程序的名称并判断是否安装 + if (packageName != null && packageName.equals(info.getName())){ + isInstalled = true; + break; + } + } + return isInstalled; + } +``` \ No newline at end of file diff --git a/content/res/Configuration.md b/content/res/Configuration.md new file mode 100644 index 0000000..6080aa1 --- /dev/null +++ b/content/res/Configuration.md @@ -0,0 +1,10 @@ +### **ORIENTATION_PORTRAIT** +>+ openharmony API: ohos.bundle.AbilityInfo.DisplayOrientation.PORTRAIT +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 指示纵向方向 +android中该类描述了可能影响应用程序检索资源的所有设备配置信息。这包括用户指定的配置选项(语言环境列表和缩放比例)以及设备配置(例如输入模式,屏幕尺寸和屏幕方向)。ORIENTATION_PORTRAIT:对应于端口资源限定符 +AbilityInfo.DisplayOrientation portrait = AbilityInfo.DisplayOrientation.PORTRAIT; +``` diff --git a/content/res/Resources.md b/content/res/Resources.md new file mode 100644 index 0000000..3dd6b1f --- /dev/null +++ b/content/res/Resources.md @@ -0,0 +1,9 @@ +### **getResources()** +>+ openharmony API: ohos.global.resource.Element.getAppContext().getResourceManager() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 通过全局上下文获取到resourceManager管理类,从而获取对应资源id的文件 +ResourceManager resourceManager = MyApplication.getAppContext().getResourceManager(); +``` \ No newline at end of file diff --git a/content/res/TypedArray.md b/content/res/TypedArray.md index 8110e62..e1d9993 100644 --- a/content/res/TypedArray.md +++ b/content/res/TypedArray.md @@ -62,4 +62,14 @@ public class SideBar extends Text { - ``` \ No newline at end of file + ``` + +### **getInt()** +>+ openharmony API: ohos.agp.components.Attr.getIntegerValue() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取到自定义属性中的int值 +mTextAppearance = attrs.getAttr("loadingTextAppearance").get().getIntegerValue(); +``` diff --git a/database/sqlite/SQLiteOpenHelper.md b/database/sqlite/SQLiteOpenHelper.md new file mode 100644 index 0000000..d10a719 --- /dev/null +++ b/database/sqlite/SQLiteOpenHelper.md @@ -0,0 +1,19 @@ +### **SQLiteOpenHelper ** +>+ openharmony API: ohos.data.DatabaseHelper +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 获取或创建数据库。 +// 直接创建: +DatabaseHelper databaseHelper = new DatabaseHelper(this); +StoreConfig storeConfig = StoreConfig.newDefaultConfig("D:text/text"); +return new DebugSQLiteDB(databaseHelper.getRdbStore(storeConfig, 1, new RdbOpenCallback() { + @Override + public void onCreate(RdbStore rdbStore) { + } + @Override + public void onUpgrade(RdbStore rdbStore, int i, int i1) { + } +})); +``` \ No newline at end of file diff --git a/graphics/Bitmap.md b/graphics/Bitmap.md index 55b8631..c487cf0 100644 --- a/graphics/Bitmap.md +++ b/graphics/Bitmap.md @@ -77,6 +77,7 @@ int height = pixelMap.getImageInfo().size.height; >+ IDE版本:2.1.0.141 >+ 实现方案:替换使用 + ### **getDensity()** >+ openharmony API: ohos.media.image.PixelMap.getBaseDensity(); >+ openharmony SDK版本:2.1.0.17 @@ -87,4 +88,16 @@ int height = pixelMap.getImageInfo().size.height; >+ openharmony API: ohos.media.image.PixelMap.release() >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 ->+ 实现方案:替换使用 \ No newline at end of file +>+ 实现方案:替换使用 + + +### **setPixels(pixels: IntArray!, offset: Int, stride: Int, x: Int, y: Int, width: Int, height: Int)** +>+ openharmony API: ohos.media.image.PixelMap.release() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 从指定的颜色数据数组(基于开始偏移量和步幅)中写入数据到这个PixelMap的指定区域 +PixelMap pixelMap = item; +pixelMap.writePixels(pixels,0,0,null); +``` diff --git a/graphics/BitmapFactory.md b/graphics/BitmapFactory.md index 2c6dbf9..c773d87 100644 --- a/graphics/BitmapFactory.md +++ b/graphics/BitmapFactory.md @@ -51,4 +51,24 @@ public static PixelMap decodeStream(FileDescriptor fd) { ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions(); return source.createPixelmap(decodingOptions);//decodingOptions可为null } +``` + +### **Options()** +>+ openharmony API: ohos.media.image.ImageSource.DecodingOptions() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 提供图像解码选项 +ImageSource.DecodingOptions decodingOpts = new ImageSource.DecodingOptions(); +``` + +### **decodeFile(pathName: String!, opts: BitmapFactory.Options!)** +>+ openharmony API: ohos.media.image.ImageSource.create(File file, ImageSource.SourceOptions opts) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 基于File对象创建一个ImageSource +ImageSource imageSource = ImageSource.create(filedesc, null); ``` \ No newline at end of file diff --git a/graphics/Canvas.md b/graphics/Canvas.md index 11246dd..996d3f3 100644 --- a/graphics/Canvas.md +++ b/graphics/Canvas.md @@ -66,4 +66,65 @@ Canvas canvas = new Canvas(new Texture(pixelMap)); >+ openharmony API: `ohos.agp.render.Canvas` >+ openharmony SDK版本:2.1.0.17 >+ IDE版本:2.1.0.141 ->+ 实现方案:使用`drawLine(Point point1 ,Point point2,Paint)`方法 \ No newline at end of file +>+ 实现方案:使用`drawLine(Point point1 ,Point point2,Paint)`方法 + + +### **drawRect(rect: RectF, paint: Paint)** +>+ openharmony API: ohos.agp.render.Canvas.drawRect(RectFloat rect, Paint paint) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 在画布上画一个矩形 +@Override +protected void onDraw(Canvas canvas) { + mPaint.setStyle(Paint.Style.FILL_STYLE); + mPaint.setStrokeWidth(getPaintStrokeWidth()); + if (getRect() != null) { + Rect bounds = clipSquare(getRect(), 50); + int width = (int) (bounds.getWidth() * 0.33f); + int height = (int) (bounds.getHeight() * 0.33f); + for (int i = 0; i < num; i++) { + int x = i % 3; + int y = i / 3; + int l = bounds.left + x * width; + int t = bounds.top + y * height; + RectFloat max = new RectFloat(l, t, l + width, t + width); + float r = max.getWidth() / 2f * radius[i]; + RectFloat now = new RectFloat( + max.getVerticalCenter() - r, + max.getHorizontalCenter() - r, + max.getVerticalCenter() + r, + max.getHorizontalCenter() + r + ; + canvas.drawRect(now, mPaint); + } + + startAnimator(); + } +} +``` + +### **drawPoint(x: Float, y: Float, paint: Paint)** +>+ openharmony API: ohos.agp.render.Canvas.drawPoint(float posX, float posY, Paint paint) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 画一个点 +@Override +public void onDraw(Component component, Canvas canvas) { + paint.setStrokeWidth(btnWidth * clickValue * (shineDistanceMultiple - distanceOffset)); + if (clickValue != 0f) { + paint2.setStrokeWidth(btnWidth * clickValue * (shineDistanceMultiple - distanceOffset) - 8); + } else { + paint2.setStrokeWidth(0f); + } + canvas.drawPoint(centerAnimX, centerAnimY, paint); + canvas.drawPoint(centerAnimX, centerAnimY, paint2); + if (mRxShineAnimator != null && !isRun) { + isRun = true; + showAnimation(mRxShineButton); + } +} +``` \ No newline at end of file diff --git a/graphics/Color.md b/graphics/Color.md new file mode 100644 index 0000000..76a8f91 --- /dev/null +++ b/graphics/Color.md @@ -0,0 +1,18 @@ +### **Color.YELLOW** +>+ openharmony API: ohos.agp.utils.Color.YELLOW +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +Color yellow = Color.YELLOW; +``` + +### **Color.WHITE** +>+ openharmony API: ohos.agp.utils.Color.WHITE +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +Color white = Color.WHITE; +``` + diff --git a/graphics/DashPathEffect.md b/graphics/DashPathEffect.md new file mode 100644 index 0000000..3972deb --- /dev/null +++ b/graphics/DashPathEffect.md @@ -0,0 +1,11 @@ +### **PathDashPathEffect(shape: Path!, advance: Float, phase: Float, style: PathDashPathEffect.Style!)** +>+ openharmony API: ohos.agp.render.PathEffect.PathEffect(Path shape, float advance, float phase, PathEffect.Style style) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 创建实例的构造函数 +public void pathEffect(Path shape, float advance, float phase, PathEffect.Style style){ + PathEffect pathEffect = new PathEffect(shape,advance,phase,style); +} +``` diff --git a/graphics/LinearGradient.md b/graphics/LinearGradient.md new file mode 100644 index 0000000..3f25b86 --- /dev/null +++ b/graphics/LinearGradient.md @@ -0,0 +1,11 @@ +### **LinearGradient(x0: Float, y0: Float, x1: Float, y1: Float, colors: IntArray, positions: FloatArray?, tile: Shader.TileMode)** +>+ openharmony API: ohos.agp.render.LinearShader.LinearShader(Point[] newPoints, float[] newStops, Color[] newColors, Shader.TileMode newTileMode) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 创建用于基于指定的点、颜色位置、颜色和平铺模式创建线性着色器实例的构造函数 +public void pathEffect(Point[] newPoints, float[] newStops, Color[] newColors, Shader.TileMode newTileMode){ + LinearShader linearShader = new LinearShader(newPoints,newStops,newColors,newTileMode); +} +``` diff --git a/graphics/Matrix.md b/graphics/Matrix.md index 6746e12..bb487e0 100644 --- a/graphics/Matrix.md +++ b/graphics/Matrix.md @@ -50,3 +50,41 @@ matrix.setRotate(90, 100f, 100f); ``` +### **postScale(sx: Float,sy: Float)** +>+ openharmony API: ohos.agp.utils.Matrix.setScale​(float sx, float sy) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 缩放矩阵 +public void postTranslate(float dx, float dy){ + Matrix matrix = new Matrix(); + matrix.setScale(dx, dy); +} +``` + +### **postRotate(degrees: Float)** +>+ openharmony API: ohos.agp.utils.Matrix.setRotate​(float degrees) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 将矩阵与指定的旋转后连接 +Matrix matrix = new Matrix(); +matrix.setRotate(dx); +``` + + +### **postTranslate(dx: Float, dy: Float)** +>+ openharmony API: ohos.agp.utils.Matrix.postTranslate(float dx, float dy) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 将矩阵与指定的比例后连 +public void postTranslate(float dx, float dy){ + Matrix matrix = new Matrix(); + matrix.postTranslate(dx, dy); +} +``` + diff --git a/graphics/NinePatch.md b/graphics/NinePatch.md new file mode 100644 index 0000000..4eb58b5 --- /dev/null +++ b/graphics/NinePatch.md @@ -0,0 +1,18 @@ +### **NinePatch(bitmap: Bitmap!, chunk: ByteArray!, srcName: String!)** +>+ openharmony API: ohos.media.image.PixelMap.create​(PixelMap source, PixelMap.InitializationOptions opts) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 于初始化选项(如图像大小、像素格式和alpha类型)和源像素映射所描述的数据源创建像素映射 +// 由于鸿蒙暂不支持点9图片,所以用位图代替 +public void create( int bmpResId) throws IOException, NotExistException { + ImageSource source = ImageSource.create(getContext().getResourceManager().getResource(bmpResId), null); + PixelMap original = source.createPixelmap(null); + PixelMap.InitializationOptions options = new PixelMap.InitializationOptions(); + options.size = new Size(mThumbSize, mThumbSize); + options.pixelFormat = original.getImageInfo().pixelFormat; + options.editable = true; + PixelMap bmp = PixelMap.create(original, options); +} +``` \ No newline at end of file diff --git a/graphics/Paint.md b/graphics/Paint.md index c850e0d..20113c1 100644 --- a/graphics/Paint.md +++ b/graphics/Paint.md @@ -12,4 +12,23 @@ openharmony : ```java BlurDrawLooper textBlurDrawLooper = new BlurDrawLooper(shadowRadius, shadowDx, shadowDy, new Color(shadowColor)); paint.setBlurDrawLooper(textBlurDrawLooper); +``` + +### **Paint** +>+ openharmony API: ohos.agp.render.Paint +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 对画布进行绘制,定义颜色等属性 +public Sprite() { + super(); + if (mPaint == null) { + mPaint = new Paint(); + mPaint.setColor(new Color(paintColor)); + mPaint.setStyle(Paint.Style.STROKE_STYLE); + mPaint.setStrokeWidth(strokeWidth); + mPaint.setAntiAlias(true); + } +} ``` \ No newline at end of file diff --git a/graphics/Path.md b/graphics/Path.md index 7b803e7..28512c0 100644 --- a/graphics/Path.md +++ b/graphics/Path.md @@ -43,3 +43,19 @@ Path path = new Path(); path.addRect(new RectFloat(0f, 0f, 100f, 100f), Path.Direction.CLOCK_WISE); ``` + +### **reset()** +>+ openharmony API: ohos.agp.render.Path.reset() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 创建对象 +path = new Path(); +// 设置此路径的起点 +path.moveTo(currentCursor, 0f); +// 向Path对象添加一行 +path.lineTo(currentCursor + TRIANGLE_LENGTH, 0f); +// 清除Path对象 +path.reset(); +``` diff --git a/graphics/PathMeasure.md b/graphics/PathMeasure.md new file mode 100644 index 0000000..076c179 --- /dev/null +++ b/graphics/PathMeasure.md @@ -0,0 +1,38 @@ +### **PathMeasure(path: Path!, forceClosed: Boolean)** +>+ openharmony API: ohos.agp.render.PathMeasure.PathMeasure​(Path path, boolean forceClosed) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 创建用于基于指定路径创建PathMeasure对象的构造函数 +public void pathEffect(Path path ,boolean forceClosed){ + PathMeasure pathMeasure = new PathMeasure(path,forceClosed); +} +``` + +### **setPath(path: Path!, forceClosed: Boolean)** +>+ openharmony API: ohos.agp.render.PathMeasure.setPath(Path path, boolean forceClosed) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 将指定的路径与PathMearue对象关联 +public void setPath(Path path){ + PathMeasure pathMeasure = new PathMeasure(path,false); + pathMeasure.setPath(path,false); +} +``` + +### **getPosTan(distance: Float, pos: FloatArray!, tan: FloatArray!)** +>+ openharmony API: ohos.agp.render.PathMeasure.getPosTan(float distance, float[] position, float[] tangent) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 获取指定指定长度在关联路径上的位置的坐标及其切线值 +public void setPath(Path path,float distance,float[] position,float[] tangent){ + PathMeasure pathMeasure = new PathMeasure(path,false); + pathMeasure.setPath(path,false); + pathMeasure.getPosTan(distance,position,tangent); +} +``` \ No newline at end of file diff --git a/graphics/Rect.md b/graphics/Rect.md new file mode 100644 index 0000000..3fe856f --- /dev/null +++ b/graphics/Rect.md @@ -0,0 +1,34 @@ +### **width()** +>+ openharmony API: ohos.agp.utils.Rect.getWidth() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 获取矩形的宽度 +Rect rect = new Rect(); +int width = rect.getHeight(); +``` + +### **height()** +>+ openharmony API: ohos.agp.utils.Rect.getHeight() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 获取矩形的高度 +Rect rect = new Rect(); +int height = rect.getWidth(); +``` + +### **intersects(a: Rect, b: Rect)** +>+ openharmony API: ohos.agp.utils.Rect.isIntersect(Rect rectA, Rect rectB) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 检查指定的两个矩形是否相交 +public void isIntersect(Rect a,Rect b){ + Rect rect = new Rect(); + rect.isIntersect(a,b); +} +``` \ No newline at end of file diff --git a/graphics/Shader.md b/graphics/Shader.md new file mode 100644 index 0000000..4b23712 --- /dev/null +++ b/graphics/Shader.md @@ -0,0 +1,9 @@ +### **Shader()** +>+ openharmony API: ohos.agp.render.Shader.Shader​(Color[] colors, Shader.TileMode newTileMode) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 创建用于创建Shader实例的参数化构造函数 +shader = new Shader(new Color[]{new Color(0), new Color(c3), new Color(c2), new Color(c1), new Color(0xff000000), new Color(0xff000000), new Color(c1), new Color(c2), new Color(c3), new Color(0)}, Shader.TileMode.CLAMP_TILEMODE) { +``` \ No newline at end of file diff --git a/graphics/drawable/ColorDrawable.md b/graphics/drawable/ColorDrawable.md new file mode 100644 index 0000000..6627ca6 --- /dev/null +++ b/graphics/drawable/ColorDrawable.md @@ -0,0 +1,10 @@ +### **ColorDrawable(int rgba)** +>+ openharmony API: ohos.agp.colors.RgbColor​(int rgba) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 使用颜色整数(一种颜色代码的组合)来定义颜色的构造函数 +ShapeElement shapeElement = new ShapeElement(); +shapeElement.setRgbColor(new RgbColor(Color.WHITE.getValue())); +``` \ No newline at end of file diff --git a/graphics/drawable/Drawable.md b/graphics/drawable/Drawable.md index f787825..8a2fbae 100644 --- a/graphics/drawable/Drawable.md +++ b/graphics/drawable/Drawable.md @@ -17,4 +17,42 @@ ``` >+ 补充说明:目前直接继承Element会报错,请继承其子类。 原三方库中构造自定义Drawable后会自动调用draw()方法,但是drawToCanvas无法自动调用, -需要在外部主动调用才执行,目前验证可行的方案是在自定义Component的addDrawTask中手动调用,在其他的非自定义控件场景中暂时未找到触发回调的办法,自定义element后续会支持并完善。 \ No newline at end of file +需要在外部主动调用才执行,目前验证可行的方案是在自定义Component的addDrawTask中手动调用,在其他的非自定义控件场景中暂时未找到触发回调的办法,自定义element后续会支持并完善。 + + +### **Drawable()/BitmapDrawable()** +### **将drawable转换为BitmapDrawable对象,获取位图** +>+ openharmony API: ohos.agp.colors.RgbColor​(int rgba) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 通过图片资源id,查找到它的输入流,根据输入流创建位图 +private PixelMap getPixelMapFromResource(Context context, int resourceId) { + InputStream inputStream = null; + try { + // 创建图像数据源ImageSource对象 + inputStream = context.getResourceManager().getResource(resourceId); + ImageSource.SourceOptions srcOpts = new ImageSource.SourceOptions(); + srcOpts.formatHint = "image/jpg"; + ImageSource imageSource = ImageSource.create(inputStream, srcOpts); + + // 设置图片参数 + ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions(); + return imageSource.createPixelmap(decodingOptions); + } catch (IOException e) { + Logger.getLogger(TAG).severe("IOException"); + } catch (NotExistException e) { + Logger.getLogger(TAG).severe("NotExistException"); + } finally { + if (inputStream != null) { + try { + inputStream.close(); + } catch (IOException e) { + Logger.getLogger(TAG).severe("inputStream IOException"); + } + } + } + return null; +} +``` \ No newline at end of file diff --git a/hardware/Camera.md b/hardware/Camera.md new file mode 100644 index 0000000..92bbbe8 --- /dev/null +++ b/hardware/Camera.md @@ -0,0 +1,19 @@ +### **autoFocus()** +>+ openharmony API: ohos.media.camera.device.Camera;ohos.media.camera.CameraKit +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +>//应用调用autoFocus(),相机将停止发送面部回叫。最后的面部回调指示用于进行自动对焦的区域。焦点完成后,面部检测将继续发送面部回调. +// 替换使用,使用方法如下: +if (useAutoFocus){ + if (!stopped && focusing){ + try{ + //todo 自动对焦回调 + focusing = true; + }catch (RuntimeException re){ + autoFocusAgainLater(); + } + } +} +``` \ No newline at end of file diff --git a/hardware/Hardware.md b/hardware/Hardware.md new file mode 100644 index 0000000..05822a0 --- /dev/null +++ b/hardware/Hardware.md @@ -0,0 +1,13 @@ +### **getParameters().getFocusMode()** +>+ openharmony API: ohos.media.camera.device.Camera;ohos.media.camera.CameraKit +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +>//检查相机是否能自动对焦. +// 替换使用,使用方法如下: +public AutoFocusManager(Camera camera,CameraSettings settings){ + camera.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PREVIEW).getAfMode(); +} +``` + diff --git a/location/location.md b/location/location.md new file mode 100644 index 0000000..e5274bf --- /dev/null +++ b/location/location.md @@ -0,0 +1,64 @@ +### **requestLocationUpdates(**String provider, long minTime, float minDistance,LocationListener listener**)** +>+ openharmony API: ohos.location.Locator.startLocating(RequestParam +> request, LocatorCallback callback) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接获取单例 + Locator locator = new Locator(this); +``` + +### **onLocationChanged(location: Location)** +>+ openharmony API: ohos.location.LocatorCallback.onLocationReport(Location +> location); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 直接new一个callback +LocatorCallback locatorCallback = new LocatorCallback() { + @Override + public void onLocationReport(Location location) { + + } + + @Override + public void onStatusChanged(int i) { + + } + + @Override + public void onErrorReport(int i) { + + } +}; +``` + +### **onStatusChanged(**provider: String, status: +Int, extras: Bundle) +>+ openharmony API: ohos.location.LocatorCallback.onStatusChanged(int type) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接new一个callback +LocatorCallback locatorCallback = new LocatorCallback() { + @Override + public void onLocationReport(Location location) { + + } + + @Override + public void onStatusChanged(int i) { + + } + + @Override + public void onErrorReport(int i) { + + } +}; +``` + diff --git a/media/MediaPlayer.md b/media/MediaPlayer.md new file mode 100644 index 0000000..c246668 --- /dev/null +++ b/media/MediaPlayer.md @@ -0,0 +1,132 @@ +### **setAudioStreamType(streamtype: Int)** +>+ openharmony API: ohos.media.player.Player.setAudioStreamType​(int type) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置音频类型 +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +``` + +### **setOnCompletionListener(listener: MediaPlayer.OnCompletionListener!)** +### **setOnErrorListener(listener: MediaPlayer.OnErrorListener!)** +>+ openharmony API: ohos.media.player.Player.setPlayerCallback(Player.IPlayerCallback callback) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 注册一个IPlayerCallback来接收事件通知 +Player player = new Player(getContext()); +player.setPlayerCallback(new Player.IPlayerCallback() { + @Override + public void onPrepared() { + + } + + @Override + public void onMessage(int i, int i1) { + + } + + @Override + public void onError(int i, int i1) { + + } + + @Override + public void onResolutionChanged(int i, int i1) { + + } + + @Override + public void onPlayBackComplete() { + + } + + @Override + public void onRewindToComplete() { + + } + + @Override + public void onBufferingChange(int i) { + + } + + @Override + public void onNewTimedMetaData(Player.MediaTimedMetaData mediaTimedMetaData) { + + } + + @Override + public void onMediaTimeIncontinuity(Player.MediaTimeInfo mediaTimeInfo) { + + } +}); +``` + +### **stop()** +>+ openharmony API: ohos.media.player.Player.stop() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 停止播放 +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +player.stop(); +``` + +### **release()** +>+ openharmony API: ohos.media.player.Player.release() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 发布播放资源 +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +player.release(); +player.stop(); +``` + +### **setDataSource(dataSource: MediaDataSource!)** +>+ openharmony API: ohos.media.player.Player.setSource​(Source source) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置要使用的数据源(MediaDataSource) +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +player.setSource(source); +``` + + +### **setVolume(leftVolume: Float, rightVolume: Float)** +>+ openharmony API: ohos.media.player.Player.setVolume(float volume) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 调整音量 +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +player.setSource(source); +player.setVolume(15f); +``` + +### **prepare​()** +>+ openharmony API: ohos.media.player.Player.prepare() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 准备播放器播放,同步 +Player player = new Player(getContext()); +player.setAudioStreamType(Player.PLAYER_ERROR_IO); +player.setSource(source); +player.setVolume(15f); +player.prepare(); +``` \ No newline at end of file diff --git a/nekocode/camerafilter/NekoCode.md b/nekocode/camerafilter/NekoCode.md new file mode 100644 index 0000000..42d5783 --- /dev/null +++ b/nekocode/camerafilter/NekoCode.md @@ -0,0 +1,10 @@ +### **cn.nekocode.camerafilter.R** +>+ openharmony API: ohos.global.resource.ResourceManager +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 替换使用,使用方法如下: +ResourceManager resourceManager = getContext().getResourceManager(); +RawFileEntry rawFileEntry = resourceManager.getRawFileEntry("resoure/rawfile/vertext.vsh"); +``` \ No newline at end of file diff --git a/net/ProxyInfo.md b/net/ProxyInfo.md new file mode 100644 index 0000000..6704e4e --- /dev/null +++ b/net/ProxyInfo.md @@ -0,0 +1,21 @@ +### **getHost()** +>+ openharmony API: ohos.net.HttpProxy.getHost() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构造 +HttpProxy httpProxy = new HttpProxy(); + httpProxy.getHost(); +``` + +### **getPort()** +>+ openharmony API: ohos.net.HttpProxy.getPort(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构造 +HttpProxy httpProxy = new HttpProxy(); + httpProxy.getPort(); +``` \ No newline at end of file diff --git a/net/Uri.md b/net/Uri.md new file mode 100644 index 0000000..78d7984 --- /dev/null +++ b/net/Uri.md @@ -0,0 +1,11 @@ +### **parse(String uri)** +>+ openharmony API: ohos.utils.net.Uri.parse(String uri) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//静态调用 +Intent intent1=new Intent(); +intent1.setUri(Uri.parse("struri")); +startAbility(intent1); +``` diff --git a/net/wifi/WifiConfiguration.md b/net/wifi/WifiConfiguration.md new file mode 100644 index 0000000..af42082 --- /dev/null +++ b/net/wifi/WifiConfiguration.md @@ -0,0 +1,9 @@ +### **setSsid(String ssid);** +>+ openharmony API: ohos.wifi.WifiDeviceConfig.setSsid(String ssid); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构造 + WifiDeviceConfig wifiDeviceConfig = new WifiDeviceConfig(); +``` \ No newline at end of file diff --git a/net/wifi/WifiManager.md b/net/wifi/WifiManager.md new file mode 100644 index 0000000..3136a45 --- /dev/null +++ b/net/wifi/WifiManager.md @@ -0,0 +1,20 @@ +### **getConnectionInfo()** +>+ openharmony API: ohos.wifi.WifiDevice.getLinkedInfo() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接获取单例 +WifiDevice instance = WifiDevice.getInstance(); +``` + +### **getIpAddress()** +>+ openharmony API: ohos.wifi.WifiLinkedInfo.getIpAddress(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 通过实列对象获取 +WifiLinkedInfo wifiLinkedInfo=WifiDevice.getInstance().getLinkedInfo.get(); +``` \ No newline at end of file diff --git a/opengl/GLES11Ext.md b/opengl/GLES11Ext.md new file mode 100644 index 0000000..a310c93 --- /dev/null +++ b/opengl/GLES11Ext.md @@ -0,0 +1,12 @@ +### **GLES11Ext** +>+ openharmony API: ohos.agp.render.opengl.GLESExt;ohos.agp.render.opengl.GLES1X +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 表示GLES11Ext。 +// 替换使用,使用方法如下: +if (TextureType == GLESExt.GL_TEXTURE_EXTERNAL_OES){ + GLES20.glTexParameterf(GLESExt.GL_TEXTURE_EXTERNAL_OES, GLES1X.GL_TEXTURE_MIN_FILTER,GLES1X.GL_LINEAR); +} +``` \ No newline at end of file diff --git a/opengl/GLES20.md b/opengl/GLES20.md new file mode 100644 index 0000000..8856bd9 --- /dev/null +++ b/opengl/GLES20.md @@ -0,0 +1,12 @@ +### **GLES20 ** +>+ openharmony API: ohos.agp.render.opengl.GLES20 +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 表示GLES2.0接口。 +// 替换使用,使用方法如下: +GLES20.glViewport(0,0,1,1); +GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT); +``` + diff --git a/org/org.md b/org/org.md new file mode 100644 index 0000000..c28f58e --- /dev/null +++ b/org/org.md @@ -0,0 +1,31 @@ +### **setInput(Reader in)** +>+ openharmony API: ohos.javax.xml.parsers.SAXParser.parse(InputStream is, DefaultHandler dh) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接获取单例 +SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); +``` + +### **newInstance()** +>+ openharmony API: ohos.javax.xml.parsers.SAXParserFactory.newInstance (); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 直接获取单例 +SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); +``` + +### **newPullParser()** +>+ openharmony API: ohos.javax.xml.parsers.SAXParserFactory.newSAXParser() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 由实例对象获取 +SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); +``` + diff --git a/os/Handler.md b/os/Handler.md index b11e111..6ff422b 100644 --- a/os/Handler.md +++ b/os/Handler.md @@ -13,4 +13,14 @@ public class MyHandler extends EventHandler { } } } +``` + +### **post(Runable runable)** +>+ openharmony API: ohos.eventhandler.EventHandler.post(Runable runable) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接构建 +EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner()); ``` \ No newline at end of file diff --git a/os/Vibrator.md b/os/Vibrator.md new file mode 100644 index 0000000..3d120a9 --- /dev/null +++ b/os/Vibrator.md @@ -0,0 +1,36 @@ +### **onSaveInstanceState(Bundle bundle))** +>+ openharmony API: ohos.aafwk.ability.onPostStart(PacMap pacMap); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 当前ability 复写即可 +@Override +protected void onPostStart(PacMap pacMap) { + super.onPostStart(pacMap); +} +``` + +### **vibrateOnce(context: Context, millisecond: Int)** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.startOnce(int duration) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.startOnce(200); +``` + +### **vibrateStop();** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.vibrateStop(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.vibrateStop(); +``` + diff --git a/provider/provider.md b/provider/provider.md new file mode 100644 index 0000000..0b34f5e --- /dev/null +++ b/provider/provider.md @@ -0,0 +1,10 @@ +### **getContentUri()** +>+ openharmony API:ohos.media.photokit.metadata.AVStorage..Images.Media.EXTERNAL_DATA_ABILITY_URI +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接查询 +ResultSet result = helper.query(AVStorage.Images.Media.EXTERNAL_DATA_ABILITY_URI, null, null); +``` + diff --git a/support/design/widget/Snackbar.md b/support/design/widget/Snackbar.md new file mode 100644 index 0000000..f656688 --- /dev/null +++ b/support/design/widget/Snackbar.md @@ -0,0 +1,12 @@ +### **make()** +### **Snackbar提供消息反馈,在屏幕底下显示,出现在屏所有其他元素之上,一次只能显示一个,经过一段时间会自动消失。make方法内需要三个参数 view视图,text 字符串内容, duration参数** +>+ openharmony API: ohos.agp.window.dialog.ToastDialog +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 在窗口上方提供一个toast对话框,用于通知操作的简单反馈 +public void toastDialog(Component component) { + new ToastDialog(getContext()).setComponent(component).setText("请输入数字或字母").setDuration(1000).show(); +} +``` diff --git a/support/v4/app/FragmentActivity.md b/support/v4/app/FragmentActivity.md new file mode 100644 index 0000000..8bd1981 --- /dev/null +++ b/support/v4/app/FragmentActivity.md @@ -0,0 +1,14 @@ +### **onStart()& onCreate** +### **用基于支持的 Fragment和 Loader API的活动的基类,使用 getSupportFragmentManager()和 getSupportLoaderManager()来访问其内置功能** +>+ openharmony API: ohos.aafwk.ability.AbilitySlice +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// AbilitySlice的执行场景类似于FragmentActivity +@Override +public void onStart(Intent intent) { + super.onStart(intent); + setUIContent(ResourceTable.Layout_ability_main); +} +``` diff --git a/support/v4/app/PagerAdapter.md b/support/v4/app/PagerAdapter.md new file mode 100644 index 0000000..c10e255 --- /dev/null +++ b/support/v4/app/PagerAdapter.md @@ -0,0 +1,9 @@ +### **PagerAdapter** +>+ openharmony API: ohos.agp.components. PageSliderProvider +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 一般配合PageSlider一起使用,为PageSlider提供数据以及对view的一些操作 +private class MyPagerAdapter extends PageSliderProvider {} +``` \ No newline at end of file diff --git a/support/v4/view/ViewPager.md b/support/v4/view/ViewPager.md new file mode 100644 index 0000000..98f6f1f --- /dev/null +++ b/support/v4/view/ViewPager.md @@ -0,0 +1,26 @@ +### **setAdapter()** +>+ openharmony API: ohos.agp.components.PageSlider.setProvider(PageSliderProvider provider) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 设置提供当前页视图的寻呼机适配器 +public void setProvider(PageSliderProvider pageSliderProvider) { + PageSlider pageSlider = new PageSlider(getContext()); + pageSlider.setProvider(pageSliderProvider); +} +``` + +### **setViewPager()** +>+ openharmony API: ohos.agp.components.PageSliderIndicator.setViewPager(PageSlider pageSlider) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 将指示器项与PageSlider对象关联 +public void setViewPager(PageSliderProvider pageSliderProvider,PageSliderIndicator pageSliderIndicator) { + PageSlider pageSlider = new PageSlider(getContext()); + pageSlider.setProvider(pageSliderProvider); + pageSliderIndicator.setViewPager(pageSlider); +} +``` \ No newline at end of file diff --git a/support/v4/widget/ScrollerCompat.md b/support/v4/widget/ScrollerCompat.md new file mode 100644 index 0000000..3cd7869 --- /dev/null +++ b/support/v4/widget/ScrollerCompat.md @@ -0,0 +1,73 @@ +### **abortAnimation()** +>+ openharmony API: ohos.agp.components.ScrollHelper.abortAnimation​() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 停止动画。终止动画将导致滚动条移动到最后的x和y位置 +ScrollHelper mScroller = new ScrollHelper(); +mScroller.abortAnimation(); +``` + +### **getCurrX()** +>+ openharmony API: ohos.agp.components.ScrollHelper.getCurrValue​(ScrollHelper.AXIS_X) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 获取滚动或投掷过程中的X轴坐标 +ScrollHelper mScroller = new ScrollHelper(); +mScroller.abortAnimation(); +mScroller.getCurrValue(ScrollHelper.AXIS_X); +``` + +### **getCurrY()** +>+ openharmony API: ohos.agp.components.ScrollHelper.getCurrValue​(ScrollHelper.AXIS_Y) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 获取滚动或投掷过程中的y轴坐标 +ScrollHelper mScroller = new ScrollHelper(); +mScroller.abortAnimation(); +mScroller.getCurrValue(ScrollHelper.AXIS_Y); +``` + +### **startScroll(int startX, int startY, int dx, int dy, int duration)** +>+ openharmony API: ohos.agp.components.ScrollHelper.startScroll​(int startX, int startY, int dx, int dy) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 开始滚动组件中的内容 +public void drawPixelMapHolder(int startX, int startY, int dx, int dy) { + ScrollHelper mScroller = new ScrollHelper(); + mScroller.abortAnimation(); + mScroller.getCurrValue(ScrollHelper.AXIS_X); + mScroller.getCurrValue(ScrollHelper.AXIS_Y); + mScroller.startScroll(startX,startY,dx,dy); +} +``` + + +### **isFinished()** +>+ openharmony API: ohos.agp.components.ScrollHelper.isFinished() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 确定滚动或投掷是否结束 +public boolean drawPixelMapHolder(int startX, int startY, int dx, int dy) { + ScrollHelper mScroller = new ScrollHelper(); + mScroller.abortAnimation(); + mScroller.getCurrValue(ScrollHelper.AXIS_X); + mScroller.getCurrValue(ScrollHelper.AXIS_Y); + mScroller.startScroll(startX,startY,dx,dy); + boolean isFinished = mScroller.isFinished(); + if(isFinished){ + return true; + }else{ + return false; + } +} +``` \ No newline at end of file diff --git a/support/v7/app/AppCompatActivity.md b/support/v7/app/AppCompatActivity.md new file mode 100644 index 0000000..b6d972b --- /dev/null +++ b/support/v7/app/AppCompatActivity.md @@ -0,0 +1,10 @@ +### **onStart()& onCreate** +### **用基于支持的 Fragment和 Loader API的活动的基类,使用 getSupportFragmentManager()和 getSupportLoaderManager()来访问其内置功能** +>+ openharmony API: ohos.aafwk.ability.Ability +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// android中该类主要是旧安卓设备实现新的视图功能的一个类,总的来说对应的还是视图(activity),鸿蒙中对应Ability +public class MainAbility extends Ability{} +``` diff --git a/support/v7/widget/LinearLayoutManager.md b/support/v7/widget/LinearLayoutManager.md new file mode 100644 index 0000000..c09c0ca --- /dev/null +++ b/support/v7/widget/LinearLayoutManager.md @@ -0,0 +1,11 @@ +### **设置recyclerview视图页面的风格,LinearLayoutManager表示为列表风格** +>+ openharmony API: ohos.agp.components.DirectionalLayoutManager +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 设置视图风格 +public void setLayoutManager(ListContainer list) { + list.setLayoutManager(new DirectionalLayoutManager()); +} +``` \ No newline at end of file diff --git a/support/v7/widget/RecyclerView.md b/support/v7/widget/RecyclerView.md new file mode 100644 index 0000000..3d109c9 --- /dev/null +++ b/support/v7/widget/RecyclerView.md @@ -0,0 +1,52 @@ +### **适配器类TreeViewAdapter继承RecyclerView.Adapter ,重写getItemViewType()、onCreateViewHolder()、onBindViewHolder()、getItemCount()等方法** +### **onCreateViewHolder()用于创建ViewHolder实例,并把加载的布局传入到构造函数去,再把ViewHolder实例返回。onBindViewHolder()则是用于对子项的数据进行赋值,会在每个子项被滚动到屏幕内时执行。position得到当前项的实例** +### **getItemCount()返回RecyclerView的子项数目。在刷新页面数据时还会调用notifyItemRangeChanged()、notifyItemChanged()、notifyDataSetChanged()、notifyItemRangeInserted()、notifyItemRangeRemoved()、notifyItemRemoved()等方法** +>+ openharmony API: ohos.agp.components.ListContainer +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 重写getItemViewType、getComponent()、getCount()等方法,刷新页面数据时调用的对应方法分别为notifyDataSetItemRangeChanged()、 +// notifyDataSetItemChanged()、notifyDataChanged()、notifyDataSetItemRangeInserted()、notifyDataSetItemRangeRemoved()、 +// notifyDataSetItemRemoved() +public class SampleItemProvider extends BaseItemProvider { + final List list; + final Context context; + public SampleItemProvider(List list, Context context) { + this.list = list; + this.context = context; + } + + @Override + public int getCount() { + return list == null ? 0 : list.size(); + } + @Override + public Object getItem(int position) { + if (list != null && position >= 0 && position < list.size()) { + return list.get(position); + } + return null; + } + @Override + public long getItemId(int position) { + return position; + } + @Override + public Component getComponent(int position, Component convertComponent, ComponentContainer componentContainer) { + final Component cpt; + if (convertComponent == null) { + cpt = LayoutScatter.getInstance(context).parse(ResourceTable.Layout_wearmenu_list_element, null, false); + } else { + cpt = convertComponent; + } + SampleItem sampleItem = list.get(position); + Text text = (Text) cpt.findComponentById(ResourceTable.Id_text); + text.setText(sampleItem.getName()); + Image image = (Image) cpt.findComponentById(ResourceTable.Id_imageButton); + image.setPixelMap(sampleItem.getImage()); + return cpt; + } + +} +``` diff --git a/support/v7/widget/SwitchCompat.md b/support/v7/widget/SwitchCompat.md new file mode 100644 index 0000000..44bd20d --- /dev/null +++ b/support/v7/widget/SwitchCompat.md @@ -0,0 +1,42 @@ +### **setOnCheckedChangeListener()** +>+ openharmony API: ohos.agp.components.Switch.setCheckedStateChangedListener() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代实现,使用方法如下: +```java +// 为按钮的状态更改事件注册一个侦听器 +checkboxFormatCard.setCheckedStateChangedListener(new AbsButton.CheckedStateChangedListener() { + @Override + public void onCheckedChanged(AbsButton buttonView, boolean isChecked) { + String value0 = tvBankCardNumber0.getText(); + String value = tvBankCardNumber.getText(); + String value1 = tvBankCardNumberICBC.getText(); + String value2 = tvBankCardNumberICBC1.getText(); + String value3 = tvBankCardNumber1.getText(); + + if (isChecked) { + if (!RxDataTool.isContainSpace(value)) { + tvBankCardNumber.setText(RxDataTool.formatCard(value)); + } + if (!RxDataTool.isContainSpace(value)) { + tvBankCardNumber0.setText(RxDataTool.formatCard(value0)); + } + if (!RxDataTool.isContainSpace(value1)) { + tvBankCardNumberICBC.setText(RxDataTool.formatCard(value1)); + } + if (!RxDataTool.isContainSpace(value2)) { + tvBankCardNumberICBC1.setText(RxDataTool.formatCard(value2)); + } + if (!RxDataTool.isContainSpace(value3)) { + tvBankCardNumber1.setText(RxDataTool.formatCard(value3)); + } + } else { + tvBankCardNumber0.setText(RxDataTool.cleanSpace(value0)); + tvBankCardNumber.setText(RxDataTool.cleanSpace(value)); + tvBankCardNumberICBC.setText(RxDataTool.cleanSpace(value1)); + tvBankCardNumberICBC1.setText(RxDataTool.cleanSpace(value2)); + tvBankCardNumber1.setText(RxDataTool.cleanSpace(value3)); + } + } +}); +``` diff --git a/support/v8/renderscript/ScriptIntrinsicBlur.md b/support/v8/renderscript/ScriptIntrinsicBlur.md new file mode 100644 index 0000000..11fe474 --- /dev/null +++ b/support/v8/renderscript/ScriptIntrinsicBlur.md @@ -0,0 +1,23 @@ +### **ScriptIntrinsicBlur.create(rs, Element.U8_4(rs))** +>+ openharmony API: ohos.agp.render.MaskFilter +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 使用高斯模糊视图 +// 新建画笔,设置它的MaskFilter,定制模糊半径和模糊效果,将视图绘制到新的位图上。实现类似高斯模糊效果 +public void drawPixelMapHolder(Image iv, PixelMap src, float radius, int color) { + Paint paint = new Paint(); + paint.setAntiAlias(true); + paint.setColor(new ohos.agp.utils.Color(color)); + paint.setMaskFilter(new MaskFilter(radius,MaskFilter.Blur.OUTER)); + + PixelMap.InitializationOptions initializationOptions = new PixelMap.InitializationOptions(); + initializationOptions.pixelFormat = PixelFormat.ARGB_8888; + initializationOptions.size = new Size(10, 20); + PixelMap dest = PixelMap.create(initializationOptions); + Canvas canvas = new Canvas(new Texture(dest)); + PixelMap alpha = src.createFromAlpha(); + canvas.drawPixelMapHolder(new PixelMapHolder(alpha), 0.0F, 0.0F, paint); +} +``` diff --git a/support/wearable/view/WearableListView.md b/support/wearable/view/WearableListView.md new file mode 100644 index 0000000..5c5af85 --- /dev/null +++ b/support/wearable/view/WearableListView.md @@ -0,0 +1,26 @@ +### **setAdapter(Adapter adapter)** +>+ openharmony API: ohos.agp.components.ListContainer.setItemProvider(BaseItemProvider itemProvider) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 设置一个BaseItemProvider对象,以提供一个包含要显示组件的ListContainer对象 +SampleItemProvider sampleItemProvider = new SampleItemProvider(elementList,this); +pager.setItemProvider(sampleItemProvider); +pager.setReboundEffect(false); +``` + +### **setClickListener(WearableListView.ClickListener clickListener)** +>+ openharmony API: ohos.agp.components.ListContainer.setItemClickedListener(ListContainer.ItemClickedListener listener) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换实现,使用方法如下: +```java +// 为组件项设置单击侦听器 +pager.setItemClickedListener(new ListContainer.ItemClickedListener() { + @Override + public void onItemClicked(ListContainer listContainer, Component component, int i, long l) { + new ToastDialog(MainAbility.this).setOffset(20,150).setContentText(String.format("Selected Title %d", (i + 1))).show(); + } +}); +``` \ No newline at end of file diff --git a/telephony/TelephonyManager.md b/telephony/TelephonyManager.md new file mode 100644 index 0000000..609330f --- /dev/null +++ b/telephony/TelephonyManager.md @@ -0,0 +1,217 @@ +### **getDeviceSoftwareVersion()** +>+ openharmony API: ohos.bundle.BundleInfo.getVersionCode() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取App版本号 +public static final int getAppVersionNo(Context context) { + if (context == null) { + return -1; + } + IBundleManager bundleManager = context.getBundleManager(); + try { + BundleInfo bundleInfo = bundleManager.getBundleInfo(context.getBundleName(), 0); + return bundleInfo != null ? bundleInfo.getVersionCode() : -1; + } catch (RemoteException e) { + } + return -1; +} +``` + +### **getNetworkOperator()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getSimOperatorNumeric(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取设备的 MCC + MNC +public static final String getNetworkOperator(Context context) { + if (context == null) { + return ""; + } + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getSimOperatorNumeric(getDefaultSlotId(context)) : ""; +} +``` + +### **getNetworkOperatorName()** +>+ openharmony API: ohos.telephony.RadioInfoManager.getInstance(context).getOperatorName(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取(当前已注册的用户)的名字 +public static final String getNetworkOperatorName(Context context) { + if (context == null) { + return ""; + } + + RadioInfoManager radioInfoManager = RadioInfoManager.getInstance(context); + return radioInfoManager != null ? radioInfoManager.getOperatorName(getDefaultSlotId(context)) : ""; +} +``` + +### **getNetworkCountryIso()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getIsoCountryCodeForSim​(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取ISO标准的国家码,即国际长途区号 +public static final String getNetworkCountryIso(Context context) { + if (context == null) { + return ""; + } + + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getIsoCountryCodeForSim(getDefaultSlotId(context)) : ""; +} +``` + +### **getSimOperator()** +>+ openharmony API: ohos.telephony.RadioInfoManager.getInstance(context).getOperatorName(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取SIM卡提供的移动国家码和移动网络码.5或6位的十进制数字 +public static final String getNetworkOperatorName(Context context) { + if (context == null) { + return ""; + } + + RadioInfoManager radioInfoManager = RadioInfoManager.getInstance(context); + return radioInfoManager != null ? radioInfoManager.getOperatorName(getDefaultSlotId(context)) : ""; +} +``` + +### **getSimSerialNumber()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getSimIccId​(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取SIM卡的序列号 +public static final String getSimSerialNumber(Context context) { + if (context == null) { + return ""; + } + + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getSimIccId(getDefaultSlotId(context)) : ""; +} +``` + +### **getSimState()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getSimState​(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取SIM的状态信息 +public static final int getSimState(Context context) { + if (context == null) { + return TelephonyConstants.SIM_STATE_UNKNOWN; + } + + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getSimState(getDefaultSlotId(context)) : TelephonyConstants.SIM_STATE_UNKNOWN; +} +``` + +### **getSimOperatorName()** +>+ openharmony API: ohos.telephony.RadioInfoManager.getInstance(context).getOperatorName(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取服务商名称 +public static final String getNetworkOperatorName(Context context) { + if (context == null) { + return ""; + } + + RadioInfoManager radioInfoManager = RadioInfoManager.getInstance(context); + return radioInfoManager != null ? radioInfoManager.getOperatorName(getDefaultSlotId(context)) : ""; +} +``` + +### **getSubscriberId()** +>+ openharmony API: ohos.telephony.RadioInfoManager.getInstance(context).getUniqueDeviceId(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取唯一的用户ID +public static final String getSubscriberId(Context context) { + if (context == null) { + return ""; + } + + RadioInfoManager radioInfoManager = RadioInfoManager.getInstance(context); + return radioInfoManager != null ? radioInfoManager.getUniqueDeviceId(getDefaultSlotId(context)) : ""; +} +``` + +### **getVoiceMailNumber()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getVoiceMailNumber(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取语音邮件号码 +public static final String getVoiceMailNumber(Context context) { + if (context == null) { + return ""; + } + + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getVoiceMailNumber(getDefaultSlotId(context)) : ""; +} +``` + +### **getLine1Number()** +>+ openharmony API: ohos.telephony.SimInfoManager.getInstance(context).getSimTelephoneNumber(int slotId) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取手机号 +public static final String getLine1Number(Context context) { + if (context == null) { + return "invalid number"; + } + + SimInfoManager simInfoManager = SimInfoManager.getInstance(context); + return simInfoManager != null ? simInfoManager.getSimTelephoneNumber(getDefaultSlotId(context)) : "invalid number"; +} +``` + +### **getSubscriberId()** +>+ openharmony API: ohos.distributedschedule.interwork.DeviceInfo.getDeviceId() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取IMEI +public static final String getDeviceIdIMEI(Context context) { + if (context == null) { + return ""; + } + + String id = null; + List list = DeviceManager.getDeviceList(ohos.distributedschedule.interwork.DeviceInfo.FLAG_GET_ALL_DEVICE); + if (list == null || list.size() == 0) { + return ""; + } + + for (int i = 0; i < list.size(); ++i) { + ohos.distributedschedule.interwork.DeviceInfo info = list.get(i); + if (info.getDeviceType() == ohos.distributedschedule.interwork.DeviceInfo.DeviceType.SMART_PHONE) { + return info.getDeviceId(); + } + } + return id; +} +``` \ No newline at end of file diff --git a/telephony/telephony.md b/telephony/telephony.md new file mode 100644 index 0000000..1d89674 --- /dev/null +++ b/telephony/telephony.md @@ -0,0 +1,75 @@ +### **getColor()** +>+ openharmony API: ohos.global.resource.Element.getColor() +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// AbilityContext直接获取ResourceManager +int color = getResourceManager().getElement(ResourceTable.Color_aqua).getColor(); +``` + +### **onSaveInstanceState(Bundle bundle))** +>+ openharmony API: ohos.aafwk.ability.onPostStart(PacMap pacMap); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java + +// 当前ability 复写即可 +@Override +protected void onPostStart(PacMap pacMap) { + super.onPostStart(pacMap); +} +``` + +### **vibrateOnce(context: Context, millisecond: Int)** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.startOnce(int duration) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.startOnce(200); +``` + +### **vibrateStop();** +>+ openharmony API: ohos.vibrator.agent.VibratorAgent.vibrateStop(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +//直接构造 +VibratorAgent vibratorAgent = new VibratorAgent(); +vibratorAgent.vibrateStop(); +``` + +### **setOnDrawerOpenListener(SlidingDrawer.OnDrawerOpenListener listener)** +>+ openharmony API: ohos.agp.components.SlideDrawer.addSlideListener(); +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +SlideDrawer slideDrawer =new SlideDrawer(this); +slideDrawer.addSlideListener(new SlideDrawer.SlideListener() { + @Override + public void onOpen(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { + + } + + @Override + public void onMiddle(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, SlideDrawer.DrawerState drawerState) { + + } + + @Override + public void onClose(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { + + } + + @Override + public void onSlideChange(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, int i, int i1) { + + } +}); +``` \ No newline at end of file diff --git a/text/Editable.md b/text/Editable.md new file mode 100644 index 0000000..ba5e94c --- /dev/null +++ b/text/Editable.md @@ -0,0 +1,10 @@ +### **Editable ** +>+ openharmony API: ohos.agp.components.TextField.TextField​(Context context) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 这是文本的界面,其内容和标记可以更改(与不变的文本(如字符串)相对)。 +// 直接构建: +TextField textField = new TextField(this); +``` diff --git a/text/TextPaint.md b/text/TextPaint.md new file mode 100644 index 0000000..fd541b5 --- /dev/null +++ b/text/TextPaint.md @@ -0,0 +1,39 @@ +### **setAntiAlias(boolean aa) ** +>+ openharmony API: ohos.agp.render.Paint.setAntiAlias​(boolean flag); +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// setFlags() 的助手,设置或清除 ANTI_ALIAS_FLAG 位 AntiAliasing 平滑了正在绘制的边缘,但对形状的内部没有影响。 +// 设置画笔抗锯齿 +// 直接构建: +Paint paint = new Paint(); +paint.setAntiAlias(true); +``` + +### **setTextSize(float textSize) ** +>+ openharmony API: ohos.agp.render.Paint.setTextSize​(int textSize); +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 设置画笔字体大小 +// 直接构建: +Paint paint = new Paint(); +paint.setTextSize(10); +``` + +### **setColor(int color) ** +>+ openharmony API: ohos.agp.render.Paint.setColor(Color newColor); +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +// 设置画笔颜色 +// 直接构建: +```java +Paint paint = new Paint(); +paint.setColor(new Color()); +``` + + + \ No newline at end of file diff --git a/text/TextUtils.md b/text/TextUtils.md index 614eaff..44c18c5 100644 --- a/text/TextUtils.md +++ b/text/TextUtils.md @@ -1,4 +1,4 @@ -### **isEmpty** +### **isEmpty()** >+ openharmony API: ohos.agp.utils.TextTool.isNullOrEmpty >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 @@ -10,7 +10,7 @@ TextTool.isNullOrEmpty(str); ``` -### **equals** +### **equals()** >+ openharmony API: ohos.agp.utils.TextTool.isEqual >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 diff --git a/util/AttributeSet.md b/util/AttributeSet.md new file mode 100644 index 0000000..ca606c0 --- /dev/null +++ b/util/AttributeSet.md @@ -0,0 +1,10 @@ +### **AttributeSet** +>+ openharmony API: ohos.agp.components.AttrSet +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 安卓中往往需要自定义控件,自定义控件多是继承于标准控件,需要使用AttributeSet来完成控件类的构造函数,并在构造函数中将自定义控件类中变量与attrs.xml中的属性连接起来 +// 替换使用,使用方法如下: +public void CustomLayout(Context context , AttrSet attrSet){} +``` \ No newline at end of file diff --git a/util/DisplayMetrics.md b/util/DisplayMetrics.md new file mode 100644 index 0000000..d2d114f --- /dev/null +++ b/util/DisplayMetrics.md @@ -0,0 +1,13 @@ +### **displayMetrics.widthPixels,displayMetrics. heightPixels ** +>+ openharmony API: ohos.agp.window.service.DisplayManager,ohos.agp.window.service.Display,ohos.agp.window.service. DisplayAttributes +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 获取手机屏幕中的一些信息,显示屏幕绝对高度(单位 像素), 显示屏幕绝对宽度(单位 像素)。 +// 替换使用,使用方法如下: +DisplayManager displayManager = DisplayManager.getInstance(); +Display display = displayManager.getDefaultDisplay(getContext()).get(); +int width = display.getRealAttributes().width; +int height = display.getRealAttributes().height; +``` \ No newline at end of file diff --git a/util/Log.md b/util/Log.md new file mode 100644 index 0000000..4656800 --- /dev/null +++ b/util/Log.md @@ -0,0 +1,12 @@ +### **Log.e(String tag, String msg, Throwable tr)** +>+ openharmony API: ohos.hiviewdfx.HiLog.error​(HiLogLabel label, String format, Object... args) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 用于发送日志输出的 API,一个好的约定是标志在你的类中声明一个常量,并在随后对日志方法的调用中使用它。。 +// 直接构建 +HiLogLabel label = new HiLogLabel(HiLog.DEBUG,0x00001,"MainAbility"); +HiLog.error(label,"onStart"); +``` + diff --git a/util/Pair.md b/util/Pair.md new file mode 100644 index 0000000..d57bb9d --- /dev/null +++ b/util/Pair.md @@ -0,0 +1,10 @@ +### **pair(any, any)** +>+ openharmony API: ohos.utils.Pair.s 和 .c +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 通过将两个参数打包成一个,Pair 容器使参数传递更容易。 +// 直接构建 +Pair pair = new Pair(1,"name"); +``` diff --git a/util/SparseArray.md b/util/SparseArray.md index 4ad24a2..78aed15 100644 --- a/util/SparseArray.md +++ b/util/SparseArray.md @@ -57,3 +57,14 @@ plainArray.contains(1); PlainArray plainArray = new PlainArray<>(); plainArray.clear(); ``` + +### **SparseArray ** +>+ openharmony API: ohos.utils.PlainArray.PlainArray() +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// SparseArray将整数映射到对象,并且与普通的对象数组不同,其索引可以包含空格。 +// 直接构建 +private PlainArray plainIntArray = new PlainArray(); +``` \ No newline at end of file diff --git a/view/Display.md b/view/Display.md new file mode 100644 index 0000000..bd25f4f --- /dev/null +++ b/view/Display.md @@ -0,0 +1,9 @@ +### **Display** +>+ openharmony API: ohos.agp.window.service.Display +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 封装显示属性和操作。 +Display display = DisplayManager.getInstance().getDefaultDisplay(this).get(); +``` \ No newline at end of file diff --git a/view/Gravity.md b/view/Gravity.md new file mode 100644 index 0000000..f2ded06 --- /dev/null +++ b/view/Gravity.md @@ -0,0 +1,10 @@ +### **Gravity** +>+ openharmony API: ohos.agp.utils.LayoutAlignment +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 用于定义组件的水平和垂直对齐的实用程序类。 +DirectionalLayout layout = (DirectionalLayout) findComponentById(ResourceTable.Id_dl_main); +layout.setAlignment(LayoutAlignment.RIGHT); +``` \ No newline at end of file diff --git a/view/Menu.md b/view/Menu.md new file mode 100644 index 0000000..1a257c1 --- /dev/null +++ b/view/Menu.md @@ -0,0 +1,19 @@ +### **Menu** +>+ openharmony API: ohos.agp.components.ClickedListener +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替代实现,使用方法如下: +```java +// 安卓项目中将相机的操作选项添加到菜单中进行控制,转移到鸿蒙中是将这些选项设置成对应的Button按键并添加对应的点击事件监听来控制相机。 +private Component.ClickedListener clickedListener = new Component.ClickedListener() { + @Override + public void onClick(Component component) { + mFlash = !mFlash; + if (mFlash) { + button.setText("Flash [ON]"); + } else { + button.setText("Flash [OFF]"); + } + } +}; +``` \ No newline at end of file diff --git a/view/OnClickListener.md b/view/OnClickListener.md new file mode 100644 index 0000000..37968a8 --- /dev/null +++ b/view/OnClickListener.md @@ -0,0 +1,15 @@ +### **OnClickListener** +>+ openharmony API: ohos.agp.components.Component.ClickedListener +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 提供在单击组件时调用的回调。 +Button button = findComponentById(ResourceTable.Id_button2); + button.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + + } + }); +``` \ No newline at end of file diff --git a/view/SurfaceView.md b/view/SurfaceView.md new file mode 100644 index 0000000..61da040 --- /dev/null +++ b/view/SurfaceView.md @@ -0,0 +1,9 @@ +### **SurfaceView** +>+ openharmony API: ohos.agp.components.surfaceprovider.SurfaceProvider +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 提供一个专用的绘图曲面,它是组件的基本组件之一。它通常用于需要快速绘制图像的地方,例如视频回放的情况 +SurfaceProvider surfaceProvider = new SurfaceProvider(this); +``` \ No newline at end of file diff --git a/view/TextureView.md b/view/TextureView.md new file mode 100644 index 0000000..97b325c --- /dev/null +++ b/view/TextureView.md @@ -0,0 +1,9 @@ +### **TextureView** +>+ openharmony API: ohos.agp.components.surfaceprovider.SurfaceProvider +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 提供一个专用的绘图曲面,它是组件的基本组件之一。它通常用于需要快速绘制图像的地方,例如视频回放的情况 +SurfaceProvider surfaceProvider = new SurfaceProvider(this); +``` \ No newline at end of file diff --git a/view/VelocityTracker.md b/view/VelocityTracker.md index 637ee65..7602a3b 100644 --- a/view/VelocityTracker.md +++ b/view/VelocityTracker.md @@ -67,4 +67,28 @@ detector.getVerticalVelocity(); ```java VelocityDetector detector = VelocityDetector.obtainInstance(); detector.clear(); +``` + +### **VelocityTracker** +>+ openharmony API: ohos.agp.components.VelocityDetector +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 帮助检测触摸事件的速度,用于实现投掷和其他类似的手势。 +velocityDetector = VelocityDetector.obtainInstance(); + +if (velocityDetector != null) { + velocityDetector.clear(); + velocityDetector = null; +} +velocityDetector.getHorizontalVelocity(); +velocityDetector.getVerticalVelocity(); +velocityDetector.calculateCurrentVelocity(10000); + + +@Override +protected boolean onTouchEvent(TouchEvent event) { + velocityDetector.addEvent(event); +} ``` \ No newline at end of file diff --git a/view/ViewGroup.md b/view/ViewGroup.md new file mode 100644 index 0000000..c43f78d --- /dev/null +++ b/view/ViewGroup.md @@ -0,0 +1,21 @@ +### **getChildCount()** +>+ openharmony API: ohos.agp.components.ComponentContainer.getChildCount() +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取子组件的数量。 +ComponentContainer componentContainer = (ComponentContainer) findComponentById(ResourceTable.Id_dl_main); +int childCount = componentContainer.getChildCount(); +``` + +### **getChildAt()** +>+ openharmony API: ohos.agp.components.ComponentContainer.getComponentAt() +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 使用索引获取子组件。 +ComponentContainer componentContainer = (ComponentContainer) findComponentById(ResourceTable.Id_dl_main); +Component componentAt = componentContainer.getComponentAt(0); +``` \ No newline at end of file diff --git a/view/ViewParent.md b/view/ViewParent.md new file mode 100644 index 0000000..9b788f5 --- /dev/null +++ b/view/ViewParent.md @@ -0,0 +1,55 @@ +### **ViewParent** +>+ openharmony API: ohos.agp.components.ComponentParent +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 定义父组件的特性。这个类提供了组件与其父组件交互的接口。 +class MyComponentParent extends ComponentParent { + + @Override + public void postLayout() { + + } + + @Override + public int getChildIndex(Component component) { + return 0; + } + + @Override + public void removeComponent(Component component) { + + } + + @Override + public void removeComponentAt(int i) { + + } + + @Override + public void removeComponents(int i, int i1) { + + } + + @Override + public ComponentContainer.LayoutConfig verifyLayoutConfig(ComponentContainer.LayoutConfig layoutConfig) { + return null; + } + + @Override + public ComponentParent getComponentParent() { + return null; + } + + @Override + public void moveChildToFront(Component component) { + + } + + @Override + public boolean onDrag(Component component, DragEvent dragEvent) { + return false; + } + } +``` \ No newline at end of file diff --git a/view/Window.md b/view/Window.md new file mode 100644 index 0000000..e356e19 --- /dev/null +++ b/view/Window.md @@ -0,0 +1,32 @@ +### **getAttributes()** +>+ openharmony API: ohos.agp.window.service.Window.getLayoutConfig() +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取要读取或修改的Window实例的LayoutConfig对象。 +Window window = getWindow(); +WindowManager.LayoutConfig layoutConfig = window.getLayoutConfig().get(); +``` + +### **setStatusBarColor(int)** +>+ openharmony API: ohos.agp.window.service.Window.setStatusBarColor(int) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置状态栏的颜色。 +Window window = getWindow(); +window.setStatusBarColor(Color.RED.getValue()); +``` + +### **setAttributes(LayoutParams)** +>+ openharmony API: ohos.agp.window.service.Window.setLayoutConfig(ohos.agp.window.service.WindowManager.LayoutConfig) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置Window实例的LayoutConfig。 +Window window = getWindow(); +window.setLayoutConfig(new WindowManager.LayoutConfig()); +``` \ No newline at end of file diff --git a/view/WindowManager.md b/view/WindowManager.md index a1a5d88..2bd446a 100644 --- a/view/WindowManager.md +++ b/view/WindowManager.md @@ -23,4 +23,16 @@ popupDialog.setBackColor(new Color(0x00000000)); popupDialog.show(); ``` ->+ 补充说明:当前SDK版本:2.1.0.17不生效,后续支持。 \ No newline at end of file +>+ 补充说明:当前SDK版本:2.1.0.17不生效,后续支持。 + + +### **LayoutParams()** +>+ openharmony API: ohos.agp.window.service.WindowManager.LayoutConfig(); +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 应用程序用来与窗口管理器对话的界面 +Window window = getWindow(); +WindowManager.LayoutConfig layoutConfig = window.getLayoutConfig().get(); +``` \ No newline at end of file diff --git a/view/animation/DecelerateInterpolator.md b/view/animation/DecelerateInterpolator.md new file mode 100644 index 0000000..af8e6c9 --- /dev/null +++ b/view/animation/DecelerateInterpolator.md @@ -0,0 +1,10 @@ +### **DecelerateInterpolator** +>+ openharmony API: ohos.agp.animation.Animator +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案:替换使用,使用方法如下: +```java +// 动画器的基类。这个类为动画提供了基本的支持。除了启动、停止、暂停和恢复动画器,它还允许您获得动画器的持续时间、启动延迟、重复次数和指定的曲线类型。 +AnimatorValue animatorValue = new AnimatorValue(); +animatorValue.setCurveType(Animator.CurveType.DECELERATE); +``` \ No newline at end of file diff --git a/widget/CompoundButton.md b/widget/CompoundButton.md new file mode 100644 index 0000000..4cabf24 --- /dev/null +++ b/widget/CompoundButton.md @@ -0,0 +1,16 @@ +### **OnCheckedChangeListener()** +>+ openharmony API: ohos.agp.components.ComponentStateChangedListener +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 复合按钮,具有两个状态(已选中和未选中)的按钮。当按下或单击按钮时,状态将自动更改 +public static interface ComponentStateChangedListener { + void onComponentStateChanged(ohos.agp.components.Component component, int i); +} + +// 实现该接口 +public class TextView implements Component.ComponentStateChangedListener{} +@Override +public void onComponentStateChanged(Component component, int i) {} +``` diff --git a/widget/EditText.md b/widget/EditText.md new file mode 100644 index 0000000..b38d6e7 --- /dev/null +++ b/widget/EditText.md @@ -0,0 +1,9 @@ +### **getText()** +>+ openharmony API: ohos.agp.components.TextField.getText() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取到输入的值 +String Text = et_bar_code.getText(); +``` \ No newline at end of file diff --git a/widget/ImageView.md b/widget/ImageView.md index ac6cb10..dd59090 100644 --- a/widget/ImageView.md +++ b/widget/ImageView.md @@ -1,4 +1,4 @@ -### **setColorFilter** +### **setColorFilter(color: Int, mode: PorterDuff.Mode!)** >+ openharmony API:暂无 >+ openharmony SDK版本:2.1.1.21 >+ IDE版本:2.1.0.501 diff --git a/widget/LinearLayout.md b/widget/LinearLayout.md new file mode 100644 index 0000000..e30d3db --- /dev/null +++ b/widget/LinearLayout.md @@ -0,0 +1,9 @@ +### **setGravity(gravity: Int)** +>+ openharmony API: ohos.agp.components.DirectionalLayout.setAlignment​(int alignment) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 在容器的可用空间(如果有的话)中设置子组件对齐方式 +setAlignment(LayoutAlignment.VERTICAL_CENTER); +``` diff --git a/widget/ProgressBar.md b/widget/ProgressBar.md new file mode 100644 index 0000000..70cfb46 --- /dev/null +++ b/widget/ProgressBar.md @@ -0,0 +1,35 @@ +### **setMin(min: Int)** +>+ openharmony API: ohos.agp.components.RoundProgressBar.setStartAngle​(float startAngle) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置起始角度 +roundProgressBar.setStartAngle(0f); +``` + +### **setMax(max: Int)** +>+ openharmony API: ohos.agp.components.RoundProgressBar.setMaxAngle​(float maxAngle) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置起始角度 +roundProgressBar.setStartAngle(0f); +// 设置最大角度 +roundProgressBar.setMaxAngle(0f); +``` + +### **setProgress(int progress)** +>+ openharmony API: ohos.agp.components.ProgressBar.setProgressValue(int progress) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置起始角度 +roundProgressBar.setStartAngle(0f); +// 设置最大角度 +roundProgressBar.setMaxAngle(0f); +// 设置当前进度条的值 +roundProgressBar.setProgressValue(20); +``` \ No newline at end of file diff --git a/widget/RadioButton.md b/widget/RadioButton.md new file mode 100644 index 0000000..f6ace1e --- /dev/null +++ b/widget/RadioButton.md @@ -0,0 +1,13 @@ +### **setText(CharSequence text)** +>+ openharmony API: ohos.agp.components.Text.setText​(String text) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置单选按钮文本 +protected void updateBootstrapState() { + if (bootstrapText != null) { + setText(bootstrapText); + } +} +``` \ No newline at end of file diff --git a/widget/RadioGroup.md b/widget/RadioGroup.md new file mode 100644 index 0000000..76f2dff --- /dev/null +++ b/widget/RadioGroup.md @@ -0,0 +1,12 @@ +### **setOnCheckedChangeListener(listener: RadioGroup.OnCheckedChangeListener!)** +>+ openharmony API: ohos.agp.component.RadioContainer.setMarkChangedListener​(RadioContainer.CheckedStateChangedListener listener) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置单选容器中单选按钮更改事件的监听器 +@Override +public void setMarkChangedListener(CheckedStateChangedListener listener) { + mCheckedChangeListener = listener; +} +``` \ No newline at end of file diff --git a/widget/RatingBar.md b/widget/RatingBar.md new file mode 100644 index 0000000..ec708b2 --- /dev/null +++ b/widget/RatingBar.md @@ -0,0 +1,21 @@ +### **RatingBar(context: Context!)** +>+ openharmony API: ohos.agp.components.Rating.Rating​(Context context) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +Rating rating = new Rating(getContext()); +``` + +### **setIsIndicator(isIndicator: Boolean)** +>+ openharmony API: ohos.agp.components.Rating.setIsOperable​(boolean isOperable) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +Rating rating = new Rating(getContext()); +// 设置是否可以操作 +rating.setIsOperable(false); +``` \ No newline at end of file diff --git a/widget/SeekBar.md b/widget/SeekBar.md new file mode 100644 index 0000000..841f312 --- /dev/null +++ b/widget/SeekBar.md @@ -0,0 +1,13 @@ +### **SeekBar(context: Context!)** +>+ openharmony API: ohos.agp.components.ProgressBar.ProgressBar​(Context context) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +progressBar = new ProgressBar(getContext()); +// 设置最小值 +progressBar.setMinValue(0); +// 设置最大值 +progressBar.setMaxValue(100); +``` diff --git a/widget/Spinner.md b/widget/Spinner.md new file mode 100644 index 0000000..7362c67 --- /dev/null +++ b/widget/Spinner.md @@ -0,0 +1,31 @@ +### **Spinner(context: Context!)** +>+ openharmony API: ohos.agp.window.dialog.PopupDialog +>+ openharmony API: ohos.agp.components.ListContainer +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代使用,使用方法如下: +```java +// 下拉菜单 +public class CustomSpinner extends ListContainer{ + + private Text mText; + private PopupDialog mPopupDialog; + private Slider slider; + + public CustomSpinner(Context context) { + this(context,null); + } + public CustomSpinner(Context context,AttrSet attrSet) { + this(context,null,""); + } + public CustomSpinner(Context context,AttrSet attrSet,String styleName) { + super(context,attrSet,styleName); + init(); + } + public void setCustomComponent(Text text,PopupDialog popupDialog,Slider slider1){ + mText = text; + mPopupDialog = popupDialog; + slider = slider1; + } +} +``` diff --git a/widget/Switch.md b/widget/Switch.md new file mode 100644 index 0000000..73ca773 --- /dev/null +++ b/widget/Switch.md @@ -0,0 +1,16 @@ +### **Switch(context: Context!)** +>+ openharmony API: ohos.agp.components.Switch.Switch​(Context context) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +mSwitch = new Switch(getContext()); +// 给switch设置一个点击事件,再实现点击监听类对该checkbox进行选择状态判断,并修改滑块和轨迹的样式 +mSwitch.setCheckedStateChangedListener(new AbsButton.CheckedStateChangedListener() { + @Override + public void onCheckedChanged(AbsButton absButton, boolean b) { + // 修改轨迹和样式 + } +}); +``` diff --git a/widget/TextView.md b/widget/TextView.md new file mode 100644 index 0000000..8db10c8 --- /dev/null +++ b/widget/TextView.md @@ -0,0 +1,50 @@ +### **setText(text: CharSequence!)** +>+ openharmony API: ohos.agp.components.Text.setText​(String text) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置要在文本组件中显示的文本 +text.setText("test"); +``` + +### **setTextSize(size: Float)** +>+ openharmony API: ohos.agp.components.Text.setTextSize​(int size) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 为文本设置指定的字体大小 +text.setTextSize(10); +``` + +### **getTextSize()** +>+ openharmony API: ohos.agp.components.Text.getTextSize​() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 获取文本组件的文本大小 +text.getTextSize(); +``` + +### **setTextColor(color: Int)** +>+ openharmony API: ohos.agp.components.Text.setTextColor​(Color color) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置文本组件的文本颜色 +text.setTextColor(Color.BLUE); +``` + +### **setTypeface(tf: Typeface?)** +>+ openharmony API: ohos.agp.components.Text.setFont​(Font font) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 设置文本字体 +text.setFont(Font.DEFAULT_BOLD); +``` + diff --git a/widget/Toast.md b/widget/Toast.md new file mode 100644 index 0000000..5200f7e --- /dev/null +++ b/widget/Toast.md @@ -0,0 +1,18 @@ +### **makeText(context: Context!, text: CharSequence!, duration: Int)** +>+ openharmony API: ohos.agp.window.dialog.ToastDialog +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 在窗口上方提供一个toast对话框,用于通知操作的简单反馈 +// 实例化 +ToastDialog toastDialog = new ToastDialog(context); +// 设置时长 +toastDialog.setDuration(500); +// 设置内容 +toastDialog.setText("测试"); +// 设置对话框对齐模式 +toastDialog.setAlignment(LayoutAlignment.CENTER) +// 显示 +toastDialog.show(); +``` \ No newline at end of file -- Gitee From e3b34b2be9d51a13f0409a4e4576734c954e4ed9 Mon Sep 17 00:00:00 2001 From: zm <87072237@qq.com> Date: Fri, 25 Jun 2021 09:41:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/Camera.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/Camera.md b/hardware/Camera.md index 92bbbe8..e4afbfe 100644 --- a/hardware/Camera.md +++ b/hardware/Camera.md @@ -4,7 +4,7 @@ >+ IDE版本:2.1.0.501 >+ 实现方案: ```java ->//应用调用autoFocus(),相机将停止发送面部回叫。最后的面部回调指示用于进行自动对焦的区域。焦点完成后,面部检测将继续发送面部回调. +//应用调用autoFocus(),相机将停止发送面部回叫。最后的面部回调指示用于进行自动对焦的区域。焦点完成后,面部检测将继续发送面部回调. // 替换使用,使用方法如下: if (useAutoFocus){ if (!stopped && focusing){ -- Gitee From 1ffdf8e50b027f5aa971eabcf69fd5d8f39d69bf Mon Sep 17 00:00:00 2001 From: zm <87072237@qq.com> Date: Fri, 25 Jun 2021 09:55:30 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- location/location.md | 3 +- net/ProxyInfo.md | 4 +-- telephony/telephony.md | 75 ------------------------------------------ text/Editable.md | 2 +- text/TextPaint.md | 6 ++-- util/DisplayMetrics.md | 2 +- util/SparseArray.md | 2 +- 7 files changed, 9 insertions(+), 85 deletions(-) delete mode 100644 telephony/telephony.md diff --git a/location/location.md b/location/location.md index e5274bf..1565a41 100644 --- a/location/location.md +++ b/location/location.md @@ -36,8 +36,7 @@ LocatorCallback locatorCallback = new LocatorCallback() { }; ``` -### **onStatusChanged(**provider: String, status: -Int, extras: Bundle) +### **onStatusChanged(provider: String, status:nt, extras: Bundle)** >+ openharmony API: ohos.location.LocatorCallback.onStatusChanged(int type) >+ openharmony SDK版本:2.1.1.18 以上 >+ IDE版本:2.1.0.302 diff --git a/net/ProxyInfo.md b/net/ProxyInfo.md index 6704e4e..0347179 100644 --- a/net/ProxyInfo.md +++ b/net/ProxyInfo.md @@ -6,7 +6,7 @@ ```java // 直接构造 HttpProxy httpProxy = new HttpProxy(); - httpProxy.getHost(); +httpProxy.getHost(); ``` ### **getPort()** @@ -17,5 +17,5 @@ HttpProxy httpProxy = new HttpProxy(); ```java // 直接构造 HttpProxy httpProxy = new HttpProxy(); - httpProxy.getPort(); +httpProxy.getPort(); ``` \ No newline at end of file diff --git a/telephony/telephony.md b/telephony/telephony.md deleted file mode 100644 index 1d89674..0000000 --- a/telephony/telephony.md +++ /dev/null @@ -1,75 +0,0 @@ -### **getColor()** ->+ openharmony API: ohos.global.resource.Element.getColor() ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -// AbilityContext直接获取ResourceManager -int color = getResourceManager().getElement(ResourceTable.Color_aqua).getColor(); -``` - -### **onSaveInstanceState(Bundle bundle))** ->+ openharmony API: ohos.aafwk.ability.onPostStart(PacMap pacMap); ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java - -// 当前ability 复写即可 -@Override -protected void onPostStart(PacMap pacMap) { - super.onPostStart(pacMap); -} -``` - -### **vibrateOnce(context: Context, millisecond: Int)** ->+ openharmony API: ohos.vibrator.agent.VibratorAgent.startOnce(int duration) ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -//直接构造 -VibratorAgent vibratorAgent = new VibratorAgent(); -vibratorAgent.startOnce(200); -``` - -### **vibrateStop();** ->+ openharmony API: ohos.vibrator.agent.VibratorAgent.vibrateStop(); ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -//直接构造 -VibratorAgent vibratorAgent = new VibratorAgent(); -vibratorAgent.vibrateStop(); -``` - -### **setOnDrawerOpenListener(SlidingDrawer.OnDrawerOpenListener listener)** ->+ openharmony API: ohos.agp.components.SlideDrawer.addSlideListener(); ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -SlideDrawer slideDrawer =new SlideDrawer(this); -slideDrawer.addSlideListener(new SlideDrawer.SlideListener() { - @Override - public void onOpen(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { - - } - - @Override - public void onMiddle(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, SlideDrawer.DrawerState drawerState) { - - } - - @Override - public void onClose(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection) { - - } - - @Override - public void onSlideChange(SlideDrawer slideDrawer, SlideDrawer.SlideDirection slideDirection, int i, int i1) { - - } -}); -``` \ No newline at end of file diff --git a/text/Editable.md b/text/Editable.md index ba5e94c..e19bc48 100644 --- a/text/Editable.md +++ b/text/Editable.md @@ -1,4 +1,4 @@ -### **Editable ** +### **Editable** >+ openharmony API: ohos.agp.components.TextField.TextField​(Context context) >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 diff --git a/text/TextPaint.md b/text/TextPaint.md index fd541b5..b5e4627 100644 --- a/text/TextPaint.md +++ b/text/TextPaint.md @@ -1,4 +1,4 @@ -### **setAntiAlias(boolean aa) ** +### **setAntiAlias(boolean aa)** >+ openharmony API: ohos.agp.render.Paint.setAntiAlias​(boolean flag); >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 @@ -11,7 +11,7 @@ Paint paint = new Paint(); paint.setAntiAlias(true); ``` -### **setTextSize(float textSize) ** +### **setTextSize(float textSize)** >+ openharmony API: ohos.agp.render.Paint.setTextSize​(int textSize); >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 @@ -23,7 +23,7 @@ Paint paint = new Paint(); paint.setTextSize(10); ``` -### **setColor(int color) ** +### **setColor(int color)** >+ openharmony API: ohos.agp.render.Paint.setColor(Color newColor); >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 diff --git a/util/DisplayMetrics.md b/util/DisplayMetrics.md index d2d114f..11c9819 100644 --- a/util/DisplayMetrics.md +++ b/util/DisplayMetrics.md @@ -1,4 +1,4 @@ -### **displayMetrics.widthPixels,displayMetrics. heightPixels ** +### **displayMetrics.widthPixels,displayMetrics. heightPixels** >+ openharmony API: ohos.agp.window.service.DisplayManager,ohos.agp.window.service.Display,ohos.agp.window.service. DisplayAttributes >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 diff --git a/util/SparseArray.md b/util/SparseArray.md index 78aed15..c907ccb 100644 --- a/util/SparseArray.md +++ b/util/SparseArray.md @@ -58,7 +58,7 @@ PlainArray plainArray = new PlainArray<>(); plainArray.clear(); ``` -### **SparseArray ** +### **SparseArray** >+ openharmony API: ohos.utils.PlainArray.PlainArray() >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 -- Gitee From 6cd3c9a536f646c051071bf54b8628d1bf05383c Mon Sep 17 00:00:00 2001 From: zm <87072237@qq.com> Date: Fri, 25 Jun 2021 11:47:45 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20SensorManager=E7=B1=BB?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/Camera.md | 15 ++++++++++++++- hardware/Hardware.md | 13 ------------- hardware/SensorManager.md | 27 +++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) delete mode 100644 hardware/Hardware.md create mode 100644 hardware/SensorManager.md diff --git a/hardware/Camera.md b/hardware/Camera.md index e4afbfe..1ac0325 100644 --- a/hardware/Camera.md +++ b/hardware/Camera.md @@ -1,10 +1,23 @@ +### **getParameters().getFocusMode()** +>+ openharmony API: ohos.media.camera.device.Camera;ohos.media.camera.CameraKit +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 检查相机是否能自动对焦. +// 替换使用,使用方法如下: +public AutoFocusManager(Camera camera,CameraSettings settings){ + camera.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PREVIEW).getAfMode(); +} +``` + ### **autoFocus()** >+ openharmony API: ohos.media.camera.device.Camera;ohos.media.camera.CameraKit >+ openharmony SDK版本:2.1.1.21 以上 >+ IDE版本:2.1.0.501 >+ 实现方案: ```java -//应用调用autoFocus(),相机将停止发送面部回叫。最后的面部回调指示用于进行自动对焦的区域。焦点完成后,面部检测将继续发送面部回调. +// 应用调用autoFocus(),相机将停止发送面部回叫。最后的面部回调指示用于进行自动对焦的区域。焦点完成后,面部检测将继续发送面部回调. // 替换使用,使用方法如下: if (useAutoFocus){ if (!stopped && focusing){ diff --git a/hardware/Hardware.md b/hardware/Hardware.md deleted file mode 100644 index 05822a0..0000000 --- a/hardware/Hardware.md +++ /dev/null @@ -1,13 +0,0 @@ -### **getParameters().getFocusMode()** ->+ openharmony API: ohos.media.camera.device.Camera;ohos.media.camera.CameraKit ->+ openharmony SDK版本:2.1.1.21 以上 ->+ IDE版本:2.1.0.501 ->+ 实现方案: -```java ->//检查相机是否能自动对焦. -// 替换使用,使用方法如下: -public AutoFocusManager(Camera camera,CameraSettings settings){ - camera.getFrameConfigBuilder(Camera.FrameConfigType.FRAME_CONFIG_PREVIEW).getAfMode(); -} -``` - diff --git a/hardware/SensorManager.md b/hardware/SensorManager.md new file mode 100644 index 0000000..c807baf --- /dev/null +++ b/hardware/SensorManager.md @@ -0,0 +1,27 @@ +### **getDefaultSensor(type: Int)** +>+ openharmony API: ohos.sensor.agent.SensorAgent.getSingleSensor​(int sensorType) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 获取传感器类别中指定类型的默认传感器 +public void start(){ + if(cameraSettings.isAutoTorchEnabled){ + lightSensor = new CategoryLightAgent(); + SensorBase categoryLight = lightSensor.getSingleSensor(SensorAgent.SENSOR_CATEGORY_LIGHT); + if(categoryLight != null){ + lightSensor.setSensorDataCallback(this,categoryLight,30); + } + } +} +``` + +### **unregisterListener(listener: SensorListener!)** +>+ openharmony API: ohos.sensor.agent.SensorAgent.releaseSensorDataCallback​(L callback) +>+ openharmony SDK版本:2.1.1.21 以上 +>+ IDE版本:2.1.0.501 +>+ 实现方案: +```java +// 释放所有传感器的回调 +lightSensor.releaseSensorDataCallback(iSensorDataCallback); +``` \ No newline at end of file -- Gitee From 8836697a3ab46999003fc6dae264183c34864700 Mon Sep 17 00:00:00 2001 From: zm <87072237@qq.com> Date: Fri, 25 Jun 2021 15:17:38 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AlertDialog.md | 49 ++++++++++++++++++- app/Builder.md | 46 ----------------- location/{location.md => LocationListener.md} | 14 +----- location/LocationManager.md | 10 ++++ org/xmlpull/v1/XmlPullParser.md | 9 ++++ .../v1/XmlPullParserFactory.md} | 10 ---- 6 files changed, 69 insertions(+), 69 deletions(-) delete mode 100644 app/Builder.md rename location/{location.md => LocationListener.md} (68%) create mode 100644 location/LocationManager.md create mode 100644 org/xmlpull/v1/XmlPullParser.md rename org/{org.md => xmlpull/v1/XmlPullParserFactory.md} (65%) diff --git a/app/AlertDialog.md b/app/AlertDialog.md index 5b31bcb..7d09d1b 100644 --- a/app/AlertDialog.md +++ b/app/AlertDialog.md @@ -24,4 +24,51 @@ listDialog.setSize(400,600); listDialog.show(); // 从BaseDialog调用来销毁列表对话框 listDialog.destroy(); -``` \ No newline at end of file +``` + +### **setMultiChoiceItems(itemsId: Int, checkedItems: BooleanArray!, listener: DialogInterface.OnMultiChoiceClickListener!)** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 初始化 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +// 设置要在对话框中显示的项目列表作为内容 +listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); +// 设置确认按钮 +listDialog.setButton(1,"Ok",this); +// 设置取消按钮 +listDialog.setButton(2,"Cancel",this); +``` + +### **setPositiveButton(textId: Int, listener: DialogInterface.OnClickListener!)** +### **setNegativeButton(textId: Int, listener: DialogInterface.OnClickListener!)** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替代使用,自定义使用方法如下: +```java +// 自定义确认,取消点击时间 +@Override +public void onClick(IDialog dialog ,int id){ + if(id == 1){ + //确定 + }else if(id == 2){ + //取消 + } +} +``` + +### **create()** +>+ openharmony API: ohos.agp.window.dialog.ListDialog.show() +>+ openharmony SDK版本:2.1.1.20 以上 +>+ IDE版本:2.1.0.303 +>+ 实现方案:替换使用,使用方法如下: +```java +// 从BaseDialog调用来显示列表对话框 +ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); +listDialog.setTitleText("test"); +listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); +listDialog.show(); +``` diff --git a/app/Builder.md b/app/Builder.md deleted file mode 100644 index dfe8f8a..0000000 --- a/app/Builder.md +++ /dev/null @@ -1,46 +0,0 @@ -### **setMultiChoiceItems(itemsId: Int, checkedItems: BooleanArray!, listener: DialogInterface.OnMultiChoiceClickListener!)** ->+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) ->+ openharmony SDK版本:2.1.1.20 以上 ->+ IDE版本:2.1.0.303 ->+ 实现方案:替换使用,使用方法如下: -```java -// 初始化 -ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); -// 设置要在对话框中显示的项目列表作为内容 -listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); -// 设置确认按钮 -listDialog.setButton(1,"Ok",this); -// 设置取消按钮 -listDialog.setButton(2,"Cancel",this); -``` - -### **setPositiveButton(textId: Int, listener: DialogInterface.OnClickListener!)** -### **setNegativeButton(textId: Int, listener: DialogInterface.OnClickListener!)** ->+ openharmony API: ohos.agp.window.dialog.ListDialog.setMultiSelectItems​(String[] items, boolean[] selectedItems) ->+ openharmony SDK版本:2.1.1.20 以上 ->+ IDE版本:2.1.0.303 ->+ 实现方案:替代使用,自定义使用方法如下: -```java -// 自定义确认,取消点击时间 -@Override -public void onClick(IDialog dialog ,int id){ - if(id == 1){ - //确定 - }else if(id == 2){ - //取消 - } -} -``` - -### **create()** ->+ openharmony API: ohos.agp.window.dialog.ListDialog.show() ->+ openharmony SDK版本:2.1.1.20 以上 ->+ IDE版本:2.1.0.303 ->+ 实现方案:替换使用,使用方法如下: -```java -// 从BaseDialog调用来显示列表对话框 -ListDialog listDialog = new ListDialog(getContext(),ListDialog.MULTI); -listDialog.setTitleText("test"); -listDialog.setMultiSelectItems(new String[]{"1","2","3"},new boolean[]{false,false,true}); -listDialog.show(); -``` diff --git a/location/location.md b/location/LocationListener.md similarity index 68% rename from location/location.md rename to location/LocationListener.md index 1565a41..9435f77 100644 --- a/location/location.md +++ b/location/LocationListener.md @@ -1,14 +1,3 @@ -### **requestLocationUpdates(**String provider, long minTime, float minDistance,LocationListener listener**)** ->+ openharmony API: ohos.location.Locator.startLocating(RequestParam -> request, LocatorCallback callback) ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -// 直接获取单例 - Locator locator = new Locator(this); -``` - ### **onLocationChanged(location: Location)** >+ openharmony API: ohos.location.LocatorCallback.onLocationReport(Location > location); @@ -36,7 +25,8 @@ LocatorCallback locatorCallback = new LocatorCallback() { }; ``` -### **onStatusChanged(provider: String, status:nt, extras: Bundle)** +### **onStatusChanged(**provider: String, status: +Int, extras: Bundle) >+ openharmony API: ohos.location.LocatorCallback.onStatusChanged(int type) >+ openharmony SDK版本:2.1.1.18 以上 >+ IDE版本:2.1.0.302 diff --git a/location/LocationManager.md b/location/LocationManager.md new file mode 100644 index 0000000..480d7bf --- /dev/null +++ b/location/LocationManager.md @@ -0,0 +1,10 @@ +### **requestLocationUpdates(**String provider, long minTime, float minDistance,LocationListener listener**)** +>+ openharmony API: ohos.location.Locator.startLocating(RequestParam +> request, LocatorCallback callback) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接获取单例 + Locator locator = new Locator(this); +``` \ No newline at end of file diff --git a/org/xmlpull/v1/XmlPullParser.md b/org/xmlpull/v1/XmlPullParser.md new file mode 100644 index 0000000..369b2d9 --- /dev/null +++ b/org/xmlpull/v1/XmlPullParser.md @@ -0,0 +1,9 @@ +### **setInput(Reader in)** +>+ openharmony API: ohos.javax.xml.parsers.SAXParser.parse(InputStream is, DefaultHandler dh) +>+ openharmony SDK版本:2.1.1.18 以上 +>+ IDE版本:2.1.0.302 +>+ 实现方案:替换使用,使用方法如下: +```java +// 直接获取单例 +SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); +``` \ No newline at end of file diff --git a/org/org.md b/org/xmlpull/v1/XmlPullParserFactory.md similarity index 65% rename from org/org.md rename to org/xmlpull/v1/XmlPullParserFactory.md index c28f58e..0f89315 100644 --- a/org/org.md +++ b/org/xmlpull/v1/XmlPullParserFactory.md @@ -1,13 +1,3 @@ -### **setInput(Reader in)** ->+ openharmony API: ohos.javax.xml.parsers.SAXParser.parse(InputStream is, DefaultHandler dh) ->+ openharmony SDK版本:2.1.1.18 以上 ->+ IDE版本:2.1.0.302 ->+ 实现方案:替换使用,使用方法如下: -```java -// 直接获取单例 -SAXParser saxParser = SAXParserFactory.newInstance().newSAXParser(); -``` - ### **newInstance()** >+ openharmony API: ohos.javax.xml.parsers.SAXParserFactory.newInstance (); >+ openharmony SDK版本:2.1.1.18 以上 -- Gitee