Initial commit: deardiary project setup

This commit is contained in:
lotherk
2026-03-26 19:57:20 +00:00
commit 3f9bc1f484
73 changed files with 8627 additions and 0 deletions

73
android/README.md Normal file
View File

@@ -0,0 +1,73 @@
# Android App
Native Android app using Kotlin and Jetpack Compose that connects to the same TotalRecall API.
## Requirements
- Android Studio Hedgehog or newer
- Android SDK 34
- Kotlin 1.9+
- Java 17
## Building
1. Open Android Studio
2. File > Open > select the `android` folder
3. Wait for Gradle sync to complete
4. Build > Build APK
Or from command line:
```bash
cd android
./gradlew assembleDebug
```
The APK will be at: `app/build/outputs/apk/debug/app-debug.apk`
## Configuration
By default, the app connects to `http://10.0.2.2:3000/api/v1/` (localhost for Android emulator).
To change the API URL, edit `app/build.gradle.kts`:
```kotlin
buildConfigField("String", "API_BASE_URL", "\"http://your-server:3000/api/v1/\"")
```
## Features
- User registration and login
- Create text entries
- Voice memos
- Health check-ins
- View history by day
- Generate AI journal
- Configure AI provider (OpenAI, Anthropic, Ollama, LM Studio)
## Project Structure
```
android/
├── app/src/main/java/com/totalrecall/
│ ├── api/ # API client
│ ├── model/ # Data models
│ ├── repository/ # Repository pattern
│ ├── viewmodel/ # ViewModels
│ └── ui/ # Compose UI screens
│ ├── auth/
│ ├── home/
│ ├── history/
│ ├── journal/
│ └── settings/
├── build.gradle.kts
└── settings.gradle.kts
```
## Screenshots
Coming soon...
## License
MIT

View File

@@ -0,0 +1,57 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.totalrecall"
compileSdk = 34
defaultConfig {
applicationId = "com.totalrecall"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"
buildConfigField("String", "API_BASE_URL", "\"http://10.0.2.2:3000/api/v1/\"")
}
buildFeatures {
compose = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.4"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.12.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.8.1")
implementation(platform("androidx.compose:compose-bom:2023.10.01"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.navigation:navigation-compose:2.7.5")
implementation("com.google.code.gson:gson:2.10.1")
implementation("androidx.datastore:datastore-preferences:1.0.0")
implementation("io.coil-kt:coil-compose:2.5.0")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}

View File

@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32" />
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.microphone" android:required="false" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.TotalRecall"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:exported="true"
android:theme="@style/Theme.TotalRecall">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -0,0 +1,29 @@
package com.totalrecall
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import com.totalrecall.ui.AppNavigation
import com.totalrecall.ui.TotalRecallTheme
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContent {
TotalRecallTheme {
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
AppNavigation()
}
}
}
}
}

View File

