feat: Add (blank) categories activity & logic to enter it

This commit is contained in:
Peter Vacho 2025-01-03 18:00:49 +01:00
parent 275e65b9be
commit 6781410b87
Signed by: school
GPG key ID: 8CFC3837052871B4
5 changed files with 54 additions and 0 deletions

View file

@ -16,6 +16,9 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/Theme.NeatCalendar" android:theme="@style/Theme.NeatCalendar"
tools:targetApi="31"> tools:targetApi="31">
<activity
android:name=".activities.CategoriesActivity"
android:exported="false" />
<activity <activity
android:name=".activities.NotificationsActivity" android:name=".activities.NotificationsActivity"
android:exported="false" /> android:exported="false" />

View file

@ -0,0 +1,21 @@
package com.p_vacho.neat_calendar.activities
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.p_vacho.neat_calendar.R
class CategoriesActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_categories)
ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
insets
}
}
}

View file

@ -265,6 +265,10 @@ class CreateEventActivity : AppCompatActivity() {
.setNegativeButton(getString(R.string.cancel)) { dialog, _ -> .setNegativeButton(getString(R.string.cancel)) { dialog, _ ->
dialog.dismiss() dialog.dismiss()
} }
.setNeutralButton(getString(R.string.manage_categories)) { dialog, _ ->
navigateToCategoriesActivity()
dialog.dismiss()
}
builder.create().show() builder.create().show()
} }
@ -418,4 +422,19 @@ class CreateEventActivity : AppCompatActivity() {
categoryViewSwitcher.displayedChild = 0 // Show RecyclerView categoryViewSwitcher.displayedChild = 0 // Show RecyclerView
} }
} }
/**
* Navigate to the Categories Activity, without closing this activity,
* hence allowing the user to return back.
*/
private fun navigateToCategoriesActivity() {
val intent = Intent(this, CategoriesActivity::class.java)
startActivity(intent)
}
override fun onResume() {
super.onResume()
// Re-fetch categories when returning (most likely from CategoriesActivity)
fetchCategories()
}
} }

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activities.CategoriesActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -74,4 +74,5 @@
<string name="event_saved">Event Saved: %1$s</string> <string name="event_saved">Event Saved: %1$s</string>
<string name="choose_event_color">Choose Event Color</string> <string name="choose_event_color">Choose Event Color</string>
<string name="select_time">Select Time</string> <string name="select_time">Select Time</string>
<string name="manage_categories">Manage categories</string>
</resources> </resources>