Switch to API level 27 and updated libraries
This commit is contained in:
@ -47,28 +47,24 @@ object Assets {
|
||||
}
|
||||
|
||||
@DrawableRes
|
||||
fun getStatusDrawable(status: Plaintext.Status): Int {
|
||||
when (status) {
|
||||
Plaintext.Status.RECEIVED -> return 0
|
||||
Plaintext.Status.DRAFT -> return R.drawable.draft
|
||||
Plaintext.Status.PUBKEY_REQUESTED -> return R.drawable.public_key
|
||||
Plaintext.Status.DOING_PROOF_OF_WORK -> return R.drawable.ic_notification_proof_of_work
|
||||
Plaintext.Status.SENT -> return R.drawable.sent
|
||||
Plaintext.Status.SENT_ACKNOWLEDGED -> return R.drawable.sent_acknowledged
|
||||
else -> return 0
|
||||
}
|
||||
fun getStatusDrawable(status: Plaintext.Status) = when (status) {
|
||||
Plaintext.Status.RECEIVED -> 0
|
||||
Plaintext.Status.DRAFT -> R.drawable.draft
|
||||
Plaintext.Status.PUBKEY_REQUESTED -> R.drawable.public_key
|
||||
Plaintext.Status.DOING_PROOF_OF_WORK -> R.drawable.ic_notification_proof_of_work
|
||||
Plaintext.Status.SENT -> R.drawable.sent
|
||||
Plaintext.Status.SENT_ACKNOWLEDGED -> R.drawable.sent_acknowledged
|
||||
else -> 0
|
||||
}
|
||||
|
||||
@StringRes
|
||||
fun getStatusString(status: Plaintext.Status): Int {
|
||||
when (status) {
|
||||
Plaintext.Status.RECEIVED -> return R.string.status_received
|
||||
Plaintext.Status.DRAFT -> return R.string.status_draft
|
||||
Plaintext.Status.PUBKEY_REQUESTED -> return R.string.status_public_key
|
||||
Plaintext.Status.DOING_PROOF_OF_WORK -> return R.string.proof_of_work_title
|
||||
Plaintext.Status.SENT -> return R.string.status_sent
|
||||
Plaintext.Status.SENT_ACKNOWLEDGED -> return R.string.status_sent_acknowledged
|
||||
else -> return 0
|
||||
}
|
||||
fun getStatusString(status: Plaintext.Status) = when (status) {
|
||||
Plaintext.Status.RECEIVED -> R.string.status_received
|
||||
Plaintext.Status.DRAFT -> R.string.status_draft
|
||||
Plaintext.Status.PUBKEY_REQUESTED -> R.string.status_public_key
|
||||
Plaintext.Status.DOING_PROOF_OF_WORK -> R.string.proof_of_work_title
|
||||
Plaintext.Status.SENT -> R.string.status_sent
|
||||
Plaintext.Status.SENT_ACKNOWLEDGED -> R.string.status_sent_acknowledged
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
|
@ -33,5 +33,5 @@ object Constants {
|
||||
|
||||
const val BITMESSAGE_URL_SCHEMA = "bitmessage:"
|
||||
|
||||
val BITMESSAGE_ADDRESS_PATTERN = Pattern.compile("\\bBM-[a-zA-Z0-9]+\\b")
|
||||
val BITMESSAGE_ADDRESS_PATTERN = Pattern.compile("\\bBM-[a-zA-Z0-9]+\\b")!!
|
||||
}
|
||||
|
@ -39,9 +39,7 @@ object Labels {
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
fun getColor(label: Label): Int {
|
||||
return if (label.type == null) {
|
||||
label.color
|
||||
} else 0xFF000000.toInt()
|
||||
}
|
||||
fun getColor(label: Label) = if (label.type == null) {
|
||||
label.color
|
||||
} else 0xFF000000.toInt()
|
||||
}
|
||||
|
@ -12,8 +12,8 @@ import java.math.BigInteger
|
||||
object PowStats {
|
||||
private val TWO_POW_64: BigInteger = BigInteger.valueOf(2).pow(64)
|
||||
|
||||
var averagePowUnitTime = 0L
|
||||
var powCount = 0L
|
||||
private var averagePowUnitTime = 0L
|
||||
private var powCount = 0L
|
||||
|
||||
fun getExpectedPowTimeInMilliseconds(ctx: Context, target: ByteArray): Long {
|
||||
if (averagePowUnitTime == 0L) {
|
||||
|
@ -19,7 +19,6 @@ package ch.dissem.apps.abit.util
|
||||
import android.content.Context
|
||||
import android.preference.PreferenceManager
|
||||
import ch.dissem.apps.abit.R
|
||||
import ch.dissem.apps.abit.listener.WifiReceiver
|
||||
import ch.dissem.apps.abit.notification.ErrorNotification
|
||||
import ch.dissem.apps.abit.util.Constants.PREFERENCE_FULL_NODE
|
||||
import ch.dissem.apps.abit.util.Constants.PREFERENCE_REQUEST_ACK
|
||||
@ -27,7 +26,6 @@ import ch.dissem.apps.abit.util.Constants.PREFERENCE_SYNC_TIMEOUT
|
||||
import ch.dissem.apps.abit.util.Constants.PREFERENCE_TRUSTED_NODE
|
||||
import ch.dissem.apps.abit.util.Constants.PREFERENCE_WIFI_ONLY
|
||||
import org.jetbrains.anko.connectivityManager
|
||||
import org.jetbrains.anko.networkStatsManager
|
||||
import org.slf4j.LoggerFactory
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
@ -24,17 +24,15 @@ import java.util.regex.Pattern
|
||||
object Strings {
|
||||
private val WHITESPACES = Pattern.compile("\\s+")
|
||||
|
||||
private fun trim(string: CharSequence?, length: Int) = if (string == null) {
|
||||
""
|
||||
} else if (string.length <= length) {
|
||||
string
|
||||
} else {
|
||||
string.subSequence(0, length)
|
||||
private fun trim(string: CharSequence?, length: Int) = when {
|
||||
string == null -> ""
|
||||
string.length <= length -> string
|
||||
else -> string.subSequence(0, length)
|
||||
}
|
||||
|
||||
/**
|
||||
* Trim the string to 200 characters and normalizes all whitespaces by replacing any sequence
|
||||
* of whitespace characters with a single space character.
|
||||
*/
|
||||
fun prepareMessageExtract(string: CharSequence?) = WHITESPACES.matcher(trim(string, 200)).replaceAll(" ")
|
||||
fun prepareMessageExtract(string: CharSequence?): String = WHITESPACES.matcher(trim(string, 200)).replaceAll(" ")
|
||||
}
|
||||
|
Reference in New Issue
Block a user