mirror of
https://github.com/LiveFastEatTrashRaccoon/RaccoonForLemmy.git
synced 2025-02-09 07:18:39 +01:00
refactor: build warnings (#412)
* chore: remove empty modules * chore: remove expect objects
This commit is contained in:
parent
c249ae37ca
commit
7381e6d30f
@ -1,10 +1,10 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.api.provider
|
||||
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.debug.Log
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.debug.logDebug
|
||||
import io.ktor.client.plugins.logging.Logger
|
||||
|
||||
internal val defaultLogger = object : Logger {
|
||||
override fun log(message: String) {
|
||||
Log.d(message)
|
||||
logDebug(message)
|
||||
}
|
||||
}
|
||||
|
@ -1,48 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "core"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
implementation(libs.koin.core)
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.diegoberaldin.raccoonforlemmy.core"
|
||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "commonui"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.diegoberaldin.raccoonforlemmy.core.commonui"
|
||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.CornerSize
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.appearance.theme.Spacing
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.StringUtils.toHexDigit
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.toHexDigit
|
||||
import com.github.diegoberaldin.raccoonforlemmy.resources.MR
|
||||
import dev.icerock.moko.resources.compose.stringResource
|
||||
|
||||
|
@ -36,7 +36,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.model.Mark
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.compose.model.ReferenceLinkHandlerImpl
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.di.getMarkwonProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.markdown.provider.MarkwonProvider
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.DateTime
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.epochMillis
|
||||
import io.noties.markwon.image.AsyncDrawableSpan
|
||||
import kotlinx.coroutines.delay
|
||||
|
||||
@ -109,7 +109,7 @@ actual fun CustomMarkdown(
|
||||
private var lastClickTime = 0L
|
||||
|
||||
override fun onSingleTapConfirmed(e: MotionEvent): Boolean {
|
||||
val currentTime = DateTime.epochMillis()
|
||||
val currentTime = epochMillis()
|
||||
if ((currentTime - lastClickTime) < 300) return false
|
||||
lastClickTime = currentTime
|
||||
if (!markwonProvider.blockClickPropagation.value) {
|
||||
@ -120,7 +120,7 @@ actual fun CustomMarkdown(
|
||||
}
|
||||
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
val currentTime = DateTime.epochMillis()
|
||||
val currentTime = epochMillis()
|
||||
if ((currentTime - lastClickTime) < 300) return false
|
||||
lastClickTime = currentTime
|
||||
if (!markwonProvider.blockClickPropagation.value) {
|
||||
|
@ -0,0 +1,7 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
import android.util.Patterns
|
||||
|
||||
actual fun String.isValidUrl(): Boolean = Patterns.WEB_URL.matcher(this).matches()
|
||||
|
||||
actual fun Int.toHexDigit(): String = String.format("%02X", this)
|
@ -1,9 +0,0 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
import android.util.Patterns
|
||||
|
||||
actual object StringUtils {
|
||||
actual fun String.isValidUrl(): Boolean = Patterns.WEB_URL.matcher(this).matches()
|
||||
|
||||
actual fun Int.toHexDigit(): String = String.format("%02X", this)
|
||||
}
|
@ -5,76 +5,74 @@ import java.time.ZonedDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.util.GregorianCalendar
|
||||
|
||||
actual object DateTime {
|
||||
actual fun epochMillis(): Long = System.currentTimeMillis()
|
||||
actual fun epochMillis(): Long = System.currentTimeMillis()
|
||||
|
||||
actual fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp)
|
||||
val formatter = DateTimeFormatter.ofPattern(format)
|
||||
return date.format(formatter)
|
||||
}
|
||||
actual fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp)
|
||||
val formatter = DateTimeFormatter.ofPattern(format)
|
||||
return date.format(formatter)
|
||||
}
|
||||
|
||||
actual fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String {
|
||||
val now = GregorianCalendar().toZonedDateTime()
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp)
|
||||
val delta = Period.between(date.toLocalDate(), now.toLocalDate())
|
||||
val years = delta.years
|
||||
val months = delta.months
|
||||
val days = delta.days
|
||||
val nowSeconds = now.toEpochSecond()
|
||||
val dateSeconds = date.toEpochSecond()
|
||||
val diffSeconds = (nowSeconds - dateSeconds)
|
||||
val hours = ((diffSeconds % 86400) / 3600) % 24
|
||||
val minutes = ((diffSeconds % 3600) / 60) % 60
|
||||
val seconds = diffSeconds % 60
|
||||
return when {
|
||||
years >= 1 -> buildString {
|
||||
append("${years}$yearLabel")
|
||||
if (months >= 1) {
|
||||
append(" ${months}$monthLabel")
|
||||
}
|
||||
if (days >= 1) {
|
||||
append(" ${days}$dayLabel")
|
||||
}
|
||||
actual fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String {
|
||||
val now = GregorianCalendar().toZonedDateTime()
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp)
|
||||
val delta = Period.between(date.toLocalDate(), now.toLocalDate())
|
||||
val years = delta.years
|
||||
val months = delta.months
|
||||
val days = delta.days
|
||||
val nowSeconds = now.toEpochSecond()
|
||||
val dateSeconds = date.toEpochSecond()
|
||||
val diffSeconds = (nowSeconds - dateSeconds)
|
||||
val hours = ((diffSeconds % 86400) / 3600) % 24
|
||||
val minutes = ((diffSeconds % 3600) / 60) % 60
|
||||
val seconds = diffSeconds % 60
|
||||
return when {
|
||||
years >= 1 -> buildString {
|
||||
append("${years}$yearLabel")
|
||||
if (months >= 1) {
|
||||
append(" ${months}$monthLabel")
|
||||
}
|
||||
|
||||
months >= 1 -> buildString {
|
||||
append("${months}$monthLabel")
|
||||
if (days >= 1) {
|
||||
append(" ${days}$dayLabel")
|
||||
}
|
||||
}
|
||||
|
||||
days >= 1 -> buildString {
|
||||
append("${days}$dayLabel")
|
||||
}
|
||||
|
||||
hours >= 1 -> buildString {
|
||||
append(" ${hours}$hourLabel")
|
||||
}
|
||||
|
||||
minutes >= 1 -> buildString {
|
||||
append(" ${minutes}$minuteLabel")
|
||||
}
|
||||
|
||||
else -> buildString {
|
||||
append(" ${seconds}$secondLabel")
|
||||
if (days >= 1) {
|
||||
append(" ${days}$dayLabel")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDateFromIso8601Timestamp(string: String): ZonedDateTime {
|
||||
return ZonedDateTime.parse(string)
|
||||
months >= 1 -> buildString {
|
||||
append("${months}$monthLabel")
|
||||
if (days >= 1) {
|
||||
append(" ${days}$dayLabel")
|
||||
}
|
||||
}
|
||||
|
||||
days >= 1 -> buildString {
|
||||
append("${days}$dayLabel")
|
||||
}
|
||||
|
||||
hours >= 1 -> buildString {
|
||||
append(" ${hours}$hourLabel")
|
||||
}
|
||||
|
||||
minutes >= 1 -> buildString {
|
||||
append(" ${minutes}$minuteLabel")
|
||||
}
|
||||
|
||||
else -> buildString {
|
||||
append(" ${seconds}$secondLabel")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDateFromIso8601Timestamp(string: String): ZonedDateTime {
|
||||
return ZonedDateTime.parse(string)
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils.debug
|
||||
|
||||
actual object Log {
|
||||
|
||||
private const val TAG = "com.github.diegoberaldin.raccoonforlemmy"
|
||||
actual fun d(message: String) {
|
||||
android.util.Log.d(TAG, message)
|
||||
}
|
||||
private const val TAG = "com.github.diegoberaldin.raccoonforlemmy"
|
||||
actual fun logDebug(message: String) {
|
||||
android.util.Log.d(TAG, message)
|
||||
}
|
||||
|
@ -146,4 +146,28 @@ fun String.md5(): String {
|
||||
}
|
||||
|
||||
fun Int.toInboxUnreadOnly(): Boolean = this == 0
|
||||
|
||||
fun Boolean.toInboxDefaultType(): Int = if (this) 0 else 1
|
||||
|
||||
val String.looksLikeAnImage: Boolean
|
||||
get() {
|
||||
val imageExtensions = listOf(".jpeg", ".jpg", ".png", ".webp", ".gif")
|
||||
return imageExtensions.any { this.endsWith(it) }
|
||||
}
|
||||
|
||||
val String.looksLikeAVideo: Boolean
|
||||
get() {
|
||||
val imageExtensions = listOf(".mp4", ".mov", ".webm", ".avi")
|
||||
return imageExtensions.any { this.endsWith(it) }
|
||||
}
|
||||
|
||||
|
||||
fun String?.ellipsize(length: Int = 100, ellipsis: String = "…"): String {
|
||||
if (isNullOrEmpty() || length == 0) {
|
||||
return ""
|
||||
}
|
||||
if (this.length < length) {
|
||||
return this
|
||||
}
|
||||
return take(length - 1) + ellipsis
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
expect fun String.isValidUrl(): Boolean
|
||||
expect fun Int.toHexDigit(): String
|
@ -1,29 +0,0 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
expect object StringUtils {
|
||||
fun String.isValidUrl(): Boolean
|
||||
fun Int.toHexDigit(): String
|
||||
}
|
||||
|
||||
val String.looksLikeAnImage: Boolean
|
||||
get() {
|
||||
val imageExtensions = listOf(".jpeg", ".jpg", ".png", ".webp", ".gif")
|
||||
return imageExtensions.any { this.endsWith(it) }
|
||||
}
|
||||
|
||||
val String.looksLikeAVideo: Boolean
|
||||
get() {
|
||||
val imageExtensions = listOf(".mp4", ".mov", ".webm", ".avi")
|
||||
return imageExtensions.any { this.endsWith(it) }
|
||||
}
|
||||
|
||||
|
||||
fun String?.ellipsize(length: Int = 100, ellipsis: String = "…"): String {
|
||||
if (isNullOrEmpty() || length == 0) {
|
||||
return ""
|
||||
}
|
||||
if (this.length < length) {
|
||||
return this
|
||||
}
|
||||
return take(length - 1) + ellipsis
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime
|
||||
|
||||
expect fun epochMillis(): Long
|
||||
|
||||
expect fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String
|
||||
|
||||
expect fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String
|
@ -1,20 +0,0 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime
|
||||
|
||||
expect object DateTime {
|
||||
fun epochMillis(): Long
|
||||
|
||||
fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String
|
||||
|
||||
fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String
|
||||
}
|
@ -11,7 +11,7 @@ fun String.prettifyDate(): String = let {
|
||||
when {
|
||||
it.isEmpty() -> it
|
||||
!it.endsWith("Z") -> {
|
||||
DateTime.getPrettyDate(
|
||||
getPrettyDate(
|
||||
iso8601Timestamp = it + "Z",
|
||||
yearLabel = stringResource(
|
||||
MR.strings.profile_year_short
|
||||
@ -33,7 +33,7 @@ fun String.prettifyDate(): String = let {
|
||||
}
|
||||
|
||||
else -> {
|
||||
DateTime.getPrettyDate(
|
||||
getPrettyDate(
|
||||
iso8601Timestamp = it,
|
||||
yearLabel = stringResource(
|
||||
MR.strings.profile_year_short
|
||||
|
@ -1,5 +1,3 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils.debug
|
||||
|
||||
expect object Log {
|
||||
fun d(message: String)
|
||||
}
|
||||
expect fun logDebug(message: String)
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
import platform.Foundation.NSString
|
||||
import platform.Foundation.NSURL
|
||||
import platform.Foundation.stringWithFormat
|
||||
|
||||
actual fun String.isValidUrl(): Boolean = NSURL.URLWithString(this) != null
|
||||
|
||||
actual fun Int.toHexDigit(): String {
|
||||
return NSString.stringWithFormat("%02X", this)
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package com.github.diegoberaldin.raccoonforlemmy.core.utils
|
||||
|
||||
import platform.Foundation.NSString
|
||||
import platform.Foundation.NSURL
|
||||
import platform.Foundation.stringWithFormat
|
||||
|
||||
|
||||
actual object StringUtils {
|
||||
actual fun String.isValidUrl(): Boolean = NSURL.URLWithString(this) != null
|
||||
|
||||
actual fun Int.toHexDigit(): String {
|
||||
return NSString.stringWithFormat("%02X", this)
|
||||
}
|
||||
}
|
@ -17,81 +17,79 @@ import platform.Foundation.autoupdatingCurrentLocale
|
||||
import platform.Foundation.localTimeZone
|
||||
import platform.Foundation.timeIntervalSince1970
|
||||
|
||||
actual object DateTime {
|
||||
|
||||
actual fun epochMillis(): Long {
|
||||
return (NSDate().timeIntervalSince1970 * 1000).toLong()
|
||||
}
|
||||
actual fun epochMillis(): Long {
|
||||
return (NSDate().timeIntervalSince1970 * 1000).toLong()
|
||||
}
|
||||
|
||||
actual fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp) ?: return ""
|
||||
actual fun getFormattedDate(
|
||||
iso8601Timestamp: String,
|
||||
format: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp) ?: return ""
|
||||
|
||||
val dateFormatter = NSDateFormatter()
|
||||
dateFormatter.timeZone = NSTimeZone.localTimeZone
|
||||
dateFormatter.locale = NSLocale.autoupdatingCurrentLocale
|
||||
dateFormatter.dateFormat = format
|
||||
return dateFormatter.stringFromDate(date)
|
||||
}
|
||||
val dateFormatter = NSDateFormatter()
|
||||
dateFormatter.timeZone = NSTimeZone.localTimeZone
|
||||
dateFormatter.locale = NSLocale.autoupdatingCurrentLocale
|
||||
dateFormatter.dateFormat = format
|
||||
return dateFormatter.stringFromDate(date)
|
||||
}
|
||||
|
||||
actual fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp) ?: return ""
|
||||
val now = NSDate()
|
||||
val calendar = NSCalendar(calendarIdentifier = NSCalendarIdentifierGregorian)
|
||||
val delta = calendar.components(
|
||||
unitFlags = NSCalendarUnitSecond.or(NSCalendarUnitMinute).or(NSCalendarUnitHour)
|
||||
.or(NSCalendarUnitDay).or(NSCalendarUnitMonth).or(NSCalendarUnitYear),
|
||||
fromDate = date,
|
||||
toDate = now,
|
||||
options = 0u,
|
||||
)
|
||||
return when {
|
||||
delta.year >= 1 -> buildString {
|
||||
append("${delta.year}$yearLabel")
|
||||
if (delta.month >= 1) {
|
||||
append(" ${delta.month}$monthLabel")
|
||||
}
|
||||
if (delta.day >= 1) {
|
||||
append(" ${delta.day}$dayLabel")
|
||||
}
|
||||
actual fun getPrettyDate(
|
||||
iso8601Timestamp: String,
|
||||
yearLabel: String,
|
||||
monthLabel: String,
|
||||
dayLabel: String,
|
||||
hourLabel: String,
|
||||
minuteLabel: String,
|
||||
secondLabel: String,
|
||||
): String {
|
||||
val date = getDateFromIso8601Timestamp(iso8601Timestamp) ?: return ""
|
||||
val now = NSDate()
|
||||
val calendar = NSCalendar(calendarIdentifier = NSCalendarIdentifierGregorian)
|
||||
val delta = calendar.components(
|
||||
unitFlags = NSCalendarUnitSecond.or(NSCalendarUnitMinute).or(NSCalendarUnitHour)
|
||||
.or(NSCalendarUnitDay).or(NSCalendarUnitMonth).or(NSCalendarUnitYear),
|
||||
fromDate = date,
|
||||
toDate = now,
|
||||
options = 0u,
|
||||
)
|
||||
return when {
|
||||
delta.year >= 1 -> buildString {
|
||||
append("${delta.year}$yearLabel")
|
||||
if (delta.month >= 1) {
|
||||
append(" ${delta.month}$monthLabel")
|
||||
}
|
||||
|
||||
delta.month >= 1 -> buildString {
|
||||
append("${delta.month}$monthLabel")
|
||||
if (delta.day >= 1) {
|
||||
append(" ${delta.day}$dayLabel")
|
||||
}
|
||||
}
|
||||
|
||||
delta.day >= 1 -> buildString {
|
||||
append("${delta.day}$dayLabel")
|
||||
}
|
||||
|
||||
delta.hour >= 1 -> buildString {
|
||||
append(" ${delta.hour}$hourLabel")
|
||||
}
|
||||
|
||||
delta.minute >= 1 -> buildString {
|
||||
append(" ${delta.minute}$minuteLabel")
|
||||
}
|
||||
|
||||
else -> buildString {
|
||||
append(" ${delta.second}$secondLabel")
|
||||
if (delta.day >= 1) {
|
||||
append(" ${delta.day}$dayLabel")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDateFromIso8601Timestamp(string: String): NSDate? {
|
||||
return NSISO8601DateFormatter().dateFromString(string)
|
||||
delta.month >= 1 -> buildString {
|
||||
append("${delta.month}$monthLabel")
|
||||
if (delta.day >= 1) {
|
||||
append(" ${delta.day}$dayLabel")
|
||||
}
|
||||
}
|
||||
|
||||
delta.day >= 1 -> buildString {
|
||||
append("${delta.day}$dayLabel")
|
||||
}
|
||||
|
||||
delta.hour >= 1 -> buildString {
|
||||
append(" ${delta.hour}$hourLabel")
|
||||
}
|
||||
|
||||
delta.minute >= 1 -> buildString {
|
||||
append(" ${delta.minute}$minuteLabel")
|
||||
}
|
||||
|
||||
else -> buildString {
|
||||
append(" ${delta.second}$secondLabel")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getDateFromIso8601Timestamp(string: String): NSDate? {
|
||||
return NSISO8601DateFormatter().dateFromString(string)
|
||||
}
|
||||
|
@ -2,8 +2,6 @@ package com.github.diegoberaldin.raccoonforlemmy.core.utils.debug
|
||||
|
||||
import platform.Foundation.NSLog
|
||||
|
||||
actual object Log {
|
||||
actual fun d(message: String) {
|
||||
NSLog(message)
|
||||
}
|
||||
actual fun logDebug(message: String) {
|
||||
NSLog(message)
|
||||
}
|
||||
|
@ -1,47 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "domain"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.diegoberaldin.raccoonforlemmy.domain"
|
||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
@ -3,7 +3,7 @@ package com.github.diegoberaldin.raccoonforlemmy.domain.identity.usecase
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.data.AccountModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.AccountRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.debug.Log
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.debug.logDebug
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.ApiConfigurationRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.AuthRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.IdentityRepository
|
||||
@ -31,7 +31,7 @@ internal class DefaultLoginUseCase(
|
||||
totp2faToken = totp2faToken,
|
||||
)
|
||||
return response.onFailure {
|
||||
Log.d("Login failure: ${it.message}")
|
||||
logDebug("Login failure: ${it.message}")
|
||||
}.map {
|
||||
val auth = it.token
|
||||
if (auth == null) {
|
||||
|
@ -1,47 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "feature"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.diegoberaldin.raccoonforlemmy.feature"
|
||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
@ -21,11 +21,9 @@ include(":androidApp")
|
||||
include(":shared")
|
||||
include(":resources")
|
||||
|
||||
include(":core")
|
||||
include(":core:api")
|
||||
include(":core:appearance")
|
||||
include(":core:architecture")
|
||||
include(":core:commonui")
|
||||
include(":core:commonui:components")
|
||||
include(":core:commonui:detailopener-api")
|
||||
include(":core:commonui:detailopener-impl")
|
||||
@ -38,21 +36,18 @@ include(":core:persistence")
|
||||
include(":core:preferences")
|
||||
include(":core:utils")
|
||||
|
||||
include(":domain")
|
||||
include(":domain:identity")
|
||||
include(":domain:inbox")
|
||||
include(":domain:lemmy")
|
||||
include(":domain:lemmy:data")
|
||||
include(":domain:lemmy:repository")
|
||||
|
||||
include(":feature")
|
||||
include(":feature:home")
|
||||
include(":feature:inbox")
|
||||
include(":feature:profile")
|
||||
include(":feature:search")
|
||||
include(":feature:settings")
|
||||
|
||||
include(":unit")
|
||||
include(":unit:about")
|
||||
include(":unit:ban")
|
||||
include(":unit:chat")
|
||||
|
@ -1,47 +0,0 @@
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.multiplatform)
|
||||
alias(libs.plugins.android.library)
|
||||
alias(libs.plugins.compose)
|
||||
}
|
||||
|
||||
@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
|
||||
kotlin {
|
||||
applyDefaultHierarchyTemplate()
|
||||
|
||||
androidTarget {
|
||||
compilations.all {
|
||||
kotlinOptions {
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
listOf(
|
||||
iosX64(),
|
||||
iosArm64(),
|
||||
iosSimulatorArm64()
|
||||
).forEach {
|
||||
it.binaries.framework {
|
||||
baseName = "unit"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
val commonMain by getting {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
val commonTest by getting {
|
||||
dependencies {
|
||||
implementation(kotlin("test"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
namespace = "com.github.diegoberaldin.raccoonforlemmy.unit"
|
||||
compileSdk = libs.versions.android.targetSdk.get().toInt()
|
||||
defaultConfig {
|
||||
minSdk = libs.versions.android.minSdk.get().toInt()
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import com.github.diegoberaldin.raccoonforlemmy.core.appearance.repository.Theme
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.DefaultMviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.MviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.StringUtils.isValidUrl
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.isValidUrl
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.identity.repository.IdentityRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.LemmyItemCache
|
||||
import com.github.diegoberaldin.raccoonforlemmy.domain.lemmy.repository.PostRepository
|
||||
|
@ -3,7 +3,7 @@ package com.github.diegoberaldin.raccoonforlemmy.unit.zoomableimage
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.DefaultMviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.architecture.MviModel
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.persistence.repository.SettingsRepository
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.DateTime
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.datetime.epochMillis
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.gallery.GalleryHelper
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.gallery.download
|
||||
import com.github.diegoberaldin.raccoonforlemmy.core.utils.share.ShareHelper
|
||||
@ -51,7 +51,7 @@ class ZoomableImageViewModel(
|
||||
val idx = s.lastIndexOf(".").takeIf { it >= 0 } ?: s.length
|
||||
s.substring(idx).takeIf { it.isNotEmpty() } ?: ".jpeg"
|
||||
}
|
||||
galleryHelper.saveToGallery(bytes, "${DateTime.epochMillis()}.$extension")
|
||||
galleryHelper.saveToGallery(bytes, "${epochMillis()}.$extension")
|
||||
mvi.emitEffect(ZoomableImageMviModel.Effect.ShareSuccess)
|
||||
} catch (e: Throwable) {
|
||||
e.printStackTrace()
|
||||
|
Loading…
x
Reference in New Issue
Block a user