Skip to content

Commit ff15025

Browse files
committed
Clean up unused declarations based on dual-flavor lint analysis
Removed code unused in BOTH standalone and pepper flavors: - PerceptionData.HumanInfo: Removed unused display methods (getLastSeenDisplay, isStale, getAttentionLevel, getEngagementLevel, getDemographics, getBasicEmotionDisplay, getSmileStateDisplay, getPleasureStateDisplay, getExcitementStateDisplay, computeBasicEmotion) Note: Kept id and worldPitch as they are used by Pepper flavor - Game Managers: Removed isGameActive()/isQuizVisible() convenience methods - SessionImageManager: Removed getImageCount() - SettingsRepository: Removed getSettings() - SpeechRecognizerManager: Removed unused recognizerLock - ToneGenerator: Removed playMelody() overload without callback - GoogleLiveEvents: Removed unused Voices and Audio objects (kept as comments) - HttpClientManager: Removed unused postJson() and get() methods - RealtimeApiProvider: Removed isXaiProvider()
1 parent 61c3a22 commit ff15025

11 files changed

Lines changed: 3 additions & 281 deletions
Lines changed: 1 addition & 185 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package ch.fhnw.pepper_realtime.data
22

3-
import android.graphics.Bitmap
43
import java.util.Locale
54

65
/**
@@ -12,7 +11,7 @@ class PerceptionData {
1211
* Information about a detected human
1312
*/
1413
class HumanInfo {
15-
var id: Int = 0
14+
var id: Int = 0 // Human ID (for Pepper QiSDK compatibility)
1615
var estimatedAge: Int = -1
1716
var gender: String = "Unknown"
1817
var pleasureState: String = "Unknown"
@@ -22,7 +21,6 @@ class PerceptionData {
2221
var smileState: String = "Unknown"
2322
var distanceMeters: Double = -1.0
2423
var basicEmotion: BasicEmotion = BasicEmotion.UNKNOWN
25-
var facePicture: Bitmap? = null // Face picture from QiSDK
2624

2725
// --- Position relative to robot (for bird's eye view) ---
2826
var positionX: Double = 0.0 // Meters in front of robot (positive = in front)
@@ -86,65 +84,6 @@ class PerceptionData {
8684
}
8785
}
8886

89-
/**
90-
* Get freshness indicator for UI display.
91-
* Shows how recently this person was seen.
92-
*/
93-
fun getLastSeenDisplay(): String {
94-
if (lastSeenMs <= 0L) return ""
95-
val elapsed = System.currentTimeMillis() - lastSeenMs
96-
return when {
97-
elapsed < 500 -> "🟢 Now"
98-
elapsed < 1000 -> "🟢 <1s"
99-
elapsed < 2000 -> "🟡 ${elapsed / 1000}s"
100-
elapsed < 3000 -> "🟠 ${elapsed / 1000}s"
101-
else -> "🔴 ${elapsed / 1000}s"
102-
}
103-
}
104-
105-
/**
106-
* Check if data is stale (not seen recently)
107-
*/
108-
fun isStale(): Boolean {
109-
if (lastSeenMs <= 0L) return true
110-
return (System.currentTimeMillis() - lastSeenMs) > 2000
111-
}
112-
113-
/**
114-
* Get attention level for UI display.
115-
* Uses head-based gaze detection if available (trackId >= 0).
116-
*/
117-
fun getAttentionLevel(): String {
118-
// Use head-based gaze detection if available
119-
if (trackId >= 0) {
120-
return if (lookingAtRobot) "Looking at Robot" else "Looking Away"
121-
}
122-
// Fall back to QiSDK attention state
123-
return when (attentionState.uppercase(Locale.US)) {
124-
"LOOKING_AT_ROBOT" -> "Looking at Robot"
125-
"LOOKING_ELSEWHERE" -> "Looking Elsewhere"
126-
"LOOKING_UP" -> "Looking Up"
127-
"LOOKING_DOWN" -> "Looking Down"
128-
"LOOKING_LEFT" -> "Looking Left"
129-
"LOOKING_RIGHT" -> "Looking Right"
130-
"UNKNOWN" -> "Unknown"
131-
else -> capitalize(attentionState.replace("_", " "))
132-
}
133-
}
134-
135-
/**
136-
* Get engagement level for UI display
137-
*/
138-
fun getEngagementLevel(): String {
139-
return when (engagementState.uppercase(Locale.US)) {
140-
"INTERESTED" -> "Interested"
141-
"NOT_INTERESTED" -> "Not Interested"
142-
"SEEKING_ENGAGEMENT" -> "Seeking Engagement"
143-
"UNKNOWN" -> "Unknown"
144-
else -> capitalize(engagementState.replace("_", " "))
145-
}
146-
}
147-
14887
/**
14988
* Get formatted distance string
15089
*/
@@ -155,128 +94,5 @@ class PerceptionData {
15594
else -> String.format(Locale.US, "%.1fm", distanceMeters)
15695
}
15796
}
158-
159-
/**
160-
* Get age and gender summary
161-
*/
162-
fun getDemographics(): String {
163-
val demo = StringBuilder()
164-
165-
if (estimatedAge > 0) {
166-
demo.append(estimatedAge).append("y")
167-
}
168-
169-
if (gender != "Unknown") {
170-
if (demo.isNotEmpty()) demo.append(", ")
171-
when (gender.uppercase(Locale.US)) {
172-
"MALE" -> demo.append("♂️")
173-
"FEMALE" -> demo.append("♀️")
174-
else -> demo.append(capitalize(gender))
175-
}
176-
}
177-
178-
return if (demo.isNotEmpty()) demo.toString() else "Unknown"
179-
}
180-
181-
/**
182-
* Get basic emotion for display
183-
*/
184-
fun getBasicEmotionDisplay(): String {
185-
return basicEmotion.getFormattedDisplay()
186-
}
187-
188-
/**
189-
* Get smile state for UI display
190-
*/
191-
fun getSmileStateDisplay(): String {
192-
return when (smileState.uppercase(Locale.US)) {
193-
"GENUINE" -> "😊 Genuine"
194-
"FAKE" -> "😏 Fake"
195-
"NOT_SMILING" -> "😐 Not Smiling"
196-
"UNKNOWN" -> "❓ Unknown"
197-
else -> "${capitalize(smileState.replace("_", " "))}"
198-
}
199-
}
200-
201-
/**
202-
* Get pleasure state for UI display with emojis
203-
*/
204-
fun getPleasureStateDisplay(): String {
205-
return when (pleasureState.uppercase(Locale.US)) {
206-
"POSITIVE" -> "😊 Positive"
207-
"NEGATIVE" -> "😔 Negative"
208-
"NEUTRAL" -> "😐 Neutral"
209-
"UNKNOWN" -> "❓ Unknown"
210-
else -> "${capitalize(pleasureState.replace("_", " "))}"
211-
}
212-
}
213-
214-
/**
215-
* Get excitement state for UI display with emojis
216-
*/
217-
fun getExcitementStateDisplay(): String {
218-
return when (excitementState.uppercase(Locale.US)) {
219-
"EXCITED" -> "⚡ Excited"
220-
"CALM" -> "😌 Calm"
221-
"UNKNOWN" -> "❓ Unknown"
222-
else -> "${capitalize(excitementState.replace("_", " "))}"
223-
}
224-
}
225-
226-
/**
227-
* Capitalize first letter of each word
228-
*/
229-
private fun capitalize(input: String?): String {
230-
if (input.isNullOrEmpty()) {
231-
return input ?: ""
232-
}
233-
234-
return input.lowercase(Locale.US)
235-
.split("\\s+".toRegex())
236-
.joinToString(" ") { word ->
237-
word.replaceFirstChar {
238-
if (it.isLowerCase()) it.titlecase(Locale.US) else it.toString()
239-
}
240-
}
241-
}
242-
243-
companion object {
244-
/**
245-
* Compute basic emotion from excitement and pleasure states
246-
* Based on James Russell's emotion model as used in QiSDK
247-
*/
248-
fun computeBasicEmotion(excitementState: String, pleasureState: String): BasicEmotion {
249-
if (excitementState.equals("UNKNOWN", ignoreCase = true) ||
250-
pleasureState.equals("UNKNOWN", ignoreCase = true)) {
251-
return BasicEmotion.UNKNOWN
252-
}
253-
254-
if (pleasureState.equals("NEUTRAL", ignoreCase = true)) {
255-
return BasicEmotion.NEUTRAL
256-
}
257-
258-
if (pleasureState.equals("POSITIVE", ignoreCase = true)) {
259-
return if (excitementState.equals("CALM", ignoreCase = true)) {
260-
BasicEmotion.CONTENT
261-
} else {
262-
BasicEmotion.JOYFUL
263-
}
264-
}
265-
266-
if (pleasureState.equals("NEGATIVE", ignoreCase = true)) {
267-
return if (excitementState.equals("CALM", ignoreCase = true)) {
268-
BasicEmotion.SAD
269-
} else {
270-
BasicEmotion.ANGRY
271-
}
272-
}
273-
274-
return BasicEmotion.NEUTRAL
275-
}
276-
}
27797
}
278-
279-
// Snapshot and status classes removed for now; can be reintroduced when dashboard requires them
28098
}
281-
282-

app/src/main/java/ch/fhnw/pepper_realtime/manager/DrawingGameManager.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ class DrawingGameManager @Inject constructor() {
7474
return true
7575
}
7676

77-
/**
78-
* Check if the drawing game is currently active.
79-
*/
80-
fun isGameActive(): Boolean = _state.value.isVisible
81-
8277
/**
8378
* Called when the user draws on the canvas.
8479
* Resets the inactivity timer and stores the current bitmap.

app/src/main/java/ch/fhnw/pepper_realtime/manager/MemoryGameManager.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ class MemoryGameManager @Inject constructor() {
9696
return true
9797
}
9898

99-
/**
100-
* Check if a game is currently active.
101-
*/
102-
fun isGameActive(): Boolean = _state.value.isVisible
103-
10499
/**
105100
* Handle card click.
106101
* @param cardId The ID of the clicked card

app/src/main/java/ch/fhnw/pepper_realtime/manager/QuizGameManager.kt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ class QuizGameManager @Inject constructor() {
4949
Log.i(TAG, "Quiz shown: $question")
5050
}
5151

52-
/**
53-
* Check if a quiz is currently visible.
54-
*/
55-
fun isQuizVisible(): Boolean = _state.value.isVisible
56-
5752
/**
5853
* Handle user answer selection.
5954
* Note: Does NOT dismiss the quiz immediately - the UI handles the delay

app/src/main/java/ch/fhnw/pepper_realtime/manager/SessionImageManager.kt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ class SessionImageManager {
4949
Log.i(TAG, "Session image cleanup complete - deleted: $deletedCount, failed: $failedCount")
5050
}
5151

52-
/**
53-
* Get the number of tracked images
54-
*/
55-
@Synchronized
56-
fun getImageCount(): Int = sessionImagePaths.size
57-
5852
companion object {
5953
private const val TAG = "SessionImageManager"
6054
}

app/src/main/java/ch/fhnw/pepper_realtime/manager/SettingsRepository.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ class SettingsRepository @Inject constructor(
2828
}
2929
}
3030

31-
fun getSettings(): SharedPreferences = settings
32-
3331
var systemPrompt: String
3432
get() = settings.getString(KEY_SYSTEM_PROMPT, defaultSystemPrompt) ?: defaultSystemPrompt
3533
set(value) = settings.edit().putString(KEY_SYSTEM_PROMPT, value).apply()

