diff options
author | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-05 07:15:23 +0100 |
---|---|---|
committer | Jelena Petrovic <jelenapetrovic.7119@gmail.com> | 2022-12-05 07:15:23 +0100 |
commit | a18cd1c5439780e84fa983b62cdaef8445df4542 (patch) | |
tree | d075065abec39b9a635ca41a62130373ad40d77b | |
parent | 9d9a6b56dcbfe5d1a1f1ad9ea61b28c59fb603a2 (diff) |
Prepravljen izgled četa i liste četova, omogućeno vraćanje na pritisak dugmeta u uglu ekrana, dodat prikaz zadnje poruke i njenog datuma/vremena u listi četova #70
14 files changed, 408 insertions, 244 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml b/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml index 2241c80..4555917 100644 --- a/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml +++ b/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml @@ -56,7 +56,7 @@ android:name=".Activities.ChatActivityConversation" android:exported="false" android:screenOrientation="portrait" - android:windowSoftInputMode="stateVisible|adjustPan"> + android:windowSoftInputMode="stateAlwaysHidden|adjustResize"> <meta-data android:name="android.app.lib_name" android:value="" /> diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivity.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivity.kt index 951cbb4..14a4ba5 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivity.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivity.kt @@ -20,6 +20,7 @@ import com.example.brzodolokacije.Services.SharedPreferencesHelper import com.example.brzodolokacije.chat.SignalRListener import com.example.brzodolokacije.databinding.ActivityChatBinding import retrofit2.Call +import retrofit2.Callback import retrofit2.Response import java.util.* @@ -64,6 +65,9 @@ class ChatActivity : AppCompatActivity(), SwipeRefreshLayout.OnRefreshListener { intent.putExtra("receiverId","") startActivity(intent) } + findViewById<ImageButton>(R.id.btnBack).setOnClickListener { + finish() + } } fun requestForChats(){ @@ -77,7 +81,7 @@ class ChatActivity : AppCompatActivity(), SwipeRefreshLayout.OnRefreshListener { val api=RetrofitHelper.getInstance() val token=SharedPreferencesHelper.getValue("jwt",this@ChatActivity) val request2=api?.getNewMessages("Bearer "+token) - request2?.enqueue(object : retrofit2.Callback<MutableList<MessageReceive>?> { + request2?.enqueue(object : Callback<MutableList<MessageReceive>?> { override fun onResponse(call: Call<MutableList<MessageReceive>?>, response: Response<MutableList<MessageReceive>?>) { if(response.isSuccessful()){ var messages=response.body() diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivityConversation.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivityConversation.kt index 19fd836..985735f 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivityConversation.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ChatActivityConversation.kt @@ -1,5 +1,6 @@ package com.example.brzodolokacije.Activities +import android.graphics.Bitmap import android.os.Bundle import android.util.Log import android.view.View @@ -37,6 +38,7 @@ class ChatActivityConversation : AppCompatActivity() { var dbConnection: DBHelper?=null var webSocketConnection:SignalRListener?=null var items:MutableList<Message>?=mutableListOf() + var userImage:Bitmap?=null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -44,6 +46,7 @@ class ChatActivityConversation : AppCompatActivity() { setContentView(binding.root) userId=intent.extras?.get("userId").toString() receiverUsername=intent.extras?.get("username").toString() + userImage=intent.extras?.get("pfp") as Bitmap? dbConnection=DBHelper.getInstance(this@ChatActivityConversation) setHeader() setRecyclerView() @@ -56,85 +59,89 @@ class ChatActivityConversation : AppCompatActivity() { private fun setListeners() { findViewById<ImageButton>(R.id.btnSendMessage).setOnClickListener { var token=SharedPreferencesHelper.getValue("jwt",this@ChatActivityConversation) - var messageContent=findViewById<EditText>(R.id.etNewMessage).text.toString() + var messageContent=findViewById<EditText>(R.id.etNewMessage).text.trim().toString() val Api= RetrofitHelper.getInstance() - if(userId.isNullOrEmpty() || userId.equals("null")){ - //zahtev sa username=om - receiverUsername=findViewById<EditText>(R.id.etReceiverUsername).text.toString() - val request=Api.getProfile("Bearer "+token, - receiverUsername!! - ) - request.enqueue(object : retrofit2.Callback<UserReceive?> { - override fun onResponse(call: Call<UserReceive?>, response: Response<UserReceive?>) { - if(response.isSuccessful()){ - //zahtev da se posalje poruka - userId=response.body()?._id - setHeader() - var message= MessageSend(userId!!,messageContent) - val request2=Api.sendMessage("Bearer "+token, - message - ) - request2.enqueue(object : retrofit2.Callback<Message?> { - override fun onResponse(call: Call<Message?>, response: Response<Message?>) { - if(response.isSuccessful()){ - //zahtev da se posalje poruka - var responseMessage=response.body() - var cal: Calendar = Calendar.getInstance() - cal.time=responseMessage?.timestamp - responseMessage?.usableTimeStamp=cal - dbConnection?.addMessage(responseMessage!!) - requestMessages() - binding.etNewMessage.text?.clear() + if(!messageContent.isNullOrEmpty()){ + if(userId.isNullOrEmpty() || userId.equals("null")){ + //zahtev sa username=om + receiverUsername=findViewById<EditText>(R.id.etReceiverUsername).text.toString() + val request=Api.getProfile("Bearer "+token, + receiverUsername!! + ) + request.enqueue(object : retrofit2.Callback<UserReceive?> { + override fun onResponse(call: Call<UserReceive?>, response: Response<UserReceive?>) { + if(response.isSuccessful()){ + //zahtev da se posalje poruka + var user:UserReceive=response.body()!! + userId=user._id + setHeader() + var message= MessageSend(userId!!,messageContent) + val request2=Api.sendMessage("Bearer "+token, + message + ) + request2.enqueue(object : retrofit2.Callback<Message?> { + override fun onResponse(call: Call<Message?>, response: Response<Message?>) { + if(response.isSuccessful()){ + //zahtev da se posalje poruka + var responseMessage=response.body() + var cal: Calendar = Calendar.getInstance() + cal.time=responseMessage?.timestamp + responseMessage?.usableTimeStamp=cal + dbConnection?.addMessage(responseMessage!!,username=user.username) + requestMessages() + binding.etNewMessage.text?.clear() + } + else{ + Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime1.",Toast.LENGTH_LONG).show() + } } - else{ - Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime1.",Toast.LENGTH_LONG).show() + + override fun onFailure(call: Call<Message?>, t: Throwable) { + Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime2.",Toast.LENGTH_LONG).show() } - } + }) + } + else{ + Log.d("main",response.message()) + //Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime3.",Toast.LENGTH_LONG).show() + } + } - override fun onFailure(call: Call<Message?>, t: Throwable) { - Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime2.",Toast.LENGTH_LONG).show() - } - }) + override fun onFailure(call: Call<UserReceive?>, t: Throwable) { + Toast.makeText(this@ChatActivityConversation,"fail.",Toast.LENGTH_LONG).show() } - else{ - Log.d("main",response.message()) - //Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime3.",Toast.LENGTH_LONG).show() + }) + } + else{ + //zahtev da se posalje poruka + var message= MessageSend(userId!!,messageContent) + val request2=Api.sendMessage("Bearer "+token, + message + ) + request2.enqueue(object : retrofit2.Callback<Message?> { + override fun onResponse(call: Call<Message?>, response: Response<Message?>) { + if(response.isSuccessful()){ + //zahtev da se posalje poruka + var responseMessage=response.body() + var cal: Calendar = Calendar.getInstance() + cal.time=responseMessage?.timestamp + responseMessage?.usableTimeStamp=cal + dbConnection?.addMessage(responseMessage!!,username=receiverUsername) + requestMessages() + binding.etNewMessage.text?.clear() + } + else{ + Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime.",Toast.LENGTH_LONG).show() + } } - } - override fun onFailure(call: Call<UserReceive?>, t: Throwable) { - Toast.makeText(this@ChatActivityConversation,"fail.",Toast.LENGTH_LONG).show() - } - }) - } - else{ - //zahtev da se posalje poruka - var message= MessageSend(userId!!,messageContent) - val request2=Api.sendMessage("Bearer "+token, - message - ) - request2.enqueue(object : retrofit2.Callback<Message?> { - override fun onResponse(call: Call<Message?>, response: Response<Message?>) { - if(response.isSuccessful()){ - //zahtev da se posalje poruka - var responseMessage=response.body() - var cal: Calendar = Calendar.getInstance() - cal.time=responseMessage?.timestamp - responseMessage?.usableTimeStamp=cal - dbConnection?.addMessage(responseMessage!!) - requestMessages() - binding.etNewMessage.text?.clear() - } - else{ + override fun onFailure(call: Call<Message?>, t: Throwable) { Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime.",Toast.LENGTH_LONG).show() } - } + }) + } - override fun onFailure(call: Call<Message?>, t: Throwable) { - Toast.makeText(this@ChatActivityConversation,"Pogresno korisnicko ime.",Toast.LENGTH_LONG).show() - } - }) } } @@ -144,19 +151,24 @@ class ChatActivityConversation : AppCompatActivity() { if(userId.isNullOrEmpty() || userId.equals("null")){ binding.cvParentUsername.visibility= View.VISIBLE binding.cvParentUsername.forceLayout() - binding.tvFragmentTitle.visibility= View.GONE - binding.tvFragmentTitle.invalidate() - binding.tvFragmentTitle.forceLayout() + binding.llHeader.visibility= View.GONE + binding.llHeader.invalidate() + binding.llHeader.forceLayout() } else{ - binding.tvFragmentTitle.visibility= View.VISIBLE - binding.tvFragmentTitle.invalidate() - binding.tvFragmentTitle.forceLayout() + binding.llHeader.visibility= View.VISIBLE + binding.llHeader.invalidate() + binding.llHeader.forceLayout() binding.tvFragmentTitle.text=receiverUsername binding.tvFragmentTitle.invalidate() binding.cvParentUsername.visibility= View.GONE binding.cvParentUsername.forceLayout() } + binding.btnBack.setOnClickListener { + finish() + } + if(userImage!=null) + binding.ivUserImage.setImageBitmap(userImage) } fun setRecyclerView(setParams:Boolean=true){ MainScope().launch { @@ -173,6 +185,7 @@ class ChatActivityConversation : AppCompatActivity() { } catch (e: Exception) { Log.d("error", e.message!!) } + recyclerView?.addOnLayoutChangeListener { _, i, i2, i3, i4, i5, i6, i7, i8 -> recyclerView?.scrollToPosition(items?.size?.minus(1) ?: 0) } recyclerView?.scrollToPosition(items?.size?.minus(1) ?: 0) } } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ChatPreviewsAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ChatPreviewsAdapter.kt index 6e62180..be564f4 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ChatPreviewsAdapter.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ChatPreviewsAdapter.kt @@ -5,6 +5,8 @@ import android.graphics.Typeface import android.view.LayoutInflater import android.view.ViewGroup import android.widget.Toast +import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.toBitmap import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide import com.exam.DBHelper @@ -13,12 +15,14 @@ import com.example.brzodolokacije.Activities.ChatActivityConversation import com.example.brzodolokacije.Interfaces.IBackendApi import com.example.brzodolokacije.Models.ChatPreview import com.example.brzodolokacije.Models.UserReceive +import com.example.brzodolokacije.R import com.example.brzodolokacije.Services.RetrofitHelper import com.example.brzodolokacije.Services.SharedPreferencesHelper import com.example.brzodolokacije.databinding.ChatPreviewBinding import kotlinx.android.synthetic.main.chat_preview.view.* import retrofit2.Call import retrofit2.Response +import java.util.* class ChatPreviewsAdapter (val items : MutableList<ChatPreview>,val activity:ChatActivity) : RecyclerView.Adapter<ChatPreviewsAdapter.ViewHolder>(){ @@ -42,6 +46,7 @@ class ChatPreviewsAdapter (val items : MutableList<ChatPreview>,val activity:Cha val intent: Intent = Intent(activity, ChatActivityConversation::class.java) intent.putExtra("userId",items[position].userId) intent.putExtra("username",holder.itemView.tvUsername.text) + intent.putExtra("pfp",holder.itemView.ivUserImage.drawable.toBitmap(200,200)) db.readContact(items[position].userId) items[position].read=true holder.itemView.tvUsername.typeface= Typeface.DEFAULT @@ -61,11 +66,12 @@ class ChatPreviewsAdapter (val items : MutableList<ChatPreview>,val activity:Cha //zahtev da se posalje poruka var user=response.body()!! if(!item.read) - tvUsername.typeface= Typeface.DEFAULT_BOLD + setUnread() tvUsername.text=user.username if(user.pfp!=null) { Glide.with(activity) .load(RetrofitHelper.baseUrl + "/api/post/image/" + user.pfp!!._id) + .circleCrop() .into(ivUserImage) } } @@ -81,7 +87,41 @@ class ChatPreviewsAdapter (val items : MutableList<ChatPreview>,val activity:Cha Toast.LENGTH_LONG).show() } }) + var lastMessage=db.getLastMessage(item.userId) + tvUsername.text=item.username + if(lastMessage!=null){ + tvLastMessage.text=lastMessage.messagge + if(layoutPosition==0 || isDifferentDays(lastMessage.usableTimeStamp,Calendar.getInstance())){ + tvLastMessageDate.text=lastMessage.usableTimeStamp.get(Calendar.HOUR_OF_DAY).toString() + ":" + lastMessage.usableTimeStamp.get( + Calendar.MINUTE).toString() + } + else{ + tvLastMessageDate.text=lastMessage.usableTimeStamp.get(Calendar.DAY_OF_MONTH).toString()+"/"+ + (lastMessage.usableTimeStamp.get(Calendar.MONTH)+1).toString()+"/"+ + lastMessage.usableTimeStamp.get(Calendar.YEAR).toString() + } + + } } } + fun isDifferentDays(c1:Calendar,c2:Calendar):Boolean{ + if(c1.get(Calendar.DAY_OF_YEAR)!=c2.get(Calendar.DAY_OF_YEAR)){ + return true + } + else if(c1.get(Calendar.YEAR)!=c2.get(Calendar.YEAR)){ + return true + } + return false + } + fun setUnread(){ + itemView.tvUsername.typeface= Typeface.DEFAULT_BOLD + itemView.tvUsername.invalidate() + itemView.tvLastMessage.typeface= Typeface.DEFAULT_BOLD + itemView.tvLastMessage.invalidate() + itemView.tvLastMessageDate.typeface= Typeface.DEFAULT_BOLD + itemView.tvLastMessageDate.invalidate() + itemView.readIndicator.background= ContextCompat.getDrawable(activity,R.color.dark_blue_transparent) + itemView.readIndicator.invalidate() + } } }
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Chat.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Chat.kt index 6725c15..f3af84c 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Chat.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Chat.kt @@ -24,5 +24,6 @@ data class Message( data class ChatPreview( var userId:String, - var read:Boolean + var read:Boolean, + var username:String )
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/chat/DBHelper.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/chat/DBHelper.kt index a3d5a13..041eebb 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/chat/DBHelper.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/chat/DBHelper.kt @@ -9,6 +9,11 @@ import android.database.sqlite.SQLiteOpenHelper import android.util.Log import com.example.brzodolokacije.Models.ChatPreview import com.example.brzodolokacije.Models.Message +import com.example.brzodolokacije.Models.UserReceive +import com.example.brzodolokacije.Services.RetrofitHelper +import com.example.brzodolokacije.Services.SharedPreferencesHelper +import retrofit2.Call +import retrofit2.Response import java.util.* @@ -17,7 +22,7 @@ class DBHelper : var db:SQLiteDatabase?=null - constructor(context: Context, factory: SQLiteDatabase.CursorFactory?):super(context, DATABASE_NAME, factory,3){ + constructor(context: Context, factory: SQLiteDatabase.CursorFactory?):super(context, DATABASE_NAME, factory,5){ db=readableDatabase } @@ -28,8 +33,10 @@ class DBHelper : //database tables val CONTACTS_TABLE_NAME = "contacts" val MESSAGES_TABLE_NAME = "messages" + var activity:Activity?=null private var instance:DBHelper?=null fun getInstance(activity: Activity):DBHelper{ + this.activity =activity if(instance==null){ instance= DBHelper(activity,null) } @@ -41,7 +48,8 @@ class DBHelper : if(!doesTableExist(CONTACTS_TABLE_NAME,db)){ var sql:String="CREATE TABLE "+ CONTACTS_TABLE_NAME+" (" + "userId " +"TEXT PRIMARY KEY,"+ - "read " +"INTEGER"+ + "read " +"INTEGER,"+ + "username "+"TEXT"+ ")" db?.execSQL(sql) } @@ -77,7 +85,7 @@ class DBHelper : onCreate(db) } - fun addMessage(message: Message, sent:Boolean=true){ + fun addMessage(message: Message, sent:Boolean=true,username:String?=null){ onCreate(db) if(!message._id.isNullOrEmpty() && message.senderId==message.receiverId){ Log.d("main", "ne zapisuje se dupla poruka") @@ -101,9 +109,41 @@ class DBHelper : var id:String id = if(sent) message.receiverId else message.senderId var read:Int=if(sent) 1 else 0 - sql="INSERT INTO "+ CONTACTS_TABLE_NAME+"(userId,read) VALUES('"+id+"','"+ - read+"')" - db?.execSQL(sql) + if(username==null){ + //request + var api=RetrofitHelper.getInstance() + var token= activity?.let { SharedPreferencesHelper.getValue("jwt", it) } + val request2=api.getProfileFromId("Bearer "+token, + message.senderId + ) + request2?.enqueue(object : retrofit2.Callback<UserReceive?> { + override fun onResponse(call: Call<UserReceive?>, response: Response<UserReceive?>) { + if(response.isSuccessful()){ + var user=response.body()!! + sql="INSERT INTO "+ CONTACTS_TABLE_NAME+"(userId,read,username) VALUES('"+id+"','"+ + read+"','"+user.username+"')" + db?.execSQL(sql) + } + else{ + sql="INSERT INTO "+ CONTACTS_TABLE_NAME+"(userId,read) VALUES('"+id+"','"+ + read+"')" + db?.execSQL(sql) + } + } + + override fun onFailure(call: Call<UserReceive?>, t: Throwable) { + sql="INSERT INTO "+ CONTACTS_TABLE_NAME+"(userId,read) VALUES('"+id+"','"+ + read+"')" + db?.execSQL(sql) + } + }) + } + else{ + sql="INSERT INTO "+ CONTACTS_TABLE_NAME+"(userId,read,username) VALUES('"+id+"','"+ + read+"','"+username+"')" + db?.execSQL(sql) + } + } else{ if(!sent) @@ -111,7 +151,36 @@ class DBHelper : } } } - fun getMessages(userId:String, self:Boolean=false): MutableList<Message>? { + fun getLastMessage(userId:String): Message? { + onCreate(db) + var sql:String = "SELECT * FROM "+ MESSAGES_TABLE_NAME+" WHERE senderId='"+userId+"'"+" OR receiverId='"+userId+"'"+" ORDER BY timestamp DESC LIMIT 1" + var cursor=db?.rawQuery(sql,null) + if(cursor?.count!! >0){ + var msg:Message + var idIndex=cursor.getColumnIndexOrThrow("_id") + var senderIdIndex=cursor.getColumnIndexOrThrow("senderId") + var receiverIdIndex=cursor.getColumnIndexOrThrow("receiverId") + var messageIndex=cursor.getColumnIndexOrThrow("messagge") + var timestampIndex=cursor.getColumnIndexOrThrow("timestamp") + cursor.moveToNext() + var cal:Calendar= Calendar.getInstance() + cal.timeInMillis=cursor.getLong(timestampIndex) + msg=Message( + cursor.getString(idIndex), + cursor.getString(senderIdIndex), + cursor.getString(receiverIdIndex), + cursor.getString(messageIndex), + cal.time, + cal + ) + + Log.d("main",cal.time.toString()) + readContact(userId) + return msg + } + return null + } + fun getMessages(userId:String,self:Boolean=false): MutableList<Message>? { onCreate(db) var sql:String if(!self) @@ -137,8 +206,8 @@ class DBHelper : cursor.getString(messageIndex), cal.time, cal - ) ) + ) Log.d("main",cal.time.toString()) } readContact(userId) @@ -155,8 +224,9 @@ class DBHelper : var contactList:MutableList<ChatPreview> =mutableListOf() var userIdIndex=cursor.getColumnIndexOrThrow("userId") var readIndex=cursor.getColumnIndexOrThrow("read") + var usernameIndex=cursor.getColumnIndexOrThrow("username") while(cursor.moveToNext()){ - contactList.add(ChatPreview(cursor.getString(userIdIndex),cursor.getInt(readIndex)==1)) + contactList.add(ChatPreview(cursor.getString(userIdIndex),cursor.getInt(readIndex)==1,cursor.getString(usernameIndex))) } Log.d("main",contactList.size.toString()) return contactList diff --git a/Client/BrzoDoLokacije/app/src/main/res/drawable/expand.png b/Client/BrzoDoLokacije/app/src/main/res/drawable/expand.png Binary files differnew file mode 100644 index 0000000..2051733 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/res/drawable/expand.png diff --git a/Client/BrzoDoLokacije/app/src/main/res/drawable/shrink.png b/Client/BrzoDoLokacije/app/src/main/res/drawable/shrink.png Binary files differnew file mode 100644 index 0000000..d4c07e1 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/res/drawable/shrink.png diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat.xml index 680bada..acdab4a 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat.xml @@ -18,16 +18,20 @@ app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" /> +<androidx.appcompat.widget.LinearLayoutCompat + android:layout_width="match_parent" + android:id="@+id/llHeader" + android:layout_height="50dp" + android:background="@color/unfollow"> - <ImageView - android:id="@+id/btnActivityShowFollowersAndFollowingBackToUser" - android:layout_width="35dp" - android:layout_height="35dp" - android:layout_marginStart="16dp" - android:layout_marginTop="16dp" + <ImageButton + android:id="@+id/btnBack" + android:layout_width="50dp" + android:layout_height="match_parent" + android:layout_gravity="center_vertical" android:clickable="true" android:src="@drawable/ic_baseline_arrow_back" - android:textAllCaps="false" + android:background="@null" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> @@ -36,13 +40,20 @@ android:id="@+id/tvActivityShowFollowersOrFollowingShow" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="16dp" - android:layout_marginEnd="268dp" + android:layout_gravity="center_vertical" + android:layout_weight="1" android:text="Poruke" android:textSize="25dp" android:textStyle="bold" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" /> +<!-- + <ImageButton + android:layout_width="50dp" + android:layout_height="match_parent" + android:layout_gravity="center_vertical"/>--> + +</androidx.appcompat.widget.LinearLayoutCompat> <androidx.swiperefreshlayout.widget.SwipeRefreshLayout android:id="@+id/swipeContainer" @@ -50,7 +61,7 @@ android:layout_height="0dp" android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvActivityShowFollowersOrFollowingShow" + app:layout_constraintTop_toBottomOf="@+id/llHeader" app:layout_constraintVertical_bias="1.0" tools:layout_editor_absoluteX="-27dp"> diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat_conversation.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat_conversation.xml index 72060f7..4dcab31 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat_conversation.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_chat_conversation.xml @@ -1,69 +1,94 @@ <?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.LinearLayoutCompat 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:layout_width="match_parent" + android:orientation="vertical" android:layout_height="match_parent" + android:fitsSystemWindows="true" tools:context=".Activities.ChatActivityConversation"> - <androidx.constraintlayout.widget.ConstraintLayout - android:id="@+id/topBanner" - android:layout_width="match_parent" - android:layout_height="50dp" - android:elevation="5dp" - android:background="@color/dark_blue_transparent" - android:clickable="true" - app:layout_constraintStart_toStartOf="parent"> - - <TextView - android:id="@+id/tvFragmentTitle" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:text="Chat" - android:textColor="@color/white" - android:textSize="40dp" /> - <androidx.cardview.widget.CardView - android:id="@+id/cvParentUsername" + <androidx.appcompat.widget.LinearLayoutCompat + android:id="@+id/topBanner" android:layout_width="match_parent" - android:layout_height="40dp" - android:layout_marginStart="16dp" - android:layout_marginTop="10dp" - android:layout_marginEnd="16dp" - android:elevation="0dp" - app:cardCornerRadius="20dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> - - - <com.google.android.material.textfield.TextInputEditText - android:id="@+id/etReceiverUsername" - android:layout_width="match_parent" + android:elevation="5dp" + android:layout_height="50dp" + android:background="@color/unfollow"> + <ImageButton + android:id="@+id/btnBack" + android:layout_width="50dp" android:layout_height="match_parent" - android:background="@drawable/rounded_white_button_login" - android:hint=" kome slati poruku?" - android:inputType="textPersonName" - android:paddingLeft="15dp" /> + android:layout_gravity="center_vertical" + android:clickable="true" + android:src="@drawable/ic_baseline_arrow_back" + android:background="@null" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + tools:ignore="SpeakableTextPresentCheck,TouchTargetSizeCheck" /> + + <androidx.appcompat.widget.LinearLayoutCompat + android:layout_width="match_parent" + android:id="@+id/llHeader" + android:layout_height="50dp"> + <ImageView + android:id="@+id/ivUserImage" + android:layout_width="50dp" + android:layout_height="match_parent" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_nav_profile" + android:padding="5dp" + android:scaleType="centerCrop"/> + <TextView + android:id="@+id/tvFragmentTitle" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:gravity="center_vertical" + android:text="Chat" + android:textSize="20dp" /> + </androidx.appcompat.widget.LinearLayoutCompat> + + <androidx.cardview.widget.CardView + android:id="@+id/cvParentUsername" + android:layout_width="wrap_content" + android:layout_height="40dp" + android:layout_gravity="center_vertical" + android:layout_weight="1" + android:elevation="0dp" + app:cardCornerRadius="20dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + + <com.google.android.material.textfield.TextInputEditText + android:id="@+id/etReceiverUsername" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="@drawable/rounded_white_button_login" + android:hint=" kome slati poruku?" + android:inputType="textPersonName" + android:paddingLeft="15dp" /> + + + </androidx.cardview.widget.CardView> + </androidx.appcompat.widget.LinearLayoutCompat> - </androidx.cardview.widget.CardView> - </androidx.constraintlayout.widget.ConstraintLayout> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/messagesContainer" android:layout_width="match_parent" android:layout_height="wrap_content" - app:layout_constraintBottom_toTopOf="@id/cvParentMessageEdit" - app:layout_constrainedHeight="true"> + android:animateLayoutChanges="true" + android:layout_weight="1"> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rvMain" android:layout_width="match_parent" android:layout_height="wrap_content" - app:layout_constraintBottom_toBottomOf="parent" - > + app:layout_constraintBottom_toBottomOf="parent"> </androidx.recyclerview.widget.RecyclerView> </androidx.constraintlayout.widget.ConstraintLayout> @@ -72,14 +97,12 @@ android:id="@+id/cvParentMessageEdit" android:layout_width="match_parent" android:layout_height="40dp" + android:layout_marginBottom="5dp" android:layout_marginStart="16dp" android:layout_marginTop="10dp" android:layout_marginEnd="16dp" android:elevation="0dp" - app:cardCornerRadius="20dp" - app:layout_constraintBottom_toBottomOf="parent" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintStart_toStartOf="parent"> + app:cardCornerRadius="20dp"> <com.google.android.material.textfield.TextInputEditText @@ -89,16 +112,21 @@ android:background="@drawable/rounded_white_button_login" android:hint=" poruka" android:inputType="textPersonName" - android:paddingLeft="15dp" /> + android:paddingLeft="15dp" + tools:ignore="TouchTargetSizeCheck" + android:autofillHints="emailAddress"/> <ImageButton android:id="@+id/btnSendMessage" - android:layout_width="49dp" - android:layout_height="50dp" - android:layout_gravity="right" + android:layout_width="25dp" + android:layout_height="25dp" + android:layout_gravity="right|center_vertical" android:scaleType="centerCrop" + android:layout_marginEnd="10dp" + android:background="@null" android:src="@drawable/post_comment" - app:cornerRadius="16dp" /> + app:cornerRadius="16dp" + tools:ignore="SpeakableTextPresentCheck" /> </androidx.cardview.widget.CardView> -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file +</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message.xml index 7858e94..f7ef08c 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message.xml @@ -1,42 +1,15 @@ <?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" - android:id="@+id/clMessage" android:layout_margin="@dimen/text_padding" android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:layout_gravity="end"> - - <androidx.cardview.widget.CardView - android:id="@+id/cardView" - android:layout_width="wrap_content" - android:layout_height="30dp" - android:backgroundTint="@color/unfollow" - android:elevation="5dp" - app:cardCornerRadius="15dp" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> - - - <com.google.android.material.textview.MaterialTextView - - android:id="@+id/tvMessage" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:layout_marginEnd="16dp" - android:background="@drawable/view_corner_radius" - android:backgroundTint="@color/unfollow" - android:padding="5dp" - android:text="blabla" - app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + android:layout_width="match_parent"> <TextView android:id="@+id/tvDate" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="32dp" android:paddingStart="8dp" android:paddingTop="4dp" android:paddingEnd="8dp" @@ -45,23 +18,31 @@ android:textColor="#C0C0C0" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent"/> <androidx.cardview.widget.CardView android:id="@+id/cvContainer" android:layout_width="wrap_content" - android:layout_height="wrap_content" - app:cardBackgroundColor="@color/dark_blue_transparent" - app:cardCornerRadius="12dp" - app:cardElevation="0dp" - app:cardPreventCornerOverlap="false" - app:cardUseCompatPadding="true" + android:minWidth="40dp" + android:layout_height="30dp" + android:layout_marginBottom="10dp" + android:layout_marginLeft="10dp" + android:backgroundTint="@color/unfollow" + app:cardCornerRadius="15dp" + android:background="@drawable/view_corner_radius" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvDate"> - - - - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvDate"> + + <com.google.android.material.textview.MaterialTextView + android:id="@+id/tvMessage" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:backgroundTint="@color/unfollow" + android:padding="5dp" + android:paddingHorizontal="15dp" + android:text="blabla" + app:layout_constraintEnd_toEndOf="parent" /> </androidx.cardview.widget.CardView> <TextView diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message_other.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message_other.xml index aaabd86..b076cf8 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message_other.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_message_other.xml @@ -1,78 +1,58 @@ <?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/clMessage" - android:layout_width="wrap_content" android:layout_height="wrap_content" - - android:layout_marginStart="8dp" - android:layout_marginTop="16dp"> + android:layout_width="match_parent"> <TextView android:id="@+id/tvDate" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="32dp" - android:elevation="10dp" - + android:paddingStart="8dp" android:paddingTop="4dp" android:paddingEnd="8dp" android:paddingBottom="4dp" android:text="June 10" android:textColor="#C0C0C0" app:layout_constraintEnd_toEndOf="parent" - app:layout_constraintHorizontal_bias="0.0" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent"/> <androidx.cardview.widget.CardView android:id="@+id/cvContainer" android:layout_width="wrap_content" + android:minWidth="40dp" android:layout_height="30dp" - android:layout_margin="5dp" - android:elevation="5dp" - app:cardCornerRadius="10dp" + android:layout_marginBottom="10dp" + android:layout_marginLeft="10dp" + android:backgroundTint="#eef1f6" + android:background="@drawable/view_corner_radius" + app:cardCornerRadius="15dp" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent"> - - + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvDate"> - <LinearLayout - android:id="@+id/llContainer" + <com.google.android.material.textview.MaterialTextView + android:id="@+id/tvMessage" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:orientation="vertical"> - <TextView - android:id="@+id/tvMessage" - android:layout_width="wrap_content" - android:layout_height="wrap_content" - android:padding="5dp" - android:text="blabla" - app:cardBackgroundColor="#eef1f6" - app:cardCornerRadius="12dp" - app:cardElevation="0dp" - app:cardPreventCornerOverlap="false" - app:cardUseCompatPadding="true" - app:layout_constraintTop_toBottomOf="@+id/tvDate"/> - - </LinearLayout> - + android:backgroundTint="#eef1f6" + android:padding="5dp" + android:paddingHorizontal="15dp" + android:text="blabla" + app:layout_constraintEnd_toEndOf="parent" /> </androidx.cardview.widget.CardView> - <TextView android:id="@+id/tvTimestamp" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginStart="4dp" - android:layout_marginTop="-5dp" - android:text="8:00" + android:text="10:00" android:textColor="#C0C0C0" android:textSize="10sp" - app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@+id/tvDate" /> + app:layout_constraintBottom_toBottomOf="@+id/cvContainer" + app:layout_constraintStart_toEndOf="@+id/cvContainer" /> </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_preview.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_preview.xml index 35431ff..c995b4b 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/chat_preview.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/chat_preview.xml @@ -1,19 +1,54 @@ <?xml version="1.0" encoding="utf-8"?> -<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" +<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" - android:layout_height="wrap_content" + android:layout_height="70dp" + android:padding="5dp" xmlns:app="http://schemas.android.com/apk/res-auto"> - <androidx.appcompat.widget.AppCompatImageView - android:layout_width="50dp" - android:layout_height="50dp" + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="5dp" + android:id="@+id/readIndicator" + android:layout_height="5dp" + android:layout_gravity="center_vertical"/> + <ImageView android:id="@+id/ivUserImage" - android:src="@drawable/ic_nav_profile"/> - <TextView + android:layout_width="70dp" + android:layout_height="match_parent" + android:layout_gravity="center_vertical" + android:src="@drawable/ic_nav_profile" + android:padding="5dp" + android:scaleType="centerCrop"/> + <androidx.appcompat.widget.LinearLayoutCompat android:layout_width="wrap_content" android:layout_height="match_parent" - android:id="@+id/tvUsername" - android:textSize="@dimen/header1_size" - android:textColor="@color/black" - app:layout_constraintStart_toEndOf="@id/ivUserImage"/> - -</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file + android:layout_weight="1" + android:orientation="vertical"> + <androidx.appcompat.widget.LinearLayoutCompat + android:layout_width="match_parent" + android:layout_height="wrap_content"> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/tvUsername" + android:layout_weight="1" + android:textSize="@dimen/header1_size" + android:textColor="@color/black"/> + <TextView + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:id="@+id/tvLastMessageDate" + android:text="1/1/1" + android:textSize="@dimen/header2_size" + android:textColor="@color/unfollow"/> + </androidx.appcompat.widget.LinearLayoutCompat> + <TextView + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:id="@+id/tvLastMessage" + android:text="hej, sta ima novo?" + android:layout_weight="1" + android:gravity="center_vertical" + android:textAlignment="gravity" + android:textSize="@dimen/header2_size" + android:textColor="@color/unfollow"/> + </androidx.appcompat.widget.LinearLayoutCompat> +</androidx.appcompat.widget.LinearLayoutCompat>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/values/dimens.xml b/Client/BrzoDoLokacije/app/src/main/res/values/dimens.xml index 181591b..5f0b4e1 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/values/dimens.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/values/dimens.xml @@ -2,6 +2,7 @@ <dimen name="fab_margin">16dp</dimen> <dimen name="text_padding">5dp</dimen> <dimen name="header1_size">20dp</dimen> + <dimen name="header2_size">18dp</dimen> <dimen name="component_padding">10dp</dimen> <dimen name="list_item_spacing">16dp</dimen> <dimen name="list_item_spacing_half">8dp</dimen> |