@@ -0,0 +1,181 @@
package com.totalrecall.api
import com.google.gson.Gson
import com.google.gson.annotations.SerializedName
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.URL
data class ApiResponse<T>(
val data: T?,
val error: ApiError?
)
data class ApiError(
val code: String,
val message: String
)
data class User(
val id: String,
val email: String,
@SerializedName("createdAt") val createdAt: String? = null
)
data class LoginResponse(
val token: String,
val userId: String
)
data class CreateApiKeyResponse(
val apiKey: String,
val id: String,
val name: String
)
data class Entry(
val id: String,
val date: String,
val type: String,
val content: String,
val mediaPath: String? = null,
val metadata: String? = null,
val createdAt: String
)
data class Journal(
val id: String? = null,
val date: String,
val content: String,
val entryCount: Int,
val generatedAt: String
)
data class DayInfo(
val date: String,
val entryCount: Int,
val hasJournal: Boolean,
val journalGeneratedAt: String? = null
)
data class DayResponse(
val date: String,
val entries: List<Entry>,
val journal: Journal?
)
data class Settings(
val aiProvider: String = "openai",
val aiApiKey: String? = null,
val aiModel: String = "gpt-4",
val aiBaseUrl: String? = null,
val journalPrompt: String = "You are a thoughtful journal writer.",
val language: String = "en"
)
class ApiClient(private var baseUrl: String) {
private var apiKey: String? = null
private val gson = Gson()
fun setApiKey(key: String) {
apiKey = key
}
fun getApiKey(): String? = apiKey
fun clearApiKey() {
apiKey = null
}
private suspend fun <T> request(
method: String,
path: String,
body: Any? = null,
authenticated: Boolean = true
): ApiResponse<T> = withContext(Dispatchers.IO) {
try {
val url = URL("$baseUrl$path")
val conn = url.openConnection() as HttpURLConnection
conn.requestMethod = method
conn.setRequestProperty("Content-Type", "application/json")
if (authenticated && apiKey != null) {
conn.setRequestProperty("Authorization", "Bearer $apiKey")
}
if (body != null) {
conn.doOutput = true
conn.outputStream.write(gson.toJson(body).toByteArray())
}
val responseCode = conn.responseCode
val reader = BufferedReader(InputStreamReader(
if (responseCode in 200..299) conn.inputStream else conn.errorStream
))
val response = reader.readText()
reader.close()
val type = object : com.google.gson.reflect.TypeToken<ApiResponse<T>>() {}.type
gson.fromJson(response, type)
} catch (e: Exception) {
ApiResponse(null, ApiError("NETWORK_ERROR", e.message ?: "Unknown error"))
}
}
suspend fun register(email: String, password: String): ApiResponse<Map<String, User>> {
return request("POST", "auth/register", mapOf("email" to email, "password" to password), false)
}
suspend fun login(email: String, password: String): ApiResponse<LoginResponse> {
return request("POST", "auth/login", mapOf("email" to email, "password" to password), false)
}
suspend fun createApiKey(name: String, token: String): ApiResponse<CreateApiKeyResponse> {
return request("POST", "auth/api-key", mapOf("name" to name), authenticated = true).let { resp ->
if (resp.data != null) {
ApiResponse(resp.data, null)
} else {
resp
}
}
}
suspend fun getDays(): ApiResponse<List<DayInfo>> {
return request("GET", "days")
}
suspend fun getDay(date: String): ApiResponse<DayResponse> {
return request("GET", "days/$date")
}
suspend fun createEntry(date: String, type: String, content: String): ApiResponse<Entry> {
return request("POST", "entries", mapOf(
"date" to date,
"type" to type,
"content" to content
))
}
suspend fun deleteEntry(id: String): ApiResponse<Map<String, Boolean>> {
return request("DELETE", "entries/$id")
}
suspend fun generateJournal(date: String): ApiResponse<Journal> {
return request("POST", "journal/generate/$date")
}
suspend fun getJournal(date: String): ApiResponse<Journal> {
return request("GET", "journal/$date")
}
suspend fun getSettings(): ApiResponse<Settings> {
return request("GET", "settings")
}
suspend fun updateSettings(settings: Settings): ApiResponse<Settings> {
return request("PUT", "settings", settings)
}
}

View File

@@ -0,0 +1,114 @@
package com.totalrecall.repository
import android.content.Context
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import androidx.datastore.preferences.core.stringPreferencesKey
import androidx.datastore.preferences.preferencesDataStore
import com.totalrecall.api.*
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "totalrecall")
class Repository(context: Context, private val baseUrl: String) {
private val api = ApiClient(baseUrl)
private val dataStore = context.dataStore
companion object {
private val API_KEY = stringPreferencesKey("api_key")
private val USER_EMAIL = stringPreferencesKey("user_email")
}
suspend fun loadSavedState() {
dataStore.data.collect { prefs ->
prefs[API_KEY]?.let { api.setApiKey(it) }
}
}
suspend fun isLoggedIn(): Boolean = api.getApiKey() != null
suspend fun register(email: String, password: String): Result<Unit> {
val response = api.register(email, password)
return if (response.data != null) Result.success(Unit)
else Result.failure(Exception(response.error?.message ?: "Registration failed"))
}
suspend fun login(email: String, password: String): Result<Unit> {
val response = api.login(email, password)
return if (response.data != null) {
val loginResponse = api.login(email, password)
if (loginResponse.data != null) {
val token = loginResponse.data.token
val keyResponse = api.createApiKey("Android App", token)
if (keyResponse.data != null) {
api.setApiKey(keyResponse.data.apiKey)
dataStore.edit { it[API_KEY] = keyResponse.data.apiKey }
dataStore.edit { it[USER_EMAIL] = email }
Result.success(Unit)
} else {
Result.failure(Exception(keyResponse.error?.message ?: "Failed to create API key"))
}
} else {
Result.failure(Exception(loginResponse.error?.message ?: "Login failed"))
}
} else {
Result.failure(Exception(response.error?.message ?: "Login failed"))
}
}
suspend fun logout() {
api.clearApiKey()
dataStore.edit { prefs ->
prefs.remove(API_KEY)
prefs.remove(USER_EMAIL)
}
}
suspend fun getDays(): Result<List<DayInfo>> {
val response = api.getDays()
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to get days"))
}
suspend fun getDay(date: String): Result<DayResponse> {
val response = api.getDay(date)
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to get day"))
}
suspend fun createEntry(date: String, type: String, content: String): Result<Entry> {
val response = api.createEntry(date, type, content)
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to create entry"))
}
suspend fun deleteEntry(id: String): Result<Unit> {
val response = api.deleteEntry(id)
return if (response.data != null) Result.success(Unit)
else Result.failure(Exception(response.error?.message ?: "Failed to delete entry"))
}
suspend fun generateJournal(date: String): Result<Journal> {
val response = api.generateJournal(date)
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to generate journal"))
}
suspend fun getJournal(date: String): Result<Journal> {
val response = api.getJournal(date)
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to get journal"))
}
suspend fun getSettings(): Result<Settings> {
val response = api.getSettings()
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to get settings"))
}
suspend fun updateSettings(settings: Settings): Result<Settings> {
val response = api.updateSettings(settings)
return if (response.data != null) Result.success(response.data)
else Result.failure(Exception(response.error?.message ?: "Failed to update settings"))
}
}

