Коммит 5dcd0564 создал по автору Зарубин Виталий Викторович's avatar Зарубин Виталий Викторович
Просмотр файлов

imp: add example to readme, up libs after refactoring

владелец 87810591
......@@ -7,3 +7,36 @@ The library to access various information about the battery of the device.
- Battery charge level.
- Battery charger status.
- Listen charger status.
### Permissions
```
Permissions=DeviceInfo
```
### Dependency shared libs
- `LIBS += -ldbus-1`
### Example
```kotlin
var states: MutableMap<ULong, Boolean> = mutableMapOf()
class AuroraBatteryInfo {
fun getLevel(): Int {
return BatteryInfo.getLevel()
}
fun listen(): ULong {
return BatteryInfo.listenCharger { id, value ->
states.put(id, value)
}
}
fun getStateCharger(id: ULong): Boolean {
return states[id] ?: false
}
}
```
......@@ -6,3 +6,31 @@ The library allows you to get information about the device's cameras.
- Getting information about cameras.
- Getting information about the number of cameras.
### Example
```kotlin
data class SharedCameraInfo(
val id: String,
val name: String,
val provider: String,
val mountAngle: Int,
)
class AuroraCameraInfo {
fun getSharedCameraInfo(): List<SharedCameraInfo> {
return CameraInfo.getInfoList().map {
SharedCameraInfo(
id = it.id,
name = it.name,
provider = it.provider,
mountAngle = it.mountAngle,
)
}
}
fun getInfoCount(): ULong {
return CameraInfo.getInfoCount()
}
}
```
......@@ -6,3 +6,26 @@ The library allows listen state type of bearer used by this network configuratio
- State is online.
- Listen change state.
### Example
```kotlin
var states: MutableMap<ULong, ConnectivityInfoState> = mutableMapOf()
class AuroraConnectivityInfo {
fun isOnline(): Boolean {
return ConnectivityInfo.isOnline()
}
fun listen(): ULong {
return ConnectivityInfo.listen { id, value ->
states.put(id, value)
}
}
fun getState(id: ULong): String {
return states[id]?.name ?: "-"
}
}
```
......@@ -28,3 +28,135 @@ The library that allows you to obtain information about the device.
- Information on external storage the device.
- Information on internal storage the device.
### Example
```kotlin
class AuroraDeviceInfo {
fun id(): String {
return DeviceInfo.id()
}
fun hasGNSS(): Boolean {
return DeviceInfo.hasGNSS()
}
fun hasNFC(): Boolean {
return DeviceInfo.hasNFC()
}
fun hasBluetooth(): Boolean {
return DeviceInfo.hasBluetooth()
}
fun hasWlan(): Boolean {
return DeviceInfo.hasWlan()
}
fun getMaxCpuClockSpeed(): UInt {
return DeviceInfo.getMaxCpuClockSpeed()
}
fun getNumberCpuCores(): UInt {
return DeviceInfo.getNumberCpuCores()
}
fun getBatteryChargePercentage(): UInt {
return DeviceInfo.getBatteryChargePercentage()
}
fun getMainCameraResolution(): Double {
return DeviceInfo.getMainCameraResolution()
}
fun getFrontalCameraResolution(): Double {
return DeviceInfo.getFrontalCameraResolution()
}
fun getRamTotalSize(): ULong {
return DeviceInfo.getRamTotalSize()
}
fun getRamFreeSize(): ULong {
return DeviceInfo.getRamFreeSize()
}
fun getScreenResolution(): String {
return DeviceInfo.getScreenResolution()
}
fun getOsVersion(): String {
return DeviceInfo.getOsVersion()
}
fun getDeviceModel(): String {
return DeviceInfo.getDeviceModel()
}
}
data class SharedSimCard(
val enabled: Boolean,
val operatorName: String,
val preferredDataTransfer: Boolean,
val preferredVoiceCall: Boolean,
val simName: String,
)
class AuroraSimCards {
fun getSimCardsInfo(): List<SharedSimCard> {
return DeviceSim.getSimCardsInfo().map {
SharedSimCard(
enabled = it.enabled,
operatorName = it.operatorName,
preferredDataTransfer = it.preferredDataTransfer,
preferredVoiceCall = it.preferredVoiceCall,
simName = it.simName,
)
}
}
}
data class SharedExternalStorage(
val bytesAvailable: ULong,
val bytesTotal: ULong,
val bytesUsed: ULong,
val countMountedPartitions: UInt,
val deviceLabel: String,
val mounted: Boolean,
)
data class SharedInternalStorage(
val bytesAvailable: ULong,
val bytesTotal: ULong,
val bytesUsed: ULong,
val deviceLabel: String,
val filesystemType: String,
)
class AuroraStorageInfo {
fun getExternalInfo(): SharedExternalStorage {
return DeviceStorage.getExternalInfo().let {
SharedExternalStorage(
bytesAvailable = it.bytesAvailable,
bytesTotal = it.bytesTotal,
bytesUsed = it.bytesUsed,
countMountedPartitions = it.countMountedPartitions,
deviceLabel = it.deviceLabel,
mounted = it.mounted,
)
}
}
fun getInternalInfo(): SharedInternalStorage {
return DeviceStorage.getInternalInfo().let {
SharedInternalStorage(
bytesAvailable = it.bytesAvailable,
bytesTotal = it.bytesTotal,
bytesUsed = it.bytesUsed,
deviceLabel = it.deviceLabel,
filesystemType = it.filesystemType,
)
}
}
}
```
......@@ -6,3 +6,22 @@ The library for displaying local notifications.
- Show local notification.
- Close local notification by ID.
### Example
```kotlin
class AuroraLocalNotification {
fun show(
title: String,
summary: String,
body: String,
): UInt {
return LocalNotification.show(title, summary, body)
}
fun close(id: UInt): Boolean {
return LocalNotification.close(id)
}
}
```
......@@ -7,3 +7,30 @@ The library for determining the real geographic location of device.
- Check is supported.
- Listen change location.
- Get listen location method.
### Example
```kotlin
var states: MutableMap<ULong, LocationState> = mutableMapOf()
class AuroraLocationInfo {
fun isSupported(): Boolean {
return LocationInfo.isSupported()
}
fun listen(): ULong {
return LocationInfo.listen { id, value ->
states.put(id, value)
}
}
fun getState(id: ULong): String {
return states[id]?.let { """
lat: ${it.latitude.toString().take(12)},
lon: ${it.longitude.toString().take(12)},
alt: ${it.altitude.toString().take(12)}
""".trimIndent() } ?: "loading..."
}
}
```
......@@ -13,3 +13,45 @@ The library that allows you to obtain information about the current package inst
- Size of bin directory with executable file.
- Size of package data directory.
- Size of the directory with package libraries.
### Example
```kotlin
class AuroraPackageInfo {
fun getApplicationId(): String {
return PackageInfo.getApplicationId()
}
fun getAppName(): String {
return PackageInfo.getAppName()
}
fun getOrgName(): String {
return PackageInfo.getOrgName()
}
fun getVersion(): String {
return PackageInfo.getVersion()
}
fun getSubgroup(): String {
return PackageInfo.getSubgroup()
}
fun getSize(): ULong {
return PackageInfo.getSize()
}
fun getSizeBin(): ULong {
return PackageInfo.getSizeBin()
}
fun getSizeData(): ULong {
return PackageInfo.getSizeData()
}
fun getSizeDataLib(): ULong {
return PackageInfo.getSizeDataLib()
}
}
```
......@@ -27,3 +27,97 @@ The library that allows you to obtain information about path application.
- Path to Videos folder.
- Path to Music folder.
- Path to Pictures folder.
### Example
```kotlin
class AuroraPathInfo {
fun getAppCache(): String {
return PathInfo.getAppCache()
}
fun getAppData(): String {
return PathInfo.getAppData()
}
fun appLocalCache(): String {
return PathInfo.appLocalCache()
}
fun getAppLocalData(): String {
return PathInfo.getAppLocalData()
}
fun getPackageFiles(): String {
return PathInfo.getPackageFiles()
}
fun getTranslations(): String {
return PathInfo.getTranslations()
}
fun getOrgCache(): String {
return PathInfo.getOrgCache()
}
fun getOrgData(): String {
return PathInfo.getOrgData()
}
fun getOrgFiles(): String {
return PathInfo.getOrgFiles()
}
fun getOrgLocalCache(): String {
return PathInfo.getOrgLocalCache()
}
fun getOrgLocalData(): String {
return PathInfo.getOrgLocalData()
}
fun getFonts(): String {
return PathInfo.getFonts()
}
fun getRemovableMedia(): String {
return PathInfo.getRemovableMedia()
}
fun getRuntime(): String {
return PathInfo.getRuntime()
}
fun getTemp(): String {
return PathInfo.getTemp()
}
fun getHome(): String {
return PathInfo.getHome()
}
fun getDesktop(): String {
return PathInfo.getDesktop()
}
fun getDocuments(): String {
return PathInfo.getDocuments()
}
fun getDownloads(): String {
return PathInfo.getDownloads()
}
fun getVideos(): String {
return PathInfo.getVideos()
}
fun getMusic(): String {
return PathInfo.getMusic()
}
fun getPictures(): String {
return PathInfo.getPictures()
}
}
```
......@@ -14,3 +14,157 @@ The library allows access to sensor data.
- Listen state sensor Proximity.
- Listen state sensor Rotation.
- Listen state sensor Tap.
### Example
```kotlin
var statesAccelerometer: MutableMap<ULong, AccelerometerState> = mutableMapOf()
var statesAmbientLight: MutableMap<ULong, AmbientLightSensorState> = mutableMapOf()
var statesCompass: MutableMap<ULong, CompassState> = mutableMapOf()
var statesGyroscope: MutableMap<ULong, GyroscopeState> = mutableMapOf()
var statesMagnetometer: MutableMap<ULong, MagnetometerState> = mutableMapOf()
var statesOrientation: MutableMap<ULong, OrientationState> = mutableMapOf()
var statesPressure: MutableMap<ULong, PressureState> = mutableMapOf()
var statesProximity: MutableMap<ULong, ProximityState> = mutableMapOf()
var statesRotation: MutableMap<ULong, RotationState> = mutableMapOf()
var statesTap: MutableMap<ULong, TapState> = mutableMapOf()
class AuroraSensorsInfo {
// Accelerometer
fun listenAccelerometer(): ULong {
return SensorsInfo.accelerometer.listen { id, value ->
statesAccelerometer.put(id, value)
}
}
fun getStateAccelerometer(id: ULong): String {
return statesAccelerometer[id]?.let { """
x: ${it.x.toString().take(12)}
y: ${it.y.toString().take(12)}
z: ${it.z.toString().take(12)}
""".trimIndent() } ?: "-"
}
// AmbientLight
fun listenAmbientLight(): ULong {
return SensorsInfo.ambientLight.listen { id, value ->
statesAmbientLight.put(id, value)
}
}
fun getStateAmbientLight(id: ULong): String {
return statesAmbientLight[id]?.name ?: "-"
}
// Compass
fun listenCompass(): ULong {
return SensorsInfo.compass.listen { id, value ->
statesCompass.put(id, value)
}
}
fun getStateCompass(id: ULong): String {
return statesCompass[id]?.let { """
azimuth: ${it.azimuth.toString().take(12)}
level: ${it.calibrationLevel.toString().take(12)}
""".trimIndent() } ?: "-"
}
// Gyroscope
fun listenGyroscope(): ULong {
return SensorsInfo.gyroscope.listen { id, value ->
statesGyroscope.put(id, value)
}
}
fun getStateGyroscope(id: ULong): String {
return statesGyroscope[id]?.let { """
x: ${it.x.toString().take(12)}
y: ${it.y.toString().take(12)}
z: ${it.z.toString().take(12)}
""".trimIndent() } ?: "-"
}
// Magnetometer
fun listenMagnetometer(): ULong {
return SensorsInfo.magnetometer.listen { id, value ->
statesMagnetometer.put(id, value)
}
}
fun getStateMagnetometer(id: ULong): String {
return statesMagnetometer[id]?.let { """
x: ${it.x.toString().take(12)}
y: ${it.y.toString().take(12)}
z: ${it.z.toString().take(12)}
""".trimIndent() } ?: "-"
}
// Orientation
fun listenOrientation(): ULong {
return SensorsInfo.orientation.listen { id, value ->
statesOrientation.put(id, value)
}
}
fun getStateOrientation(id: ULong): String {
return statesOrientation[id]?.name ?: "-"
}
// Pressure
fun listenPressure(): ULong {
return SensorsInfo.pressure.listen { id, value ->
statesPressure.put(id, value)
}
}
fun getStatePressure(id: ULong): String {
return statesPressure[id]?.let { """
pressure: ${it.pressure.toString().take(12)}
""".trimIndent() } ?: "-"
}
// Proximity
fun listenProximity(): ULong {
return SensorsInfo.proximity.listen { id, value ->
statesProximity.put(id, value)
}
}
fun getStateProximity(id: ULong): String {
return statesProximity[id]?.let { """
isClose: ${it.isClose}
""".trimIndent() } ?: "-"
}
// Rotation
fun listenRotation(): ULong {
return SensorsInfo.rotation.listen { id, value ->
statesRotation.put(id, value)
}
}
fun getStateRotation(id: ULong): String {
return statesRotation[id]?.let { """
x: ${it.x.toString().take(12)}
y: ${it.y.toString().take(12)}
z: ${it.z.toString().take(12)}
""".trimIndent() } ?: "-"
}
// Tap
fun listenTap(): ULong {
return SensorsInfo.tap.listen { id, value ->
statesTap.put(id, value)
}
}
fun getStateTap(id: ULong): String {
return statesTap[id]?.let { """
direction: ${it.tapDirection.toString().take(12)}
isDouble: ${it.isDoubleTap.toString().take(12)}
""".trimIndent() } ?: "-"
}
}
```
......@@ -9,3 +9,32 @@ The library to share data from app via the platform share dialog.
- Share data.
- Share text like file.
- Share file by path.
### Example
```kotlin
class AuroraShareData {
fun share(
title: String,
subject: String,
body: String,
): Boolean {
return ShareData.share(title, subject, body)
}
fun shareTextLikeFile(
title: String,
fileName: String,
text: String,
): Boolean {
return ShareData.shareTextLikeFile(title, fileName, text)
}
fun shareDataByPath(
title: String,
path: String,
): Boolean {
return ShareData.shareDataByPath(title, path)
}
}
```
......@@ -14,3 +14,66 @@ The library allows keep preferences in the form of key-value pairs with data enc
- Check is value exist.
- Save data.
- Clear data.
### Example
```kotlin
const val keyBool = "keyBool"
const val keyInt = "keyInt"
const val keyLong = "keyLong"
const val keyFloat = "keyFloat"
const val keyDouble = "keyDouble"
const val keyString = "keyString"
const val keyListString = "keyListString"
class AuroraSharedPreferencesSecure {
fun getBool(): Boolean {
return SharedPreferencesSecure.getBool(keyBool, false)
}
fun getInt(): Int {
return SharedPreferencesSecure.getInt(keyInt, 0)
}
fun getLong(): Long {
return SharedPreferencesSecure.getLong(keyLong, 0)
}
fun getFloat(): Float {
return SharedPreferencesSecure.getFloat(keyFloat, 0.0f)
}
fun getDouble(): Double {
return SharedPreferencesSecure.getDouble(keyDouble, 0.0)
}
fun getString(): String {
return SharedPreferencesSecure.getString(keyString, "-")
}
fun getListString(): List<String> {
return SharedPreferencesSecure.getListString(keyListString, listOf())
}
fun drop() {
SharedPreferencesSecure.drop()
}
fun refreshRandomData() {
// Set data
SharedPreferencesSecure.putBool(keyBool, Random.nextBoolean())
SharedPreferencesSecure.putInt(keyInt, Random.nextInt())
SharedPreferencesSecure.putLong(keyLong, Random.nextLong())
SharedPreferencesSecure.putFloat(keyFloat, Random.nextFloat())
SharedPreferencesSecure.putDouble(keyDouble, Random.nextDouble())
SharedPreferencesSecure.putString(keyString, listOf("first", "second", "third").random())
SharedPreferencesSecure.putListString(keyListString, listOf(
listOf("first1", "second1", "third1"),
listOf("first2", "second2", "third2"),
listOf("first3", "second3", "third3"),
).random())
// Save change
SharedPreferencesSecure.save()
}
}
```
......@@ -14,3 +14,66 @@ The library allows keep preferences in the form of key-value pairs.
- Check is value exist.
- Save data.
- Clear data.
### Example
```kotlin
const val keyBool = "keyBool"
const val keyInt = "keyInt"
const val keyLong = "keyLong"
const val keyFloat = "keyFloat"
const val keyDouble = "keyDouble"
const val keyString = "keyString"
const val keyListString = "keyListString"
class AuroraSharedPreferences {
fun getBool(): Boolean {
return SharedPreferences.getBool(keyBool, false)
}
fun getInt(): Int {
return SharedPreferences.getInt(keyInt, 0)
}
fun getLong(): Long {
return SharedPreferences.getLong(keyLong, 0)
}
fun getFloat(): Float {
return SharedPreferences.getFloat(keyFloat, 0.0f)
}
fun getDouble(): Double {
return SharedPreferences.getDouble(keyDouble, 0.0)
}
fun getString(): String {
return SharedPreferences.getString(keyString, "-")
}
fun getListString(): List<String> {
return SharedPreferences.getListString(keyListString, listOf())
}
fun drop() {
SharedPreferences.drop()
}
fun refreshRandomData() {
// Set data
SharedPreferences.putBool(keyBool, Random.nextBoolean())
SharedPreferences.putInt(keyInt, Random.nextInt())
SharedPreferences.putLong(keyLong, Random.nextLong())
SharedPreferences.putFloat(keyFloat, Random.nextFloat())
SharedPreferences.putDouble(keyDouble, Random.nextDouble())
SharedPreferences.putString(keyString, listOf("first", "second", "third").random())
SharedPreferences.putListString(keyListString, listOf(
listOf("first1", "second1", "third1"),
listOf("first2", "second2", "third2"),
listOf("first3", "second3", "third3"),
).random())
// Save change
SharedPreferences.save()
}
}
```
......@@ -7,3 +7,21 @@ The library that allows you to obtain information about the theme configuration.
- Mathematical ratio that compares the physical pixel density of a display device to its logical pixel density.
- Calculates the height of the screen by including the height of the notch as well.
- An area in a graphical user interface that is used to display information about the current state of an application or system.
### Example
```kotlin
class AuroraThemeInfo {
fun getPixelRatio(): Double {
return ThemeInfo.getPixelRatio()
}
fun getCutoutAreaHeight(): Int {
return ThemeInfo.cutoutAreaHeight()
}
fun getStatusBarHeight(): Int {
return ThemeInfo.getStatusBarHeight()
}
}
```
......@@ -7,3 +7,13 @@ The library for launching a URI.
- Open URI.
- Open URI with state callback.
- Check is valid URI.
### Example
```kotlin
class AuroraUriLauncher {
fun open(uri: String): Boolean {
return UriLauncher.open(uri)
}
}
```
......@@ -7,3 +7,21 @@ The library for handling vibration.
- Is vibration available.
- Start vibration.
- Start vibration effect.
### Example
```kotlin
class AuroraVibration {
fun isAvailable(): Boolean {
return Vibration.isAvailable()
}
fun start() {
Vibration.start(1000, 0.5)
}
fun startEffect(): Boolean {
return Vibration.startEffect(VibrationEffect.Basic)
}
}
```
......@@ -6,3 +6,21 @@ The library does not allow dimming of screen.
- Enable blocking dimming.
- Disable blocking dimming.
### Example
```kotlin
class AuroraWakeLock {
fun isEnable(): Boolean {
return WakeLock.isEnable()
}
fun enable(): Boolean {
return WakeLock.enable()
}
fun disable(): Boolean {
return WakeLock.disable()
}
}
```
Нет предварительного просмотра для этого типа файлов
Нет предварительного просмотра для этого типа файлов
Нет предварительного просмотра для этого типа файлов
Нет предварительного просмотра для этого типа файлов
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать