Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 639c1d0e authored by septs's avatar septs Committed by Peter Cai
Browse files

feat: official website url (#286)

parent d7fb53ce
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
package im.angry.openeuicc.di

import android.net.Uri
import im.angry.openeuicc.core.EuiccChannel

interface CustomizableTextProvider {
@@ -14,6 +15,11 @@ interface CustomizableTextProvider {
     */
    val profileSwitchingTimeoutMessage: String

    /**
     * Display the website link in settings; null if not available.
     */
    val websiteUri: Uri?

    /**
     * Format the name of a logical slot -- not for USB channels
     */
+7 −7
Original line number Diff line number Diff line
package im.angry.openeuicc.di

import android.content.Context
import android.net.Uri
import im.angry.openeuicc.common.R
import im.angry.openeuicc.core.EuiccChannel

open class DefaultCustomizableTextProvider(private val context: Context) :
    CustomizableTextProvider {
open class DefaultCustomizableTextProvider(private val context: Context) : CustomizableTextProvider {
    override val noEuiccExplanation: String
        get() = context.getString(R.string.no_euicc)

    override val profileSwitchingTimeoutMessage: String
        get() = context.getString(R.string.profile_switch_timeout)

    override val websiteUri: Uri?
        get() = null

    override fun formatNonUsbChannelName(logicalSlotId: Int): String =
        context.getString(R.string.channel_name_format, logicalSlotId)

    override fun formatNonUsbChannelNameWithSeId(
        logicalSlotId: Int,
        seId: EuiccChannel.SecureElementId
    ): String =
    override fun formatNonUsbChannelNameWithSeId(logicalSlotId: Int, seId: EuiccChannel.SecureElementId): String =
        context.getString(R.string.channel_name_format_se, logicalSlotId, seId.id)
}
+9 −2
Original line number Diff line number Diff line
@@ -13,16 +13,16 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import im.angry.openeuicc.common.R
import im.angry.openeuicc.util.OpenEuiccContextMarker
import im.angry.openeuicc.util.PreferenceFlowWrapper
import im.angry.openeuicc.util.mainViewPaddingInsetHandler
import im.angry.openeuicc.util.preferenceRepository
import im.angry.openeuicc.util.selfAppVersion
import im.angry.openeuicc.util.setupRootViewSystemBarInsets
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch

open class SettingsFragment : PreferenceFragmentCompat() {
open class SettingsFragment : PreferenceFragmentCompat(), OpenEuiccContextMarker {
    private lateinit var developerPref: PreferenceCategory

    // Hidden developer options switch
@@ -91,6 +91,13 @@ open class SettingsFragment : PreferenceFragmentCompat() {
        requirePreference<Preference>("pref_developer_isdr_aid_list").apply {
            intent = Intent(requireContext(), IsdrAidListActivity::class.java)
        }

        requirePreference<Preference>("pref_info_website").apply {
            val uri = appContainer.customizableTextProvider.websiteUri ?: return@apply
            isVisible = true
            summary = uri.buildUpon().clearQuery().build().toString()
            intent = Intent(/* action = */ Intent.ACTION_VIEW, uri)
        }
    }

    protected fun <T : Preference> requirePreference(key: CharSequence) =
+8 −7
Original line number Diff line number Diff line
package im.angry.openeuicc.util

import android.content.Context
import android.content.pm.PackageInfo
import android.content.pm.PackageManager
import android.graphics.Bitmap
import android.se.omapi.SEService
@@ -21,14 +22,14 @@ import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException
import kotlin.coroutines.suspendCoroutine

val Context.packageInfo: PackageInfo
    get() = packageManager.getPackageInfo(packageName, /* flags = */ 0)!!

val Context.selfAppVersion: String
    get() =
        try {
            val pInfo = packageManager.getPackageInfo(packageName, 0)
            pInfo.versionName!!
        } catch (e: PackageManager.NameNotFoundException) {
            throw RuntimeException(e)
        }
    get() = packageInfo.versionName!!

val Context.selfAppVersionCode: Long
    get() = packageInfo.longVersionCode

suspend fun readSelfLog(lines: Int = 2048): String = withContext(Dispatchers.IO) {
    try {
+1 −0
Original line number Diff line number Diff line
@@ -192,6 +192,7 @@
    <string name="pref_developer_isdr_aid_list_desc">一部ブランドのリムーバブル eSIM は独自の非標準な ISD-R AID を使用しているため、サードパーティー製アプリからアクセスできない場合があります。このリストに追加された非標準な AID の使用を試みますが、動作の保証はできません。</string>
    <string name="pref_info">情報</string>
    <string name="pref_info_app_version">アプリバージョン</string>
    <string name="pref_info_website">公式サイト</string>
    <string name="pref_info_source_code">ソースコード</string>
    <string name="channel_name_format_se">論理スロット %1$d, SE %2$d</string>
</resources>
Loading