Skip to content

Commit e68fd35

Browse files
author
Paul Lammertsma
committed
refactor(ui): modularize mobile presentation into ui/mobile package
- Extract mobile screen composables into ui/mobile/ (MobileAgentDemoContent, MobileDebuggingContent, MobileSettingsContent, MobileConnectedAppsContent). - Update top-level screen files (AgentDemoScreen, DebuggingScreen, SettingsScreen, ConnectedAppsScreen) to delegate UI rendering to ScreenLayoutFactory. - Zero visual changes (100% parity with existing mobile UX).
1 parent 16aa38a commit e68fd35

21 files changed

Lines changed: 2110 additions & 1412 deletions

‎agent/app/src/main/java/com/example/appfunctions/agent/data/DataStoreSettingsRepository.kt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package com.example.appfunctions.agent.data
1717

1818
import androidx.datastore.core.DataStore
1919
import androidx.datastore.preferences.core.Preferences
20+
import androidx.datastore.preferences.core.booleanPreferencesKey
2021
import androidx.datastore.preferences.core.edit
2122
import androidx.datastore.preferences.core.stringPreferencesKey
2223
import androidx.datastore.preferences.core.stringSetPreferencesKey
@@ -39,6 +40,7 @@ class DataStoreSettingsRepository
3940
val SERVICE_TIER = stringPreferencesKey("service_tier")
4041
val PINNED_APPS = stringSetPreferencesKey("pinned_apps")
4142
val DISCONNECTED_APPS = stringSetPreferencesKey("disconnected_apps")
43+
val APP_FUNCTION_DEBUGGING = booleanPreferencesKey("app_function_debugging")
4244
}
4345

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

78+
override val appFunctionDebuggingEnabled: Flow<Boolean> =
79+
dataStore.data.map { preferences ->
80+
preferences[PreferencesKeys.APP_FUNCTION_DEBUGGING] ?: true
81+
}
82+
7683
override suspend fun setGeminiApiKey(apiKey: String) {
7784
dataStore.edit { preferences -> preferences[PreferencesKeys.GEMINI_API_KEY] = apiKey }
7885
}
@@ -118,4 +125,10 @@ class DataStoreSettingsRepository
118125
preferences[PreferencesKeys.DISCONNECTED_APPS] = newDisconnected
119126
}
120127
}
128+
129+
override suspend fun setAppFunctionDebuggingEnabled(enabled: Boolean) {
130+
dataStore.edit { preferences ->
131+
preferences[PreferencesKeys.APP_FUNCTION_DEBUGGING] = enabled
132+
}
133+
}
121134
}

‎agent/app/src/main/java/com/example/appfunctions/agent/data/SettingsRepository.kt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,10 @@ interface SettingsRepository {
5454
packageName: String,
5555
connected: Boolean,
5656
)
57+
58+
/** Flow of AppFunction debugging setting. */
59+
val appFunctionDebuggingEnabled: Flow<Boolean>
60+
61+
/** Sets whether AppFunction debugging is enabled. */
62+
suspend fun setAppFunctionDebuggingEnabled(enabled: Boolean)
5763
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright 2026 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.example.appfunctions.agent.ui.layout
17+
18+
import com.example.appfunctions.agent.ui.contracts.AgentDemoScreenLayout
19+
import com.example.appfunctions.agent.ui.contracts.ConnectedAppsScreenLayout
20+
import com.example.appfunctions.agent.ui.contracts.DebuggingScreenLayout
21+
import com.example.appfunctions.agent.ui.contracts.SettingsScreenLayout
22+
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileAgentDemoLayout
23+
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileConnectedAppsLayout
24+
import com.example.appfunctions.agent.ui.mobile.agentdemo.MobileSettingsLayout
25+
import com.example.appfunctions.agent.ui.mobile.debugging.MobileDebuggingLayout
26+
27+
/**
28+
* Centralized layout factory that resolves screen layout contracts for specific form factors.
29+
* This pattern decouples screen routers from explicit form factor resolution conditionals,
30+
* allowing new device form factors (e.g., Wear OS, Android XR, Auto) to be added cleanly.
31+
*/
32+
fun FormFactor.resolveAgentDemoLayout(): AgentDemoScreenLayout = MobileAgentDemoLayout
33+
34+
fun FormFactor.resolveConnectedAppsLayout(): ConnectedAppsScreenLayout = MobileConnectedAppsLayout
35+
36+
fun FormFactor.resolveSettingsLayout(): SettingsScreenLayout = MobileSettingsLayout
37+
38+
fun FormFactor.resolveDebuggingLayout(): DebuggingScreenLayout = MobileDebuggingLayout

0 commit comments

Comments
 (0)