Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve test options #313

Merged
merged 3 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,4 +291,9 @@
<string name="results_limited_notice">Only the last %1$d results are shown</string>
<string name="auto_test_not_uploaded_limit">Skip after this amount of results failed to upload</string>
<string name="AddDescriptor_Toasts_Unsupported_Url">Unsupported URL</string>
<string name="Settings_Sharing_UploadResults_Description">Results are automatically uploaded to OONI explorer</string>
<string name="Settings_Websites_MaxRuntimeEnabled_New">Limit Websites test duration</string>
<string name="Settings_Websites_MaxRuntime_New">Maximum Websites test duration</string>
<string name="Settings_AutomatedTesting_RunAutomatically_Description">Tests will run every hour in the background</string>
<string name="Settings_Websites_MaxRuntimeEnabled_Description">Only for manual runs</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.ooni.probe.config

object BuildTypeDefaults : BuildTypeDefaultsInterface {
override val ooniApiBaseUrl = "https://api.dev.ooni.io"
override val ooniRunDomain = "run.test.ooni.org"
override val ooniRunDashboardUrl = "https://run.test.ooni.org"
override val explorerUrl = "https://explorer.ooni.org"
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ package org.ooni.probe.config

import org.jetbrains.compose.resources.DrawableResource

interface OrganizationConfigInterface {
val baseSoftwareName: String
val testDisplayMode: TestDisplayMode
val autorunTaskId: String
val onboardingImages: OnboardingImages
val updateDescriptorTaskId: String
val hasWebsitesDescriptor: Boolean

val ooniApiBaseUrl get() = BuildTypeDefaults.ooniApiBaseUrl
val ooniRunDomain get() = BuildTypeDefaults.ooniRunDomain
val ooniRunDashboardUrl get() = BuildTypeDefaults.ooniRunDashboardUrl
val explorerUrl get() = BuildTypeDefaults.explorerUrl
}

interface BuildTypeDefaultsInterface {
val ooniApiBaseUrl: String
val ooniRunDomain: String
val ooniRunDashboardUrl: String
val explorerUrl: String
}

data class OnboardingImages(
val image1: DrawableResource,
val image2: DrawableResource,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.ooni.probe.data.models

import androidx.compose.runtime.Composable
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.StringResource

open class PreferenceItem(
open val title: StringResource,
open val icon: DrawableResource? = null,
open val type: PreferenceItemType,
open val key: SettingsKey,
open val supportingContent: @Composable (() -> Unit)? = null,
open val trailingContent: @Composable (() -> Unit)? = null,
open val enabled: Boolean = true,
open val indentation: Int = 0,
)

data class SettingsItem(
override val icon: DrawableResource? = null,
override val title: StringResource,
override val type: PreferenceItemType,
override val key: SettingsKey,
override val supportingContent: @Composable (() -> Unit)? = null,
override val trailingContent: @Composable (() -> Unit)? = null,
override val enabled: Boolean = true,
override val indentation: Int = 0,
) : PreferenceItem(
title = title,
icon = icon,
supportingContent = supportingContent,
type = type,
key = key,
enabled = enabled,
)

data class SettingsCategoryItem(
override val icon: DrawableResource? = null,
override val title: StringResource,
val route: PreferenceCategoryKey,
val settings: List<PreferenceItem>? = emptyList(),
override val supportingContent: @Composable (() -> Unit)? = null,
val footerContent: @Composable (() -> Unit)? = null,
override val indentation: Int = 0,
) : PreferenceItem(
title = title,
icon = icon,
supportingContent = supportingContent,
type = PreferenceItemType.ROUTE,
key = SettingsKey.ROUTE,
)

enum class PreferenceItemType {
SWITCH,
INT,
BUTTON,
SELECT,
ROUTE,
}

enum class PreferenceCategoryKey(val value: String) {
NOTIFICATIONS("notifications"),
TEST_OPTIONS("test_options"),
PRIVACY("privacy"),
PROXY("proxy"),
ADVANCED("advanced"),
SEND_EMAIL("send_email"),
ABOUT_OONI("about_ooni"),

WEBSITES_CATEGORIES("websites_categories"),
SEE_RECENT_LOGS("see_recent_logs"),
;

companion object {
fun fromValue(value: String?) = value?.let { entries.firstOrNull { it.value == value } }
}
}
Original file line number Diff line number Diff line change
@@ -1,77 +1,5 @@
package org.ooni.probe.data.models

import androidx.compose.runtime.Composable
import org.jetbrains.compose.resources.DrawableResource
import org.jetbrains.compose.resources.StringResource

open class PreferenceItem(
open val title: StringResource,
open val icon: DrawableResource? = null,
open val type: PreferenceItemType,
open val key: SettingsKey,
open val supportingContent: @Composable (() -> Unit)? = null,
open val trailingContent: @Composable (() -> Unit)? = null,
open val enabled: Boolean = true,
)

data class SettingsItem(
override val icon: DrawableResource? = null,
override val title: StringResource,
override val type: PreferenceItemType,
override val key: SettingsKey,
override val supportingContent: @Composable (() -> Unit)? = null,
override val trailingContent: @Composable (() -> Unit)? = null,
override val enabled: Boolean = true,
) : PreferenceItem(
title = title,
icon = icon,
supportingContent = supportingContent,
type = type,
key = key,
enabled = enabled,
)

data class SettingsCategoryItem(
override val icon: DrawableResource? = null,
override val title: StringResource,
val route: PreferenceCategoryKey,
val settings: List<PreferenceItem>? = emptyList(),
override val supportingContent: @Composable (() -> Unit)? = null,
val footerContent: @Composable (() -> Unit)? = null,
) : PreferenceItem(
title = title,
icon = icon,
supportingContent = supportingContent,
type = PreferenceItemType.ROUTE,
key = SettingsKey.ROUTE,
)

enum class PreferenceItemType {
SWITCH,
INT,
BUTTON,
SELECT,
ROUTE,
}

enum class PreferenceCategoryKey(val value: String) {
NOTIFICATIONS("notifications"),
TEST_OPTIONS("test_options"),
PRIVACY("privacy"),
PROXY("proxy"),
ADVANCED("advanced"),
SEND_EMAIL("send_email"),
ABOUT_OONI("about_ooni"),

WEBSITES_CATEGORIES("websites_categories"),
SEE_RECENT_LOGS("see_recent_logs"),
;

companion object {
fun fromValue(value: String) = entries.first { it.value == value }
}
}

enum class SettingsKey(val value: String) {
// Notifications
NOTIFICATIONS_ENABLED("notifications_enabled"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class BootstrapPreferences(
SettingsKey.AUTOMATED_TESTING_CHARGING to true,
SettingsKey.AUTOMATED_TESTING_NOT_UPLOADED_LIMIT to NOT_UPLOADED_LIMIT_DEFAULT,
) +
preferenceDefaults(),
organizationPreferenceDefaults(),
)
}

Expand Down
Loading