View File

@@ -0,0 +1,148 @@
package com.totalrecall.ui
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.rememberCoroutineScope
import androidx.lifecycle.viewmodel.compose.viewModel
import androidx.navigation.NavType
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
import androidx.navigation.compose.rememberNavController
import androidx.navigation.navArgument
import com.totalrecall.ui.auth.AuthScreen
import com.totalrecall.ui.history.HistoryScreen
import com.totalrecall.ui.home.HomeScreen
import com.totalrecall.ui.journal.JournalScreen
import com.totalrecall.ui.settings.SettingsScreen
import com.totalrecall.viewmodel.MainViewModel
import kotlinx.coroutines.launch
sealed class Screen(val route: String) {
object Auth : Screen("auth")
object Home : Screen("home")
object History : Screen("history")
object Day : Screen("day/{date}") {
fun createRoute(date: String) = "day/$date"
}
object Journal : Screen("journal/{date}") {
fun createRoute(date: String) = "journal/$date"
}
object Settings : Screen("settings")
}
@Composable
fun AppNavigation(
viewModel: MainViewModel = viewModel()
) {
val navController = rememberNavController()
val isLoggedIn by viewModel.isLoggedIn.collectAsState()
val authState by viewModel.authState.collectAsState()
val days by viewModel.days.collectAsState()
val currentDay by viewModel.currentDay.collectAsState()
val journal by viewModel.journal.collectAsState()
val settings by viewModel.settings.collectAsState()
val scope = rememberCoroutineScope()
val today = java.text.SimpleDateFormat("yyyy-MM-dd", java.util.Locale.getDefault()).format(java.util.Date())
if (!isLoggedIn) {
AuthScreen(
authState = authState,
onLogin = { email, password -> viewModel.login(email, password) },
onRegister = { email, password -> viewModel.register(email, password) }
)
} else {
NavHost(navController = navController, startDestination = Screen.Home.route) {
composable(Screen.Home.route) {
HomeScreen(
dayResponse = currentDay,
onAddEntry = { date, type, content ->
viewModel.createEntry(date, type, content)
},
onDeleteEntry = { id -> viewModel.deleteEntry(id, today) },
onGenerateJournal = { viewModel.generateJournal(today) },
onNavigateToJournal = {
viewModel.loadJournal(today)
navController.navigate(Screen.Journal.createRoute(today))
},
onNavigateToHistory = {
viewModel.loadDays()
navController.navigate(Screen.History.route)
},
onNavigateToSettings = {
viewModel.loadSettings()
navController.navigate(Screen.Settings.route)
}
)
}
composable(Screen.History.route) {
HistoryScreen(
days = days,
onDayClick = { date ->
viewModel.loadDay(date)
navController.navigate(Screen.Day.createRoute(date))
},
onBack = { navController.popBackStack() }
)
}
composable(
route = Screen.Day.route,
arguments = listOf(navArgument("date") { type = NavType.StringType })
) { backStackEntry ->
val date = backStackEntry.arguments?.getString("date") ?: today
HomeScreen(
dayResponse = currentDay,
onAddEntry = { d, type, content -> viewModel.createEntry(d, type, content) },
onDeleteEntry = { id -> viewModel.deleteEntry(id, date) },
onGenerateJournal = { viewModel.generateJournal(date) },
onNavigateToJournal = {
viewModel.loadJournal(date)
navController.navigate(Screen.Journal.createRoute(date))
},
onNavigateToHistory = {
viewModel.loadDays()
navController.navigate(Screen.History.route)
},
onNavigateToSettings = {
viewModel.loadSettings()
navController.navigate(Screen.Settings.route)
}
)
}
composable(
route = Screen.Journal.route,
arguments = listOf(navArgument("date") { type = NavType.StringType })
) { backStackEntry ->
val date = backStackEntry.arguments?.getString("date") ?: today
JournalScreen(
journal = journal,
isGenerating = false,
onBack = { navController.popBackStack() },
onRegenerate = { viewModel.generateJournal(date) }
)
}
composable(Screen.Settings.route) {
SettingsScreen(
settings = settings,
onSave = { newSettings -> viewModel.updateSettings(newSettings) },
onLogout = {
viewModel.logout()
navController.navigate(Screen.Auth.route) {
popUpTo(0) { inclusive = true }
}
},
onBack = { navController.popBackStack() }
)
}
}
androidx.compose.runtime.LaunchedEffect(Unit) {
viewModel.loadDay(today)
}
}
}

