Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Add: Message Encryption and Decryption added" #255

Merged
merged 1 commit into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 0 additions & 76 deletions TalkIn/app/src/main/java/com/example/talk_in/AESUtils.java

This file was deleted.

8 changes: 4 additions & 4 deletions TalkIn/app/src/main/java/com/example/talk_in/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class ChatActivity : AppCompatActivity() {
if (!replyMessage.isNullOrEmpty() && intent.getBooleanExtra("fromNotification", false)) {
// If a reply message is received from notification, send it to the receiver
isReplyingFromNotification = true
val messageObject = Message(AESUtils.encrypt(replyMessage), senderUid, System.currentTimeMillis())
val messageObject = Message(replyMessage, senderUid, System.currentTimeMillis())
sendMessage(messageObject)
}

Expand All @@ -117,7 +117,7 @@ class ChatActivity : AppCompatActivity() {
sendButton.setOnClickListener {
val messageText = messageBox.text.toString().trim()
if (messageText.isNotEmpty()) {
val messageObject = Message(AESUtils.encrypt(messageText), senderUid, System.currentTimeMillis())
val messageObject = Message(messageText, senderUid, System.currentTimeMillis())
sendMessage(messageObject)
messageBox.setText("")
}
Expand Down Expand Up @@ -176,7 +176,7 @@ class ChatActivity : AppCompatActivity() {
messageList.clear()
var currentDate: String? = null
for (postSnapshot in snapshot.children) {
var message = postSnapshot.getValue(Message::class.java)
val message = postSnapshot.getValue(Message::class.java)
message?.let {
// Get the date from the timestamp
val date = getDateFromTimestamp(it.timestamp ?: 0L)
Expand Down Expand Up @@ -285,4 +285,4 @@ class ChatActivity : AppCompatActivity() {
currentChatUser = null
isActive = false
}
}
}
4 changes: 2 additions & 2 deletions TalkIn/app/src/main/java/com/example/talk_in/Message.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.example.talk_in

data class Message(
var message: String? = null,
val message: String? = null,
val senderId: String? = null,
val timestamp: Long? = null,
val isDateSection: Boolean = false
)
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.example.talk_in

import android.content.Context
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
Expand All @@ -12,7 +11,7 @@ import java.text.SimpleDateFormat
import java.util.*

class MessageAdapter(private val context: Context, private var messageList: ArrayList<Message>) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
RecyclerView.Adapter<RecyclerView.ViewHolder>() {

private val ITEM_RECEIVE = 1
private val ITEM_SENT = 2
Expand Down Expand Up @@ -55,11 +54,11 @@ class MessageAdapter(private val context: Context, private var messageList: Arra

when (holder) {
is SentViewHolder -> {
holder.sentMessage.text = AESUtils.decrypt(currentMessage.message.toString())
holder.sentMessage.text = currentMessage.message
holder.sendTimestamp.text = formattedTime
}
is ReceiveViewHolder -> {
holder.receiveMessage.text = AESUtils.decrypt(currentMessage.message.toString())
holder.receiveMessage.text = currentMessage.message
holder.receiveTimestamp.text = formattedTime
}
}
Expand Down Expand Up @@ -90,4 +89,4 @@ class MessageAdapter(private val context: Context, private var messageList: Arra
class DateViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val dateTextView: TextView = itemView.findViewById(R.id.date_section_text)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class UserAdapter(val context: Context, val userList: ArrayList<User>) :
override fun onDataChange(snapshot: DataSnapshot) {
if (snapshot.exists()) {
val lastMessage = snapshot.children.first().getValue(Message::class.java)
holder.txt_last_message.setText(AESUtils.decrypt(lastMessage?.message.toString()))
holder.txt_last_message.setText(lastMessage?.message.toString())
}
else{
var aboutUser = currentUser.aboutMe.toString().trim()
Expand Down