Initial commit

This commit is contained in:
2026-06-04 18:19:46 +03:00
commit 1d8dbe1a6b
64 changed files with 3577 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
/build
+99
View File
@@ -0,0 +1,99 @@
plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.google.gms.google.services)
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
alias(libs.plugins.kotlin.compose)
}
android {
namespace = 'com.yaros.shiftmanager'
compileSdk 36
defaultConfig {
applicationId "com.yaros.shiftmanager"
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
coreLibraryDesugaringEnabled = true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose = true
}
packaging {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
dependencies {
implementation libs.androidx.room.runtime
// Hilt
implementation("com.google.dagger:hilt-android:2.59.2") // ← Update this
kapt("com.google.dagger:hilt-compiler:2.59.2") // ← Update this
// Room (ensure versions are consistent)
implementation("androidx.room:room-runtime:2.8.4")
implementation("androidx.room:room-ktx:2.8.4")
kapt("androidx.room:room-compiler:2.8.4")
implementation 'com.google.code.gson:gson:2.14.0'
// If using Hilt with Room, also add:
implementation("androidx.hilt:hilt-common:1.3.0")
kapt("androidx.hilt:hilt-compiler:1.3.0")
implementation libs.androidx.room.ktx
implementation libs.androidx.datastore.preferences
implementation(libs.vico.compose)
coreLibraryDesugaring libs.desugar.jdk.libs
implementation("com.kizitonwose.calendar:view:2.10.1")
implementation("com.kizitonwose.calendar:compose:2.10.1")
implementation(libs.vico.compose.m2)
implementation(libs.vico.compose.m3)
implementation(libs.vico.core)
implementation(libs.vico.views)
implementation libs.hilt.android
kapt libs.dagger.hilt.compiler
implementation libs.androidx.core.ktx
implementation libs.androidx.lifecycle.runtime.ktx
implementation libs.androidx.activity.compose
implementation platform(libs.androidx.compose.bom)
implementation(libs.androidx.navigation.compose)
implementation libs.androidx.ui
implementation libs.androidx.ui.graphics
implementation libs.androidx.ui.tooling.preview
implementation libs.androidx.material3
implementation libs.firebase.auth
implementation("androidx.hilt:hilt-navigation-compose:1.2.0")
testImplementation libs.junit
androidTestImplementation libs.androidx.junit
androidTestImplementation libs.androidx.espresso.core
androidTestImplementation platform(libs.androidx.compose.bom)
androidTestImplementation libs.androidx.ui.test.junit4
debugImplementation libs.androidx.ui.tooling
debugImplementation libs.androidx.ui.test.manifest
}
+29
View File
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "221091718064",
"project_id": "shiftmanageryaroshumster",
"storage_bucket": "shiftmanageryaroshumster.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:221091718064:android:c5ca694f79c4f1d6f02c75",
"android_client_info": {
"package_name": "com.yaros.shiftmanager"
}
},
"oauth_client": [],
"api_key": [
{
"current_key": "AIzaSyDMJMZrKLkVNujMh71dqh0J3_z3qtpQkBY"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": "1"
}
+21
View File
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -0,0 +1,24 @@
package com.yaros.shiftmanager
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.yaros.shiftmanager", appContext.packageName)
}
}
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
android:name=".ShiftManagerApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.ShiftManager"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.ShiftManager">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
@@ -0,0 +1,116 @@
package com.yaros.shiftmanager
import android.content.Context
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import androidx.room.TypeConverter
import androidx.room.TypeConverters
import androidx.room.migration.Migration
import androidx.sqlite.db.SupportSQLiteDatabase
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import java.util.Date
@Database(
entities = [Income::class, Shift::class, TaxReminder::class, ShiftTemplate::class],
version = 2,
exportSchema = false
)
@TypeConverters(Converters::class)
abstract class AppDatabase : RoomDatabase() {
abstract fun incomeDao(): IncomeDao
abstract fun shiftDao(): ShiftDao
abstract fun taxReminderDao(): TaxReminderDao
abstract fun shiftTemplateDao(): ShiftTemplateDao
companion object {
@Volatile
private var INSTANCE: AppDatabase? = null
val MIGRATION_1_2 = object : Migration(1, 2) {
override fun migrate(db: SupportSQLiteDatabase) {
db.execSQL("ALTER TABLE shifts ADD COLUMN hoursWorked REAL NOT NULL DEFAULT 0.0")
db.execSQL("ALTER TABLE shifts ADD COLUMN hourlyRate REAL NOT NULL DEFAULT 0.0")
db.execSQL("ALTER TABLE shifts ADD COLUMN isCompleted INTEGER NOT NULL DEFAULT 0")
db.execSQL("ALTER TABLE shifts ADD COLUMN templateId TEXT DEFAULT NULL")
db.execSQL("""CREATE TABLE IF NOT EXISTS shift_templates (
id TEXT NOT NULL PRIMARY KEY,
name TEXT NOT NULL,
hourlyRate REAL NOT NULL,
coefficientRules TEXT NOT NULL DEFAULT '[]'
)""")
}
}
fun getInstance(context: Context): AppDatabase {
return INSTANCE ?: synchronized(this) {
val instance = Room.databaseBuilder(
context.applicationContext,
AppDatabase::class.java,
"shift_manager_database"
)
.addMigrations(MIGRATION_1_2)
.build()
INSTANCE = instance
instance
}
}
}
}
// Add this class to handle Date conversions for Room
class Converters {
private val gson = Gson()
// --- 1. Ваши старые конвертеры для Date ---
@TypeConverter
fun fromTimestamp(value: Long?): Date? {
return value?.let { Date(it) }
}
@TypeConverter
fun dateToTimestamp(date: Date?): Long? {
return date?.time
}
// --- 2. Конвертеры для Enum ShiftType ---
// Room не умеет сохранять enum напрямую, поэтому сохраняем его имя (String)
@TypeConverter
fun fromShiftType(value: ShiftType?): String? {
return value?.name
}
@TypeConverter
fun toShiftType(value: String?): ShiftType? {
return value?.let { ShiftType.valueOf(it) }
}
// --- 3. Новые конвертеры для сложного объекта RecurringPattern ---
// Преобразуем объект в JSON-строку для сохранения в БД
@TypeConverter
fun fromRecurringPattern(pattern: RecurringPattern?): String? {
return gson.toJson(pattern)
}
// Преобразуем JSON-строку из БД обратно в объект
@TypeConverter
fun toRecurringPattern(patternString: String?): RecurringPattern? {
if (patternString == null) return null
val type = object : TypeToken<RecurringPattern>() {}.type
return gson.fromJson(patternString, type)
}
// --- 4. Конвертеры для List<CoefficientRule> ---
@TypeConverter
fun fromCoefficientRules(rules: List<CoefficientRule>?): String? {
return gson.toJson(rules ?: emptyList<CoefficientRule>())
}
@TypeConverter
fun toCoefficientRules(json: String?): List<CoefficientRule> {
if (json == null) return emptyList()
val type = object : TypeToken<List<CoefficientRule>>() {}.type
return gson.fromJson(json, type) ?: emptyList()
}
}
@@ -0,0 +1,123 @@
package com.yaros.shiftmanager
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.tasks.await
import javax.inject.Inject
class AuthRepository @Inject constructor() {
private val auth: FirebaseAuth = FirebaseAuth.getInstance()
suspend fun signUp(email: String, password: String): Result<FirebaseUser> {
return try {
val result = auth.createUserWithEmailAndPassword(email, password).await()
Result.success(result.user!!)
} catch (e: Exception) {
Result.failure(e)
}
}
suspend fun signIn(email: String, password: String): Result<FirebaseUser> {
return try {
val result = auth.signInWithEmailAndPassword(email, password).await()
Result.success(result.user!!)
} catch (e: Exception) {
Result.failure(e)
}
}
fun signOut() {
auth.signOut()
}
fun getCurrentUser(): FirebaseUser? {
return auth.currentUser
}
}
@HiltViewModel
class AuthViewModel @Inject constructor(private val repository: AuthRepository) : ViewModel() {
private val _user = MutableStateFlow<FirebaseUser?>(repository.getCurrentUser())
val user: StateFlow<FirebaseUser?> = _user.asStateFlow()
fun signUp(email: String, password: String) = viewModelScope.launch {
repository.signUp(email, password).onSuccess { _user.value = it }
}
fun signIn(email: String, password: String) = viewModelScope.launch {
repository.signIn(email, password).onSuccess { _user.value = it }
}
fun signOut() {
repository.signOut()
_user.value = null
}
}
@Composable
fun AuthScreen(viewModel: AuthViewModel, onAuthSuccess: () -> Unit) {
var email by remember { mutableStateOf("") }
var password by remember { mutableStateOf("") }
var isSignUp by remember { mutableStateOf(false) }
val user by viewModel.user.collectAsState()
LaunchedEffect(user) {
if (user != null) {
onAuthSuccess()
}
}
Column(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
verticalArrangement = Arrangement.Center
) {
TextField(
value = email,
onValueChange = { email = it },
label = { Text("Email") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(8.dp))
TextField(
value = password,
onValueChange = { password = it },
label = { Text("Password") },
modifier = Modifier.fillMaxWidth()
)
Spacer(modifier = Modifier.height(16.dp))
Button(
onClick = {
if (isSignUp) {
viewModel.signUp(email, password)
} else {
viewModel.signIn(email, password)
}
},
modifier = Modifier.fillMaxWidth()
) {
Text(if (isSignUp) "Sign Up" else "Sign In")
}
Spacer(modifier = Modifier.height(8.dp))
TextButton(
onClick = { isSignUp = !isSignUp },
modifier = Modifier.fillMaxWidth()
) {
Text(if (isSignUp) "Already have an account? Sign In" else "Don't have an account? Sign Up")
}
}
}
@@ -0,0 +1,551 @@
package com.yaros.shiftmanager
import androidx.compose.foundation.background
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.foundation.rememberScrollState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Add
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.material.icons.filled.ArrowForward
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import java.time.DayOfWeek
import java.time.LocalDate
import java.time.YearMonth
import java.time.ZoneId
import java.time.format.TextStyle
import java.time.temporal.TemporalAdjusters
import java.time.temporal.WeekFields
import java.util.*
import kotlin.math.roundToInt
// ─────────────────── Calendar Screen ───────────────────
@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun CalendarScreen(viewModel: ShiftViewModel = hiltViewModel()) {
val currentMonth by viewModel.currentMonth.collectAsState()
val monthShifts by viewModel.monthShifts.collectAsState()
val templates by viewModel.allTemplates.collectAsState()
var selectedDate by remember { mutableStateOf(LocalDate.now()) }
var showAddDialog by remember { mutableStateOf(false) }
var editingShift by remember { mutableStateOf<Shift?>(null) }
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = {
editingShift = null
showAddDialog = true
}) {
Icon(Icons.Default.Add, contentDescription = "Add Shift")
}
}
) { paddingValues ->
Column(
modifier = Modifier
.padding(paddingValues)
.fillMaxSize()
.verticalScroll(rememberScrollState())
) {
// ── Month navigation header ──
Row(
modifier = Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
IconButton(onClick = { viewModel.previousMonth() }) {
Icon(Icons.Default.ArrowBack, contentDescription = "Previous month")
}
Text(
text = currentMonth.month.getDisplayName(TextStyle.FULL, Locale.getDefault()) +
" ${currentMonth.year}",
style = MaterialTheme.typography.titleLarge,
fontWeight = FontWeight.Bold
)
IconButton(onClick = { viewModel.nextMonth() }) {
Icon(Icons.Default.ArrowForward, contentDescription = "Next month")
}
}
// ── Day-of-week headers ──
val firstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek
val orderedDays = DayOfWeek.entries.let { all ->
val idx = all.indexOf(firstDayOfWeek)
all.drop(idx) + all.take(idx)
}
Row(modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
orderedDays.forEach { dow ->
Text(
text = dow.getDisplayName(TextStyle.SHORT, Locale.getDefault()),
modifier = Modifier.weight(1f),
style = MaterialTheme.typography.labelSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant,
textAlign = TextAlign.Center
)
}
}
// ── Calendar grid ──
CalendarGrid(
yearMonth = currentMonth,
shifts = monthShifts,
selectedDate = selectedDate,
onDateSelected = { selectedDate = it }
)
// ── Shifts for selected date ──
val shiftsForSelected = monthShifts.filter { shift ->
shift.startTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate() == selectedDate
}
HorizontalDivider(modifier = Modifier.padding(vertical = 4.dp))
Text(
text = "Shifts on ${selectedDate.dayOfMonth} ${selectedDate.month.getDisplayName(TextStyle.SHORT, Locale.getDefault())}",
style = MaterialTheme.typography.titleMedium,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp)
)
if (shiftsForSelected.isEmpty()) {
Text(
text = "No shifts — tap + to add one",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(16.dp)
)
} else {
shiftsForSelected.forEach { shift ->
ShiftCard(
shift = shift,
templates = templates,
onClick = {
editingShift = shift
showAddDialog = true
},
onDelete = { viewModel.deleteShift(shift) }
)
}
}
}
}
if (showAddDialog) {
AddShiftDialog(
selectedDate = selectedDate,
templates = templates,
existingShift = editingShift,
onDismiss = { showAddDialog = false },
onSave = { shift ->
if (editingShift != null) viewModel.updateShift(shift)
else viewModel.insertShift(shift)
showAddDialog = false
}
)
}
}
// ─────────────────── Calendar Grid ───────────────────
@Composable
private fun CalendarGrid(
yearMonth: YearMonth,
shifts: List<Shift>,
selectedDate: LocalDate,
onDateSelected: (LocalDate) -> Unit
) {
val firstDayOfMonth = yearMonth.atDay(1)
val firstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek
val gridStart = firstDayOfMonth.with(TemporalAdjusters.previousOrSame(firstDayOfWeek))
// 6 weeks × 7 days covers any month
val gridDays = (0 until 42).map { gridStart.plusDays(it.toLong()) }
Column(modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp)) {
gridDays.chunked(7).forEach { week ->
Row(modifier = Modifier.fillMaxWidth()) {
week.forEach { date ->
val isCurrentMonth = date.monthValue == yearMonth.monthValue &&
date.year == yearMonth.year
val dayShifts = shifts.filter { shift ->
shift.startTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate() == date
}
DayCell(
date = date,
shifts = dayShifts,
isSelected = date == selectedDate,
isInMonth = isCurrentMonth,
modifier = Modifier.weight(1f),
onClick = { if (isCurrentMonth) onDateSelected(date) }
)
}
}
}
}
}
// ─────────────────── Day Cell ───────────────────
@Composable
private fun DayCell(
date: LocalDate,
shifts: List<Shift>,
isSelected: Boolean,
isInMonth: Boolean,
modifier: Modifier = Modifier,
onClick: () -> Unit
) {
val hasDayShift = shifts.any { it.type == ShiftType.DAY }
val hasNightShift = shifts.any { it.type == ShiftType.NIGHT }
Column(
horizontalAlignment = Alignment.CenterHorizontally,
modifier = modifier
.aspectRatio(1f)
.padding(2.dp)
.clickable(enabled = isInMonth) { onClick() }
) {
Box(
modifier = Modifier
.weight(1f)
.fillMaxWidth()
.background(
if (isSelected) MaterialTheme.colorScheme.primaryContainer
else Color.Transparent,
CircleShape
),
contentAlignment = Alignment.Center
) {
Text(
text = date.dayOfMonth.toString(),
color = when {
!isInMonth -> MaterialTheme.colorScheme.onSurface.copy(alpha = 0.2f)
isSelected -> MaterialTheme.colorScheme.onPrimaryContainer
else -> MaterialTheme.colorScheme.onSurface
},
style = MaterialTheme.typography.bodySmall
)
}
// Shift type indicators
if (isInMonth && shifts.isNotEmpty()) {
Row(
horizontalArrangement = Arrangement.Center,
modifier = Modifier.height(8.dp)
) {
if (hasDayShift) {
Box(
modifier = Modifier
.size(5.dp)
.background(Color(0xFFFFC107), CircleShape)
)
Spacer(Modifier.width(2.dp))
}
if (hasNightShift) {
Box(
modifier = Modifier
.size(5.dp)
.background(Color(0xFF2196F3), CircleShape)
)
}
}
} else {
Spacer(Modifier.height(8.dp))
}
}
}
// ─────────────────── Shift Card ───────────────────
@Composable
private fun ShiftCard(
shift: Shift,
templates: List<ShiftTemplate>,
onClick: () -> Unit,
onDelete: () -> Unit
) {
val template = templates.find { it.id == shift.templateId }
val typeLabel = when (shift.type) {
ShiftType.DAY -> "Day"
ShiftType.NIGHT -> "Night"
ShiftType.WEEKEND -> "Weekend"
}
val typeColor = when (shift.type) {
ShiftType.DAY -> Color(0xFFFFC107)
ShiftType.NIGHT -> Color(0xFF2196F3)
ShiftType.WEEKEND -> Color(0xFF9C27B0)
}
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 4.dp)
.clickable { onClick() },
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant)
) {
Row(modifier = Modifier.padding(12.dp), verticalAlignment = Alignment.CenterVertically) {
// Color strip
Box(
modifier = Modifier
.width(4.dp)
.height(48.dp)
.background(typeColor, MaterialTheme.shapes.small)
)
Spacer(Modifier.width(12.dp))
Column(modifier = Modifier.weight(1f)) {
Text(
text = template?.name ?: shift.title.ifBlank { typeLabel },
style = MaterialTheme.typography.titleSmall
)
Text(
text = "${String.format(Locale.getDefault(), "%.1f", shift.hoursWorked)} h · $typeLabel",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
Column(horizontalAlignment = Alignment.End) {
val earnings = if (template != null) {
ShiftViewModel.calculateEarnings(
shift.hourlyRate, shift.hoursWorked, template.coefficientRules
)
} else {
shift.hourlyRate * shift.hoursWorked
}
Text(
text = "$${String.format(Locale.getDefault(), "%.2f", earnings)}",
style = MaterialTheme.typography.titleSmall,
color = MaterialTheme.colorScheme.primary
)
if (shift.isCompleted) {
Text(
text = "Completed",
style = MaterialTheme.typography.labelSmall,
color = Color(0xFF4CAF50)
)
}
}
IconButton(onClick = onDelete) {
Text("", color = MaterialTheme.colorScheme.error)
}
}
}
}
// ─────────────────── Add / Edit Shift Dialog ───────────────────
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun AddShiftDialog(
selectedDate: LocalDate,
templates: List<ShiftTemplate>,
existingShift: Shift?,
onDismiss: () -> Unit,
onSave: (Shift) -> Unit
) {
var title by remember { mutableStateOf(existingShift?.title ?: "") }
var selectedTemplateId by remember { mutableStateOf(existingShift?.templateId) }
var hoursText by remember {
mutableStateOf(
if (existingShift != null && existingShift.hoursWorked > 0)
existingShift.hoursWorked.toString() else ""
)
}
var rateText by remember {
mutableStateOf(
if (existingShift != null && existingShift.hourlyRate > 0)
existingShift.hourlyRate.toString() else ""
)
}
var shiftType by remember { mutableStateOf(existingShift?.type ?: ShiftType.DAY) }
var isCompleted by remember { mutableStateOf(existingShift?.isCompleted ?: true) }
var startTime by remember {
mutableStateOf(
existingShift?.startTime?.toInstant()?.atZone(ZoneId.systemDefault())?.toLocalTime()
?: java.time.LocalTime.of(9, 0)
)
}
var showTimePicker by remember { mutableStateOf(false) }
val selectedTemplate = templates.find { it.id == selectedTemplateId }
// Auto-fill rate from template
LaunchedEffect(selectedTemplate) {
selectedTemplate?.let { rateText = it.hourlyRate.toString() }
}
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(if (existingShift != null) "Edit Shift" else "Add Shift") },
text = {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
// Template picker
if (templates.isNotEmpty()) {
Text("Template", style = MaterialTheme.typography.labelMedium)
Row(
horizontalArrangement = Arrangement.spacedBy(6.dp),
modifier = Modifier.fillMaxWidth()
) {
templates.forEach { tmpl ->
FilterChip(
selected = selectedTemplateId == tmpl.id,
onClick = {
selectedTemplateId =
if (selectedTemplateId == tmpl.id) null else tmpl.id
},
label = { Text(tmpl.name, style = MaterialTheme.typography.labelSmall) }
)
}
}
}
OutlinedTextField(
value = title,
onValueChange = { title = it },
label = { Text("Title (optional)") },
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
// Shift type
Text("Type", style = MaterialTheme.typography.labelMedium)
Row(horizontalArrangement = Arrangement.spacedBy(6.dp)) {
ShiftType.entries.forEach { type ->
FilterChip(
selected = shiftType == type,
onClick = { shiftType = type },
label = {
Text(
when (type) {
ShiftType.DAY -> "Day"
ShiftType.NIGHT -> "Night"
ShiftType.WEEKEND -> "Weekend"
}
)
}
)
}
}
Row(horizontalArrangement = Arrangement.spacedBy(8.dp)) {
OutlinedTextField(
value = hoursText,
onValueChange = { hoursText = it },
label = { Text("Hours") },
modifier = Modifier.weight(1f),
singleLine = true
)
OutlinedTextField(
value = rateText,
onValueChange = { rateText = it },
label = { Text("$/hour") },
modifier = Modifier.weight(1f),
singleLine = true
)
}
// Start time button
OutlinedButton(onClick = { showTimePicker = true }) {
Text(
"Start: ${
String.format(
Locale.getDefault(),
"%02d:%02d",
startTime.hour,
startTime.minute
)
}"
)
}
Row(verticalAlignment = Alignment.CenterVertically) {
Checkbox(checked = isCompleted, onCheckedChange = { isCompleted = it })
Text("Completed")
}
// Earnings preview
val hours = hoursText.toDoubleOrNull() ?: 0.0
val rate = rateText.toDoubleOrNull() ?: 0.0
val earnings = if (selectedTemplate != null) {
ShiftViewModel.calculateEarnings(rate, hours, selectedTemplate.coefficientRules)
} else {
rate * hours
}
if (hours > 0 && rate > 0) {
Text(
text = "Earnings: $${String.format(Locale.getDefault(), "%.2f", earnings)}",
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.primary
)
}
}
},
confirmButton = {
Button(onClick = {
val hours = hoursText.toDoubleOrNull() ?: 0.0
val rate = rateText.toDoubleOrNull() ?: 0.0
val startDateTime = selectedDate.atTime(startTime)
val endDateTime = startDateTime.plusHours(hours.toLong())
.plusMinutes(((hours % 1) * 60).roundToInt().toLong())
val zone = ZoneId.systemDefault()
val shift = Shift(
id = existingShift?.id ?: UUID.randomUUID().toString(),
title = title.ifBlank {
when (shiftType) {
ShiftType.DAY -> "Day Shift"
ShiftType.NIGHT -> "Night Shift"
ShiftType.WEEKEND -> "Weekend Shift"
}
},
startTime = Date.from(startDateTime.atZone(zone).toInstant()),
endTime = Date.from(endDateTime.atZone(zone).toInstant()),
type = shiftType,
hoursWorked = hours,
hourlyRate = rate,
isCompleted = isCompleted,
templateId = selectedTemplateId
)
onSave(shift)
}) { Text("Save") }
},
dismissButton = { TextButton(onClick = onDismiss) { Text("Cancel") } }
)
if (showTimePicker) {
val pickerState = rememberTimePickerState(
initialHour = startTime.hour,
initialMinute = startTime.minute,
is24Hour = true
)
AlertDialog(
onDismissRequest = { showTimePicker = false },
title = { Text("Shift start time") },
text = { TimePicker(state = pickerState) },
confirmButton = {
Button(onClick = {
startTime = java.time.LocalTime.of(pickerState.hour, pickerState.minute)
showTimePicker = false
}) { Text("OK") }
},
dismissButton = {
TextButton(onClick = { showTimePicker = false }) { Text("Cancel") }
}
)
}
}
@@ -0,0 +1,39 @@
package com.yaros.shiftmanager
import android.content.Context
import androidx.room.Room
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {
@Provides
@Singleton
fun provideDatabase(@ApplicationContext context: Context): AppDatabase {
return Room.databaseBuilder(
context,
AppDatabase::class.java,
"shift_manager_database"
)
.addMigrations(AppDatabase.MIGRATION_1_2)
.build()
}
@Provides
fun provideIncomeDao(database: AppDatabase): IncomeDao = database.incomeDao()
@Provides
fun provideShiftDao(database: AppDatabase): ShiftDao = database.shiftDao()
@Provides
fun provideTaxReminderDao(database: AppDatabase): TaxReminderDao = database.taxReminderDao()
@Provides
fun provideShiftTemplateDao(database: AppDatabase): ShiftTemplateDao = database.shiftTemplateDao()
}
@@ -0,0 +1,86 @@
package com.yaros.shiftmanager
import androidx.lifecycle.LiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.asLiveData
import androidx.lifecycle.viewModelScope
import androidx.room.*
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import android.content.Context
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.launch
import java.util.*
import javax.inject.Inject
@Entity(tableName = "incomes")
data class Income(
@PrimaryKey val id: String = UUID.randomUUID().toString(),
val shiftId: String,
val amount: Double,
val type: IncomeType,
val date: Date
)
enum class IncomeType {
REGULAR, TIPS, BONUS
}
@Dao
interface IncomeDao {
@Query("SELECT * FROM incomes")
fun getAllIncomes(): Flow<List<Income>>
@Query("SELECT * FROM incomes WHERE date BETWEEN :startDate AND :endDate")
fun getIncomesForPeriod(startDate: Date, endDate: Date): Flow<List<Income>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertIncome(income: Income)
@Update
suspend fun updateIncome(income: Income)
@Delete
suspend fun deleteIncome(income: Income)
}
class IncomeRepository @Inject constructor(private val incomeDao: IncomeDao) {
val allIncomes: Flow<List<Income>> = incomeDao.getAllIncomes()
fun getIncomesForPeriod(startDate: Date, endDate: Date): Flow<List<Income>> {
return incomeDao.getIncomesForPeriod(startDate, endDate)
}
suspend fun insertIncome(income: Income) {
incomeDao.insertIncome(income)
}
suspend fun updateIncome(income: Income) {
incomeDao.updateIncome(income)
}
suspend fun deleteIncome(income: Income) {
incomeDao.deleteIncome(income)
}
}
@HiltViewModel
class IncomeViewModel @Inject constructor(private val repository: IncomeRepository) : ViewModel() {
val allIncomes: LiveData<List<Income>> = repository.allIncomes.asLiveData()
fun getIncomesForPeriod(startDate: Date, endDate: Date): LiveData<List<Income>> {
return repository.getIncomesForPeriod(startDate, endDate).asLiveData()
}
fun insertIncome(income: Income) = viewModelScope.launch {
repository.insertIncome(income)
}
fun updateIncome(income: Income) = viewModelScope.launch {
repository.updateIncome(income)
}
fun deleteIncome(income: Income) = viewModelScope.launch {
repository.deleteIncome(income)
}
}
@@ -0,0 +1,86 @@
package com.yaros.shiftmanager
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.viewModels
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import dagger.hilt.android.AndroidEntryPoint
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val settingsViewModel: SettingsViewModel by viewModels()
private val incomeViewModel: IncomeViewModel by viewModels()
private val shiftViewModel: ShiftViewModel by viewModels()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
val themeMode by settingsViewModel.themeMode.collectAsState()
AppTheme(themeMode = themeMode) {
MainScreen(
shiftViewModel = shiftViewModel,
incomeViewModel = incomeViewModel,
settingsViewModel = settingsViewModel
)
}
}
}
}
@Composable
fun MainScreen(
shiftViewModel: ShiftViewModel,
incomeViewModel: IncomeViewModel,
settingsViewModel: SettingsViewModel
) {
val navigationItems = listOf("Shifts", "Templates", "Income", "Settings")
val (selectedItem, setSelectedItem) = remember { mutableStateOf(0) }
Scaffold(
bottomBar = {
NavigationBar {
navigationItems.forEachIndexed { index, item ->
NavigationBarItem(
icon = {
Text(
when (index) {
0 -> "📅"
1 -> "📋"
2 -> "💰"
3 -> "⚙️"
else -> "📌"
}
)
},
label = { Text(item) },
selected = selectedItem == index,
onClick = { setSelectedItem(index) }
)
}
}
}
) { paddingValues ->
Column(modifier = Modifier.padding(paddingValues)) {
when (selectedItem) {
0 -> CalendarScreen(shiftViewModel)
1 -> ShiftTemplatesScreen(shiftViewModel)
2 -> StatisticsScreen(incomeViewModel)
3 -> SettingsScreen(settingsViewModel)
}
}
}
}
@@ -0,0 +1,75 @@
//package com.yaros.shiftmanager
//
//import android.app.NotificationChannel
//import android.app.NotificationManager
//import android.content.Context
//import android.os.Build
//import androidx.core.app.NotificationCompat
//import androidx.core.app.NotificationManagerCompat
//import androidx.work.*
//import com.yaros.shiftmanager.*
//import java.util.concurrent.TimeUnit
//
//class NotificationHelper(private val context: Context) {
// private val channelId = "ShiftManagerChannel"
// private val notificationId = 1
//
// init {
// createNotificationChannel()
// }
//
// private fun createNotificationChannel() {
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// val name = "Shift Manager"
// val descriptionText = "Notifications for upcoming shifts"
// val importance = NotificationManager.IMPORTANCE_DEFAULT
// val channel = NotificationChannel(channelId, name, importance).apply {
// description = descriptionText
// }
// val notificationManager: NotificationManager =
// context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
// notificationManager.createNotificationChannel(channel)
// }
// }
//
// fun showShiftNotification(shift: Shift) {
// val builder = NotificationCompat.Builder(context, channelId)
// .setSmallIcon(R.drawable.ic_notification)
// .setContentTitle("Upcoming Shift")
// .setContentText("You have a ${shift.type} shift starting at ${shift.startTime}")
// .setPriority(NotificationCompat.PRIORITY_DEFAULT)
// .setAutoCancel(true)
//
// with(NotificationManagerCompat.from(context)) {
// notify(notificationId, builder.build())
// }
// }
//}
//
//class ShiftNotificationWorker(
// context: Context,
// params: WorkerParameters
//) : Worker(context, params) {
// override fun doWork(): Result {
// val shiftId = inputData.getString("shiftId") ?: return Result.failure()
// val shift = // Retrieve shift from database using shiftId
// NotificationHelper(applicationContext).showShiftNotification(shift)
// return Result.success()
// }
//
// companion object {
// fun scheduleNotification(context: Context, shift: Shift) {
// val notificationWork = OneTimeWorkRequestBuilder<ShiftNotificationWorker>()
// .setInputData(workDataOf("shiftId" to shift.id))
// .setInitialDelay(calculateInitialDelay(shift), TimeUnit.MILLISECONDS)
// .build()
//
// WorkManager.getInstance(context).enqueue(notificationWork)
// }
//
// private fun calculateInitialDelay(shift: Shift): Long {
// val currentTime = System.currentTimeMillis()
// return shift.startTime.time - currentTime - TimeUnit.HOURS.toMillis(1) // Notify 1 hour before shift
// }
// }
//}
@@ -0,0 +1,156 @@
package com.yaros.shiftmanager
import android.content.Context
import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.*
import androidx.datastore.preferences.preferencesDataStore
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import dagger.hilt.android.lifecycle.HiltViewModel
import dagger.hilt.android.qualifiers.ApplicationContext
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import javax.inject.Inject
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "settings")
class SettingsRepository @Inject constructor(@ApplicationContext private val context: Context) {
private val dataStore = context.dataStore
val themeFlow: Flow<ThemeMode> = dataStore.data.map { preferences ->
ThemeMode.valueOf(preferences[PreferencesKeys.THEME_MODE] ?: ThemeMode.SYSTEM.name)
}
val displayModeFlow: Flow<DisplayMode> = dataStore.data.map { preferences ->
DisplayMode.valueOf(preferences[PreferencesKeys.DISPLAY_MODE] ?: DisplayMode.WEEKLY.name)
}
suspend fun setThemeMode(themeMode: ThemeMode) {
dataStore.edit { preferences ->
preferences[PreferencesKeys.THEME_MODE] = themeMode.name
}
}
suspend fun setDisplayMode(displayMode: DisplayMode) {
dataStore.edit { preferences ->
preferences[PreferencesKeys.DISPLAY_MODE] = displayMode.name
}
}
private object PreferencesKeys {
val THEME_MODE = stringPreferencesKey("theme_mode")
val DISPLAY_MODE = stringPreferencesKey("display_mode")
}
}
enum class ThemeMode {
LIGHT, DARK, SYSTEM
}
enum class DisplayMode {
WEEKLY, MONTHLY
}
@HiltViewModel
class SettingsViewModel @Inject constructor(private val repository: SettingsRepository) : ViewModel() {
val themeMode: StateFlow<ThemeMode> = repository.themeFlow.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000),
ThemeMode.SYSTEM
)
val displayMode: StateFlow<DisplayMode> = repository.displayModeFlow.stateIn(
viewModelScope,
SharingStarted.WhileSubscribed(5000),
DisplayMode.WEEKLY
)
fun setThemeMode(themeMode: ThemeMode) = viewModelScope.launch {
repository.setThemeMode(themeMode)
}
fun setDisplayMode(displayMode: DisplayMode) = viewModelScope.launch {
repository.setDisplayMode(displayMode)
}
}
@Composable
fun SettingsScreen(viewModel: SettingsViewModel) {
val themeMode by viewModel.themeMode.collectAsState()
val displayMode by viewModel.displayMode.collectAsState()
Column(modifier = Modifier.padding(16.dp)) {
Text("Settings", style = MaterialTheme.typography.titleLarge)
Spacer(modifier = Modifier.height(16.dp))
ThemeModeSelector(themeMode) { viewModel.setThemeMode(it) }
Spacer(modifier = Modifier.height(16.dp))
DisplayModeSelector(displayMode) { viewModel.setDisplayMode(it) }
}
}
@Composable
fun ThemeModeSelector(currentMode: ThemeMode, onModeSelected: (ThemeMode) -> Unit) {
Column {
Text("Theme Mode", style = MaterialTheme.typography.titleMedium)
Spacer(modifier = Modifier.height(8.dp))
ThemeMode.values().forEach { mode ->
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(mode.name)
RadioButton(
selected = mode == currentMode,
onClick = { onModeSelected(mode) }
)
}
}
}
}
@Composable
fun DisplayModeSelector(currentMode: DisplayMode, onModeSelected: (DisplayMode) -> Unit) {
Column {
Text("Display Mode", style = MaterialTheme.typography.titleMedium)
Spacer(modifier = Modifier.height(8.dp))
DisplayMode.values().forEach { mode ->
Row(
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(mode.name)
RadioButton(
selected = mode == currentMode,
onClick = { onModeSelected(mode) }
)
}
}
}
}
@Composable
fun AppTheme(
themeMode: ThemeMode,
content: @Composable () -> Unit
) {
val darkTheme = when (themeMode) {
ThemeMode.LIGHT -> false
ThemeMode.DARK -> true
ThemeMode.SYSTEM -> isSystemInDarkTheme()
}
MaterialTheme(
colorScheme = if (darkTheme) darkColorScheme() else lightColorScheme(),
content = content
)
}
@@ -0,0 +1,177 @@
package com.yaros.shiftmanager
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.room.*
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.launch
import java.time.LocalDate
import java.time.YearMonth
import java.time.ZoneId
import java.util.*
import javax.inject.Inject
// ─────────────────── Shift Entity ───────────────────
@Entity(tableName = "shifts")
data class Shift(
@PrimaryKey val id: String = UUID.randomUUID().toString(),
val title: String,
val startTime: Date,
val endTime: Date,
val type: ShiftType,
val isRecurring: Boolean = false,
val recurringPattern: RecurringPattern? = null,
val hoursWorked: Double = 0.0,
val hourlyRate: Double = 0.0,
val isCompleted: Boolean = false,
val templateId: String? = null
)
enum class ShiftType {
DAY, NIGHT, WEEKEND
}
data class RecurringPattern(
val frequency: RecurringFrequency,
val interval: Int,
val daysOfWeek: List<Int>? = null,
val endDate: Date? = null
)
enum class RecurringFrequency {
DAILY, WEEKLY, MONTHLY
}
// ─────────────────── ShiftTemplate Entity ───────────────────
@Entity(tableName = "shift_templates")
data class ShiftTemplate(
@PrimaryKey val id: String = UUID.randomUUID().toString(),
val name: String,
val hourlyRate: Double,
val coefficientRules: List<CoefficientRule> = emptyList()
)
data class CoefficientRule(
val startHour: Int, // 0-23
val endHour: Int, // 0-23 (next day if < startHour)
val coefficient: Double // e.g. 1.4 = +40%
)
// ─────────────────── DAOs ───────────────────
@Dao
interface ShiftDao {
@Query("SELECT * FROM shifts")
fun getAllShifts(): Flow<List<Shift>>
@Query("SELECT * FROM shifts WHERE startTime >= :start AND startTime < :end ORDER BY startTime ASC")
fun getShiftsForMonth(start: Date, end: Date): Flow<List<Shift>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertShift(shift: Shift)
@Update
suspend fun updateShift(shift: Shift)
@Delete
suspend fun deleteShift(shift: Shift)
}
@Dao
interface ShiftTemplateDao {
@Query("SELECT * FROM shift_templates")
fun getAllTemplates(): Flow<List<ShiftTemplate>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertTemplate(template: ShiftTemplate)
@Update
suspend fun updateTemplate(template: ShiftTemplate)
@Delete
suspend fun deleteTemplate(template: ShiftTemplate)
}
// ─────────────────── Repositories ───────────────────
class ShiftRepository @Inject constructor(private val shiftDao: ShiftDao) {
val allShifts: Flow<List<Shift>> = shiftDao.getAllShifts()
fun getShiftsForMonth(yearMonth: YearMonth): Flow<List<Shift>> {
val start = yearMonth.atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant().let { Date.from(it) }
val end = yearMonth.plusMonths(1).atDay(1).atStartOfDay(ZoneId.systemDefault()).toInstant().let { Date.from(it) }
return shiftDao.getShiftsForMonth(start, end)
}
suspend fun insertShift(shift: Shift) = shiftDao.insertShift(shift)
suspend fun updateShift(shift: Shift) = shiftDao.updateShift(shift)
suspend fun deleteShift(shift: Shift) = shiftDao.deleteShift(shift)
}
class ShiftTemplateRepository @Inject constructor(private val dao: ShiftTemplateDao) {
val allTemplates: Flow<List<ShiftTemplate>> = dao.getAllTemplates()
suspend fun insertTemplate(template: ShiftTemplate) = dao.insertTemplate(template)
suspend fun updateTemplate(template: ShiftTemplate) = dao.updateTemplate(template)
suspend fun deleteTemplate(template: ShiftTemplate) = dao.deleteTemplate(template)
}
// ─────────────────── ViewModels ───────────────────
@OptIn(ExperimentalCoroutinesApi::class)
@HiltViewModel
class ShiftViewModel @Inject constructor(
private val repository: ShiftRepository,
private val templateRepository: ShiftTemplateRepository
) : ViewModel() {
private val _currentMonth = MutableStateFlow(YearMonth.now())
val currentMonth: StateFlow<YearMonth> = _currentMonth.asStateFlow()
val monthShifts: StateFlow<List<Shift>> = _currentMonth
.flatMapLatest { month -> repository.getShiftsForMonth(month) }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
val allTemplates: StateFlow<List<ShiftTemplate>> = templateRepository.allTemplates
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
fun setMonth(month: YearMonth) { _currentMonth.value = month }
fun nextMonth() { _currentMonth.value = _currentMonth.value.plusMonths(1) }
fun previousMonth() { _currentMonth.value = _currentMonth.value.minusMonths(1) }
fun insertShift(shift: Shift) = viewModelScope.launch { repository.insertShift(shift) }
fun updateShift(shift: Shift) = viewModelScope.launch { repository.updateShift(shift) }
fun deleteShift(shift: Shift) = viewModelScope.launch { repository.deleteShift(shift) }
fun insertTemplate(template: ShiftTemplate) = viewModelScope.launch { templateRepository.insertTemplate(template) }
fun updateTemplate(template: ShiftTemplate) = viewModelScope.launch { templateRepository.updateTemplate(template) }
fun deleteTemplate(template: ShiftTemplate) = viewModelScope.launch { templateRepository.deleteTemplate(template) }
fun shiftsForDate(date: LocalDate): List<Shift> {
return monthShifts.value.filter { shift ->
shift.startTime.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate() == date
}
}
companion object {
fun calculateEarnings(baseRate: Double, hoursWorked: Double, rules: List<CoefficientRule>): Double {
if (rules.isEmpty()) return baseRate * hoursWorked
val hoursByCoefficient = mutableListOf<Double>()
for (i in 0 until hoursWorked.toInt().coerceAtMost(24)) {
val coeff = rules.firstOrNull { rule ->
if (rule.startHour <= rule.endHour)
i >= rule.startHour && i < rule.endHour
else
i >= rule.startHour || i < rule.endHour
}?.coefficient ?: 1.0
hoursByCoefficient.add(coeff)
}
return hoursByCoefficient.sumOf { baseRate * it }
}
}
}
@@ -0,0 +1,7 @@
package com.yaros.shiftmanager
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class ShiftManagerApplication : Application()
@@ -0,0 +1,285 @@
package com.yaros.shiftmanager
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.Add
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.snapshots.SnapshotStateList
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import java.util.Locale
import java.util.UUID
// ─────────────────── Templates Screen ───────────────────
@Composable
fun ShiftTemplatesScreen(viewModel: ShiftViewModel = hiltViewModel()) {
val templates by viewModel.allTemplates.collectAsState()
var showDialog by remember { mutableStateOf(false) }
var editingTemplate by remember { mutableStateOf<ShiftTemplate?>(null) }
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = {
editingTemplate = null
showDialog = true
}) {
Icon(Icons.Default.Add, contentDescription = "Add Template")
}
}
) { paddingValues ->
Column(modifier = Modifier.padding(paddingValues).fillMaxSize()) {
Text(
text = "Shift Templates",
style = MaterialTheme.typography.headlineSmall,
modifier = Modifier.padding(16.dp)
)
Text(
text = "Create templates with hourly rates and night/weekend coefficients",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant,
modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp)
)
if (templates.isEmpty()) {
Box(modifier = Modifier.fillMaxSize(), contentAlignment = Alignment.Center) {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
Text(
"No templates yet",
style = MaterialTheme.typography.titleMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
Spacer(Modifier.height(8.dp))
Text(
"Tap + to create your first shift template",
style = MaterialTheme.typography.bodyMedium,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
} else {
LazyColumn(modifier = Modifier.fillMaxWidth()) {
items(templates) { template ->
TemplateCard(
template = template,
onEdit = {
editingTemplate = template
showDialog = true
},
onDelete = { viewModel.deleteTemplate(template) }
)
}
}
}
}
}
if (showDialog) {
TemplateDialog(
existingTemplate = editingTemplate,
onDismiss = { showDialog = false },
onSave = { template ->
if (editingTemplate != null) viewModel.updateTemplate(template)
else viewModel.insertTemplate(template)
showDialog = false
}
)
}
}
// ─────────────────── Template Card ───────────────────
@Composable
private fun TemplateCard(
template: ShiftTemplate,
onEdit: () -> Unit,
onDelete: () -> Unit
) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp, vertical = 6.dp),
onClick = onEdit
) {
Column(modifier = Modifier.padding(16.dp)) {
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(template.name, style = MaterialTheme.typography.titleMedium)
IconButton(onClick = onDelete) {
Text("", color = MaterialTheme.colorScheme.error)
}
}
Text(
text = "Base rate: $${String.format(Locale.getDefault(), "%.2f", template.hourlyRate)}/hr",
style = MaterialTheme.typography.bodyMedium
)
if (template.coefficientRules.isNotEmpty()) {
Spacer(Modifier.height(8.dp))
Text("Coefficient rules:", style = MaterialTheme.typography.labelMedium)
template.coefficientRules.forEach { rule ->
val percent = ((rule.coefficient - 1.0) * 100).toInt()
val sign = if (percent > 0) "+" else ""
Text(
text = " ${String.format(Locale.getDefault(), "%02d:00", rule.startHour)} " +
"${String.format(Locale.getDefault(), "%02d:00", rule.endHour)}" +
"${sign}${percent}% (×${String.format(Locale.getDefault(), "%.1f", rule.coefficient)})",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.primary
)
}
}
}
}
}
// ─────────────────── Template Dialog ───────────────────
@Composable
private fun TemplateDialog(
existingTemplate: ShiftTemplate?,
onDismiss: () -> Unit,
onSave: (ShiftTemplate) -> Unit
) {
var name by remember { mutableStateOf(existingTemplate?.name ?: "") }
var rateText by remember {
mutableStateOf(
if (existingTemplate != null) existingTemplate.hourlyRate.toString() else ""
)
}
val rules = remember {
mutableStateListOf<CoefficientRule>().also {
it.addAll(existingTemplate?.coefficientRules ?: emptyList())
}
}
// New rule fields
var newStartHour by remember { mutableStateOf("") }
var newEndHour by remember { mutableStateOf("") }
var newCoefficient by remember { mutableStateOf("") }
AlertDialog(
onDismissRequest = onDismiss,
title = { Text(if (existingTemplate != null) "Edit Template" else "New Template") },
text = {
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
OutlinedTextField(
value = name,
onValueChange = { name = it },
label = { Text("Template name (e.g. Day Shift, Night Shift)") },
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
OutlinedTextField(
value = rateText,
onValueChange = { rateText = it },
label = { Text("Base hourly rate ($)") },
modifier = Modifier.fillMaxWidth(),
singleLine = true
)
Divider()
Text("Coefficient rules", style = MaterialTheme.typography.labelLarge)
Text(
"Example: 00:0006:00 → 1.4 means +40% for hours between midnight and 6 AM",
style = MaterialTheme.typography.bodySmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
// Existing rules
rules.forEachIndexed { index, rule ->
Row(
modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(
text = "${String.format(Locale.getDefault(), "%02d:00", rule.startHour)}" +
"${String.format(Locale.getDefault(), "%02d:00", rule.endHour)}" +
"×${String.format(Locale.getDefault(), "%.1f", rule.coefficient)}",
style = MaterialTheme.typography.bodyMedium,
modifier = Modifier.weight(1f)
)
IconButton(onClick = { rules.removeAt(index) }) {
Text("", color = MaterialTheme.colorScheme.error)
}
}
}
// Add new rule row
Text("Add rule:", style = MaterialTheme.typography.labelSmall)
Row(
horizontalArrangement = Arrangement.spacedBy(4.dp),
verticalAlignment = Alignment.CenterVertically
) {
OutlinedTextField(
value = newStartHour,
onValueChange = { newStartHour = it.filter { c -> c.isDigit() }.take(2) },
label = { Text("From") },
placeholder = { Text("00") },
modifier = Modifier.weight(1f),
singleLine = true
)
Text("")
OutlinedTextField(
value = newEndHour,
onValueChange = { newEndHour = it.filter { c -> c.isDigit() }.take(2) },
label = { Text("To") },
placeholder = { Text("06") },
modifier = Modifier.weight(1f),
singleLine = true
)
OutlinedTextField(
value = newCoefficient,
onValueChange = { newCoefficient = it },
label = { Text("×") },
placeholder = { Text("1.4") },
modifier = Modifier.weight(1f),
singleLine = true
)
FilledTonalButton(
onClick = {
val start = newStartHour.toIntOrNull() ?: return@FilledTonalButton
val end = newEndHour.toIntOrNull() ?: return@FilledTonalButton
val coeff = newCoefficient.toDoubleOrNull() ?: return@FilledTonalButton
if (start !in 0..23 || end !in 0..23) return@FilledTonalButton
rules.add(CoefficientRule(start, end, coeff))
newStartHour = ""
newEndHour = ""
newCoefficient = ""
},
modifier = Modifier.size(40.dp),
contentPadding = PaddingValues(0.dp)
) {
Text("+")
}
}
}
},
confirmButton = {
Button(onClick = {
val rate = rateText.toDoubleOrNull() ?: return@Button
val template = ShiftTemplate(
id = existingTemplate?.id ?: UUID.randomUUID().toString(),
name = name.ifBlank { "Untitled Template" },
hourlyRate = rate,
coefficientRules = rules.toList()
)
onSave(template)
}) { Text("Save") }
},
dismissButton = {
TextButton(onClick = onDismiss) { Text("Cancel") }
}
)
}
@@ -0,0 +1,97 @@
package com.yaros.shiftmanager
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import java.util.Calendar
import java.util.Date
import java.util.Locale
@Composable
fun StatisticsScreen(incomeViewModel: IncomeViewModel) {
var selectedPeriod by remember { mutableStateOf(StatisticsPeriod.MONTH) }
var incomes by remember { mutableStateOf<List<Income>>(emptyList()) }
LaunchedEffect(selectedPeriod) {
val (startDate, endDate) = getDateRangeForPeriod(selectedPeriod)
incomeViewModel.getIncomesForPeriod(startDate, endDate).observeForever { incomes = it }
}
Column(modifier = Modifier.padding(16.dp)) {
PeriodSelector(selectedPeriod) { selectedPeriod = it }
Spacer(modifier = Modifier.height(16.dp))
IncomeChart(incomes)
Spacer(modifier = Modifier.height(16.dp))
IncomeBreakdown(incomes)
}
}
@Composable
fun PeriodSelector(selectedPeriod: StatisticsPeriod, onPeriodSelected: (StatisticsPeriod) -> Unit) {
Row {
StatisticsPeriod.entries.forEach { period ->
Button(
onClick = { onPeriodSelected(period) },
modifier = Modifier.padding(4.dp),
colors = ButtonDefaults.buttonColors(
containerColor = if (period == selectedPeriod) MaterialTheme.colorScheme.primary else MaterialTheme.colorScheme.secondary
)
) {
Text(period.name)
}
}
}
}
@Composable
fun IncomeChart(incomes: List<Income>) {
// Placeholder for chart - Vico chart implementation
Text("Income Chart: ${incomes.size} entries")
}
@Composable
fun IncomeBreakdown(incomes: List<Income>) {
val totalIncome = incomes.sumOf { it.amount }
val regularIncome = incomes.filter { it.type == IncomeType.REGULAR }.sumOf { it.amount }
val tipsIncome = incomes.filter { it.type == IncomeType.TIPS }.sumOf { it.amount }
val bonusIncome = incomes.filter { it.type == IncomeType.BONUS }.sumOf { it.amount }
Column {
Text("Total Income: $${String.format(Locale.US, "%.2f", totalIncome)}", style = MaterialTheme.typography.titleLarge)
Text("Regular Income: $${String.format(Locale.US, "%.2f", regularIncome)}", style = MaterialTheme.typography.bodyLarge)
Text("Tips: $${String.format(Locale.US, "%.2f", tipsIncome)}", style = MaterialTheme.typography.bodyLarge)
Text("Bonuses: $${String.format(Locale.US, "%.2f", bonusIncome)}", style = MaterialTheme.typography.bodyLarge)
}
}
enum class StatisticsPeriod {
WEEK, MONTH, YEAR
}
fun getDateRangeForPeriod(period: StatisticsPeriod): Pair<Date, Date> {
val calendar = Calendar.getInstance()
val endDate = calendar.time
calendar.add(when (period) {
StatisticsPeriod.WEEK -> Calendar.WEEK_OF_YEAR
StatisticsPeriod.MONTH -> Calendar.MONTH
StatisticsPeriod.YEAR -> Calendar.YEAR
}, -1)
val startDate = calendar.time
return Pair(startDate, endDate)
}
@@ -0,0 +1,186 @@
package com.yaros.shiftmanager
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.Arrangement.Absolute.SpaceBetween
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.*
import androidx.compose.ui.unit.dp
import androidx.lifecycle.*
import androidx.room.*
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.stateIn
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
@Entity(tableName = "tax_reminders")
data class TaxReminder(
@PrimaryKey val id: String = UUID.randomUUID().toString(),
val dueDate: Date,
val description: String,
val isCompleted: Boolean = false
)
@Dao
interface TaxReminderDao {
@Query("SELECT * FROM tax_reminders")
fun getAllTaxReminders(): Flow<List<TaxReminder>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertTaxReminder(taxReminder: TaxReminder)
@Update
suspend fun updateTaxReminder(taxReminder: TaxReminder)
@Delete
suspend fun deleteTaxReminder(taxReminder: TaxReminder)
}
class TaxReminderRepository @Inject constructor(private val taxReminderDao: TaxReminderDao) {
val allTaxReminders: Flow<List<TaxReminder>> = taxReminderDao.getAllTaxReminders()
suspend fun insertTaxReminder(taxReminder: TaxReminder) {
taxReminderDao.insertTaxReminder(taxReminder)
}
suspend fun updateTaxReminder(taxReminder: TaxReminder) {
taxReminderDao.updateTaxReminder(taxReminder)
}
suspend fun deleteTaxReminder(taxReminder: TaxReminder) {
taxReminderDao.deleteTaxReminder(taxReminder)
}
}
@HiltViewModel
class TaxReminderViewModel @Inject constructor(private val repository: TaxReminderRepository) : ViewModel() {
val allTaxReminders: StateFlow<List<TaxReminder>> = repository.allTaxReminders.stateIn(
viewModelScope,
SharingStarted.Lazily,
emptyList()
)
fun insertTaxReminder(taxReminder: TaxReminder) = viewModelScope.launch {
repository.insertTaxReminder(taxReminder)
}
fun updateTaxReminder(taxReminder: TaxReminder) = viewModelScope.launch {
repository.updateTaxReminder(taxReminder)
}
fun deleteTaxReminder(taxReminder: TaxReminder) = viewModelScope.launch {
repository.deleteTaxReminder(taxReminder)
}
}
@Composable
fun TaxReminderScreen(viewModel: TaxReminderViewModel) {
val taxReminders by viewModel.allTaxReminders.collectAsState(initial = emptyList())
Column(modifier = Modifier.padding(16.dp)) {
Text("Tax Reminders", style = MaterialTheme.typography.titleLarge)
Spacer(modifier = Modifier.height(16.dp))
LazyColumn {
items(taxReminders) { reminder ->
TaxReminderItem(reminder, viewModel)
}
}
Spacer(modifier = Modifier.height(16.dp))
AddTaxReminderButton(viewModel)
}
}
@Composable
fun TaxReminderItem(reminder: TaxReminder, viewModel: TaxReminderViewModel) {
Card(
modifier = Modifier
.fillMaxWidth()
.padding(8.dp)
) {
Row(
modifier = Modifier
.padding(16.dp)
.fillMaxWidth(),
horizontalArrangement = SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Column {
Text(reminder.description, style = MaterialTheme.typography.bodyLarge)
Text(
"Due: ${SimpleDateFormat("MMM dd, yyyy", Locale.getDefault()).format(reminder.dueDate)}",
style = MaterialTheme.typography.bodyMedium
)
}
Checkbox(
checked = reminder.isCompleted,
onCheckedChange = { isChecked ->
viewModel.updateTaxReminder(reminder.copy(isCompleted = isChecked))
}
)
}
}
}
@Composable
fun AddTaxReminderButton(viewModel: TaxReminderViewModel) {
var showDialog by remember { mutableStateOf(false) }
Button(onClick = { showDialog = true }) {
Text("Add Tax Reminder")
}
if (showDialog) {
AddTaxReminderDialog(
onDismiss = { showDialog = false },
onAdd = { description, dueDate ->
viewModel.insertTaxReminder(TaxReminder(description = description, dueDate = dueDate))
showDialog = false
}
)
}
}
@Composable
fun AddTaxReminderDialog(onDismiss: () -> Unit, onAdd: (String, Date) -> Unit) {
var description by remember { mutableStateOf("") }
var dueDate by remember { mutableStateOf(Date()) }
AlertDialog(
onDismissRequest = onDismiss,
title = { Text("Add Tax Reminder") },
text = {
Column {
TextField(
value = description,
onValueChange = { description = it },
label = { Text("Description") }
)
Spacer(modifier = Modifier.height(8.dp))
// Add a DatePicker here for selecting dueDate
}
},
confirmButton = {
Button(onClick = { onAdd(description, dueDate) }) {
Text("Add")
}
},
dismissButton = {
Button(onClick = onDismiss) {
Text("Cancel")
}
}
)
}
@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>
@@ -0,0 +1,30 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
<background android:drawable="@drawable/ic_launcher_background" />
<foreground android:drawable="@drawable/ic_launcher_foreground" />
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
</adaptive-icon>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 982 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

+10
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>
+3
View File
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">ShiftManager</string>
</resources>
+5
View File
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.ShiftManager" parent="android:Theme.Material.Light.NoActionBar" />
</resources>
+13
View File
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample backup rules file; uncomment and customize as necessary.
See https://developer.android.com/guide/topics/data/autobackup
for details.
Note: This file is ignored for devices older that API 31
See https://developer.android.com/about/versions/12/backup-restore
-->
<full-backup-content>
<!--
<include domain="sharedpref" path="."/>
<exclude domain="sharedpref" path="device.xml"/>
-->
</full-backup-content>
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?><!--
Sample data extraction rules file; uncomment and customize as necessary.
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
for details.
-->
<data-extraction-rules>
<cloud-backup>
<!-- TODO: Use <include> and <exclude> to control what is backed up.
<include .../>
<exclude .../>
-->
</cloud-backup>
<!--
<device-transfer>
<include .../>
<exclude .../>
</device-transfer>
-->
</data-extraction-rules>
@@ -0,0 +1,17 @@
package com.yaros.shiftmanager
import org.junit.Test
import org.junit.Assert.*
/**
* Example local unit test, which will execute on the development machine (host).
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
class ExampleUnitTest {
@Test
fun addition_isCorrect() {
assertEquals(4, 2 + 2)
}
}