-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d694ee4
commit 0071f25
Showing
40 changed files
with
781 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/forcetower/uefs/core/model/edge/ChangePictureDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.forcetower.uefs.core.model.edge | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ChangePictureDTO( | ||
@SerializedName("base64") | ||
val base64: String | ||
) |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/com/forcetower/uefs/core/model/edge/SendMessagingTokenDTO.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.forcetower.uefs.core.model.edge | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class SendMessagingTokenDTO( | ||
@SerializedName("token") | ||
val token: String | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/forcetower/uefs/domain/usecase/account/ChangeProfilePictureUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.forcetower.uefs.domain.usecase.account | ||
|
||
import android.content.Context | ||
import android.graphics.Bitmap | ||
import android.graphics.BitmapFactory | ||
import android.media.ThumbnailUtils | ||
import android.net.Uri | ||
import android.util.Base64 | ||
import com.forcetower.uefs.core.storage.repository.cloud.EdgeAccountRepository | ||
import dagger.Reusable | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.withContext | ||
import java.io.ByteArrayOutputStream | ||
import javax.inject.Inject | ||
|
||
@Reusable | ||
class ChangeProfilePictureUseCase @Inject constructor( | ||
private val repository: EdgeAccountRepository, | ||
@ApplicationContext private val context: Context | ||
) { | ||
suspend operator fun invoke(uri: Uri) = withContext(Dispatchers.IO) { | ||
val resolver = context.contentResolver | ||
val stream = resolver.openInputStream(uri) ?: return@withContext | ||
|
||
val image = BitmapFactory.decodeStream(stream) | ||
image ?: return@withContext | ||
|
||
val bitmap = ThumbnailUtils.extractThumbnail(image, 1080, 1080) | ||
|
||
val baos = ByteArrayOutputStream() | ||
bitmap.compress(Bitmap.CompressFormat.PNG, 100, baos) | ||
val data = baos.toByteArray() | ||
|
||
val encoded = Base64.encodeToString(data, Base64.DEFAULT) | ||
|
||
repository.uploadPicture(encoded) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.