Skip to content

Commit a7a7c81

Browse files
authored
Merge branch 'main' into fix-scheduled-transfer-clipboard-text
2 parents b53e819 + 3f79fac commit a7a7c81

File tree

7 files changed

+54
-23
lines changed

7 files changed

+54
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
- Incorrect environment name in a private key export file for Mainnet
1212
- Improper handling of rejected identity verification when setting up a new wallet
1313
- Showing "Address copied" when copying a transaction hash to the clipboard in the scheduled transfer view
14+
- An issue where the identity name was off-center when the edit name icon was visible
15+
- An issue where exporting transaction logs for an account without any transactions would be stuck at 0%
1416

1517
### Changed
1618
- Suggest running a recovery when facing account or identity creation errors

app/src/main/java/com/concordium/wallet/ui/more/export/ExportTransactionLogActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class ExportTransactionLogActivity : BaseActivity(
3434
viewModel.onIdleRequested()
3535

3636
hideActionBarBack(isVisible = true) {
37-
viewModel.onIdleRequested()
3837
finish()
3938
}
4039
}
@@ -86,6 +85,7 @@ class ExportTransactionLogActivity : BaseActivity(
8685

8786
binding.successLayout.isVisible = downloadState is FileDownloadScreenState.Downloaded
8887
binding.failedLayout.isVisible = downloadState is FileDownloadScreenState.Failed
88+
binding.noContentLayout.isVisible = downloadState is FileDownloadScreenState.NoContent
8989

9090
binding.generate.isVisible = downloadState is FileDownloadScreenState.Idle
9191
binding.cancel.isVisible = downloadState is FileDownloadScreenState.Downloading

app/src/main/java/com/concordium/wallet/ui/more/export/ExportTransactionLogViewModel.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import kotlinx.coroutines.launch
2121
import okhttp3.OkHttpClient
2222
import okhttp3.ResponseBody
2323
import okhttp3.logging.HttpLoggingInterceptor
24+
import retrofit2.Response
2425
import retrofit2.Retrofit
2526
import retrofit2.http.GET
2627
import retrofit2.http.Streaming
@@ -31,20 +32,24 @@ import java.util.concurrent.TimeUnit
3132
interface FileDownloadApi {
3233
@Streaming
3334
@GET
34-
suspend fun downloadFile(@Url url: String?): ResponseBody
35+
suspend fun downloadFile(@Url url: String?): Response<ResponseBody>
3536
}
3637

3738
sealed class FileDownloadScreenState {
3839
object Idle : FileDownloadScreenState()
3940
data class Downloading(val progress: Int) : FileDownloadScreenState()
4041
object Failed : FileDownloadScreenState()
4142
object Downloaded : FileDownloadScreenState()
43+
object NoContent : FileDownloadScreenState()
4244
}
4345

4446
class ExportTransactionLogViewModel(application: Application) : AndroidViewModel(application) {
4547
lateinit var account: Account
4648
private lateinit var api: FileDownloadApi
4749

50+
val HTTP_OK = 200
51+
val HTTP_NO_CONTENT = 204
52+
4853
val textResourceInt: MutableLiveData<Int> by lazy { MutableLiveData<Int>() }
4954

5055
private sealed class DownloadState {
@@ -78,8 +83,17 @@ class ExportTransactionLogViewModel(application: Application) : AndroidViewModel
7883
)
7984
)
8085

81-
api.downloadFile(downloadFile)
82-
.saveFile(destinationFolder)
86+
val response = api.downloadFile(downloadFile)
87+
val statusCode = response.code()
88+
if (statusCode == HTTP_NO_CONTENT) {
89+
this@ExportTransactionLogViewModel.downloadState.postValue(FileDownloadScreenState.NoContent)
90+
return@launch
91+
} else if (statusCode != HTTP_OK || response.body() == null) {
92+
this@ExportTransactionLogViewModel.downloadState.postValue(FileDownloadScreenState.Failed)
93+
return@launch
94+
}
95+
96+
response.body()!!.saveFile(destinationFolder)
8397
.collect { downloadState ->
8498
// Add visual delay and ensure the coroutine is active.
8599
delay(300)

app/src/main/java/com/concordium/wallet/uicore/view/IdentityView.kt

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,8 @@ constructor(
4646
private var onChangeNameClickListener: OnChangeNameClickListener? = null
4747

4848
fun enableChangeNameOption(identity: Identity) {
49-
binding.nameTextview.compoundDrawablePadding = 20
50-
val drawable = AppCompatResources.getDrawable(context, R.drawable.cryptox_ico_edit)
51-
binding.nameTextview.setCompoundDrawablesRelativeWithIntrinsicBounds(
52-
null,
53-
null,
54-
drawable,
55-
null
56-
)
57-
binding.nameTextview.setOnClickListener {
49+
binding.nameIcon.isVisible = true
50+
binding.nameTextAndIcon.setOnClickListener {
5851
onChangeNameClickListener?.onChangeNameClicked(identity)
5952
}
6053
}

app/src/main/res/layout/activity_export_transaction_log.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@
100100
style="@style/CryptoX_Container_Error.TextView"
101101
android:text="@string/export_transaction_log_failed" />
102102

103+
<TextView
104+
android:id="@+id/no_content_layout"
105+
style="@style/CryptoX_Container_Information.TextView"
106+
android:text="@string/export_transaction_log_no_content" />
107+
103108
<Space
104109
android:layout_width="0dp"
105110
android:layout_height="20dp" />

app/src/main/res/layout/view_identity.xml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,34 @@
3131
tools:text="@string/view_identity_status_done"
3232
tools:textColor="@color/ccx_status_success" />
3333

34-
<TextView
35-
android:id="@+id/name_textview"
34+
<RelativeLayout
35+
android:id="@+id/name_text_and_icon"
3636
android:layout_width="match_parent"
37-
android:layout_height="wrap_content"
37+
android:layout_height="match_parent"
3838
android:layout_marginTop="8dp"
39-
android:ellipsize="end"
40-
android:gravity="center"
41-
android:maxLines="1"
42-
android:textAppearance="@style/CCX_Typography_H2"
43-
android:textColor="@color/ccx_neutral_tint_1"
44-
tools:drawableEndCompat="@drawable/cryptox_ico_edit"
45-
tools:text="Identity 1" />
39+
>
40+
41+
<TextView
42+
android:id="@+id/name_textview"
43+
android:layout_width="match_parent"
44+
android:layout_marginHorizontal="25dp"
45+
android:layout_height="wrap_content"
46+
android:gravity="center"
47+
android:ellipsize="end"
48+
android:maxLines="1"
49+
android:textAppearance="@style/CCX_Typography_H2"
50+
android:textColor="@color/ccx_neutral_tint_1"
51+
tools:text="Identity 1" />
52+
53+
<ImageView
54+
android:id="@+id/name_icon"
55+
android:layout_width="wrap_content"
56+
android:layout_height="wrap_content"
57+
android:layout_centerVertical="true"
58+
android:layout_alignParentEnd="true"
59+
android:visibility="invisible"
60+
android:src="@drawable/cryptox_ico_edit"/>
61+
</RelativeLayout>
4662

4763
<TextView
4864
android:id="@+id/expires_textview"

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,6 +1022,7 @@
10221022
<string name="export_transaction_log_cancel">Cancel</string>
10231023
<string name="export_transaction_log_saved">The transaction logs have been saved</string>
10241024
<string name="export_transaction_log_failed">Failed to download transaction logs</string>
1025+
<string name="export_transaction_log_no_content">There are no transaction logs available for this account</string>
10251026
<string name="export_transaction_log_progress">%1$d%%</string> <!-- 45% -->
10261027
<string name="export_transaction_log_downloading">Downloading transaction logs…</string>
10271028

0 commit comments

Comments
 (0)