View File

@@ -0,0 +1,28 @@
package com.totalrecall.ui
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.material3.*
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
private val DarkColorScheme = darkColorScheme(
primary = Color(0xFF6366F1),
secondary = Color(0xFF8B5CF6),
tertiary = Color(0xFFA855F7),
background = Color(0xFF020917),
surface = Color(0xFF0F172A),
onPrimary = Color.White,
onSecondary = Color.White,
onBackground = Color(0xFFE2E8F0),
onSurface = Color(0xFFE2E8F0),
)
@Composable
fun TotalRecallTheme(
content: @Composable () -> Unit
) {
MaterialTheme(
colorScheme = DarkColorScheme,
content = content
)
}

View File

@@ -0,0 +1,127 @@
package com.totalrecall.ui.auth
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import com.totalrecall.viewmodel.UiState
@Composable
fun AuthScreen(
authState: UiState<Unit>,
onLogin: (String, String) -> Unit,
onRegister: (String, String) -> Unit
) {
var isLogin by remember { mutableStateOf(true) }
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var error by remember { mutableStateOf<String?>(null) }
LaunchedEffect(authState) {
if (authState is UiState.Error) {
error = authState.message
}
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
Text(
text = "TotalRecall",
style = MaterialTheme.typography.headlineLarge,
color = MaterialTheme.colorScheme.primary
)
Spacer(modifier = Modifier.height(32.dp))
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(
modifier = Modifier.padding(24.dp),
horizontalAlignment = Alignment.CenterHorizontally
) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
FilterChip(
selected = isLogin,
onClick = { isLogin = true },
label = { Text("Login") },
modifier = Modifier.weight(1f)
)
FilterChip(
selected = !isLogin,
onClick = { isLogin = false },
label = { Text("Register") },
modifier = Modifier.weight(1f)
)
}
Spacer(modifier = Modifier.height(24.dp))
OutlinedTextField(
value = email,
onValueChange = { email = it },
label = { Text("Email") },
modifier = Modifier.fillMaxWidth(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Email),
singleLine = true
)
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
modifier = Modifier.fillMaxWidth(),
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
singleLine = true
)
error?.let {
Spacer(modifier = Modifier.height(8.dp))
Text(
text = it,
color = MaterialTheme.colorScheme.error,
style = MaterialTheme.typography.bodySmall
)
}
Spacer(modifier = Modifier.height(24.dp))
Button(
onClick = {
error = null
if (isLogin) onLogin(email, password)
else onRegister(email, password)
},
modifier = Modifier.fillMaxWidth(),
enabled = authState !is UiState.Loading && email.isNotBlank() && password.length >= 8
) {
if (authState is UiState.Loading) {
CircularProgressIndicator(
modifier = Modifier.size(20.dp),
color = MaterialTheme.colorScheme.onPrimary
)
} else {
Text(if (isLogin) "Login" else "Create Account")
}
}
}
}
}
}

View File

