diff options
5 files changed, 391 insertions, 34 deletions
diff --git a/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml b/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml index bb2d712..0c412d8 100644 --- a/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml +++ b/Client/BrzoDoLokacije/app/src/main/AndroidManifest.xml @@ -37,19 +37,30 @@ android:usesCleartextTraffic="true" tools:targetApi="31"> <activity + android:name=".Activities.ActivityUserProfile" + android:exported="false" + android:screenOrientation="portrait" > + <meta-data + android:name="android.app.lib_name" + android:value="" /> + </activity> + <activity android:name=".Activities.ChatActivityConversation" android:exported="false" - android:windowSoftInputMode="stateVisible|adjustPan"> + android:windowSoftInputMode="stateVisible|adjustPan" + android:screenOrientation="portrait" > <meta-data android:name="android.app.lib_name" android:value="" /> </activity> <activity android:name=".Activities.ChatActivity" - android:exported="true"> + android:exported="true" + android:screenOrientation="portrait" > <meta-data android:name="android.app.lib_name" android:value="" /> + </activity> <meta-data diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt index f875949..f969669 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivitySinglePost.kt @@ -1,11 +1,11 @@ package com.example.brzodolokacije.Activities +import android.content.Intent import android.os.Bundle import android.util.Log -import android.widget.Adapter +import android.widget.TextView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity -import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.example.brzodolokacije.Adapters.CommentsAdapter @@ -15,11 +15,11 @@ import com.example.brzodolokacije.R import com.example.brzodolokacije.Services.RetrofitHelper import com.example.brzodolokacije.Services.SharedPreferencesHelper import com.example.brzodolokacije.databinding.ActivitySinglePostBinding +import com.google.gson.Gson +import kotlinx.android.synthetic.main.activity_single_post.* import okhttp3.ResponseBody -import okhttp3.internal.notifyAll import retrofit2.Call import retrofit2.Response -import kotlin.math.roundToInt class ActivitySinglePost : AppCompatActivity() { @@ -33,6 +33,8 @@ class ActivitySinglePost : AppCompatActivity() { private lateinit var post:PostPreview private var comments:MutableList<CommentSend>?=mutableListOf() private var starNumber:Number=0 + private lateinit var userData:UserReceive + private lateinit var user:TextView override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -53,6 +55,14 @@ class ActivitySinglePost : AppCompatActivity() { recyclerViewImages?.adapter = adapterImages loadTextComponents() setRatingListeners() + translateOwnerIdToName(post.ownerId) + + binding.tvUser.setOnClickListener { + val intent: Intent = Intent(this@ActivitySinglePost,ActivityUserProfile::class.java) + var b= Bundle() + intent.putExtra("user", Gson().toJson(userData)) + this.startActivity(intent) + } } fun buildRecyclerViewComments(){ @@ -228,7 +238,9 @@ class ActivitySinglePost : AppCompatActivity() { tvNumberOfRatings.invalidate() tvDescription.text=post.description tvDescription.invalidate() + } + } fun addView() { var token= SharedPreferencesHelper.getValue("jwt", this).toString() @@ -245,5 +257,24 @@ class ActivitySinglePost : AppCompatActivity() { }) } + fun translateOwnerIdToName(id:String) { + var token= SharedPreferencesHelper.getValue("jwt", this).toString() + val api= RetrofitHelper.getInstance() + val request= api.getProfileFromId("Bearer " + token, id) + request.enqueue(object : retrofit2.Callback<UserReceive> { + override fun onResponse(call: Call<UserReceive>, + response: Response<UserReceive>) { + if (response.body() == null) { + return + } + userData = response.body()!! + binding.tvUser.text= userData!!.username.toString() + } + + override fun onFailure(call: Call<UserReceive>, t: Throwable) { + + } + }) + } } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt new file mode 100644 index 0000000..50c2b0e --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityUserProfile.kt @@ -0,0 +1,49 @@ +package com.example.brzodolokacije.Activities + +import android.os.Bundle +import android.widget.ImageView +import android.widget.TextView +import androidx.appcompat.app.AppCompatActivity +import com.bumptech.glide.Glide +import com.example.brzodolokacije.Models.UserReceive +import com.example.brzodolokacije.R +import com.example.brzodolokacije.Services.RetrofitHelper +import com.google.gson.Gson + +class ActivityUserProfile : AppCompatActivity() { + private lateinit var name:TextView + private lateinit var postsNumber:TextView + private lateinit var followersNumber:TextView + private lateinit var followingNumber:TextView + private lateinit var profilePicture:ImageView + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_user_profile) + + name=findViewById(R.id.tvActivityUserProfileName) + postsNumber=findViewById(R.id.tvActivityUserProfilePostsNo) + followersNumber=findViewById(R.id.tvActivityUserProfileFollowersNo) + followingNumber=findViewById(R.id.tvActivityUserProfileFollowNo) + profilePicture=findViewById(R.id.tvActivityProfileProfilePicture) + val jsonMyObject: String + val extras = intent.extras + if (extras != null) { + jsonMyObject = extras.getString("user")!! + val myObject: UserReceive = Gson().fromJson(jsonMyObject, UserReceive::class.java) + + name.text=myObject.name + postsNumber.text=myObject.postNumber.toString() + followersNumber.text="0" + followingNumber.text="0" + + if(myObject.pfp!=null) { + Glide.with(this) + .load(RetrofitHelper.baseUrl + "/api/post/image/" + myObject.pfp!!._id) + .circleCrop()//Round image + .into(profilePicture) + } + } + + } +}
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml index a8a03aa..e3cabb5 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_single_post.xml @@ -41,8 +41,8 @@ android:gravity="top|start" android:padding="@dimen/text_padding" android:text="Drzava, grad" - app:layout_constraintTop_toBottomOf="@+id/tvLocationType" - tools:layout_editor_absoluteX="0dp" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvLocationType" /> <TextView android:id="@+id/tvTitle" @@ -52,7 +52,8 @@ android:padding="@dimen/text_padding" android:text="Naslov" android:textSize="@dimen/header1_size" - android:textStyle="bold" /> + android:textStyle="bold" + app:layout_constraintStart_toStartOf="parent" /> <TextView android:id="@+id/tvLocationType" @@ -61,15 +62,27 @@ android:gravity="top|start" android:padding="@dimen/text_padding" android:text="Tip lokacije" - app:layout_constraintTop_toBottomOf="@+id/tvTitle" - tools:layout_editor_absoluteX="0dp" /> + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvTitle" /> + + <TextView + android:id="@+id/tvUser" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:clickable="true" + android:gravity="top|start" + android:padding="@dimen/text_padding" + android:text="User" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvLocationParent" /> <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/constraintLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="20dp" + android:layout_marginTop="36dp" app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/tvLocationParent"> @@ -161,6 +174,7 @@ android:layout_height="wrap_content" android:text="TextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextViewTextView" app:layout_constraintTop_toBottomOf="@+id/tvDescriptionLabel" /> + </androidx.constraintlayout.widget.ConstraintLayout> <LinearLayout @@ -177,9 +191,9 @@ android:layout_width="30dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:scaleType="centerCrop" android:layout_weight="1" android:backgroundTint="@color/white" + android:scaleType="centerCrop" android:src="@drawable/empty_star" /> <ImageButton @@ -187,9 +201,9 @@ android:layout_width="30dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:scaleType="centerCrop" android:layout_weight="1" android:backgroundTint="@color/white" + android:scaleType="centerCrop" android:src="@drawable/empty_star" /> <ImageButton @@ -197,9 +211,9 @@ android:layout_width="30dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:scaleType="centerCrop" android:layout_weight="1" android:backgroundTint="@color/white" + android:scaleType="centerCrop" android:src="@drawable/empty_star" /> <ImageButton @@ -207,9 +221,9 @@ android:layout_width="30dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:scaleType="centerCrop" android:layout_weight="1" android:backgroundTint="@color/white" + android:scaleType="centerCrop" android:src="@drawable/empty_star" /> <ImageButton @@ -217,48 +231,48 @@ android:layout_width="30dp" android:layout_height="40dp" android:layout_gravity="center_vertical" - android:scaleType="centerCrop" android:layout_weight="1" android:backgroundTint="@color/white" + android:scaleType="centerCrop" android:src="@drawable/empty_star" /> <Button android:id="@+id/submitRating" android:layout_width="30dp" android:layout_height="40dp" + android:layout_gravity="center_vertical" android:layout_weight="1" android:backgroundTint="@color/white" android:text="ok" - android:layout_gravity="center_vertical" - android:textColor="@color/black" - /> + android:textColor="@color/black" /> </LinearLayout> <androidx.constraintlayout.widget.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_constraintTop_toBottomOf="@id/linearLayout2"> + <LinearLayout + android:id="@+id/postCommentLayout" android:layout_width="match_parent" android:layout_height="wrap_content" - android:id="@+id/postCommentLayout" android:orientation="horizontal" - app:layout_constraintStart_toStartOf="parent" > + app:layout_constraintStart_toStartOf="parent"> + <EditText + android:id="@+id/NewComment" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" - android:hint="Unesite komentar ovde" - android:id="@+id/NewComment" - /> + android:hint="Unesite komentar ovde" /> <ImageButton android:id="@+id/btnPostComment" android:layout_width="50dp" - android:scaleType="fitCenter" android:layout_height="50dp" - android:src="@drawable/post_comment" - android:backgroundTint="@color/white"/> + android:backgroundTint="@color/white" + android:scaleType="fitCenter" + android:src="@drawable/post_comment" /> </LinearLayout> @@ -266,26 +280,26 @@ android:id="@+id/tvCommentLabel" android:layout_width="wrap_content" android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/postCommentLayout" android:padding="@dimen/text_padding" android:text="Komentari" - android:textStyle="bold" /> + android:textStyle="bold" + app:layout_constraintTop_toBottomOf="@id/postCommentLayout" /> <TextView android:id="@+id/tvCommentCount" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="@dimen/text_padding" - app:layout_constraintTop_toBottomOf="@id/postCommentLayout" android:text="0" - app:layout_constraintStart_toEndOf="@id/tvCommentLabel" /> + app:layout_constraintStart_toEndOf="@id/tvCommentLabel" + app:layout_constraintTop_toBottomOf="@id/postCommentLayout" /> <androidx.recyclerview.widget.RecyclerView android:id="@+id/rvComments" android:layout_width="match_parent" android:layout_height="wrap_content" - app:layout_constraintTop_toBottomOf="@id/tvCommentLabel" - android:nestedScrollingEnabled="false"> + android:nestedScrollingEnabled="false" + app:layout_constraintTop_toBottomOf="@id/tvCommentLabel"> </androidx.recyclerview.widget.RecyclerView> </androidx.constraintlayout.widget.ConstraintLayout> diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml new file mode 100644 index 0000000..8762183 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/activity_user_profile.xml @@ -0,0 +1,252 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout 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:layout_height="match_parent" + tools:context=".Activities.ActivityUserProfile"> + + + <androidx.constraintlayout.widget.ConstraintLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <ImageView + + android:id="@+id/imageView3" + android:layout_width="match_parent" + android:layout_height="300dp" + android:foreground="@drawable/b3" + android:foregroundGravity="center_vertical|center|center_horizontal|fill" + android:src="@drawable/b3" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + + <com.google.android.material.imageview.ShapeableImageView + + android:id="@+id/tvFragmentProfileInfoContainer" + android:layout_width="0dp" + android:layout_height="199dp" + android:layout_marginStart="20dp" + android:layout_marginTop="150dp" + android:layout_marginEnd="20dp" + android:adjustViewBounds="true" + android:background="@drawable/profile_view_background" + + android:elevation="1dp" + android:scaleType="fitEnd" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="0.0" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@+id/imageView3" + app:shapeAppearanceOverlay="@style/imageViewRoundedEdge" /> + + + <androidx.cardview.widget.CardView + android:id="@+id/cvFragmentHomePageProfile" + android:layout_width="140dp" + android:layout_height="140dp" + android:layout_gravity="center" + android:layout_marginTop="80dp" + android:elevation="10dp" + app:cardCornerRadius="250dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent"> + + <ImageView + + android:id="@+id/tvActivityProfileProfilePicture" + android:layout_width="match_parent" + android:layout_height="match_parent" + android:elevation="10dp" + android:scaleType="centerCrop" + android:src="@drawable/ic_baseline_person_24" + tools:ignore="ContentDescription" /> + </androidx.cardview.widget.CardView> + + <View + android:id="@+id/divider" + android:layout_width="409dp" + android:layout_height="1dp" + android:background="?android:attr/listDivider" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/btnFragmentUserProfileShowPosts" /> + + <Button + android:id="@+id/btnFragmentUserProfileShowPosts" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="20dp" + android:layout_marginTop="4dp" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Objave" + + android:textColor="@color/cardview_dark_background" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + + <Button + android:id="@+id/btnFragmentUserProfileShowData" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginTop="4dp" + android:layout_marginEnd="20dp" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Podaci" + + android:textColor="@color/cardview_dark_background" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintHorizontal_bias="1.0" + app:layout_constraintStart_toEndOf="@+id/btnFragmentUserProfileShowRecensions" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + + <Button + android:id="@+id/btnFragmentUserProfileShowRecensions" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_marginStart="36dp" + android:layout_marginTop="4dp" + android:backgroundTint="#FFFFFF" + android:stateListAnimator="@null" + android:text="Recenzije" + android:textColor="@color/cardview_dark_background" + app:layout_constraintStart_toEndOf="@+id/btnFragmentUserProfileShowPosts" + app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> + + <FrameLayout + android:id="@+id/flFragmentProfileFragmentContainer" + android:layout_width="409dp" + android:layout_height="319dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="@+id/divider"> + </FrameLayout> + + <TableLayout + + android:layout_width="363dp" + + android:layout_height="122dp" + android:layout_marginStart="30dp" + android:layout_marginTop="8dp" + android:layout_marginEnd="30dp" + android:layout_marginBottom="8dp" + android:elevation="1dp" + android:numColumns="3" + + android:stretchColumns="1" + app:layout_constraintBottom_toBottomOf="@+id/tvFragmentProfileInfoContainer" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@+id/cvFragmentHomePageProfile"> + + <TableRow + android:layout_width="match_parent" + android:layout_height="match_parent" + android:layout_column="1"> + + <TextView + android:id="@+id/tvActivityUserProfileName" + android:layout_width="wrap_content" + android:layout_height="match_parent" + android:layout_column="1" + android:layout_gravity="center" + android:layout_marginBottom="5dp" + android:text="Petar Petrović" + android:textSize="20sp" /> + </TableRow> + + <TableRow> + + <androidx.constraintlayout.widget.ConstraintLayout android:layout_span="3"> + + <ImageButton + + android:id="@+id/materialButton" + android:layout_width="115dp" + android:layout_height="40dp" + android:layout_marginStart="16dp" + android:background="@drawable/rounded_transparent_button" + android:foreground="@drawable/button_follow" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" + tools:ignore="TouchTargetSizeCheck" /> + + <ImageButton + android:layout_width="115dp" + android:layout_height="40dp" + android:layout_gravity="center" + android:layout_marginEnd="16dp" + android:height="40dp" + android:background="@drawable/rounded_transparent_button" + android:foreground="@drawable/button_chat" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintTop_toTopOf="parent" + app:layout_constraintVertical_bias="0.0" + tools:ignore="SpeakableTextPresentCheck" /> + </androidx.constraintlayout.widget.ConstraintLayout> + </TableRow> + + + <TableRow android:layout_marginTop="5dp"> + + <TextView + android:id="@+id/tvFragmentUserProfilePosts" + android:layout_width="110dp" + android:gravity="center" + android:text="OBJAVE" /> + + <TextView + android:id="@+id/tvFragmentUserProfileFollowers" + android:layout_width="10dp" + android:gravity="center" + android:text="PRATIOCI" /> + + <TextView + android:id="@+id/tvFragmentUserProfileFollow" + + android:layout_width="110dp" + android:gravity="center" + android:text="PRAĆENJA" /> + </TableRow> + + <TableRow> + + <TextView + android:id="@+id/tvActivityUserProfilePostsNo" + android:layout_width="110dp" + android:layout_height="match_parent" + android:gravity="center" + android:text="156" + android:textFontWeight="700" /> + + <TextView + android:id="@+id/tvActivityUserProfileFollowersNo" + android:layout_width="110dp" + android:gravity="center" + android:text="50" /> + + <TextView + android:id="@+id/tvActivityUserProfileFollowNo" + android:layout_width="110dp" + android:gravity="center" + android:text="40" /> + + </TableRow> + + </TableLayout> + + </androidx.constraintlayout.widget.ConstraintLayout> + + +</FrameLayout>
\ No newline at end of file |