chore: Remove ui from main activity, moving it calendar act

This removes the layout & any graphical elements that were used in the
main activity, making it purely a transitional activity (either leading
to the login activity, or to the calendar activity).
This commit is contained in:
Peter Vacho 2024-12-24 14:57:26 +01:00
parent 8f20cabb33
commit 9d9295af7e
Signed by: school
GPG key ID: 8CFC3837052871B4
6 changed files with 40 additions and 14 deletions

View file

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>

View file

@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="jbr-21" project-jdk-type="JavaSDK">

View file

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

View file

@ -0,0 +1,26 @@
package com.p_vacho.neat_calendar
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
class CalendarActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_calendar)
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
}
initializeCalendar()
}
private fun initializeCalendar() {
// TODO("Not yet implemented")
}
}

View file

@ -2,11 +2,8 @@ package com.p_vacho.neat_calendar
import android.content.Intent
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.p_vacho.neat_calendar.api.RetrofitClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
@ -24,20 +21,11 @@ class MainActivity : AppCompatActivity() {
splashScreen.setKeepOnScreenCondition { !loggedIn }
super.onCreate(savedInstanceState)
enableEdgeToEdge()
setContentView(R.layout.activity_main)
// Perform initialization (login check)
CoroutineScope(Dispatchers.Main).launch {
initialize()
}
// Handle window insets for proper layout adjustment
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
}
}
private suspend fun initialize() {
@ -53,6 +41,8 @@ class MainActivity : AppCompatActivity() {
if (!loggedIn) {
navigateToLoginActivity()
}
navigateToCalendarActivity()
}
private suspend fun checkUserLogin(): Boolean {
@ -73,4 +63,11 @@ class MainActivity : AppCompatActivity() {
startActivity(intent)
finish() // Close MainActivity
}
private fun navigateToCalendarActivity() {
val intent = Intent(this, CalendarActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
startActivity(intent)
finish() // Close MainActivity
}
}

View file

@ -5,7 +5,7 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
tools:context=".CalendarActivity">
<TextView
android:layout_width="wrap_content"