refactor: Improve file structure

This commit is contained in:
Peter Vacho 2024-12-24 15:35:03 +01:00
parent 9d9295af7e
commit bcebaede91
Signed by: school
GPG key ID: 8CFC3837052871B4
19 changed files with 46 additions and 37 deletions

View file

@ -17,19 +17,19 @@
android:theme="@style/Theme.NeatCalendar"
tools:targetApi="31">
<activity
android:name=".CalendarActivity"
android:name=".activities.CalendarActivity"
android:exported="false" />
<activity
android:name=".ApiUnreachableActivity"
android:name=".activities.ApiUnreachableActivity"
android:exported="false" />
<activity
android:name=".RegisterActivity"
android:name=".activities.RegisterActivity"
android:exported="false" />
<activity
android:name=".LoginActivity"
android:name=".activities.LoginActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:name=".activities.MainActivity"
android:exported="true"
android:theme="@style/Theme.NeatCalendar.Splash">
<intent-filter>

View file

@ -2,8 +2,8 @@ package com.p_vacho.neat_calendar
import android.app.Application
import com.p_vacho.neat_calendar.api.RetrofitClient
import com.p_vacho.neat_calendar.auth.AuthRepository
import com.p_vacho.neat_calendar.auth.TokenManager
import com.p_vacho.neat_calendar.util.auth.AuthRepository
import com.p_vacho.neat_calendar.util.auth.TokenManager
class MyApplication : Application() {
lateinit var tokenManager: TokenManager

View file

@ -1,14 +1,14 @@
package com.p_vacho.neat_calendar
package com.p_vacho.neat_calendar.activities
import android.content.Intent
import android.os.Bundle
import android.text.Html
import android.widget.Button
import android.widget.TextView
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
import com.p_vacho.neat_calendar.api.RetrofitClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

View file

@ -1,10 +1,11 @@
package com.p_vacho.neat_calendar
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 CalendarActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {

View file

@ -1,8 +1,7 @@
package com.p_vacho.neat_calendar
package com.p_vacho.neat_calendar.activities
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
@ -11,10 +10,9 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.p_vacho.neat_calendar.auth.AuthRepository
import com.p_vacho.neat_calendar.auth.LoginResult
import com.p_vacho.neat_calendar.auth.RegisterResult
import com.p_vacho.neat_calendar.auth.TokenManager
import com.p_vacho.neat_calendar.MyApplication
import com.p_vacho.neat_calendar.R
import com.p_vacho.neat_calendar.util.auth.LoginResult
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

View file

@ -1,9 +1,10 @@
package com.p_vacho.neat_calendar
package com.p_vacho.neat_calendar.activities
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
import com.p_vacho.neat_calendar.MyApplication
import com.p_vacho.neat_calendar.api.RetrofitClient
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers

View file

@ -1,4 +1,4 @@
package com.p_vacho.neat_calendar
package com.p_vacho.neat_calendar.activities
import android.content.Intent
import android.os.Bundle
@ -10,7 +10,9 @@ import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.p_vacho.neat_calendar.auth.RegisterResult
import com.p_vacho.neat_calendar.MyApplication
import com.p_vacho.neat_calendar.R
import com.p_vacho.neat_calendar.util.auth.RegisterResult
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

View file

@ -3,7 +3,7 @@ package com.p_vacho.neat_calendar.api
import android.content.Context
import android.content.Intent
import android.util.Log
import com.p_vacho.neat_calendar.ApiUnreachableActivity
import com.p_vacho.neat_calendar.activities.ApiUnreachableActivity
import okhttp3.Interceptor
import okhttp3.Protocol
import okhttp3.Response

View file

@ -3,9 +3,9 @@ package com.p_vacho.neat_calendar.api.interceptors
import android.content.Context
import android.content.Intent
import android.util.Log
import com.p_vacho.neat_calendar.LoginActivity
import com.p_vacho.neat_calendar.auth.AuthRepository
import com.p_vacho.neat_calendar.auth.TokenManager
import com.p_vacho.neat_calendar.activities.LoginActivity
import com.p_vacho.neat_calendar.util.auth.AuthRepository
import com.p_vacho.neat_calendar.util.auth.TokenManager
import androidx.core.content.ContextCompat
import com.p_vacho.neat_calendar.MyApplication
import kotlinx.coroutines.runBlocking

View file

@ -1,4 +1,4 @@
package com.p_vacho.neat_calendar
package com.p_vacho.neat_calendar.fragments
import android.os.Bundle
import android.view.LayoutInflater
@ -8,6 +8,7 @@ import android.widget.EditText
import android.widget.ImageButton
import androidx.appcompat.app.AlertDialog
import androidx.fragment.app.Fragment
import com.p_vacho.neat_calendar.R
import com.p_vacho.neat_calendar.api.RetrofitClient
class ServerSettingsBarFragment : Fragment() {

View file

@ -1,4 +1,4 @@
package com.p_vacho.neat_calendar.auth
package com.p_vacho.neat_calendar.util.auth
import android.util.Log
import com.p_vacho.neat_calendar.api.RetrofitClient
@ -12,14 +12,14 @@ import com.google.gson.Gson
sealed class RegisterResult {
data class Success(val response: RegisterResponse) : RegisterResult()
data class ValidationError(val errorData: com.p_vacho.neat_calendar.auth.ValidationError) : RegisterResult()
data class ValidationError(val errorData: com.p_vacho.neat_calendar.util.auth.ValidationError) : RegisterResult()
data object UserAlreadyExists : RegisterResult()
data class UnknownError(val exception: Throwable) : RegisterResult()
}
sealed class LoginResult {
data object Success : LoginResult()
data class ValidationError(val errorData: com.p_vacho.neat_calendar.auth.ValidationError) : LoginResult()
data class ValidationError(val errorData: com.p_vacho.neat_calendar.util.auth.ValidationError) : LoginResult()
data class UnknownError(val exception: Throwable) : LoginResult()
}

View file

@ -1,4 +1,4 @@
package com.p_vacho.neat_calendar.auth
package com.p_vacho.neat_calendar.util.auth
/**
* Error data from HTTP 422 (Unprocessable entity) responses.

View file

@ -1,4 +1,4 @@
package com.p_vacho.neat_calendar.auth
package com.p_vacho.neat_calendar.util.auth
import android.content.Context
import android.content.SharedPreferences

View file

@ -6,12 +6,12 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ApiUnreachableActivity">
tools:context=".activities.ApiUnreachableActivity">
<!-- Include Server Settings Bar -->
<fragment
android:id="@+id/serverSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.ServerSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.fragments.ServerSettingsBarFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"

View file

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

View file

@ -6,12 +6,12 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginActivity">
tools:context=".activities.LoginActivity">
<!-- Include Server Settings Bar -->
<fragment
android:id="@+id/serverSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.ServerSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.fragments.ServerSettingsBarFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"

View file

@ -5,12 +5,12 @@
android:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RegisterActivity">
tools:context=".activities.RegisterActivity">
<!-- Include Server Settings Bar -->
<fragment
android:id="@+id/serverSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.ServerSettingsBarFragment"
android:name="com.p_vacho.neat_calendar.fragments.ServerSettingsBarFragment"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"

View file

@ -7,7 +7,7 @@
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:padding="8dp"
tools:context=".ServerSettingsBarFragment">
tools:context=".fragments.ServerSettingsBarFragment">
<!-- Title Text -->
<com.google.android.material.textview.MaterialTextView

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
</androidx.constraintlayout.widget.ConstraintLayout>