diff --git a/.gitignore b/.gitignore
index aa724b7..5e1c8e4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,15 +1,55 @@
-*.iml
-.gradle
-/local.properties
-/.idea/caches
-/.idea/libraries
-/.idea/modules.xml
-/.idea/workspace.xml
-/.idea/navEditor.xml
-/.idea/assetWizardSettings.xml
+*.pyc
+*.class
+*.o
+*.exe
+*.dll
+*.so
+*.a
+*.obj
+*.out
+node_modules/
+venv/
+.venv/
+__pycache__/
+dist/
+build/
+target/
+.gradle/
+.vscode/
+.idea/
+*.swp
+*.swo
+*.log
+*.tmp
.DS_Store
-/build
-/captures
-.externalNativeBuild
-.cxx
-local.properties
+Thumbs.db
+.env
+.env.local
+*.env.*
+.mypy_cache/
+.pytest_cache/
+coverage/
+htmlcov/
+.coverage
+*.zip
+*.gz
+*.tar
+*.tgz
+*.bz2
+*.xz
+*.7z
+*.rar
+*.zst
+*.lz4
+*.lzh
+*.cab
+*.arj
+*.rpm
+*.deb
+*.Z
+*.lz
+*.lzo
+*.tar.gz
+*.tar.bz2
+*.tar.xz
+*.tar.zst
\ No newline at end of file
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..81d5d4d
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+chatmessenger
\ No newline at end of file
diff --git a/.idea/AndroidProjectSystem.xml b/.idea/AndroidProjectSystem.xml
new file mode 100644
index 0000000..4a53bee
--- /dev/null
+++ b/.idea/AndroidProjectSystem.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/appInsightsSettings.xml b/.idea/appInsightsSettings.xml
new file mode 100644
index 0000000..777ac8a
--- /dev/null
+++ b/.idea/appInsightsSettings.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/caches/deviceStreaming.xml b/.idea/caches/deviceStreaming.xml
new file mode 100644
index 0000000..cbc8166
--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idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..7643783
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 0000000..79ee123
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fb7f4a8..b589d56 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml
new file mode 100644
index 0000000..c5b4371
--- /dev/null
+++ b/.idea/deploymentTargetSelector.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/deviceManager.xml b/.idea/deviceManager.xml
new file mode 100644
index 0000000..91f9558
--- /dev/null
+++ b/.idea/deviceManager.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index a2d7c21..5ef3273 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -4,9 +4,9 @@
-
-
+
+
diff --git a/.idea/markdown.xml b/.idea/markdown.xml
new file mode 100644
index 0000000..c61ea33
--- /dev/null
+++ b/.idea/markdown.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/migrations.xml b/.idea/migrations.xml
new file mode 100644
index 0000000..f8051a6
--- /dev/null
+++ b/.idea/migrations.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index bdd9278..8978d23 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,6 @@
-
-
+
diff --git a/.idea/navEditor.xml b/.idea/navEditor.xml
new file mode 100644
index 0000000..7075c6d
--- /dev/null
+++ b/.idea/navEditor.xml
@@ -0,0 +1,113 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
new file mode 100644
index 0000000..16660f1
--- /dev/null
+++ b/.idea/runConfigurations.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/google-services.json b/app/google-services.json
new file mode 100644
index 0000000..a166424
--- /dev/null
+++ b/app/google-services.json
@@ -0,0 +1,29 @@
+{
+ "project_info": {
+ "project_number": "645941872519",
+ "project_id": "pafoschat-97215",
+ "storage_bucket": "pafoschat-97215.firebasestorage.app"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:645941872519:android:532d1abbe4dc4d6cfb7522",
+ "android_client_info": {
+ "package_name": "com.example.chatmessenger"
+ }
+ },
+ "oauth_client": [],
+ "api_key": [
+ {
+ "current_key": "AIzaSyD-5ZleDlIp1UlCZcZO0IQCIZlpGeCL_3Y"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": []
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/chatmessenger/activities/SignUpActivity.kt b/app/src/main/java/com/example/chatmessenger/activities/SignUpActivity.kt
index 00cc75b..5194710 100644
--- a/app/src/main/java/com/example/chatmessenger/activities/SignUpActivity.kt
+++ b/app/src/main/java/com/example/chatmessenger/activities/SignUpActivity.kt
@@ -4,28 +4,22 @@ package com.example.chatmessenger.activities
import android.app.ProgressDialog
import android.content.Intent
-import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
+import android.util.Patterns
import android.widget.Toast
+import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.chatmessenger.R
import com.example.chatmessenger.databinding.ActivitySignUpBinding
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.firestore.FirebaseFirestore
-
-
class SignUpActivity : AppCompatActivity() {
lateinit var binding: ActivitySignUpBinding
- lateinit var pd : ProgressDialog
- lateinit var auth : FirebaseAuth
- lateinit var firestore : FirebaseFirestore
- lateinit var name: String
- lateinit var email: String
- lateinit var password: String
-
-
+ lateinit var pd: ProgressDialog
+ lateinit var auth: FirebaseAuth
+ lateinit var firestore: FirebaseFirestore
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -33,108 +27,99 @@ class SignUpActivity : AppCompatActivity() {
auth = FirebaseAuth.getInstance()
firestore = FirebaseFirestore.getInstance()
-
-
pd = ProgressDialog(this)
-
+ // Переход на экран входа
binding.signUpTextToSignIn.setOnClickListener {
-
startActivity(Intent(this, SignInActivity::class.java))
-
-
}
+ // Обработка регистрации
binding.signUpBtn.setOnClickListener {
+ validateAndRegister()
+ }
+ }
+ /**
+ * Валидация полей и запуск регистрации
+ */
+ private fun validateAndRegister() {
+ val name = binding.signUpEtName.text.toString().trim()
+ val email = binding.signUpEmail.text.toString().trim()
+ val password = binding.signUpPassword.text.toString()
+
+ // Валидация имени
+ if (name.isEmpty()) {
+ binding.signUpEtName.error = "Введите имя"
+ binding.signUpEtName.requestFocus()
+ return
+ }
- name = binding.signUpEtName.text.toString()
- email = binding.signUpEmail.text.toString()
- password = binding.signUpPassword.text.toString()
-
-
- if (binding.signUpEtName.text.isEmpty()){
-
- Toast.makeText(this, "Enter Name", Toast.LENGTH_SHORT).show()
-
-
- }
-
-
- if (binding.signUpEmail.text.isEmpty()){
-
- Toast.makeText(this, "Enter Email", Toast.LENGTH_SHORT).show()
-
-
- }
-
-
- if (binding.signUpPassword.text.isEmpty()){
-
- Toast.makeText(this, "Enter Password", Toast.LENGTH_SHORT).show()
-
-
- }
-
-
- if (binding.signUpEtName.text.isNotEmpty() && binding.signUpEmail.text.isNotEmpty() && binding.signUpPassword.text.isNotEmpty()){
-
-
- createAnAccount(name, password, email)
-
-
-
- }
-
-
-
-
+ // Валидация email (формат)
+ if (email.isEmpty()) {
+ binding.signUpEmail.error = "Введите email"
+ binding.signUpEmail.requestFocus()
+ return
+ }
+ if (!Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
+ binding.signUpEmail.error = "Введите корректный email"
+ binding.signUpEmail.requestFocus()
+ return
+ }
+ // Валидация пароля (минимум 8 символов)
+ if (password.isEmpty()) {
+ binding.signUpPassword.error = "Введите пароль"
+ binding.signUpPassword.requestFocus()
+ return
+ }
+ if (password.length < 8) {
+ binding.signUpPassword.error = "Пароль должен содержать минимум 8 символов"
+ binding.signUpPassword.requestFocus()
+ return
}
+ // Если все валидации пройдены — регистрируем
+ createAnAccount(name, password, email)
}
private fun createAnAccount(name: String, password: String, email: String) {
-
-
pd.show()
pd.setMessage("Registering User")
- auth.createUserWithEmailAndPassword(email, password).addOnCompleteListener {task->
-
- if (task.isSuccessful){
-
-
- val user = auth.currentUser
-
- val dataHashMap = hashMapOf("userid" to user!!.uid!!, "username" to name, "useremail" to email, "status" to "default",
- "imageUrl" to "https://www.pngarts.com/files/6/User-Avatar-in-Suit-PNG.png")
-
-
-
-
- firestore.collection("Users").document(user.uid).set(dataHashMap)
-
- pd.dismiss()
- startActivity(Intent(this, SignInActivity::class.java))
-
-
-
-
-
-
- }
-
-
-
-
-
- }
-
-
-
+ auth.createUserWithEmailAndPassword(email, password)
+ .addOnCompleteListener { task ->
+ pd.dismiss()
+
+ if (task.isSuccessful) {
+ val user = auth.currentUser
+ user?.let {
+ val dataHashMap = hashMapOf(
+ "userid" to it.uid,
+ "username" to name,
+ "useremail" to email,
+ "status" to "default",
+ "imageUrl" to "https://openclipart.org/image/2000px/247320"
+ )
+
+ firestore.collection("Users")
+ .document(it.uid)
+ .set(dataHashMap)
+ .addOnSuccessListener {
+ Toast.makeText(this, "Регистрация успешна!", Toast.LENGTH_SHORT).show()
+ startActivity(Intent(this, SignInActivity::class.java))
+ finish()
+ }
+ .addOnFailureListener { e ->
+ Toast.makeText(this, "Ошибка сохранения данных: ${e.message}", Toast.LENGTH_SHORT).show()
+ }
+ }
+ } else {
+ Toast.makeText(this, "Ошибка регистрации: ${task.exception?.message}", Toast.LENGTH_SHORT).show()
+ }
+ }
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/com/example/chatmessenger/fragments/HomeFragment.kt b/app/src/main/java/com/example/chatmessenger/fragments/HomeFragment.kt
index 1e922be..61333cc 100644
--- a/app/src/main/java/com/example/chatmessenger/fragments/HomeFragment.kt
+++ b/app/src/main/java/com/example/chatmessenger/fragments/HomeFragment.kt
@@ -13,6 +13,9 @@ import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
+import android.text.Editable
+import android.text.TextWatcher
+import android.widget.EditText
import android.widget.ImageView
import android.widget.Toast
import androidx.activity.OnBackPressedCallback
@@ -53,6 +56,8 @@ class HomeFragment : Fragment(), OnItemClickListener, onChatClicked {
lateinit var recentadapter : RecentChatAdapter
lateinit var firestore : FirebaseFirestore
lateinit var binding: FragmentHomeBinding
+ lateinit var etSearchUsers: EditText
+ private var allUsers = listOf()
override fun onCreateView(
@@ -126,6 +131,7 @@ class HomeFragment : Fragment(), OnItemClickListener, onChatClicked {
rvUsers = view.findViewById(R.id.rvUsers)
rvRecentChats = view.findViewById(R.id.rvRecentChats)
+ etSearchUsers = view.findViewById(R.id.etSearchUsers)
adapter = UserAdapter()
recentadapter = RecentChatAdapter()
@@ -139,6 +145,7 @@ class HomeFragment : Fragment(), OnItemClickListener, onChatClicked {
viewModel.getUsers().observe(viewLifecycleOwner, Observer {
+ allUsers = it
adapter.setList(it)
rvUsers.adapter = adapter
@@ -175,10 +182,22 @@ class HomeFragment : Fragment(), OnItemClickListener, onChatClicked {
recentadapter.setOnChatClickListener(this)
-
-
-
-
+ // Поиск по пользователям
+ etSearchUsers.addTextChangedListener(object : TextWatcher {
+ override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
+ override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
+ override fun afterTextChanged(s: Editable?) {
+ val query = s.toString().trim()
+ if (query.isEmpty()) {
+ adapter.setList(allUsers)
+ } else {
+ val filteredList = allUsers.filter { user ->
+ user.username?.contains(query, ignoreCase = true) == true
+ }
+ adapter.setList(filteredList)
+ }
+ }
+ })
}
diff --git a/app/src/main/java/com/example/chatmessenger/mvvm/ChatAppViewModel.kt b/app/src/main/java/com/example/chatmessenger/mvvm/ChatAppViewModel.kt
index ccfb763..fd9a99f 100644
--- a/app/src/main/java/com/example/chatmessenger/mvvm/ChatAppViewModel.kt
+++ b/app/src/main/java/com/example/chatmessenger/mvvm/ChatAppViewModel.kt
@@ -72,10 +72,18 @@ class ChatAppViewModel : ViewModel() {
val context = MyApplication.instance.applicationContext
+ // Проверка на пустое сообщение
+ if (message.value.isNullOrBlank()) {
+ withContext(Dispatchers.Main) {
+ Toast.makeText(context, "Message cannot be empty", Toast.LENGTH_SHORT).show()
+ }
+ return@launch
+ }
+
val hashMap = hashMapOf(
"sender" to sender,
"receiver" to receiver,
- "message" to message.value!!,
+ "message" to message.value!!.trim(),
"time" to Utils.getTime()
)
diff --git a/app/src/main/res/drawable/chatapp.png b/app/src/main/res/drawable/chatapp.png
index 77a344a..55524a3 100644
Binary files a/app/src/main/res/drawable/chatapp.png and b/app/src/main/res/drawable/chatapp.png differ
diff --git a/app/src/main/res/drawable/logout.xml b/app/src/main/res/drawable/logout.xml
index 5098741..cbd9fd0 100644
--- a/app/src/main/res/drawable/logout.xml
+++ b/app/src/main/res/drawable/logout.xml
@@ -1,5 +1,12 @@
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/offlinestatus.xml b/app/src/main/res/drawable/offlinestatus.xml
index 06acd7d..bb6b304 100644
--- a/app/src/main/res/drawable/offlinestatus.xml
+++ b/app/src/main/res/drawable/offlinestatus.xml
@@ -1,5 +1,9 @@
-
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/onlinestatus.xml b/app/src/main/res/drawable/onlinestatus.xml
index f974995..ef1d164 100644
--- a/app/src/main/res/drawable/onlinestatus.xml
+++ b/app/src/main/res/drawable/onlinestatus.xml
@@ -1,5 +1,13 @@
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/person.xml b/app/src/main/res/drawable/person.xml
index 98730cd..62bfd35 100644
--- a/app/src/main/res/drawable/person.xml
+++ b/app/src/main/res/drawable/person.xml
@@ -1,5 +1,5 @@
-
-
+
diff --git a/app/src/main/res/drawable/rounded_rectangle_primary.xml b/app/src/main/res/drawable/rounded_rectangle_primary.xml
index bd3db96..d2a460c 100644
--- a/app/src/main/res/drawable/rounded_rectangle_primary.xml
+++ b/app/src/main/res/drawable/rounded_rectangle_primary.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/app/src/main/res/drawable/rounded_rectangle_secondary.xml b/app/src/main/res/drawable/rounded_rectangle_secondary.xml
index 2336d93..2c77abb 100644
--- a/app/src/main/res/drawable/rounded_rectangle_secondary.xml
+++ b/app/src/main/res/drawable/rounded_rectangle_secondary.xml
@@ -2,7 +2,7 @@
-
+
diff --git a/app/src/main/res/drawable/send.xml b/app/src/main/res/drawable/send.xml
new file mode 100644
index 0000000..81f5d5e
--- /dev/null
+++ b/app/src/main/res/drawable/send.xml
@@ -0,0 +1,12 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/user.png b/app/src/main/res/drawable/user.png
new file mode 100644
index 0000000..bae8416
Binary files /dev/null and b/app/src/main/res/drawable/user.png differ
diff --git a/app/src/main/res/layout/activity_sign_in.xml b/app/src/main/res/layout/activity_sign_in.xml
index b589dc3..8db0fca 100644
--- a/app/src/main/res/layout/activity_sign_in.xml
+++ b/app/src/main/res/layout/activity_sign_in.xml
@@ -4,54 +4,58 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
-
-
+ android:layout_height="match_parent"
+ android:background="#000000">
+
-
-
+
+
+
+ android:textColorHint="@color/purple_200"
+ app:boxBackgroundColor="@android:color/transparent"
+ app:boxStrokeColor="@color/purple_200">
+ android:textColorHint="@color/purple_200"
+ app:boxBackgroundColor="@android:color/transparent"
+ app:boxStrokeColor="@color/purple_200">
-
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_sign_up.xml b/app/src/main/res/layout/activity_sign_up.xml
index 8cbada5..275cb31 100644
--- a/app/src/main/res/layout/activity_sign_up.xml
+++ b/app/src/main/res/layout/activity_sign_up.xml
@@ -1,139 +1,148 @@
-
+
-
-
-
+ android:background="#000000">
+
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
+ android:layout_margin="10dp"
+ android:background="@android:color/transparent"
+ android:textColorHint="@color/purple_200"
+ app:boxBackgroundColor="@android:color/transparent"
+ app:boxStrokeColor="@color/purple_200">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
diff --git a/app/src/main/res/layout/chatitemleft.xml b/app/src/main/res/layout/chatitemleft.xml
index 413c261..ad1486e 100644
--- a/app/src/main/res/layout/chatitemleft.xml
+++ b/app/src/main/res/layout/chatitemleft.xml
@@ -1,7 +1,7 @@
-
-
+
-
+ android:visibility="visible" />
+
+ android:layout_weight="1"
+ android:fontFamily="@font/nunito"
+ android:text="14:00"
+ android:textColor="#FFFFFF"
+ android:textStyle="italic" />
diff --git a/app/src/main/res/layout/chatitemright.xml b/app/src/main/res/layout/chatitemright.xml
index 3ed6ef3..fda8f6c 100644
--- a/app/src/main/res/layout/chatitemright.xml
+++ b/app/src/main/res/layout/chatitemright.xml
@@ -1,6 +1,6 @@
-
-
+
-
+ android:text="14:00"
+ android:textColor="#FFFFFF"
+ android:textStyle="italic" />
-
+
@@ -11,134 +13,125 @@
-
-
-
-
-
-
-
+ android:layout_height="match_parent"
+ android:background="#000000">
-
-
+ android:background="@color/midnightblue">
-
+
-
-
-
-
-
+ android:orientation="horizontal"
+ android:padding="5dp">
+
-
+
-
+
-
-
-
+
+
+
+
+
-
-
-
-
-
-
+ android:layout_alignParentBottom="true"
+ android:background="@color/black"
+ android:minHeight="48dp"
+ android:orientation="horizontal">
+
+
+
+
-
+
diff --git a/app/src/main/res/layout/fragment_chatfrom_home.xml b/app/src/main/res/layout/fragment_chatfrom_home.xml
index fca5220..dae5c88 100644
--- a/app/src/main/res/layout/fragment_chatfrom_home.xml
+++ b/app/src/main/res/layout/fragment_chatfrom_home.xml
@@ -1,6 +1,8 @@
-
+
@@ -11,11 +13,10 @@
-
+ android:layout_height="match_parent"
+ android:background="#000000">
+ android:layout_marginEnd="10dp"
+ android:src="@drawable/back" />
-
+ android:orientation="horizontal"
+ android:padding="5dp">
+ app:civ_border_color="#00FE2C54"
+ app:civ_border_width="2dp" />
-
+ android:textSize="18sp" />
-
-
-
+ android:textSize="16sp" />
-
-
-
+ android:background="#000000" />
@@ -119,25 +112,25 @@
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
- android:text="@={viewModel.message}"
android:background="@android:color/transparent"
android:hint="Enter Message"
android:importantForAutofill="no"
android:inputType="textMultiLine"
- android:maxLines="6" />
+ android:maxLines="6"
+ android:text="@={viewModel.message}"
+ android:textColor="#FFFFFF"
+ android:textColorHint="@color/purple_200" />
-
+ android:layout_width="48dp"
+ android:layout_height="48dp"
+ android:background="?attr/selectableItemBackgroundBorderless"
+ android:contentDescription="@string/send_message"
+ android:src="@drawable/send" />
-
diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml
index da6bd81..06b52a1 100644
--- a/app/src/main/res/layout/fragment_home.xml
+++ b/app/src/main/res/layout/fragment_home.xml
@@ -1,106 +1,116 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_marginTop="10dp"
+ android:layout_marginRight="10dp"
+ app:cardBackgroundColor="@color/purple_700"
+ app:cardCornerRadius="20dp"
+ app:cardElevation="8dp">
-
+
-
+
+
-
+
+
-
+
-
+
+
-
+
diff --git a/app/src/main/res/layout/fragment_setting.xml b/app/src/main/res/layout/fragment_setting.xml
index 7bd202a..9e3f8d2 100644
--- a/app/src/main/res/layout/fragment_setting.xml
+++ b/app/src/main/res/layout/fragment_setting.xml
@@ -1,5 +1,7 @@
-
+
@@ -14,127 +16,121 @@
-
-
-
+ android:background="#000000">
-
-
+ android:layout_height="match_parent"
+ android:orientation="vertical"
+ >
-
+
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ android:gravity="start"
+ android:text="Update Your Profile"
+ android:textColor="#FFFFFF"
+ android:textSize="25sp"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="parent"
+ app:layout_constraintTop_toTopOf="parent" />
+
+
+
+
+
+
+
+
+
+
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/recentchatlist.xml b/app/src/main/res/layout/recentchatlist.xml
index 2d2e9da..e721191 100644
--- a/app/src/main/res/layout/recentchatlist.xml
+++ b/app/src/main/res/layout/recentchatlist.xml
@@ -1,11 +1,11 @@
-
+ android:layout_margin="4dp"
+ app:cardBackgroundColor="#000000"
+ app:cardCornerRadius="12dp">
+ app:layout_constraintTop_toTopOf="parent" />
+ app:layout_constraintTop_toTopOf="@+id/recentChatImageView" />
+ app:layout_constraintTop_toTopOf="@+id/recentChatImageView" />
+ android:layout_marginBottom="8dp"
+ android:fontFamily="@font/nunito"
+ android:text="Last Message"
+ android:textColor="#F8F7F7"
+ android:textSize="16sp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintStart_toEndOf="@+id/recentChatImageView"
+ app:layout_constraintTop_toBottomOf="@+id/recentChatTextName" />
diff --git a/app/src/main/res/layout/userlistitem.xml b/app/src/main/res/layout/userlistitem.xml
index b59a984..64b1149 100644
--- a/app/src/main/res/layout/userlistitem.xml
+++ b/app/src/main/res/layout/userlistitem.xml
@@ -1,39 +1,51 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@+id/avatarContainer"
+ android:layout_marginTop="4dp"
+ android:ellipsize="end"
+ android:fontFamily="@font/nunito_bold"
+ android:gravity="center_horizontal"
+ android:maxLines="1"
+ android:text="User name"
+ android:textColor="#FFFFFF"
+ android:textColorHighlight="#FFFFFF" />
\ No newline at end of file
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 4d591d8..ff4be91 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -1,11 +1,11 @@
- #FFBB86FC
- #FF6200EE
- #FF3700B3
- #FF03DAC5
- #FF018786
- #FF000000
- #FFFFFFFF
- #191970
+ #686868
+ #3A3A3A
+ #050505
+ #4CAF50
+ #8BC34A
+ #000000
+ #282525
+ #242424
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 5cdd3e6..5502127 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,5 +1,5 @@
- Samchat
-
+ PafosChat
Hello blank fragment
+ Send
\ No newline at end of file
diff --git a/local.properties b/local.properties
new file mode 100644
index 0000000..8961987
--- /dev/null
+++ b/local.properties
@@ -0,0 +1,8 @@
+## This file must *NOT* be checked into Version Control Systems,
+# as it contains information specific to your local configuration.
+#
+# Location of the SDK. This is only used by Gradle.
+# For customization when using a Version Control System, please read the
+# header note.
+#Fri Apr 10 09:14:05 MSK 2026
+sdk.dir=C\:\\Users\\egori\\AppData\\Local\\Android\\Sdk