mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-25 21:55:25 +01:00
ktlintformat
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
0a107c455f
commit
17f4a20cbd
@ -164,7 +164,6 @@ class MainActivity : BaseActivity(), ActionBarProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun handleActionFromContact(intent: Intent) {
|
private fun handleActionFromContact(intent: Intent) {
|
||||||
|
|
||||||
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
|
if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
|
||||||
val cursor = contentResolver.query(intent.data!!, null, null, null, null)
|
val cursor = contentResolver.query(intent.data!!, null, null, null, null)
|
||||||
|
|
||||||
|
@ -18,10 +18,10 @@ import com.nextcloud.talk.data.database.model.UserGroupsEntity
|
|||||||
interface UserCirclesOrGroupsDao {
|
interface UserCirclesOrGroupsDao {
|
||||||
|
|
||||||
@Query("SELECT groups FROM user_groups")
|
@Query("SELECT groups FROM user_groups")
|
||||||
fun getUserGroups():List<UserGroupsEntity>
|
fun getUserGroups(): List<UserGroupsEntity>
|
||||||
|
|
||||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||||
suspend fun insertUserGroups(groups:List<UserGroupsEntity>)
|
suspend fun insertUserGroups(groups: List<UserGroupsEntity>)
|
||||||
|
|
||||||
@Query("SELECT displayName FROM user_circles")
|
@Query("SELECT displayName FROM user_circles")
|
||||||
fun getUserCircles(): List<UserCirclesEntity>
|
fun getUserCircles(): List<UserCirclesEntity>
|
||||||
@ -34,5 +34,4 @@ interface UserCirclesOrGroupsDao {
|
|||||||
|
|
||||||
@Query("DELETE FROM user_circles")
|
@Query("DELETE FROM user_circles")
|
||||||
suspend fun deleteAllUserCircles()
|
suspend fun deleteAllUserCircles()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,5 @@ import androidx.room.PrimaryKey
|
|||||||
data class UserCirclesEntity(
|
data class UserCirclesEntity(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@ColumnInfo(name = "displayName")
|
@ColumnInfo(name = "displayName")
|
||||||
var displayName: String,
|
var displayName: String
|
||||||
)
|
)
|
||||||
|
@ -24,58 +24,60 @@ class UserGroupsCirclesRepository @Inject constructor(
|
|||||||
private val currentUserProvider: CurrentUserProviderNew
|
private val currentUserProvider: CurrentUserProviderNew
|
||||||
) {
|
) {
|
||||||
val user = currentUserProvider.currentUser.blockingGet()
|
val user = currentUserProvider.currentUser.blockingGet()
|
||||||
suspend fun initialize(): Boolean = withContext(Dispatchers.IO) {
|
|
||||||
try {
|
|
||||||
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
|
||||||
|
|
||||||
coroutineScope {
|
@Suppress("Detekt.TooGenericExceptionCaught")
|
||||||
launch {
|
suspend fun initialize(): Boolean =
|
||||||
userCirclesOrGroupsDao.deleteAllUserGroups()
|
withContext(Dispatchers.IO) {
|
||||||
val response = ncApiCoroutines.getUserGroups(
|
try {
|
||||||
credentials,
|
val credentials: String = ApiUtils.getCredentials(user.username, user.token)!!
|
||||||
ApiUtils.getUrlForUserGroups(
|
|
||||||
user.baseUrl!!,
|
coroutineScope {
|
||||||
user.userId!!
|
launch {
|
||||||
|
userCirclesOrGroupsDao.deleteAllUserGroups()
|
||||||
|
val response = ncApiCoroutines.getUserGroups(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForUserGroups(
|
||||||
|
user.baseUrl!!,
|
||||||
|
user.userId!!
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
val groups = response.ocs?.data?.groups ?: emptyList()
|
||||||
val groups = response.ocs?.data?.groups?: emptyList()
|
Log.d("UserDataRepo", "$groups")
|
||||||
Log.d("UserDataRepo","$groups")
|
userCirclesOrGroupsDao.insertUserGroups(
|
||||||
userCirclesOrGroupsDao.insertUserGroups(
|
groups.map {
|
||||||
groups.map{
|
UserGroupsEntity(it)
|
||||||
UserGroupsEntity(it)
|
}
|
||||||
}
|
)
|
||||||
)
|
}
|
||||||
|
|
||||||
|
launch {
|
||||||
|
userCirclesOrGroupsDao.deleteAllUserCircles()
|
||||||
|
val response = ncApiCoroutines.getUserCircles(
|
||||||
|
credentials,
|
||||||
|
ApiUtils.getUrlForUserCircles(user.baseUrl!!)
|
||||||
|
)
|
||||||
|
val circles = response.ocs?.data?.map { it.displayName!! } ?: emptyList()
|
||||||
|
Log.d("UserDataRepo", "$circles")
|
||||||
|
userCirclesOrGroupsDao.insertUserCircles(
|
||||||
|
circles.map {
|
||||||
|
UserCirclesEntity(it)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
launch {
|
return@withContext true
|
||||||
userCirclesOrGroupsDao.deleteAllUserCircles()
|
} catch (e: Exception) {
|
||||||
val response = ncApiCoroutines.getUserCircles(
|
Log.e("UserDataRepo", "Error initializing user data", e)
|
||||||
credentials,
|
return@withContext false
|
||||||
ApiUtils.getUrlForUserCircles(user.baseUrl!!)
|
|
||||||
)
|
|
||||||
val circles = response.ocs?.data?.map { it.displayName!! }?: emptyList()
|
|
||||||
Log.d("UserDataRepo","$circles")
|
|
||||||
userCirclesOrGroupsDao.insertUserCircles(
|
|
||||||
circles.map{
|
|
||||||
UserCirclesEntity(it)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return@withContext true
|
|
||||||
} catch (e: Exception) {
|
|
||||||
Log.e("UserDataRepo", "Error initializing user data", e)
|
|
||||||
return@withContext false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
fun getUserGroups(): List<UserGroupsEntity> {
|
||||||
|
|
||||||
fun getUserGroups(): List<UserGroupsEntity> {
|
|
||||||
return userCirclesOrGroupsDao.getUserGroups()
|
return userCirclesOrGroupsDao.getUserGroups()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getUserCircles(): List<UserCirclesEntity>{
|
fun getUserCircles(): List<UserCirclesEntity> {
|
||||||
return userCirclesOrGroupsDao.getUserCircles()
|
return userCirclesOrGroupsDao.getUserCircles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,5 +14,5 @@ import androidx.room.PrimaryKey
|
|||||||
@Entity(tableName = "user_groups")
|
@Entity(tableName = "user_groups")
|
||||||
data class UserGroupsEntity(
|
data class UserGroupsEntity(
|
||||||
@PrimaryKey
|
@PrimaryKey
|
||||||
@ColumnInfo (name="groups") var groups: String,
|
@ColumnInfo(name = "groups") var groups: String
|
||||||
)
|
)
|
||||||
|
@ -51,7 +51,7 @@ import java.util.Locale
|
|||||||
ConversationEntity::class,
|
ConversationEntity::class,
|
||||||
ChatMessageEntity::class,
|
ChatMessageEntity::class,
|
||||||
ChatBlockEntity::class,
|
ChatBlockEntity::class,
|
||||||
UserCirclesEntity:: class,
|
UserCirclesEntity::class,
|
||||||
UserGroupsEntity::class
|
UserGroupsEntity::class
|
||||||
],
|
],
|
||||||
version = 16,
|
version = 16,
|
||||||
|
@ -98,7 +98,7 @@ class MessageUtils(val context: Context) {
|
|||||||
return processedMessageText
|
return processedMessageText
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("NestedBlockDepth", "LongParameterList")
|
@Suppress("NestedBlockDepth", "LongParameterList", "Detekt.LongMethod")
|
||||||
private fun processMessageParameters(
|
private fun processMessageParameters(
|
||||||
themingContext: Context,
|
themingContext: Context,
|
||||||
viewThemeUtils: ViewThemeUtils,
|
viewThemeUtils: ViewThemeUtils,
|
||||||
|
Loading…
Reference in New Issue
Block a user