app/src/main/java/ch/fhnw/pepper_realtime/manager/SpeechRecognizerManager.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class SpeechRecognizerManager {
2929
private val executor: ExecutorService = Executors.newSingleThreadExecutor()
3030
private var recognizer: SpeechRecognizer? = null
3131
private var activityCallbacks: ActivityCallbacks? = null
32-
private val recognizerLock = Any()
3332

3433
@Volatile
3534
private var isRunning = false

app/src/main/java/ch/fhnw/pepper_realtime/manager/audio/ToneGenerator.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,6 @@ class ToneGenerator {
105105
callback?.onPlaybackFinished(wasCancelled = false)
106106
}
107107

108-
/**
109-
* Plays a melody string (simple version without callbacks).
110-
*/
111-
suspend fun playMelody(melody: String) {
112-
playMelody(melody, null)
113-
}
114-
115108
private suspend fun playTone(frequency: Double, durationMs: Long) = withContext(Dispatchers.Default) {
116109
if (isCancelled.get()) return@withContext
117110

app/src/main/java/ch/fhnw/pepper_realtime/network/GoogleLiveEvents.kt

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -297,30 +297,7 @@ object GoogleLiveEvents {
297297

298298
// ==================== AVAILABLE VOICES ====================
299299

300-
/**
301-
* Available voices for Google Gemini Live API.
302-
*/
303-
object Voices {
304-
const val PUCK = "Puck"
305-
const val CHARON = "Charon"
306-
const val KORE = "Kore"
307-
const val FENRIR = "Fenrir"
308-
const val AOEDE = "Aoede"
309-
310-
val ALL = listOf(PUCK, CHARON, KORE, FENRIR, AOEDE)
311-
val DEFAULT = PUCK
312-
}
313-
314-
// ==================== AUDIO CONSTANTS ====================
315-
316-
/**
317-
* Audio format constants for Google Live API.
318-
*/
319-
object Audio {
320-
const val INPUT_SAMPLE_RATE = 16000 // Input recommended at 16kHz for Pepper tablet
321-
const val OUTPUT_SAMPLE_RATE = 24000 // Output is always 24kHz
322-
const val INPUT_MIME_TYPE = "audio/pcm;rate=$INPUT_SAMPLE_RATE"
323-
const val OUTPUT_MIME_TYPE = "audio/pcm;rate=$OUTPUT_SAMPLE_RATE"
324-
}
300+
// Note: Available voices: Puck, Charon, Kore, Fenrir, Aoede
301+
// Audio: Input 16kHz, Output 24kHz (PCM format)
325302
}
326303

app/src/main/java/ch/fhnw/pepper_realtime/network/HttpClientManager.kt

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -143,41 +143,6 @@ class HttpClientManager @Inject constructor() {
143143
return quickApiClient.executeAsync(request)
144144
}
145145

146-
/**
147-
* Convenience method to POST JSON and get response body as string.
148-
*/
149-
suspend fun postJson(url: String, json: String, headers: Map<String, String> = emptyMap()): String {
150-
val mediaType = "application/json; charset=utf-8".toMediaType()
151-
val body = json.toRequestBody(mediaType)
152-
153-
val requestBuilder = Request.Builder()
154-
.url(url)
155-
.post(body)
156-
157-
headers.forEach { (key, value) ->
158-
requestBuilder.addHeader(key, value)
159-
}
160-
161-
val response = executeApiRequest(requestBuilder.build())
162-
return response.use { it.body?.string() ?: "" }
163-
}
164-
165-
/**
166-
* Convenience method to GET and return response body as string.
167-
*/
168-
suspend fun get(url: String, headers: Map<String, String> = emptyMap()): String {
169-
val requestBuilder = Request.Builder()
170-
.url(url)
171-
.get()
172-
173-
headers.forEach { (key, value) ->
174-
requestBuilder.addHeader(key, value)
175-
}
176-
177-
val response = executeQuickApiRequest(requestBuilder.build())
178-
return response.use { it.body?.string() ?: "" }
179-
}
180-
181146
/**
182147
* Extension function to convert OkHttp's callback-based API to a suspend function.
183148
*/

0 commit comments

Comments
 (0)