-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cathash image support for android client
- Loading branch information
1 parent
218185e
commit 3bb16a3
Showing
6 changed files
with
90 additions
and
10 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
16 changes: 16 additions & 0 deletions
16
androidClient/src/androidMain/kotlin/network/bisq/mobile/client/di/AndroidClientModule.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,16 @@ | ||
package network.bisq.mobile.client.di | ||
|
||
import network.bisq.mobile.client.cathash.ClientCatHashService | ||
import network.bisq.mobile.service.AndroidClientCatHashService | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.dsl.bind | ||
import org.koin.dsl.module | ||
|
||
|
||
val androidClientModule = module { | ||
single { | ||
val context = androidContext() | ||
val filesDir = context.filesDir.absolutePath | ||
AndroidClientCatHashService(context, filesDir) | ||
} bind ClientCatHashService::class | ||
} |
49 changes: 49 additions & 0 deletions
49
...dClient/src/androidMain/kotlin/network/bisq/mobile/service/AndroidClientCatHashService.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,49 @@ | ||
/* | ||
* This iconFilePath is part of Bisq. | ||
* | ||
* Bisq is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or (at | ||
* your option) any later version. | ||
* | ||
* Bisq is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bisq. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
package network.bisq.mobile.service | ||
|
||
import android.content.Context | ||
import androidx.compose.ui.graphics.ImageBitmap | ||
import androidx.compose.ui.graphics.asAndroidBitmap | ||
import androidx.compose.ui.graphics.asImageBitmap | ||
import network.bisq.mobile.client.cathash.ClientCatHashService | ||
import network.bisq.mobile.utils.ImageUtil | ||
import network.bisq.mobile.utils.ImageUtil.PATH_TO_DRAWABLE | ||
import java.io.File | ||
|
||
const val CAT_HASH_PATH = PATH_TO_DRAWABLE + "cathash/" | ||
|
||
class AndroidClientCatHashService(private val context: Context, filesDir: String) : | ||
ClientCatHashService<ImageBitmap>("$filesDir/Bisq2_mobile") { | ||
override fun composeImage(paths: Array<String>, size: Int): ImageBitmap { | ||
return ImageUtil.composeImage( | ||
context, | ||
CAT_HASH_PATH, | ||
paths, | ||
size, | ||
size | ||
).asImageBitmap() | ||
} | ||
|
||
override fun writeRawImage(image: ImageBitmap, iconFilePath: String) { | ||
ImageUtil.writeRawImage(image.asAndroidBitmap(), File(iconFilePath)) | ||
} | ||
|
||
override fun readRawImage(iconFilePath: String): ImageBitmap? { | ||
return ImageUtil.readRawImage(File((iconFilePath)))?.asImageBitmap() | ||
} | ||
} |
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