Skip to content
Open
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 @@ -17,6 +17,7 @@ package com.example.appfunctions.agent.data

import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.booleanPreferencesKey
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.core.stringSetPreferencesKey
Expand All @@ -39,6 +40,7 @@ class DataStoreSettingsRepository
val SERVICE_TIER = stringPreferencesKey("service_tier")
val PINNED_APPS = stringSetPreferencesKey("pinned_apps")
val DISCONNECTED_APPS = stringSetPreferencesKey("disconnected_apps")
val APP_FUNCTION_DEBUGGING = booleanPreferencesKey("app_function_debugging")
}

override val geminiApiKey: Flow<String?> =
Expand Down Expand Up @@ -73,6 +75,11 @@ class DataStoreSettingsRepository
preferences[PreferencesKeys.DISCONNECTED_APPS] ?: emptySet()
}

override val appFunctionDebuggingEnabled: Flow<Boolean> =
dataStore.data.map { preferences ->
preferences[PreferencesKeys.APP_FUNCTION_DEBUGGING] ?: true
}

override suspend fun setGeminiApiKey(apiKey: String) {
dataStore.edit { preferences -> preferences[PreferencesKeys.GEMINI_API_KEY] = apiKey }
}
Expand Down Expand Up @@ -118,4 +125,10 @@ class DataStoreSettingsRepository
preferences[PreferencesKeys.DISCONNECTED_APPS] = newDisconnected
}
}

override suspend fun setAppFunctionDebuggingEnabled(enabled: Boolean) {
dataStore.edit { preferences ->
preferences[PreferencesKeys.APP_FUNCTION_DEBUGGING] = enabled
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,10 @@ interface SettingsRepository {
packageName: String,
connected: Boolean,
)

/** Flow of AppFunction debugging setting. */
val appFunctionDebuggingEnabled: Flow<Boolean>

/** Sets whether AppFunction debugging is enabled. */
suspend fun setAppFunctionDebuggingEnabled(enabled: Boolean)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.example.appfunctions.agent.ui.layout

import com.example.appfunctions.agent.ui.contracts.AgentDemoScreenLayout
import com.example.appfunctions.agent.ui.contracts.ConnectedAppsScreenLayout
import com.example.appfunctions.agent.ui.contracts.DebuggingScreenLayout
import com.example.appfunctions.agent.ui.contracts.SettingsScreenLayout
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileAgentDemoLayout
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileConnectedAppsLayout
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileSettingsLayout
import com.example.appfunctions.agent.ui.mobile.debugging.MobileDebuggingLayout

/**
* Centralized layout factory that resolves screen layout contracts for specific form factors.
* This pattern decouples screen routers from explicit form factor resolution conditionals,
* allowing new device form factors (e.g., Wear OS, Android XR, Auto) to be added cleanly.
*/
fun FormFactor.resolveAgentDemoLayout(): AgentDemoScreenLayout = MobileAgentDemoLayout

fun FormFactor.resolveConnectedAppsLayout(): ConnectedAppsScreenLayout = MobileConnectedAppsLayout

fun FormFactor.resolveSettingsLayout(): SettingsScreenLayout = MobileSettingsLayout

fun FormFactor.resolveDebuggingLayout(): DebuggingScreenLayout = MobileDebuggingLayout
Loading
Loading