@@ -0,0 +1,110 @@
package com.totalrecall.ui.history
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.AutoStories
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.totalrecall.api.DayInfo
import java.text.SimpleDateFormat
import java.util.*
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HistoryScreen(
days: List<DayInfo>,
onDayClick: (String) -> Unit,
onBack: () -> Unit
) {
Scaffold(
topBar = {
TopAppBar(
title = { Text("History") },
navigationIcon = {
IconButton(onClick = onBack) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
}
}
)
}
) { padding ->
if (days.isEmpty()) {
Box(
modifier = Modifier.fillMaxSize().padding(padding),
contentAlignment = Alignment.Center
) {
Text(
text = "No entries yet.\nStart journaling!",
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
} else {
LazyColumn(
modifier = Modifier.fillMaxSize().padding(padding).padding(16.dp),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
items(days) { day ->
DayCard(
day = day,
onClick = { onDayClick(day.date) }
)
}
}
}
}
}
@Composable
fun DayCard(
day: DayInfo,
onClick: () -> Unit
) {
val dateFormat = remember { SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) }
val displayFormat = remember { SimpleDateFormat("EEEE, MMMM d, yyyy", Locale.getDefault()) }
val displayDate = remember(day.date) {
try {
displayFormat.format(dateFormat.parse(day.date) ?: Date())
} catch (e: Exception) {
day.date
}
}
Card(
modifier = Modifier.fillMaxWidth().clickable(onClick = onClick),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Row(
modifier = Modifier.padding(16.dp).fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Column(modifier = Modifier.weight(1f)) {
Text(
text = displayDate,
style = MaterialTheme.typography.bodyLarge
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = "${day.entryCount} ${if (day.entryCount == 1) "entry" else "entries"}",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
if (day.hasJournal) {
Icon(
Icons.Default.AutoStories,
contentDescription = "Has journal",
tint = MaterialTheme.colorScheme.tertiary,
modifier = Modifier.size(24.dp)
)
}
}
}
}

View File

@@ -0,0 +1,257 @@
package com.totalrecall.ui.home
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.totalrecall.api.DayResponse
import com.totalrecall.api.Entry
import java.text.SimpleDateFormat
import java.util.*
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HomeScreen(
dayResponse: DayResponse?,
onAddEntry: (String, String, String) -> Unit,
onDeleteEntry: (String) -> Unit,
onGenerateJournal: () -> Unit,
onNavigateToJournal: () -> Unit,
onNavigateToHistory: () -> Unit,
onNavigateToSettings: () -> Unit
) {
var entryType by remember { mutableStateOf("text") }
var entryContent by remember { mutableStateOf("") }
var showEntryTypes by remember { mutableStateOf(false) }
val today = remember {
SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()).format(Date())
}
Scaffold(
topBar = {
TopAppBar(
title = {
Column {
Text("Today")
Text(
text = SimpleDateFormat("EEEE, MMMM d", Locale.getDefault()).format(Date()),
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
},
actions = {
IconButton(onClick = onNavigateToSettings) {
Icon(Icons.Default.Settings, contentDescription = "Settings")
}
}
)
},
floatingActionButton = {
FloatingActionButton(
onClick = onNavigateToHistory,
containerColor = MaterialTheme.colorScheme.secondary
) {
Icon(Icons.Default.History, contentDescription = "History")
}
}
) { padding ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(16.dp)
) {
if (dayResponse?.journal != null) {
Button(
onClick = onNavigateToJournal,
modifier = Modifier.fillMaxWidth(),
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.tertiary)
) {
Icon(Icons.Default.AutoStories, contentDescription = null)
Spacer(modifier = Modifier.width(8.dp))
Text("View Journal")
}
Spacer(modifier = Modifier.height(16.dp))
} else if ((dayResponse?.entries?.size ?: 0) > 0) {
OutlinedButton(
onClick = onGenerateJournal,
modifier = Modifier.fillMaxWidth()
) {
Icon(Icons.Default.AutoAwesome, contentDescription = null)
Spacer(modifier = Modifier.width(8.dp))
Text("Generate Journal")
}
Spacer(modifier = Modifier.height(16.dp))
}
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier.padding(16.dp)) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp)
) {
FilterChip(
selected = entryType == "text",
onClick = { entryType = "text" },
label = { Text("Text") },
leadingIcon = { Icon(Icons.Default.TextFields, null, Modifier.size(18.dp)) }
)
FilterChip(
selected = entryType == "voice",
onClick = { entryType = "voice" },
label = { Text("Voice") },
leadingIcon = { Icon(Icons.Default.Mic, null, Modifier.size(18.dp)) }
)
FilterChip(
selected = entryType == "health",
onClick = { entryType = "health" },
label = { Text("Health") },
leadingIcon = { Icon(Icons.Default.Favorite, null, Modifier.size(18.dp)) }
)
}
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = entryContent,
onValueChange = { entryContent = it },
label = { Text("What's on your mind?") },
modifier = Modifier.fillMaxWidth(),
minLines = 2,
maxLines = 4
)
Spacer(modifier = Modifier.height(8.dp))
Button(
onClick = {
onAddEntry(today, entryType, entryContent)
entryContent = ""
},
modifier = Modifier.align(Alignment.End),
enabled = entryContent.isNotBlank()
) {
Icon(Icons.Default.Add, contentDescription = null)
Spacer(modifier = Modifier.width(4.dp))
Text("Add")
}
}
}
Spacer(modifier = Modifier.height(16.dp))
Text(
text = "Today's Entries (${dayResponse?.entries?.size ?: 0})",
style = MaterialTheme.typography.titleMedium
)
Spacer(modifier = Modifier.height(8.dp))
if (dayResponse?.entries.isNullOrEmpty()) {
Box(
modifier = Modifier.fillMaxWidth().weight(1f),
contentAlignment = Alignment.Center
) {
Text(
text = "No entries yet today.\nStart capturing your day!",
textAlign = TextAlign.Center,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
} else {
LazyColumn(
modifier = Modifier.weight(1f),
verticalArrangement = Arrangement.spacedBy(8.dp)
) {
items(dayResponse!!.entries) { entry ->
EntryCard(
entry = entry,
onDelete = { onDeleteEntry(entry.id) }
)
}
}
}
}
}
}
@Composable
fun EntryCard(
entry: Entry,
onDelete: () -> Unit
) {
val timeFormat = remember { SimpleDateFormat("h:mm a", Locale.getDefault()) }
val createdAt = remember(entry.createdAt) {
try {
timeFormat.format(SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault()).parse(entry.createdAt) ?: Date())
} catch (e: Exception) {
entry.createdAt
}
}
val typeIcon = when (entry.type) {
"text" -> Icons.Default.TextFields
"voice" -> Icons.Default.Mic
"photo" -> Icons.Default.Photo
"health" -> Icons.Default.Favorite
else -> Icons.Default.Note
}
val typeColor = when (entry.type) {
"text" -> MaterialTheme.colorScheme.primary
"voice" -> MaterialTheme.colorScheme.secondary
"photo" -> MaterialTheme.colorScheme.tertiary
"health" -> MaterialTheme.colorScheme.error
else -> MaterialTheme.colorScheme.onSurfaceVariant
}
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Row(
modifier = Modifier.padding(12.dp).fillMaxWidth(),
verticalAlignment = Alignment.Top
) {
Icon(
typeIcon,
contentDescription = null,
tint = typeColor,
modifier = Modifier.padding(top = 4.dp)
)
Spacer(modifier = Modifier.width(12.dp))
Column(modifier = Modifier.weight(1f)) {
Text(
text = createdAt,
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(4.dp))
Text(
text = entry.content,
style = MaterialTheme.typography.bodyMedium
)
}
IconButton(onClick = onDelete, modifier = Modifier.size(32.dp)) {
Icon(
Icons.Default.Close,
contentDescription = "Delete",
tint = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.size(18.dp)
)
}
}
}
}

