-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)
- Loading branch information
Showing
906 changed files
with
364 additions
and
207 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
play-services-base/core/src/main/kotlin/org/microg/gms/ui/settings/SettingsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.