Compare commits

..

2 commits

Author SHA1 Message Date
472f9d05ac chore: simplify progress item initialization and error message handling (#226)
Reviewed-on: PeterCxy/OpenEUICC#226
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-09-08 15:12:26 +02:00
0c98121c2a chore: ignore new file in dot-idea directory (#227)
![CleanShot 2025-09-08 at 15.51.35@2x](/attachments/8133796b-eebf-4162-b6c4-f66d9217b48d)

Reviewed-on: PeterCxy/OpenEUICC#227
Co-authored-by: septs <github@septs.pw>
Co-committed-by: septs <github@septs.pw>
2025-09-08 15:11:40 +02:00
2 changed files with 23 additions and 51 deletions

21
.idea/.gitignore generated vendored
View file

@ -1,14 +1,7 @@
/shelf *
/caches !/codeStyles/Project.xml
/libraries !/codeStyles/codeStyleConfig.xml
/assetWizardSettings.xml !/vcs.xml
/deploymentTarget*.xml !/kotlinc.xml
/gradle.xml !/compiler.xml
/misc.xml !/migrations.xml
/modules.xml
/navEditor.xml
/runConfigurations.xml
/workspace.xml
/AndroidProjectSystem.xml
**/*.iml

View file

@ -7,6 +7,7 @@ import android.view.ViewGroup
import android.widget.ImageView import android.widget.ImageView
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView import android.widget.TextView
import androidx.annotation.StringRes
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
@ -42,37 +43,17 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
} }
private data class ProgressItem( private data class ProgressItem(
val titleRes: Int, @StringRes val titleRes: Int,
var state: ProgressState, var state: ProgressState = ProgressState.NotStarted,
var errorMessage: SimplifiedErrorMessages?, var errorMessage: SimplifiedErrorMessages? = null,
) )
private val progressItems = arrayOf( private val progressItems = arrayOf(
ProgressItem( ProgressItem(R.string.download_wizard_progress_step_preparing),
R.string.download_wizard_progress_step_preparing, ProgressItem(R.string.download_wizard_progress_step_connecting),
ProgressState.NotStarted, ProgressItem(R.string.download_wizard_progress_step_authenticating),
null ProgressItem(R.string.download_wizard_progress_step_downloading),
), ProgressItem(R.string.download_wizard_progress_step_finalizing)
ProgressItem(
R.string.download_wizard_progress_step_connecting,
ProgressState.NotStarted,
null
),
ProgressItem(
R.string.download_wizard_progress_step_authenticating,
ProgressState.NotStarted,
null
),
ProgressItem(
R.string.download_wizard_progress_step_downloading,
ProgressState.NotStarted,
null
),
ProgressItem(
R.string.download_wizard_progress_step_finalizing,
ProgressState.NotStarted,
null
)
) )
private val adapter = ProgressItemAdapter() private val adapter = ProgressItemAdapter()
@ -156,9 +137,8 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
refreshButtons() refreshButtons()
} }
is EuiccChannelManagerService.ForegroundTaskState.InProgress -> { is EuiccChannelManagerService.ForegroundTaskState.InProgress ->
updateProgress(it.progress) updateProgress(it.progress)
}
else -> {} else -> {}
} }
@ -252,14 +232,13 @@ class DownloadWizardProgressFragment : DownloadWizardActivity.DownloadWizardStep
icon.setImageResource(R.drawable.ic_error_outline) icon.setImageResource(R.drawable.ic_error_outline)
icon.visibility = View.VISIBLE icon.visibility = View.VISIBLE
if (item.errorMessage != null) { item.errorMessage?.titleResId?.let {
errorTitle.visibility = View.VISIBLE errorTitle.visibility = View.VISIBLE
errorTitle.text = getString(item.errorMessage!!.titleResId) errorTitle.text = getString(it)
}
if (item.errorMessage!!.suggestResId != null) { item.errorMessage?.suggestResId?.let {
errorSuggestion.visibility = View.VISIBLE errorSuggestion.visibility = View.VISIBLE
errorSuggestion.text = getString(item.errorMessage!!.suggestResId!!) errorSuggestion.text = getString(it)
}
} }
} }
} }