Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
cn.dailystudio:devbricksx-camera
Advanced tools
DevBricksX is a remake and extended version of DevBricks. It provides plenty of useful classes that will be used in daily Android development. With these "bricks", your development will become:
With only a few lines, you can save in memory User objects into the database and represent them in a list:
To use DevBricks X Libraries in your application, follow the steps below. There are two options for you.
Starting from version 1.7.3, you can simply use DevBricks X Libraries in your application by using the related Gradle plugin. Only apply plugin in build.gradle of your module:
plugins {
id("cn.dailystudio.devbricksx.devkit") version "$devkit_version"
}
The latest version of the Gradle plugin is:
devkit_version = "1.9.5-1.1.1"
That's it. Everything is done. You can use anything provided by DevBricks X.
The primary version (number ahead of minus) of the plugin indicates the corresponding DevBricksX libraries that the plugin uses. For example, plugin "1.7.5-1.0.2" uses DevBricksX 1.7.5, whereas plugin "1.7.3-1.0.1" uses DevBricksX 1.7.3.
Compared to the manual installation below, the plugin helps you do the following things:
Check them carefully to avoid duplicated configurations in your build scripts.
And, make sure you use the compatible Kotlin version. If you meet any problem with during the compilation, please refer to Compatible Kotlin Gradle Plug-in for more information.
Instead, you can set up DevBricksX manually, especially for using those versions before 1.7.3.
Add the following dependencies in build.gradle of your application.
First, you need to add dependencies in build.gradle:
// (Optional) If you use annotations and processors to generate facilities, apply this plug-in
plugins {
id("com.google.devtools.ksp") version "$ksp_version"
}
repositories {
mavenCentral()
}
dependencies {
// Basic Library for Android development
implementation "cn.dailystudio:devbricksx:$devbricksx_version"
// (Optional) Annotations and processors to generate facilities
implementation "cn.dailystudio:devbricksx-annotations:$devbricksx_version"
ksp "cn.dailystudio:devbricksx-compiler:$devbricksx_version"
// (Optional) If you use the feature above, DO NOT forget this line
ksp "androidx.room:room-compiler:2.6.1"
}
The latest version of the dependencies above are:
ksp_version = "1.9.24-1.0.20"
devbricksx_version = "1.9.5"
Then, if you are using annotations through KSP (Kotlin Symbol Processing), DO NOT forget to add plug-ins repo in settings.gradle:
pluginManagement {
repositories {
gradlePluginPortal()
}
}
Add the following compile options in build.gradle of your application module. They are important, please DO NOT ignore them.
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
// If you are using KSP and your Room databases leveraging versioning features.
ksp {
arg("room.schemaLocation", "$projectDir/schemas".toString())
}
// Source files generated by KSP cannot be recognized by default,
// you should manually configure them into the source sets.
sourceSets.configureEach {
kotlin.srcDir("$buildDir/generated/ksp/$name/kotlin/")
}
Powered by DevBricksX and corresponding KSP processors, you can get a Fragment with a list of User in less than 5 minutes.
package com.dailystudio.devbricksx.samples.quickstart
@RoomCompanion
@ViewModel
@Adapter(viewHolder = UserViewHolder::class)
@ListFragment
data class User(
val uid: Int,
val firstName: String?,
val lastName: String?
)
class UserViewHolder(itemView: View): AbsSingleLineViewHolder<User>(itemView) {
override fun getIcon(item: User): Drawable? {
return ResourcesCompatUtils.getDrawable(itemView.context,
R.mipmap.ic_user)
}
override fun getText(item: User): CharSequence? {
return buildString {
append(item.firstName)
append(' ')
append(item.lastName?.uppercase())
}
}
}
Simply, you can directly embed a list Fragment of Users in your application, like this:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".quickstart.CaseActivity">
<fragment
android:name="com.dailystudio.devbricksx.samples.quickstart.fragment.UsersListFragment"
android:id="@+id/fragment_users"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
Then, you get the result like the screenshot shown above.
In this case, the User data is stored persistently in the SQLite database. You manipulate these data by using auto-generated companion classes in different levels of Recommendations for Android architecture:
Using ViewModel,
val viewModel = ViewModelProvider(this)[UserViewModel::class.java]
for (i in 0 until NAMES_COUNT) {
val fIndex = RANDOM.nextInt(FIRST_NAMES.size)
val lIndex = RANDOM.nextInt(LAST_NAMES.size)
val user = User(0, FIRST_NAMES[fIndex], LAST_NAMES[lIndex])
viewModel.insertUser(user)
}
Using Room interfaces,
val database = UserDatabase.getDatabase(this)
for (i in 0 until NAMES_COUNT) {
val fIndex = RANDOM.nextInt(FIRST_NAMES.size)
val lIndex = RANDOM.nextInt(LAST_NAMES.size)
val user = User(0, FIRST_NAMES[fIndex], LAST_NAMES[lIndex])
database.userDao().insert(user)
}
By default, the auto-generated ViewModel class of User provides the following shortcut properties for you to access data:
public val allUsers: List<User>
public val allUsersLive: LiveData<List<User>>
public val allUsersLivePaged: LiveData<PagedList<User>>
public val allUsersFlow: Flow<List<User>>
public val allUsersPagingSource: PagingSource<Int, User>
It almost covers all of the most popular ways of reading data. But, it also provides flexibility to extend interfaces of the ViewModel. For more details, please refer to the specific document.
This step helps you to integrate parts of utilities automatically, such as Logging facilities.
Extends your application from DevBricksApplication:
class MyApplication : DevBricksApplication() {
override fun isDebugBuild(): Boolean {
return BuildConfig.DEBUG
}
}
The BuildConfig is the one generated for your top-level application not those for modules. It provides information about your build type to the library.
Then declare it in your AndroidMenifest.xml
:
<manifest>
...
<application
android:name=".MyApplication">
...
</application>
...
</manifest>
Besides, DevBricksX also provided sufficient facilities to accelerate your everyday development. For different topics, please read the instructions carefully in each topic for details.
An enhanced logging system that can turn on/off debug outputs automatically.
A global context that you can use anywhere in your code without memory leaks.
A set of utilities to simplify the usage of Android Room components. It can generate Room, Dao, Database, and Repository for a class through one annotation.
Plenty of classes to simplify high-level development. Combine with Database facilities, you can save an object in the database and then represent it in a list view with less than 20 lines of code.
If you have encountered issues when you set up or use DevBricksX, you can first check the known issues below.
Now, DevBricksX is using KSP (Kotlin Symbol Processing) instead of Kapt (the Kotlin Annotation Processing Tool) to improve compilation performance and code quality. After version 1.6.6, the following components are deprecated:
Starting from version 1.7.3, DevBricks X Libraries can use its Gradle plugin to help you set up projects. It applies the KSP (Kotlin Symbol Processing) plugin automatically. But if this KSP plugin version is not compatible with the Kolitn Gradle Plugin that you are using in your project. It might lead to a compiling issue.
ksp-1.8.22-1.0.11 is too new for kotlin-1.8.20. Please upgrade kotlin-gradle-plugin to 1.8.22.
So, if you get an issue and see a similar build output above, please change your Kotlin Gradle Plugin version, better to be the same as the one used by DevBricksX.
After version 1.5.9, if you add compile options in your build script to use Java 1.8 binary code, you have to remove all the @JvmField in your codes.
Thanks to the new features of Kotlin, there is no need to use this annotation anymore. It simplifies the usage of our annotation processor. You can refer to the issue KT-46329 for more details.
Since JFrog to Shut down JCenter and Bintray, starting from version 1.4.1, all the artifacts will be maintained under the groupdId cn.dailystudio. The versions before that will still be available under the groupId com.dailystudio.
For example, if you want to refer to version 1.3.0, you should add the following lines in your build.gradle
repositories {
mavenCentral()
}
dependencies {
implementation 'com.dailystudio:devbricksx:1.3.1'
implementation 'com.dailystudio:devbricksx-java-annotations:1.3.1'
implementation 'com.dailystudio:devbricksx-kotlin-annotations:1.3.1'
kapt 'com.dailystudio:devbricksx-java-compiler:1.3.1'
kapt 'com.dailystudio:devbricksx-kotlin-compiler:1.3.1'
}
Copyright 2023 Daily Studio.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
FAQs
DevBricks eXetrems Camera Library
We found that cn.dailystudio:devbricksx-camera demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.