Compare commits

..

No commits in common. "43f247a71bec450fa75856cfdc3ee4d38968e354" and "895899d03ab49c108b608673ad6dfadf8fbd1cc5" have entirely different histories.

6 changed files with 24 additions and 44 deletions

View file

@ -2,7 +2,6 @@ package im.angry.openeuicc.ui.wizard
import android.os.Bundle
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.Button
import android.widget.ProgressBar
import androidx.activity.OnBackPressedCallback
@ -85,7 +84,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
val bars = insets.getInsets(
WindowInsetsCompat.Type.systemBars()
or WindowInsetsCompat.Type.displayCutout()
or WindowInsetsCompat.Type.ime()
)
v.updatePadding(bars.left, 0, bars.right, bars.bottom)
val newParams = navigation.layoutParams
@ -134,8 +132,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
}
private fun onPrevPressed() {
hideIme()
if (currentFragment?.hasPrev == true) {
val prevFrag = currentFragment?.createPrevFragment()
if (prevFrag == null) {
@ -147,8 +143,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
}
private fun onNextPressed() {
hideIme()
if (currentFragment?.hasNext == true) {
currentFragment?.beforeNext()
val nextFrag = currentFragment?.createNextFragment()
@ -198,13 +192,6 @@ class DownloadWizardActivity: BaseEuiccAccessActivity() {
}
}
private fun hideIme() {
currentFocus?.let {
val imm = getSystemService(InputMethodManager::class.java)
imm.hideSoftInputFromWindow(it.windowToken, 0)
}
}
abstract class DownloadWizardStepFragment : Fragment(), OpenEuiccContextMarker {
protected val state: DownloadWizardState
get() = (requireActivity() as DownloadWizardActivity).state

View file

@ -22,7 +22,7 @@ class DownloadWizardDetailsFragment : DownloadWizardActivity.DownloadWizardStepF
private lateinit var confirmationCode: TextInputLayout
private lateinit var imei: TextInputLayout
private fun saveState() {
override fun beforeNext() {
state.smdp = smdp.editText!!.text.toString().trim()
// Treat empty inputs as null -- this is important for the download step
state.matchingId = matchingId.editText!!.text.toString().trim().ifBlank { null }
@ -30,8 +30,6 @@ class DownloadWizardDetailsFragment : DownloadWizardActivity.DownloadWizardStepF
state.imei = imei.editText!!.text.toString().ifBlank { null }
}
override fun beforeNext() = saveState()
override fun createNextFragment(): DownloadWizardActivity.DownloadWizardStepFragment =
DownloadWizardProgressFragment()
@ -63,11 +61,6 @@ class DownloadWizardDetailsFragment : DownloadWizardActivity.DownloadWizardStepF
updateInputCompleteness()
}
override fun onPause() {
super.onPause()
saveState()
}
private fun updateInputCompleteness() {
inputComplete = Patterns.DOMAIN_NAME.matcher(smdp.editText!!.text).matches()
refreshButtons()

View file

@ -111,7 +111,7 @@ class DownloadWizardSlotSelectFragment : DownloadWizardActivity.DownloadWizardSt
} catch (e: Exception) {
""
},
channel.lpa.profiles.enabled?.displayName,
channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }?.displayName,
channel.intrinsicChannelName,
)
}

View file

@ -16,10 +16,9 @@ val LocalProfileInfo.isEnabled: Boolean
get() = state == LocalProfileInfo.State.Enabled
val List<LocalProfileInfo>.operational: List<LocalProfileInfo>
get() = filter { it.profileClass == LocalProfileInfo.Clazz.Operational }
val List<LocalProfileInfo>.enabled: LocalProfileInfo?
get() = find { it.isEnabled }
get() = filter {
it.profileClass == LocalProfileInfo.Clazz.Operational
}
val List<EuiccChannel>.hasMultipleChips: Boolean
get() = distinctBy { it.slotId }.size > 1
@ -40,7 +39,7 @@ fun LocalProfileAssistant.switchProfile(
* See EuiccManager.waitForReconnect()
*/
fun LocalProfileAssistant.disableActiveProfile(refresh: Boolean): Boolean =
profiles.enabled?.let {
profiles.find { it.isEnabled }?.let {
Log.i(TAG, "Disabling active profile ${it.iccid}")
disableProfile(it.iccid, refresh)
} ?: true
@ -53,7 +52,7 @@ fun LocalProfileAssistant.disableActiveProfile(refresh: Boolean): Boolean =
* disable.
*/
fun LocalProfileAssistant.disableActiveProfileKeepIccId(refresh: Boolean): String? =
profiles.enabled?.let {
profiles.find { it.isEnabled }?.let {
Log.i(TAG, "Disabling active profile ${it.iccid}")
if (disableProfile(it.iccid, refresh)) {
it.iccid

View file

@ -1,6 +1,5 @@
package im.angry.openeuicc.util
import android.content.ClipData
import android.content.Context
import android.content.Intent
import android.content.res.Resources
@ -82,8 +81,6 @@ fun <T : ActivityResultCaller> T.setupLogSaving(
getLogFileName: () -> String,
getLogText: () -> String
): () -> Unit {
var lastFileName = "untitled"
val launchSaveIntent =
registerForActivityResult(ActivityResultContracts.CreateDocument("text/plain")) { uri ->
if (uri == null) return@registerForActivityResult
@ -104,12 +101,10 @@ fun <T : ActivityResultCaller> T.setupLogSaving(
setMessage(R.string.logs_saved_message)
setNegativeButton(R.string.no) { _, _ -> }
setPositiveButton(R.string.yes) { _, _ ->
val intent = Intent(Intent.ACTION_SEND).apply {
val intent = Intent().apply {
action = Intent.ACTION_SEND
type = "text/plain"
clipData = ClipData.newUri(context.contentResolver, lastFileName, uri)
putExtra(Intent.EXTRA_TITLE, lastFileName)
putExtra(Intent.EXTRA_STREAM, uri)
addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
context.startActivity(Intent.createChooser(intent, null))
@ -118,7 +113,6 @@ fun <T : ActivityResultCaller> T.setupLogSaving(
}
return {
lastFileName = getLogFileName()
launchSaveIntent.launch(lastFileName)
launchSaveIntent.launch(getLogFileName())
}
}

View file

@ -186,10 +186,13 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
)
}
return@withEuiccChannelManager try {
euiccChannelManager.withEuiccChannel(slotId, port) { channel ->
try {
return@withEuiccChannelManager euiccChannelManager.withEuiccChannel(
slotId,
port
) { channel ->
val filteredProfiles =
if (preferenceRepository.unfilteredProfileListFlow.first())
if (runBlocking { preferenceRepository.unfilteredProfileListFlow.first() })
channel.lpa.profiles
else
channel.lpa.profiles.operational
@ -221,7 +224,7 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
)
}
} catch (e: EuiccChannelManager.EuiccChannelNotFoundException) {
GetEuiccProfileInfoListResult(
return@withEuiccChannelManager GetEuiccProfileInfoListResult(
RESULT_FIRST_USER,
arrayOf(),
true
@ -243,7 +246,11 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
// Check that the profile has been disabled on all slots
val enabledAnywhere = ports.any { port ->
euiccChannelManager.withEuiccChannel(slotId, port) { channel ->
channel.lpa.profiles.enabled?.iccid == iccid
val profile = channel.lpa.profiles.find {
it.iccid == iccid
} ?: return@withEuiccChannel false
profile.state == LocalProfileInfo.State.Enabled
}
}
@ -347,8 +354,8 @@ class OpenEuiccService : EuiccService(), OpenEuiccContextMarker {
// iccid == null means disabling
val foundIccid =
euiccChannelManager.withEuiccChannel(foundSlotId, foundPortId) { channel ->
channel.lpa.profiles.enabled?.iccid
} ?: return@withEuiccChannelManager RESULT_FIRST_USER
channel.lpa.profiles.find { it.state == LocalProfileInfo.State.Enabled }
}?.iccid ?: return@withEuiccChannelManager RESULT_FIRST_USER
Pair(foundIccid, false)
} else {
Pair(iccid, true)