View File

@@ -0,0 +1,131 @@
package com.totalrecall.ui.journal
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Refresh
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.totalrecall.api.Journal
import java.text.SimpleDateFormat
import java.util.*
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun JournalScreen(
journal: Journal?,
isGenerating: Boolean,
onBack: () -> Unit,
onRegenerate: () -> Unit
) {
val dateFormat = remember { SimpleDateFormat("yyyy-MM-dd", Locale.getDefault()) }
val displayFormat = remember { SimpleDateFormat("EEEE, MMMM d, yyyy", Locale.getDefault()) }
val displayDate = remember(journal?.date ?: "") {
try {
displayFormat.format(dateFormat.parse(journal?.date ?: "") ?: Date())
} catch (e: Exception) {
journal?.date ?: ""
}
}
Scaffold(
topBar = {
TopAppBar(
title = {
Column {
Text("Journal")
Text(
text = displayDate,
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
},
navigationIcon = {
IconButton(onClick = onBack) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
}
}
)
}
) { padding ->
Box(
modifier = Modifier.fillMaxSize().padding(padding).padding(16.dp),
contentAlignment = Alignment.Center
) {
when {
isGenerating -> {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
CircularProgressIndicator()
Spacer(modifier = Modifier.height(16.dp))
Text("Generating your journal...")
}
}
journal == null -> {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(
text = "No journal generated yet",
textAlign = TextAlign.Center,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(16.dp))
Button(onClick = onRegenerate) {
Text("Generate Journal")
}
}
}
else -> {
Column(modifier = Modifier.fillMaxSize()) {
journal.generatedAt.let { generatedAt ->
val genFormat = remember { SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault()) }
val timeFormat = remember { SimpleDateFormat("MMMM d, h:mm a", Locale.getDefault()) }
val time = try {
timeFormat.format(genFormat.parse(generatedAt) ?: Date())
} catch (e: Exception) {
generatedAt
}
Text(
text = "Generated $time${journal.entryCount} entries",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(modifier = Modifier.height(16.dp))
}
Card(
modifier = Modifier.fillMaxSize(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Text(
text = journal.content,
modifier = Modifier
.fillMaxSize()
.verticalScroll(rememberScrollState())
.padding(16.dp),
style = MaterialTheme.typography.bodyLarge,
lineHeight = MaterialTheme.typography.bodyLarge.lineHeight * 1.5
)
}
Spacer(modifier = Modifier.height(16.dp))
OutlinedButton(
onClick = onRegenerate,
modifier = Modifier.align(Alignment.End)
) {
Icon(Icons.Default.Refresh, contentDescription = null)
Spacer(modifier = Modifier.width(8.dp))
Text("Regenerate")
}
}
}
}
}
}
}

View File

