Compare commits
1 commit
89b5e33cd2
...
fa40b964bc
Author | SHA1 | Date | |
---|---|---|---|
fa40b964bc |
6 changed files with 89 additions and 21 deletions
|
@ -31,6 +31,7 @@ import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||||
import net.typeblog.lpac_jni.LocalProfileInfo
|
import net.typeblog.lpac_jni.LocalProfileInfo
|
||||||
import im.angry.openeuicc.common.R
|
import im.angry.openeuicc.common.R
|
||||||
|
import im.angry.openeuicc.core.EuiccChannelManager
|
||||||
import im.angry.openeuicc.service.EuiccChannelManagerService
|
import im.angry.openeuicc.service.EuiccChannelManagerService
|
||||||
import im.angry.openeuicc.service.EuiccChannelManagerService.Companion.waitDone
|
import im.angry.openeuicc.service.EuiccChannelManagerService.Companion.waitDone
|
||||||
import im.angry.openeuicc.ui.wizard.DownloadWizardActivity
|
import im.angry.openeuicc.ui.wizard.DownloadWizardActivity
|
||||||
|
@ -131,31 +132,72 @@ open class EuiccManagementFragment : Fragment(), EuiccProfilesChangedListener,
|
||||||
inflater.inflate(R.menu.fragment_euicc, menu)
|
inflater.inflate(R.menu.fragment_euicc, menu)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean =
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
||||||
when (item.itemId) {
|
super.onPrepareOptionsMenu(menu)
|
||||||
R.id.show_notifications -> {
|
menu.findItem(R.id.show_notifications).isVisible =
|
||||||
if (logicalSlotId != -1) {
|
logicalSlotId != -1
|
||||||
Intent(requireContext(), NotificationsActivity::class.java).apply {
|
menu.findItem(R.id.euicc_info).isVisible =
|
||||||
putExtra("logicalSlotId", logicalSlotId)
|
logicalSlotId != -1
|
||||||
startActivity(this)
|
menu.findItem(R.id.euicc_memory_reset).isVisible =
|
||||||
}
|
logicalSlotId == EuiccChannelManager.USB_CHANNEL_ID
|
||||||
}
|
}
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
R.id.euicc_info -> {
|
override fun onOptionsItemSelected(item: MenuItem) = when (item.itemId) {
|
||||||
if (logicalSlotId != -1) {
|
R.id.show_notifications -> {
|
||||||
Intent(requireContext(), EuiccInfoActivity::class.java).apply {
|
Intent(requireContext(), NotificationsActivity::class.java).apply {
|
||||||
putExtra("logicalSlotId", logicalSlotId)
|
putExtra("logicalSlotId", logicalSlotId)
|
||||||
startActivity(this)
|
startActivity(this)
|
||||||
}
|
|
||||||
}
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
true
|
||||||
else -> super.onOptionsItemSelected(item)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
R.id.euicc_info -> {
|
||||||
|
Intent(requireContext(), EuiccInfoActivity::class.java).apply {
|
||||||
|
putExtra("logicalSlotId", logicalSlotId)
|
||||||
|
startActivity(this)
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
R.id.euicc_memory_reset -> {
|
||||||
|
AlertDialog.Builder(requireContext()).apply {
|
||||||
|
setTitle(R.string.euicc_memory_reset_title)
|
||||||
|
setMessage(R.string.euicc_memory_reset_message)
|
||||||
|
setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
lifecycleScope.launch {
|
||||||
|
ensureEuiccChannelManager()
|
||||||
|
euiccChannelManagerService.waitForForegroundTask()
|
||||||
|
|
||||||
|
// val err = euiccChannelManagerService.launchMemoryResetTask(
|
||||||
|
// slotId,
|
||||||
|
// portId
|
||||||
|
// ).waitDone()
|
||||||
|
//
|
||||||
|
// if (err != null) {
|
||||||
|
// withContext(Dispatchers.Main) {
|
||||||
|
// AlertDialog.Builder(requireContext()).apply {
|
||||||
|
// setMessage(R.string.euicc_memory_reset_failed)
|
||||||
|
// setPositiveButton(android.R.string.ok) { dialog, _ ->
|
||||||
|
// dialog.dismiss()
|
||||||
|
// }
|
||||||
|
// show()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setNegativeButton(android.R.string.cancel) { dialog, _ ->
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
|
show()
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> super.onOptionsItemSelected(item)
|
||||||
|
}
|
||||||
|
|
||||||
protected open suspend fun onCreateFooterViews(
|
protected open suspend fun onCreateFooterViews(
|
||||||
parent: ViewGroup,
|
parent: ViewGroup,
|
||||||
profiles: List<LocalProfileInfo>
|
profiles: List<LocalProfileInfo>
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.content.Intent
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.os.Debug
|
||||||
import android.provider.Settings
|
import android.provider.Settings
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
|
@ -11,6 +12,7 @@ import androidx.preference.CheckBoxPreference
|
||||||
import androidx.preference.Preference
|
import androidx.preference.Preference
|
||||||
import androidx.preference.PreferenceCategory
|
import androidx.preference.PreferenceCategory
|
||||||
import androidx.preference.PreferenceFragmentCompat
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import im.angry.openeuicc.common.BuildConfig
|
||||||
import im.angry.openeuicc.common.R
|
import im.angry.openeuicc.common.R
|
||||||
import im.angry.openeuicc.util.*
|
import im.angry.openeuicc.util.*
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
|
@ -77,6 +79,9 @@ open class SettingsFragment: PreferenceFragmentCompat() {
|
||||||
|
|
||||||
requirePreference<CheckBoxPreference>("pref_developer_ignore_tls_certificate")
|
requirePreference<CheckBoxPreference>("pref_developer_ignore_tls_certificate")
|
||||||
.bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow)
|
.bindBooleanFlow(preferenceRepository.ignoreTLSCertificateFlow)
|
||||||
|
|
||||||
|
requirePreference<CheckBoxPreference>("pref_developer_euicc_memory_reset").
|
||||||
|
bindBooleanFlow(preferenceRepository.euiccMemoryResetFlow)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun <T : Preference> requirePreference(key: CharSequence) =
|
protected fun <T : Preference> requirePreference(key: CharSequence) =
|
||||||
|
|
|
@ -33,6 +33,7 @@ internal object PreferenceKeys {
|
||||||
val DEVELOPER_OPTIONS_ENABLED = booleanPreferencesKey("developer_options_enabled")
|
val DEVELOPER_OPTIONS_ENABLED = booleanPreferencesKey("developer_options_enabled")
|
||||||
val UNFILTERED_PROFILE_LIST = booleanPreferencesKey("unfiltered_profile_list")
|
val UNFILTERED_PROFILE_LIST = booleanPreferencesKey("unfiltered_profile_list")
|
||||||
val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate")
|
val IGNORE_TLS_CERTIFICATE = booleanPreferencesKey("ignore_tls_certificate")
|
||||||
|
val EUICC_MEMORY_RESET = booleanPreferencesKey("euicc_memory_reset")
|
||||||
}
|
}
|
||||||
|
|
||||||
class PreferenceRepository(private val context: Context) {
|
class PreferenceRepository(private val context: Context) {
|
||||||
|
@ -50,6 +51,7 @@ class PreferenceRepository(private val context: Context) {
|
||||||
val developerOptionsEnabledFlow = bindFlow(PreferenceKeys.DEVELOPER_OPTIONS_ENABLED, false)
|
val developerOptionsEnabledFlow = bindFlow(PreferenceKeys.DEVELOPER_OPTIONS_ENABLED, false)
|
||||||
val unfilteredProfileListFlow = bindFlow(PreferenceKeys.UNFILTERED_PROFILE_LIST, false)
|
val unfilteredProfileListFlow = bindFlow(PreferenceKeys.UNFILTERED_PROFILE_LIST, false)
|
||||||
val ignoreTLSCertificateFlow = bindFlow(PreferenceKeys.IGNORE_TLS_CERTIFICATE, false)
|
val ignoreTLSCertificateFlow = bindFlow(PreferenceKeys.IGNORE_TLS_CERTIFICATE, false)
|
||||||
|
val euiccMemoryResetFlow = bindFlow(PreferenceKeys.EUICC_MEMORY_RESET, false)
|
||||||
|
|
||||||
private fun <T> bindFlow(key: Preferences.Key<T>, defaultValue: T): PreferenceFlowWrapper<T> =
|
private fun <T> bindFlow(key: Preferences.Key<T>, defaultValue: T): PreferenceFlowWrapper<T> =
|
||||||
PreferenceFlowWrapper(context, key, defaultValue)
|
PreferenceFlowWrapper(context, key, defaultValue)
|
||||||
|
|
|
@ -4,10 +4,18 @@
|
||||||
<item
|
<item
|
||||||
android:id="@+id/show_notifications"
|
android:id="@+id/show_notifications"
|
||||||
android:title="@string/profile_notifications_show"
|
android:title="@string/profile_notifications_show"
|
||||||
|
android:visible="false"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/euicc_info"
|
android:id="@+id/euicc_info"
|
||||||
android:title="@string/euicc_info"
|
android:title="@string/euicc_info"
|
||||||
|
android:visible="false"
|
||||||
|
app:showAsAction="never" />
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/euicc_memory_reset"
|
||||||
|
android:title="@string/euicc_memory_reset"
|
||||||
|
android:visible="false"
|
||||||
app:showAsAction="never" />
|
app:showAsAction="never" />
|
||||||
</menu>
|
</menu>
|
|
@ -143,6 +143,10 @@
|
||||||
<string name="euicc_info_ci_unknown">Unknown eSIM CI</string>
|
<string name="euicc_info_ci_unknown">Unknown eSIM CI</string>
|
||||||
<string name="euicc_info_atr" translatable="false">Answer To Reset (ATR)</string>
|
<string name="euicc_info_atr" translatable="false">Answer To Reset (ATR)</string>
|
||||||
|
|
||||||
|
<string name="euicc_memory_reset">Erase the Chip</string>
|
||||||
|
<string name="euicc_memory_reset_title">Erase the Chip</string>
|
||||||
|
<string name="euicc_memory_reset_message">I confirm to clear all profiles on this chip and understand that this operation is irreversible.</string>
|
||||||
|
|
||||||
<string name="yes">Yes</string>
|
<string name="yes">Yes</string>
|
||||||
<string name="no">No</string>
|
<string name="no">No</string>
|
||||||
|
|
||||||
|
@ -175,6 +179,8 @@
|
||||||
<string name="pref_developer_unfiltered_profile_list_desc">Include non-production profiles in the list</string>
|
<string name="pref_developer_unfiltered_profile_list_desc">Include non-production profiles in the list</string>
|
||||||
<string name="pref_developer_ignore_tls_certificate">Ignore SM-DP+ TLS certificate</string>
|
<string name="pref_developer_ignore_tls_certificate">Ignore SM-DP+ TLS certificate</string>
|
||||||
<string name="pref_developer_ignore_tls_certificate_desc">Accept any TLS certificate used by the RSP server</string>
|
<string name="pref_developer_ignore_tls_certificate_desc">Accept any TLS certificate used by the RSP server</string>
|
||||||
|
<string name="pref_developer_euicc_memory_reset">Allow Erase Chip (USB only)</string>
|
||||||
|
<string name="pref_developer_euicc_memory_reset_desc">Don\'t erase your eSIM as a troubleshooting step unless directed to by your carrier.</string>
|
||||||
<string name="pref_info">Info</string>
|
<string name="pref_info">Info</string>
|
||||||
<string name="pref_info_app_version">App Version</string>
|
<string name="pref_info_app_version">App Version</string>
|
||||||
<string name="pref_info_source_code">Source Code</string>
|
<string name="pref_info_source_code">Source Code</string>
|
||||||
|
|
|
@ -69,6 +69,11 @@
|
||||||
app:summary="@string/pref_developer_ignore_tls_certificate_desc"
|
app:summary="@string/pref_developer_ignore_tls_certificate_desc"
|
||||||
app:title="@string/pref_developer_ignore_tls_certificate" />
|
app:title="@string/pref_developer_ignore_tls_certificate" />
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:key="pref_developer_euicc_memory_reset"
|
||||||
|
app:summary="@string/pref_developer_euicc_memory_reset_desc"
|
||||||
|
app:title="@string/pref_developer_euicc_memory_reset" />
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
|
|
Loading…
Add table
Reference in a new issue