feat: Add notifications activiy & button (only ui)

This commit is contained in:
Peter Vacho 2025-01-02 17:38:44 +01:00
parent dcf6e98427
commit 49ca0f79a2
Signed by: school
GPG key ID: 8CFC3837052871B4
7 changed files with 82 additions and 19 deletions

View file

@ -16,6 +16,9 @@
android:supportsRtl="true"
android:theme="@style/Theme.NeatCalendar"
tools:targetApi="31">
<activity
android:name=".activities.NotificationsActivity"
android:exported="false" />
<activity
android:name=".activities.SettingsActivity"
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 NotificationsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_notification)
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

@ -9,6 +9,7 @@ import android.widget.ImageButton
import androidx.fragment.app.Fragment
import com.google.android.material.textview.MaterialTextView
import com.p_vacho.neat_calendar.R
import com.p_vacho.neat_calendar.activities.NotificationsActivity
import com.p_vacho.neat_calendar.activities.SettingsActivity
class MainBarFragment : Fragment() {
@ -17,21 +18,20 @@ class MainBarFragment : Fragment() {
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
// Inflate the layout for our new app settings bar
return inflater.inflate(R.layout.fragment_main_bar, container, false)
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Optionally set the center text programmatically if needed
val titleText = view.findViewById<MaterialTextView>(R.id.appBarTitle)
titleText.text = getString(R.string.app_name) // or "NeatCalendar"
// Handle settings icon click → open the SettingsActivity
val settingsIcon = view.findViewById<ImageButton>(R.id.settingsIcon)
settingsIcon.setOnClickListener {
val btnSettings = view.findViewById<ImageButton>(R.id.btnSettings)
btnSettings.setOnClickListener {
startActivity(Intent(requireContext(), SettingsActivity::class.java))
}
val btnNotifications = view.findViewById<ImageButton>(R.id.btnNotifications)
btnNotifications.setOnClickListener {
startActivity(Intent(requireContext(), NotificationsActivity::class.java))
}
}
}

View file

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="960"
android:viewportHeight="960">
<path
android:pathData="M160,760v-80h80v-280q0,-83 50,-147.5T420,168v-28q0,-25 17.5,-42.5T480,80q25,0 42.5,17.5T540,140v28q80,20 130,84.5T720,400v280h80v80L160,760ZM480,460ZM480,880q-33,0 -56.5,-23.5T400,800h160q0,33 -23.5,56.5T480,880ZM320,680h320v-280q0,-66 -47,-113t-113,-47q-66,0 -113,47t-47,113v280Z"
android:fillColor="#e8eaed"/>
</vector>

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.NotificationsActivity">
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -17,21 +17,40 @@
android:textSize="20sp"
android:gravity="center_vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/settingsIcon"
app:layout_constraintEnd_toStartOf="@+id/iconsContainer"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
<!-- Layout for the icons on the right -->
<LinearLayout
android:id="@+id/iconsContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<!-- Notifications Icon -->
<ImageButton
android:id="@+id/btnNotifications"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/open_notifications"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_notification_bell"
android:padding="8dp"
app:tint="?attr/colorOnPrimary" />
<!-- Settings Icon -->
<ImageButton
android:id="@+id/settingsIcon"
android:id="@+id/btnSettings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/open_app_settings"
android:background="?attr/selectableItemBackgroundBorderless"
android:src="@drawable/ic_settings"
android:padding="8dp"
app:tint="?attr/colorOnPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
app:tint="?attr/colorOnPrimary" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -46,4 +46,5 @@
<string name="update_event">Update Event</string>
<string name="leave_invited_event">Leave invited event</string>
<string name="open_app_settings">Open Settings</string>
<string name="open_notifications">Open Notifications</string>
</resources>