@@ -0,0 +1,237 @@
package com.totalrecall.ui.settings
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.Logout
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import com.totalrecall.api.Settings
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun SettingsScreen(
settings: Settings?,
onSave: (Settings) -> Unit,
onLogout: () -> Unit,
onBack: () -> Unit
) {
var aiProvider by remember { mutableStateOf(settings?.aiProvider ?: "openai") }
var apiKey by remember { mutableStateOf(settings?.aiApiKey ?: "") }
var model by remember { mutableStateOf(settings?.aiModel ?: "gpt-4") }
var baseUrl by remember { mutableStateOf(settings?.aiBaseUrl ?: "") }
var journalPrompt by remember { mutableStateOf(settings?.journalPrompt ?: "You are a thoughtful journal writer.") }
var language by remember { mutableStateOf(settings?.language ?: "en") }
var saving by remember { mutableStateOf(false) }
LaunchedEffect(settings) {
settings?.let {
aiProvider = it.aiProvider
apiKey = it.aiApiKey ?: ""
model = it.aiModel
baseUrl = it.aiBaseUrl ?: ""
journalPrompt = it.journalPrompt
language = it.language
}
}
Scaffold(
topBar = {
TopAppBar(
title = { Text("Settings") },
navigationIcon = {
IconButton(onClick = onBack) {
Icon(Icons.Default.ArrowBack, contentDescription = "Back")
}
},
actions = {
IconButton(onClick = onLogout) {
Icon(Icons.Default.Logout, contentDescription = "Logout")
}
}
)
}
) { padding ->
Column(
modifier = Modifier
.fillMaxSize()
.padding(padding)
.padding(16.dp)
.verticalScroll(rememberScrollState()),
verticalArrangement = Arrangement.spacedBy(16.dp)
) {
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "AI Provider",
style = MaterialTheme.typography.titleMedium
)
Spacer(modifier = Modifier.height(16.dp))
aiProvider.let { current ->
listOf("openai" to "OpenAI (GPT-4)", "anthropic" to "Anthropic (Claude)").forEach { (value, label) ->
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically
) {
RadioButton(
selected = aiProvider == value,
onClick = { aiProvider = value }
)
Text(label)
}
}
}
Spacer(modifier = Modifier.height(16.dp))
if (aiProvider in listOf("openai", "anthropic")) {
OutlinedTextField(
value = apiKey,
onValueChange = { apiKey = it },
label = { Text("API Key") },
modifier = Modifier.fillMaxWidth(),
visualTransformation = PasswordVisualTransformation(),
keyboardOptions = KeyboardOptions(keyboardType = KeyboardType.Password),
singleLine = true
)
}
if (aiProvider in listOf("ollama", "lmstudio")) {
OutlinedTextField(
value = baseUrl,
onValueChange = { baseUrl = it },
label = { Text("Base URL") },
placeholder = {
Text(
if (aiProvider == "ollama") "http://localhost:11434"
else "http://localhost:1234/v1"
)
},
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
}
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = model,
onValueChange = { model = it },
label = { Text("Model") },
placeholder = {
Text(
when (aiProvider) {
"openai" -> "gpt-4"
"anthropic" -> "claude-3-sonnet-20240229"
"ollama" -> "llama3.2"
else -> "local-model"
}
)
},
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
}
}
Card(
modifier = Modifier.fillMaxWidth(),
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surface)
) {
Column(modifier = Modifier.padding(16.dp)) {
Text(
text = "Journal Generation",
style = MaterialTheme.typography.titleMedium
)
Spacer(modifier = Modifier.height(16.dp))
OutlinedTextField(
value = journalPrompt,
onValueChange = { journalPrompt = it },
label = { Text("System Prompt") },
modifier = Modifier.fillMaxWidth(),
minLines = 3,
maxLines = 5
)
Spacer(modifier = Modifier.height(16.dp))
var expanded by remember { mutableStateOf(false) }
ExposedDropdownMenuBox(
expanded = expanded,
onExpandedChange = { expanded = !expanded }
) {
OutlinedTextField(
value = language.let { lang ->
mapOf(
"en" to "English",
"de" to "Deutsch",
"es" to "Español",
"fr" to "Français"
)[lang] ?: lang
},
onValueChange = {},
readOnly = true,
label = { Text("Language") },
trailingIcon = { ExposedDropdownMenuDefaults.TrailingIcon(expanded) },
modifier = Modifier.fillMaxWidth().menuAnchor()
)
ExposedDropdownMenu(
expanded = expanded,
onDismissRequest = { expanded = false }
) {
listOf("en" to "English", "de" to "Deutsch", "es" to "Español", "fr" to "Français").forEach { (code, name) ->
DropdownMenuItem(
text = { Text(name) },
onClick = {
language = code
expanded = false
}
)
}
}
}
}
}
Button(
onClick = {
saving = true
onSave(
Settings(
aiProvider = aiProvider,
aiApiKey = apiKey.ifBlank { null },
aiModel = model,
aiBaseUrl = baseUrl.ifBlank { null },
journalPrompt = journalPrompt,
language = language
)
)
},
modifier = Modifier.fillMaxWidth(),
enabled = !saving
) {
if (saving) {
CircularProgressIndicator(
modifier = Modifier.size(20.dp),
color = MaterialTheme.colorScheme.onPrimary
)
} else {
Text("Save Settings")
}
}
}
}
}

