forked from PeterCxy/OpenEUICC
Compare commits
3 commits
071304349a
...
e9f4d3d1f9
Author | SHA1 | Date | |
---|---|---|---|
e9f4d3d1f9 | |||
506b0e530a | |||
e8db3d1206 |
3 changed files with 27 additions and 16 deletions
|
@ -12,6 +12,7 @@ import android.widget.ProgressBar
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.activity.result.contract.ActivityResultContracts
|
import androidx.activity.result.contract.ActivityResultContracts
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import com.google.android.material.textfield.TextInputLayout
|
import com.google.android.material.textfield.TextInputLayout
|
||||||
|
@ -25,13 +26,14 @@ import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import kotlin.Exception
|
|
||||||
|
|
||||||
class ProfileDownloadFragment : BaseMaterialDialogFragment(),
|
class ProfileDownloadFragment : BaseMaterialDialogFragment(),
|
||||||
Toolbar.OnMenuItemClickListener, EuiccChannelFragmentMarker {
|
Toolbar.OnMenuItemClickListener, EuiccChannelFragmentMarker {
|
||||||
companion object {
|
companion object {
|
||||||
const val TAG = "ProfileDownloadFragment"
|
const val TAG = "ProfileDownloadFragment"
|
||||||
|
|
||||||
|
const val LOW_NVRAM_THRESHOLD = 30 * 1024 // < 30 KiB, the alert may fail
|
||||||
|
|
||||||
fun newInstance(slotId: Int, portId: Int, finishWhenDone: Boolean = false): ProfileDownloadFragment =
|
fun newInstance(slotId: Int, portId: Int, finishWhenDone: Boolean = false): ProfileDownloadFragment =
|
||||||
newInstanceEuicc(ProfileDownloadFragment::class.java, slotId, portId) {
|
newInstanceEuicc(ProfileDownloadFragment::class.java, slotId, portId) {
|
||||||
putBoolean("finishWhenDone", finishWhenDone)
|
putBoolean("finishWhenDone", finishWhenDone)
|
||||||
|
@ -135,7 +137,21 @@ class ProfileDownloadFragment : BaseMaterialDialogFragment(),
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.ok -> {
|
R.id.ok -> {
|
||||||
|
if (freeNvram > LOW_NVRAM_THRESHOLD) {
|
||||||
startDownloadProfile()
|
startDownloadProfile()
|
||||||
|
} else {
|
||||||
|
AlertDialog.Builder(requireContext()).apply {
|
||||||
|
setTitle(R.string.profile_download_low_nvram_title)
|
||||||
|
setMessage(R.string.profile_download_low_nvram_message)
|
||||||
|
setIcon(android.R.drawable.ic_dialog_alert)
|
||||||
|
setCancelable(true)
|
||||||
|
setPositiveButton(android.R.string.ok) { _, _ ->
|
||||||
|
startDownloadProfile()
|
||||||
|
}
|
||||||
|
setNegativeButton(android.R.string.cancel, null)
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> false
|
else -> false
|
||||||
|
|
|
@ -55,6 +55,9 @@
|
||||||
<string name="profile_download_ok">Download</string>
|
<string name="profile_download_ok">Download</string>
|
||||||
<string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string>
|
<string name="profile_download_failed">Failed to download eSIM. Check your activation / QR code.</string>
|
||||||
|
|
||||||
|
<string name="profile_download_low_nvram_title">This download may fail</string>
|
||||||
|
<string name="profile_download_low_nvram_message">This download may fail due to low remaining capacity.</string>
|
||||||
|
|
||||||
<string name="profile_rename_new_name">New nickname</string>
|
<string name="profile_rename_new_name">New nickname</string>
|
||||||
|
|
||||||
<string name="profile_delete_confirm">Are you sure you want to delete the profile %s? This operation is irreversible.</string>
|
<string name="profile_delete_confirm">Are you sure you want to delete the profile %s? This operation is irreversible.</string>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package im.angry.openeuicc.ui
|
package im.angry.openeuicc.ui
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
|
@ -68,20 +67,13 @@ class CompatibilityCheckActivity: AppCompatActivity() {
|
||||||
it.visibility = View.GONE
|
it.visibility = View.GONE
|
||||||
}
|
}
|
||||||
|
|
||||||
when (item.state) {
|
val viewId = when (item.state) {
|
||||||
CompatibilityCheck.State.SUCCESS -> {
|
CompatibilityCheck.State.SUCCESS -> R.id.compatibility_check_checkmark
|
||||||
root.requireViewById<View>(R.id.compatibility_check_checkmark).visibility = View.VISIBLE
|
CompatibilityCheck.State.FAILURE -> R.id.compatibility_check_error
|
||||||
}
|
CompatibilityCheck.State.FAILURE_UNKNOWN -> R.id.compatibility_check_unknown
|
||||||
CompatibilityCheck.State.FAILURE -> {
|
else -> R.id.compatibility_check_progress_bar
|
||||||
root.requireViewById<View>(R.id.compatibility_check_error).visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
CompatibilityCheck.State.FAILURE_UNKNOWN -> {
|
|
||||||
root.requireViewById<View>(R.id.compatibility_check_unknown).visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
root.requireViewById<View>(R.id.compatibility_check_progress_bar).visibility = View.VISIBLE
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
root.requireViewById<View>(viewId).visibility = View.VISIBLE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue