aboutsummaryrefslogtreecommitdiff
path: root/wallet/src/main/java
diff options
context:
space:
mode:
authorTorsten Grote <t@grobox.de>2020-04-01 15:11:55 -0300
committerTorsten Grote <t@grobox.de>2020-04-01 15:11:55 -0300
commit9401b3e8f0d6f49751a4d203502cfb76842599c0 (patch)
treeb5fda8690ce0f43027d560064442e610981f85a4 /wallet/src/main/java
parentb2bec204e214e6b077c4c1901d07fabec27104e9 (diff)
downloadtaler-android-9401b3e8f0d6f49751a4d203502cfb76842599c0.tar.gz
taler-android-9401b3e8f0d6f49751a4d203502cfb76842599c0.tar.bz2
taler-android-9401b3e8f0d6f49751a4d203502cfb76842599c0.zip
[wallet] automatic code cleanup
Diffstat (limited to 'wallet/src/main/java')
-rw-r--r--wallet/src/main/java/net/taler/wallet/HostCardEmulatorService.kt10
-rw-r--r--wallet/src/main/java/net/taler/wallet/MainActivity.kt3
-rw-r--r--wallet/src/main/java/net/taler/wallet/Settings.kt6
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt25
-rw-r--r--wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt6
5 files changed, 20 insertions, 30 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/HostCardEmulatorService.kt b/wallet/src/main/java/net/taler/wallet/HostCardEmulatorService.kt
index 93f1d3f..751dac5 100644
--- a/wallet/src/main/java/net/taler/wallet/HostCardEmulatorService.kt
+++ b/wallet/src/main/java/net/taler/wallet/HostCardEmulatorService.kt
@@ -60,7 +60,7 @@ fun readApduBodySize(stream: ByteArrayInputStream): Int {
}
-class HostCardEmulatorService: HostApduService() {
+class HostCardEmulatorService : HostApduService() {
val queuedRequests: ConcurrentLinkedDeque<String> = ConcurrentLinkedDeque()
private lateinit var receiver: BroadcastReceiver
@@ -90,8 +90,10 @@ class HostCardEmulatorService: HostApduService() {
}
}
- override fun processCommandApdu(commandApdu: ByteArray?,
- extras: Bundle?): ByteArray {
+ override fun processCommandApdu(
+ commandApdu: ByteArray?,
+ extras: Bundle?
+ ): ByteArray {
Log.d(TAG, "Processing command APDU")
@@ -123,7 +125,7 @@ class HostCardEmulatorService: HostApduService() {
if (instruction == GET_INS) {
val req = queuedRequests.poll()
return if (req != null) {
- Log.v(TAG,"sending tunnel request")
+ Log.v(TAG, "sending tunnel request")
makeApduSuccessResponse(req.toByteArray(Charsets.UTF_8))
} else {
makeApduSuccessResponse(ByteArray(0))
diff --git a/wallet/src/main/java/net/taler/wallet/MainActivity.kt b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
index 26af3f0..6f0ed89 100644
--- a/wallet/src/main/java/net/taler/wallet/MainActivity.kt
+++ b/wallet/src/main/java/net/taler/wallet/MainActivity.kt
@@ -76,7 +76,8 @@ class MainActivity : AppCompatActivity(), OnNavigationItemSelectedListener,
setSupportActionBar(toolbar)
val appBarConfiguration = AppBarConfiguration(
- setOf(R.id.showBalance, R.id.settings, R.id.walletHistory, R.id.nav_pending_operations), drawer_layout
+ setOf(R.id.showBalance, R.id.settings, R.id.walletHistory, R.id.nav_pending_operations),
+ drawer_layout
)
toolbar.setupWithNavController(nav, appBarConfiguration)
diff --git a/wallet/src/main/java/net/taler/wallet/Settings.kt b/wallet/src/main/java/net/taler/wallet/Settings.kt
index 6d10412..572c036 100644
--- a/wallet/src/main/java/net/taler/wallet/Settings.kt
+++ b/wallet/src/main/java/net/taler/wallet/Settings.kt
@@ -71,8 +71,10 @@ class ResetDialogFragment : DialogFragment() {
listener = context as ResetDialogEventListener
} catch (e: ClassCastException) {
// The activity doesn't implement the interface, throw exception
- throw ClassCastException((context.toString() +
- " must implement ResetDialogEventListener"))
+ throw ClassCastException(
+ (context.toString() +
+ " must implement ResetDialogEventListener")
+ )
}
}
}
diff --git a/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt b/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
index b177fb4..43b7bd7 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryAdapter.kt
@@ -18,15 +18,6 @@ package net.taler.wallet.history
import android.annotation.SuppressLint
import android.graphics.Paint.STRIKE_THRU_TEXT_FLAG
-import android.text.format.DateUtils.DAY_IN_MILLIS
-import android.text.format.DateUtils.FORMAT_ABBREV_MONTH
-import android.text.format.DateUtils.FORMAT_ABBREV_RELATIVE
-import android.text.format.DateUtils.FORMAT_NO_YEAR
-import android.text.format.DateUtils.FORMAT_SHOW_DATE
-import android.text.format.DateUtils.FORMAT_SHOW_TIME
-import android.text.format.DateUtils.MINUTE_IN_MILLIS
-import android.text.format.DateUtils.formatDateTime
-import android.text.format.DateUtils.getRelativeTimeSpanString
import android.view.LayoutInflater
import android.view.View
import android.view.View.GONE
@@ -39,6 +30,7 @@ import androidx.core.net.toUri
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder
import net.taler.common.Amount
+import net.taler.common.toRelativeTime
import net.taler.wallet.BuildConfig
import net.taler.wallet.R
import net.taler.wallet.history.HistoryAdapter.HistoryEventViewHolder
@@ -92,20 +84,7 @@ internal class HistoryAdapter(
icon.setImageResource(event.icon)
if (event.title == 0) title.text = event::class.java.simpleName
else title.setText(event.title)
- time.text = getRelativeTime(event.timestamp.ms)
- }
-
- private fun getRelativeTime(timestamp: Long): CharSequence {
- val now = System.currentTimeMillis()
- return if (now - timestamp > DAY_IN_MILLIS * 2) {
- formatDateTime(
- v.context,
- timestamp,
- FORMAT_SHOW_TIME or FORMAT_SHOW_DATE or FORMAT_ABBREV_MONTH or FORMAT_NO_YEAR
- )
- } else {
- getRelativeTimeSpanString(timestamp, now, MINUTE_IN_MILLIS, FORMAT_ABBREV_RELATIVE)
- }
+ time.text = event.timestamp.ms.toRelativeTime(v.context)
}
}
diff --git a/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt b/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
index b78c062..86a7ac0 100644
--- a/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
+++ b/wallet/src/main/java/net/taler/wallet/history/HistoryEvent.kt
@@ -40,6 +40,7 @@ enum class ReserveType {
*/
@JsonProperty("manual")
MANUAL,
+
/**
* Withdrawn from a bank that has "tight" Taler integration
*/
@@ -55,17 +56,22 @@ enum class RefreshReason {
@JsonProperty("manual")
@Suppress("unused")
MANUAL,
+
@JsonProperty("pay")
PAY,
+
@JsonProperty("refund")
@Suppress("unused")
REFUND,
+
@JsonProperty("abort-pay")
@Suppress("unused")
ABORT_PAY,
+
@JsonProperty("recoup")
@Suppress("unused")
RECOUP,
+
@JsonProperty("backup-restored")
@Suppress("unused")
BACKUP_RESTORED