View File

@@ -0,0 +1,137 @@
package com.totalrecall.viewmodel
import android.app.Application
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.viewModelScope
import com.totalrecall.BuildConfig
import com.totalrecall.api.*
import com.totalrecall.repository.Repository
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.launch
sealed class UiState<out T> {
object Loading : UiState<Nothing>()
data class Success<T>(val data: T) : UiState<T>()
data class Error(val message: String) : UiState<Nothing>()
}
class MainViewModel(application: Application) : AndroidViewModel(application) {
private val repository = Repository(application, BuildConfig.API_BASE_URL)
private val _isLoggedIn = MutableStateFlow(false)
val isLoggedIn: StateFlow<Boolean> = _isLoggedIn
private val _authState = MutableStateFlow<UiState<Unit>>(UiState.Loading)
val authState: StateFlow<UiState<Unit>> = _authState
private val _days = MutableStateFlow<List<DayInfo>>(emptyList())
val days: StateFlow<List<DayInfo>> = _days
private val _currentDay = MutableStateFlow<DayResponse?>(null)
val currentDay: StateFlow<DayResponse?> = _currentDay
private val _journal = MutableStateFlow<Journal?>(null)
val journal: StateFlow<Journal?> = _journal
private val _settings = MutableStateFlow<Settings?>(null)
val settings: StateFlow<Settings?> = _settings
init {
checkLoginState()
}
private fun checkLoginState() {
viewModelScope.launch {
repository.loadSavedState()
_isLoggedIn.value = repository.isLoggedIn()
_authState.value = UiState.Success(Unit)
}
}
fun login(email: String, password: String) {
viewModelScope.launch {
_authState.value = UiState.Loading
repository.login(email, password).fold(
onSuccess = {
_isLoggedIn.value = true
_authState.value = UiState.Success(Unit)
},
onFailure = { _authState.value = UiState.Error(it.message ?: "Login failed") }
)
}
}
fun register(email: String, password: String) {
viewModelScope.launch {
_authState.value = UiState.Loading
repository.register(email, password).fold(
onSuccess = { _authState.value = UiState.Success(Unit) },
onFailure = { _authState.value = UiState.Error(it.message ?: "Registration failed") }
)
}
}
fun logout() {
viewModelScope.launch {
repository.logout()
_isLoggedIn.value = false
_days.value = emptyList()
_currentDay.value = null
_journal.value = null
}
}
fun loadDays() {
viewModelScope.launch {
repository.getDays().onSuccess { _days.value = it }
}
}
fun loadDay(date: String) {
viewModelScope.launch {
repository.getDay(date).onSuccess { _currentDay.value = it }
}
}
fun createEntry(date: String, type: String, content: String) {
viewModelScope.launch {
repository.createEntry(date, type, content).onSuccess {
loadDay(date)
}
}
}
fun deleteEntry(id: String, date: String) {
viewModelScope.launch {
repository.deleteEntry(id).onSuccess { loadDay(date) }
}
}
fun generateJournal(date: String) {
viewModelScope.launch {
repository.generateJournal(date).onSuccess {
_journal.value = it
loadDay(date)
}
}
}
fun loadJournal(date: String) {
viewModelScope.launch {
repository.getJournal(date).onSuccess { _journal.value = it }
}
}
fun loadSettings() {
viewModelScope.launch {
repository.getSettings().onSuccess { _settings.value = it }
}
}
fun updateSettings(settings: Settings) {
viewModelScope.launch {
repository.updateSettings(settings).onSuccess { _settings.value = it }
}
}
}

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color>
</resources>

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">TotalRecall</string>
</resources>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.TotalRecall" parent="android:Theme.Material.Light.NoActionBar">
<item name="android:statusBarColor">@color/black</item>
</style>
</resources>

4
android/build.gradle.kts Normal file
View File

@@ -0,0 +1,4 @@
plugins {
id("com.android.application") version "8.2.0" apply false
id("org.jetbrains.kotlin.android") version "1.9.20" apply false
}

View File

@@ -0,0 +1,5 @@
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
android.useAndroidX=true
android.enableJetifier=true
kotlin.code.style=official
android.nonTransitiveRClass=true

View File

@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

248
android/gradlew vendored Executable file
View File

@@ -0,0 +1,248 @@
#!/bin/sh
#
# Copyright © 2015 the original authors.
#
# 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.
#
# SPDX-License-Identifier: Apache-2.0
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/812c56a2fbbd51caf1865e37dbfb8e169137ab13/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"

View File

@@ -0,0 +1,18 @@
pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}
rootProject.name = "TotalRecall"
include(":app")