Android
This is a pure kotlin version of Android Base Utils for any android project. You can also get this project in gitee.
Install / Use
/learn @yhz61010/AndroidREADME
Attention
Project configurations:
minSdkis21(Android 5.0) ~~minSdkis24(Android 7.0)~~targetSdkis36(Android 16 - Baklava)
PS:
Due to limitations from other projects I am currently involved in,
the minSdk must remain at 21 and cannot be upgraded for now.
This also indirectly affects some of the open-source libraries used in this project,
preventing them from being updated to their latest versions.
How to import?
- You MUST rename or copy the
gradle.properties.templatefile togradle.propertiesand MODIFY it. - Configure the following environment variables on the CI/CD platform:
- KEYSTORE_PATH
- KEYSTORE_PASSWORD
- KEY_ALIAS
- KEY_PASSWORD
For Kotlin (build.gradle.kts)
Add the libraries as you need. For example:
[libraries]
leo-androidbase = { module = "com.leovp.android:androidbase", version.ref = "<latest-version>" }
leo-lib-compose = { module = "com.leovp.android:lib-compose", version.ref = "<latest-version>" }
leo-pref = { module = "com.leovp.android:pref", version.ref = "<latest-version>" }
...
...
Import that library in your module build.gradle.kts file:
implementation(libs.leo.androidbase)
For Groovy (build.gradle)
dependencies {
implementation "com.leovp.android:androidbase:<latest>"
implementation "com.leovp.android:lib-compose:<latest>"
implementation "com.leovp.android:pref:<latest>"
...
...
}
Upload to bintray(Maven and jcenter)
./gradlew clean build bintrayUpload -PbintrayUser=yhz61010 -PbintrayKey=<Your API Key> -PdryRun=false
You can get your API Key as following url API Key
Known Issues
- ~~AudioActivity(Solved. See AacFilePlayer.kt bf1bfe248a54308cd91cfa7f516026b237413119 commit)~~ ~~Can not play AAC file in Audio demo on OnePlus 8T device.~~
- AudioReceiver In realtime communication of Audio demo, if the audio codec is 8Khz/16bit/2ch, the volume of receiver is too small to hear.
- FFMpegH264Activity & FFMpegH265Activity When you back to previously activity while playing video, it will crash caused by ffmpeg in following place:
h264_hevc_decoder_all_in_one_file.cppindecode()method, when callingavcodec_send_packet.
TODO List
~~1. Camera2Live~~(Solved)
~~When you initialize Camera2Component, you must specify the encoder type manually.
This is not a wise way. In the next version, I will identify the encoder automatically
according to the camera characteristics.~~
~~2. Network Monitor~~(Solved) ~~Now, I do not show you a way to get the network traffic and ping by implementing a listener. That means you can just check the network traffic and ping in log, but you can not get them in your code. In the next version, I will provide you a listener that you can use them freely when network traffic and ping are changed.~~
About Log
Almost every project will use a log wrapper to manage your log. So does this library.
Here comes a question: how to save this library logs in your project if you need it?
In order to solve this problem, I implement a log system by using LogContext.
You just need to initiate LogContext with your custom log wrapper and output your log by using LogContext
I have already implemented the LLog which is a wrapper of Android default log as default implementation for LogContext.
Of course, you can implement your log wrapper by implement ILog.
DO NOT forget to initialize it first in Application.
Please check the LogActivity for details.
FYI: You can use Xlog as your wrapper implements. It is an efficient and powerful log.
About Camera2Live Module(Device Camera Information List)
Notice: All devices below are supported OMX.google.h264.encoder H.264 encoder
Nexus
Nexus 6(Root)(Android 7.1.1)
Camera supported hardware level
Lens Back: LEVEL_FULL(1)
Lens Front: LEVEL_LIMITED(0)
H.264 Encoder
OMX.qcom.video.encoder.avc
Camera supported FPS
Lens Back(Camera Sensor Orientation: 90)
[[15, 15], [24, 24], [7, 30], [30, 30]]
Lens Front(Camera Sensor Orientation: 90)
[[7, 30], [30, 30]]
Camera supported size
Lens Back(Camera Sensor Orientation: 90)
[4160, 3120][4160, 2774][4160, 2340][4000, 3000][3840, 2160][3264, 2176][3200, 2400][3200, 1800][2592, 1944][2592, 1728][2048, 1536][1920, 1440][1920, 1080][1280, 960][1280, 768][1280, 720][1024, 768][800, 600][800, 480][720, 480][640, 480][352, 288][320, 240][176, 144]
Lens Front(Camera Sensor Orientation: 90)
[1920, 1080][1280, 960][1280, 768][1280, 720][1024, 768][800, 600][800, 480][720, 480][640, 480][352, 288][320, 240][176, 144]
Nexus 6P(Root)(Android 8.1)
Camera supported hardware level
Lens Back: LEVEL_3(3)
Lens Front: LEVEL_3(3)
H.264 Encoder
OMX.qcom.video.encoder.avc
Camera supported FPS
Lens Back(Camera Sensor Orientation: 90)
[[15, 15], [24, 24], [15, 30], [30, 30]]
Lens Front(Camera Sensor Orientation: 90)
[[15, 15], [10, 20], [20, 20], [24, 24], [10, 30], [30, 30]]
Camera supported size
Lens Back(Camera Sensor Orientation: 90)
[4032, 3024][4000, 3000][3840, 2160][3288, 2480][3264, 2448][3200, 2400][2976, 2976][2592, 1944][2688, 1512][2048, 1536][1920, 1080][1600, 1200][1440, 1080][1280, 960][1280, 768][1280, 720][1024, 768][800, 600][864, 480][800, 480][720, 480][640, 480][640, 360][352, 288][320, 240][176, 144][160, 120]
Lens Front(Camera Sensor Orientation: 90)
[3264, 2448][3200, 2400][2592, 1944][2688, 1512][2048, 1536][1920, 1080][1600, 1200][1440, 1080][1280, 960][1280, 768][1280, 720][1024, 768][800, 600][864, 480][800, 480][720, 480][640, 480][640, 360][352, 288][320, 240][176, 144][160, 120]
Pixel
Google Pixel 3XL(Pixel 3XL)(Android 12)
Camera supported hardware level
Lens Back: LEVEL_3(3)
Lens Front: LEVEL_FULL(1)
H.264 Encoder
c2.qti.avc.encoder
OMX.qcom.video.encoder.avc
c2.android.avc.encoder
Camera supported FPS
Lens Back(Camera Sensor Orientation: 90)
[[15, 15], [7, 30], [15, 30], [30, 30], [15, 60], [60, 60]]
Lens Front(Camera Sensor Orientation: 270)
[[15, 15], [7, 30], [15, 30], [30, 30]]
Camera supported size
Lens Back(Camera Sensor Orientation: 90)
[4032x3024, 4000x3000, 3840x2160, 4000x2000, 3264x2448, 3200x2400, 2688x1512, 2592x1944, 2560x1280, 2048x1536, 1920x1440, 1920x1080, 1600x1200, 1920x960, 1280x960, 1280x768, 1280x720, 1024x768, 800x400, 800x600, 800x480, 720x480, 640x400, 640x480, 640x360, 352x288, 320x240, 176x144, 160x120]
Lens Front(Camera Sensor Orientation: 270)
[3264x2448, 3200x2400, 2688x1512, 2592x1944, 2560x1280, 2048x1536, 1920x1440, 1920x1080, 1600x1200, 1920x960, 1280x960, 1280x768, 1280x720, 1024x768, 800x400, 800x600, 800x480, 720x480, 640x400, 640x480, 640x360, 352x288, 320x240, 176x144, 160x120]
MeiZu
MeiZu Pro5(M576)(Android 5.1)
Camera supported hardware level
Lens Back: LEVEL_LEGACY(2)
Lens Front: LEVEL_LEGACY(2)
H.264 Encoder
OMX.Exynos.AVC.Encoder
Camera supported FPS
Lens Back(Camera Sensor Orientation: 90)
[[14000, 24000], [24000, 24000], [14000, 30000], [30000, 30000]]
Lens Front(Camera Sensor Orientation: 270)
[[14000, 30000], [30000, 30000]]
Camera supported size
Lens Back(Camera Sensor Orientation: 90)
[1920, 1440][1920, 1080][1440, 1080][1280, 720][800, 600][720, 480][640, 480][320, 240][176, 144]
Lens Front(Camera Sensor Orientation: 270)
[1920, 1440][1920, 1080][1440, 1080][1280, 720][800, 600][720, 480][640, 480][320, 240][176, 144]
MeiZu MX6(M6850)(Android 7.1.1)
Camera supported hardware level
Lens Back: LEVEL_LEGACY(2)
Lens Front: LEVEL_LEGACY(2)
H.264 Encoder
OMX.MTK.VIDEO.ENCODER.AVC
Camera supported FPS
Lens Back(Camera Sensor Orientation: 90)
[[15, 15], [20, 20], [24, 24], [5, 30], [30, 30]]
Lens Front(Camera Sensor Orientation: 270)
[[5, 15], [20, 20], [5, 30], [30, 30]]
Camera supported size
Lens Back(Camera Sensor Orientation: 90)
[1680, 1260][1920, 1088][1920, 1080][1440, 1080][1280, 720][960, 540][800, 600][864, 480][800, 480][720, 480][640, 480][480, 320][352, 288][320, 240][176, 144]
Lens Front(Camera Sensor Orientation: 270)
[1440, 1080][1280, 720][960, 720][960, 540][800, 600][864, 480][800, 480][720, 480][640, 480][480, 368][480, 320][352, 288][320, 240][176, 144]
Samsung
Samsung Galaxy S20 5G(SM-G9810)(Android 10)
Camera supported hardware level
Lens Back: LEVEL_3(3)
Lens Front: LEVEL_LIMITED(0)
H.264 Encoder
OMX.qcom.video.encoder.avc
c2.android.avc.encoder
