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

Unverified Commit dd8c5601 authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Build: Change system for optional components

- Nearby can now be configured through local build property, enabled by default
- Exposure Notifications is not displayed in settings if not used for >14 days
- Flavors per map type remain (but moved maps implementations)
parent 2c80de55
Loading
Loading
Loading
Loading
+58 −0
Original line number Original line Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2023 microG Project Team
 * SPDX-License-Identifier: Apache-2.0
 */

package org.microg.gms.ui.settings

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.graphics.drawable.Drawable
import android.os.Bundle
import android.util.Log
import androidx.navigation.NavController

private const val TAG = "SettingsProvider"

interface SettingsProvider {
    fun getEntriesStatic(context: Context): List<Entry>
    suspend fun getEntriesDynamic(context: Context): List<Entry> = getEntriesStatic(context)

    fun preProcessSettingsIntent(intent: Intent)

    fun extendNavigation(navController: NavController)

    companion object {
        enum class Group {
            HEADER,
            GOOGLE,
            OTHER,
            FOOTER
        }

        data class Entry(
            val key: String,
            val group: Group,
            val navigationId: Int,
            val title: String,
            val summary: String? = null,
            val icon: Drawable? = null,
        )
    }
}

fun getAllSettingsProviders(context: Context): List<SettingsProvider> {
    val metaData = runCatching { context.packageManager.getApplicationInfo(context.packageName, PackageManager.GET_META_DATA).metaData }.getOrNull() ?: Bundle.EMPTY
    return metaData.keySet().asSequence().filter {
        it.startsWith("org.microg.gms.ui.settings.entry:")
    }.mapNotNull {
        runCatching { metaData.getString(it) }.onFailure { Log.w(TAG, it) }.getOrNull()
    }.mapNotNull {
        runCatching { Class.forName(it) }.onFailure { Log.w(TAG, it) }.getOrNull()
    }.filter {
        SettingsProvider::class.java.isAssignableFrom(it)
    }.mapNotNull {
        runCatching { it.getDeclaredField("INSTANCE").get(null) as SettingsProvider }.onFailure { Log.w(TAG, it) }.getOrNull()
    }.toList()
}
 No newline at end of file
+7 −0
Original line number Original line Diff line number Diff line
@@ -15,4 +15,11 @@
    <string name="list_item_see_all">Паказаць усё</string>
    <string name="list_item_see_all">Паказаць усё</string>


    <string name="open_app">Aдкрыць</string>
    <string name="open_app">Aдкрыць</string>

    <string name="service_status_disabled">Выключана</string>
    <string name="service_status_enabled">Уключана</string>
    <string name="service_status_automatic">Аўтаматычна</string>
    <string name="service_status_manual">Уручную</string>
    <string name="service_status_enabled_short">Укл.</string>
    <string name="service_status_disabled_short">Выкл.</string>
</resources>
</resources>
+7 −0
Original line number Original line Diff line number Diff line
@@ -15,4 +15,11 @@
    <string name="list_item_see_all">Alle anzeigen</string>
    <string name="list_item_see_all">Alle anzeigen</string>


    <string name="open_app">Öffnen</string>
    <string name="open_app">Öffnen</string>

    <string name="service_status_disabled">Deaktiviert</string>
    <string name="service_status_enabled">Aktiviert</string>
    <string name="service_status_automatic">Automatisch</string>
    <string name="service_status_manual">Manuell</string>
    <string name="service_status_enabled_short">Ein</string>
    <string name="service_status_disabled_short">Aus</string>
</resources>
</resources>
+7 −0
Original line number Original line Diff line number Diff line
@@ -11,4 +11,11 @@
    <string name="list_item_see_all">Ver todo</string>
    <string name="list_item_see_all">Ver todo</string>


    <string name="open_app">Abrir</string>
    <string name="open_app">Abrir</string>

    <string name="service_status_disabled">Desactivado</string>
    <string name="service_status_enabled">Activado</string>
    <string name="service_status_automatic">Automático</string>
    <string name="service_status_manual">Manual</string>
    <string name="service_status_enabled_short">Encendido</string>
    <string name="service_status_disabled_short">Apagado</string>
</resources>
</resources>
+5 −0
Original line number Original line Diff line number Diff line
@@ -8,4 +8,9 @@
    <string name="menu_advanced">Avancé</string>
    <string name="menu_advanced">Avancé</string>


    <string name="list_no_item_none">Aucun</string>
    <string name="list_no_item_none">Aucun</string>

    <string name="service_status_disabled">Désactivé</string>
    <string name="service_status_enabled">Activé</string>
    <string name="service_status_automatic">Automatique</string>
    <string name="service_status_manual">Manuel</string>
</resources>
</resources>
Loading