Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/src/main/java/com/theayushyadav11/MessEase/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,22 @@ class MainActivity : AppCompatActivity() {
mess.log("Setting alarms: Breakfast ${times[0]}, Lunch ${times[1]}, " +
"Snack ${times[2]}, Dinner ${times[3]}")

val enabledStates = listOf(
mess.isMealEnabled("bt_enabled"),
mess.isMealEnabled("lt_enabled"),
mess.isMealEnabled("st_enabled"),
mess.isMealEnabled("dt_enabled")
)

for (i in times.indices) {
scheduleAlarm(i, times[i], intent)
cancelAllAlarms(this, i)
}


for (i in times.indices) {
if (enabledStates[i]) {
scheduleAlarm(i, times[i], intent)
}
}
} catch (e: Exception) {
mess.log("Error setting alarms: ${e.message}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ package com.theayushyadav11.MessEase.ui.more
import android.app.TimePickerDialog
import android.graphics.Color
import android.os.Bundle
import android.widget.Switch
import android.widget.TextView
import android.widget.Toast
import android.view.View
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import com.theayushyadav11.MessEase.databinding.ActivitySettingsBinding
Expand All @@ -13,14 +16,26 @@ import java.util.Calendar
class SettingsActivity : AppCompatActivity() {
private lateinit var binding:ActivitySettingsBinding
private lateinit var mess:Mess

private val tempStates = mutableMapOf<String, Boolean>()

override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedInstanceState)
binding= ActivitySettingsBinding.inflate(layoutInflater)
setContentView(binding.root)
mess=Mess(this)
setUpToolBar()
initialise()
listeners()
setupToggle("bt_enabled", binding.switchBreakfast, binding.timeb, binding.pickb)
setupToggle("lt_enabled", binding.switchLunch, binding.timel, binding.pickl)
setupToggle("st_enabled", binding.switchSnacks, binding.times, binding.picks)
setupToggle("dt_enabled", binding.switchDinner, binding.timed, binding.pickd)
tempStates["bt_enabled"] = mess.isMealEnabled("bt_enabled")
tempStates["lt_enabled"] = mess.isMealEnabled("lt_enabled")
tempStates["st_enabled"] = mess.isMealEnabled("st_enabled")
tempStates["dt_enabled"] = mess.isMealEnabled("dt_enabled")

}

Expand All @@ -34,7 +49,12 @@ class SettingsActivity : AppCompatActivity() {

fun listeners()
{
val b= mutableListOf("07:30","12:0","16:30","19:0")
val b = mutableListOf(
mess.get("bt","7:30"),
mess.get("lt","12:0"),
mess.get("st","16:30"),
mess.get("dt","19:0")
)
binding.pickb.setOnClickListener{
showTimePicker(0, 0, 10, 0) {it,p->
binding.timeb.text = it
Expand Down Expand Up @@ -67,8 +87,13 @@ class SettingsActivity : AppCompatActivity() {
mess.save("st",b[2])
mess.save("dt",b[3])
mess.log(b)
mess.toast("Timings Updated")
//cancelAllAlarms(this@SettingsActivity)
mess.setMealEnabled("bt_enabled", tempStates["bt_enabled"]!!)
mess.setMealEnabled("lt_enabled", tempStates["lt_enabled"]!!)
mess.setMealEnabled("st_enabled", tempStates["st_enabled"]!!)
mess.setMealEnabled("dt_enabled", tempStates["dt_enabled"]!!)

mess.toast("Settings Updated")
finish()
}

Expand Down Expand Up @@ -131,4 +156,33 @@ class SettingsActivity : AppCompatActivity() {
val formattedTime = timeFormat.format(selectedTime.time)
return formattedTime
}
private fun setupToggle(
key: String,
switch: Switch,
timeView: TextView,
picker: View
) {
val isEnabled = mess.isMealEnabled(key)
switch.isChecked = isEnabled

updateUIState(isEnabled, timeView, picker)

switch.setOnCheckedChangeListener { _, checked ->
tempStates[key] = checked
updateUIState(checked, timeView, picker)
}
}

private fun updateUIState(
isEnabled: Boolean,
timeView: TextView,
picker: View
) {
timeView.alpha = if (isEnabled) 1f else 0.4f
picker.alpha = if (isEnabled) 1f else 0.4f
picker.isEnabled = isEnabled
}



}
8 changes: 8 additions & 0 deletions app/src/main/java/com/theayushyadav11/MessEase/utils/Mess.kt
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ class Mess(context: Context) {
return get("isSkipped","false").toBoolean()
}

fun setMealEnabled(key: String, value: Boolean) {
sharedPreferences.edit().putBoolean(key, value).apply()
}

fun isMealEnabled(key: String): Boolean {
return sharedPreferences.getBoolean(key, true)
}

}


32 changes: 32 additions & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/v"
app:layout_constraintTop_toTopOf="parent" />
<Switch
android:id="@+id/switchBreakfast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/pickb"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>
Comment on lines +78 to +85

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add accessibility labels for the new meal switches.

These switches are currently unlabeled for screen readers, so assistive tech users may hear generic controls without meal context.

♿ Suggested fix
 <Switch
     android:id="@+id/switchBreakfast"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:contentDescription="@string/cd_toggle_breakfast_reminder"
     app:layout_constraintEnd_toStartOf="@id/pickb"
     app:layout_constraintTop_toTopOf="parent"
     app:layout_constraintBottom_toBottomOf="parent"
     android:layout_marginEnd="8dp"/>

 <Switch
     android:id="@+id/switchLunch"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:contentDescription="@string/cd_toggle_lunch_reminder"
     app:layout_constraintEnd_toStartOf="@id/pickl"
     app:layout_constraintTop_toTopOf="parent"
     app:layout_constraintBottom_toBottomOf="parent"
     android:layout_marginEnd="8dp"/>

 <Switch
     android:id="@+id/switchSnacks"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:contentDescription="@string/cd_toggle_snacks_reminder"
     app:layout_constraintEnd_toStartOf="@id/picks"
     app:layout_constraintTop_toTopOf="parent"
     app:layout_constraintBottom_toBottomOf="parent"
     android:layout_marginEnd="8dp"/>

 <Switch
     android:id="@+id/switchDinner"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
+    android:contentDescription="@string/cd_toggle_dinner_reminder"
     app:layout_constraintEnd_toStartOf="@id/pickd"
     app:layout_constraintTop_toTopOf="parent"
     app:layout_constraintBottom_toBottomOf="parent"
     android:layout_marginEnd="8dp"/>

Also applies to: 148-155, 220-227, 294-301

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/src/main/res/layout/activity_settings.xml` around lines 78 - 85, Add
descriptive accessibility labels to each meal Switch so screen readers announce
the meal context: for Switch elements like switchBreakfast (and the other meal
switches referenced at the other locations), set android:contentDescription to a
meaningful string resource (e.g., `@string/switch_breakfast`) and add
corresponding strings in strings.xml (e.g., "Breakfast notifications switch") so
the switch announces the meal name; update each Switch (ids: switchBreakfast and
the other meal switch ids at the ranges you flagged) to use contentDescription
rather than leaving them unlabeled.


<TextView
android:id="@+id/timeb"
Expand Down Expand Up @@ -137,6 +145,14 @@
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/v2"
app:layout_constraintTop_toTopOf="parent" />
<Switch
android:id="@+id/switchLunch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/pickl"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>

<TextView
android:id="@+id/timel"
Expand Down Expand Up @@ -201,6 +217,14 @@
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/v3"
app:layout_constraintTop_toTopOf="parent" />
<Switch
android:id="@+id/switchSnacks"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/picks"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>

<TextView
android:id="@+id/times"
Expand Down Expand Up @@ -267,6 +291,14 @@
android:textStyle="bold"
app:layout_constraintStart_toEndOf="@id/v5"
app:layout_constraintTop_toTopOf="parent" />
<Switch
android:id="@+id/switchDinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/pickd"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginEnd="8dp"/>

<TextView
android:id="@+id/timed"
Expand Down
7 changes: 5 additions & 2 deletions app/src/main/res/layout/fragment_review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg"
android:background="?attr/colorPrimary"
tools:context=".ui.MessCommittee.fragments.ReviewFragment">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="4dp"
android:layout_width="match_parent"
android:layout_height="59dp"
app:titleTextColor="@color/white"
app:titleTextColor="?attr/colorOnPrimary"
android:background="@color/food"
android:title="Upload Menu"
android:paddingBottom="5dp"
Expand All @@ -29,6 +30,7 @@
android:layout_height="match_parent"
android:gravity="center"
android:text="No Reviews."
android:textColor="?attr/colorOnBackground"

android:textSize="30sp"
android:textStyle="bold"
Expand All @@ -40,6 +42,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv"
android:layout_width="match_parent"
android:background="?attr/colorSurface"
android:layout_height="0dp"
android:padding="20dp"
app:layout_constraintBottom_toBottomOf="parent"
Expand Down
12 changes: 11 additions & 1 deletion app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@
<color name="food">#1972f0</color>
<color name="medium">#82B5FE</color>
<color name="grey">#cfd8df</color>
<color name="bg">#2E2D2D</color>
<color name="nav_black">#131313</color>
<color name="nav_element">#a0a0a2</color>
<color name="primary">#3B82F6</color>
<color name="primary_variant">#1E3A8A</color>
<color name="accent">#FBBF24</color>
<color name="accent_soft">#78350F</color>
<color name="bg">#0F172A</color>
<color name="surface">#1E293B</color>
<color name="text_primary">#F9FAFB</color>
<color name="text_secondary">#94A3B8</color>
<color name="divider">#334155</color>
<color name="error">#F87171</color>


</resources>
20 changes: 14 additions & 6 deletions app/src/main/res/values-night/themes.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<resources>
<!-- Base application theme. -->
<style name="Theme.Messease" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_200</item>
<item name="colorPrimaryVariant">@color/food</item>
<item name="colorOnPrimary">@color/white</item>

<!-- Secondary brand color. -->
<item name="colorSecondary">@color/teal_200</item>
<item name="colorSecondaryVariant">@color/teal_200</item>
<item name="colorOnSecondary">@color/white</item>
<!-- Status bar color. -->
<item name="android:statusBarColor">@color/food</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryVariant">@color/primary_variant</item>
<item name="colorOnPrimary">@color/white</item>

<item name="colorSecondary">@color/accent</item>
<item name="colorOnSecondary">@color/black</item>

<item name="android:colorBackground">@color/bg</item>
<item name="colorSurface">@color/surface</item>

<item name="colorOnBackground">@color/text_primary</item>
<item name="colorOnSurface">@color/text_primary</item>
<!-- Customize your theme here. -->
</style>
<style name="Theme.Messease.AppBarOverlay" parent="Theme.MaterialComponents.DayNight.NoActionBar" />
Expand Down
11 changes: 10 additions & 1 deletion app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,19 @@
<color name="food">#1972f0</color>
<color name="medium">#82B5FE</color>
<color name="grey">#cfd8df</color>
<color name="bg">#FFFFFF</color>
<color name="red">#CC3E44</color>
<color name="nav_black">#FFFFFF</color>
<color name="nav_element">#000000</color>
<color name="gold">#ba8e43</color>
<color name="light_gold">#f5eba3</color>
<color name="primary">#2563EB</color>
<color name="primary_variant">#1E40AF</color>
<color name="accent">#F59E0B</color>
<color name="accent_soft">#FEF3C7</color>
<color name="bg">#F9FAFB</color>
<color name="surface">#FFFFFF</color>
<color name="text_primary">#111827</color>
<color name="text_secondary">#6B7280</color>
<color name="divider">#E5E7EB</color>
<color name="error">#DC2626</color>
</resources>
20 changes: 15 additions & 5 deletions app/src/main/res/values/themes.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
<resources>
<!-- Base application theme. -->
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.Light.NoActionBar">
<style name="Theme.MyApplication" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/food</item>
<item name="android:statusBarColor">@color/food</item>
<item name="colorOnPrimary">@color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">@color/food</item>
<item name="colorSecondaryVariant">@color/white</item>
<item name="colorOnSecondary">@color/white</item>
<!-- Status bar color. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryVariant">@color/primary_variant</item>
<item name="colorOnPrimary">@color/white</item>

<item name="colorSecondary">@color/accent</item>
<item name="colorOnSecondary">@color/black</item>

<item name="android:colorBackground">@color/bg</item>
<item name="colorSurface">@color/surface</item>

<item name="colorOnBackground">@color/text_primary</item>
<item name="colorOnSurface">@color/text_primary</item>




</style>
Expand Down