A OHOSUtils library is collection of utils classes which is created for the dependencies used in SlideActionView library for implementation, but feel free to add your own contributions as you wish.
Inspired by fennifith/AndroidUtils - version 0.0.1
This library provides the collection of utils classes.
- For using OHOSUtil module in sample app, include the source code and add the below dependencies in entry/build.gradle to generate hap/support.har.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
testImplementation 'junit:junit:4.13'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
implementation project(':ohosutils')
}
- For using OHOSUtils in separate application using har file, add the har file in the entry/libs folder and add the dependencies in entry/build.gradle file.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13'
}
- For using OHOSUtils from a remote repository in separate application, add the below dependencies in entry/build.gradle file.
dependencies {
implementation 'dev.applibgroup:ohosutils:1.0.0'
testCompile 'junit:junit:4.13'
}
Includes some unit conversion functions that use getDeviceCapability() or getDefaultDisplay() to find the display density:
-
dpToPx(Float) : A value of the provided dp units returns value in Pixel.
-
spToPx(Float) : A value of the provided Sp units returns value in Pixel.
-
pxToDp(Int) : A value of the provided Pixel units returns value in Dp.
-
pxToSp(Int) : A value of the provided Pixel units returns value in Sp.
Includes method which converts the drawable to PixelMap.
- drawableToBitmap(Element) : Converts the input Element drawable to PixelMap.
Includes some methods that calculate the darkness of color and determine opaque color which will be equivalent translucent color drawn on top of another color
-
isColorDark(int) : Determine if a input color is dark or light.
-
getColorDarkness(int) : Calculates the darkness of a input color.
-
withBackground(int, int) : Calculates an opaque color that is equivalent to a translucent color drawn on top of another color.
-
getHsvColorWheelArr(float, float) : Determine the HSVColor of the color returning array.
-
Since there is no class in HarmonyOS similar to ClipDrawable and LayerDrawable, the SeekBarDrawable.java and SeekBarUtils.java are currently not implemented due to platform dependencies.
-
In DimenUtil, since currently StatusBarHeight and NavigationBarHeight cannot be set as identifiers, getStatusBarHeight and getNavigationBarHeight method are currently not implemented due to platform dependencies.