diff options
Diffstat (limited to 'Client')
21 files changed, 465 insertions, 133 deletions
| diff --git a/Client/BrzoDoLokacije/.idea/deploymentTargetDropDown.xml b/Client/BrzoDoLokacije/.idea/deploymentTargetDropDown.xml deleted file mode 100644 index c73c499..0000000 --- a/Client/BrzoDoLokacije/.idea/deploymentTargetDropDown.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> -  <component name="deploymentTargetDropDown"> -    <targetSelectedWithDropDown> -      <Target> -        <type value="QUICK_BOOT_TARGET" /> -        <deviceKey> -          <Key> -            <type value="VIRTUAL_DEVICE_PATH" /> -            <value value="C:\Users\PC\.android\avd\Copy_of_Copy_of_Pixel_2_API_32.avd" /> -          </Key> -        </deviceKey> -      </Target> -    </targetSelectedWithDropDown> -    <timeTargetWasSelectedWithDropDown value="2022-11-21T17:55:50.810481Z" /> -  </component> -</project>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt index c247743..2d305a6 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityAddPost.kt @@ -260,7 +260,9 @@ class ActivityAddPost : AppCompatActivity() {          }          var countryName=loc1[0].countryName          var address="todo not possible in query" -        var city=loc1[0].adminArea//not possible +        var city="its null" +        if(loc1[0].adminArea!=null) +            city=loc1[0].adminArea//not possible          var loc:Location=Location("",locationString,city,countryName,address,latitude,longitude,LocationType.GRAD)          var jwtString= SharedPreferencesHelper.getValue("jwt",this)          var data=api.addLocation("Bearer "+jwtString,loc) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityCapturePost.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityCapturePost.kt index 3fab37a..b02abad 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityCapturePost.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Activities/ActivityCapturePost.kt @@ -265,6 +265,7 @@ class ActivityCapturePost : AppCompatActivity() {          var countryName=loc1[0].countryName          var address="todo not possible in query"          var city=loc1[0].adminArea//not possible +        //var address=loc1[0].subAdminArea          var loc:Location=Location("",locationString,city,countryName,address,latitude,longitude,LocationType.GRAD)          var jwtString= SharedPreferencesHelper.getValue("jwt",this)          var data=api.addLocation("Bearer "+jwtString,loc) 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 c030eda..f875949 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 @@ -132,6 +132,7 @@ class ActivitySinglePost : AppCompatActivity() {                  Toast.makeText(this@ActivitySinglePost,"Unesite tekst komentara.",Toast.LENGTH_LONG).show()              }          } +        addView()      } @@ -229,5 +230,20 @@ class ActivitySinglePost : AppCompatActivity() {              tvDescription.invalidate()          }      } +    fun addView() { +        var token= SharedPreferencesHelper.getValue("jwt", this).toString() +        val Api= RetrofitHelper.getInstance() +        val request=Api.addView("Bearer "+token,post._id) +        request.enqueue(object : retrofit2.Callback<PostPreview?> { +            override fun onResponse(call: Call<PostPreview?>, response: Response<PostPreview?>) { + +            } + +            override fun onFailure(call: Call<PostPreview?>, t: Throwable) { + +            } +        }) +    } +  } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/FollowersAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/FollowersAdapter.kt new file mode 100644 index 0000000..117a2c2 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/FollowersAdapter.kt @@ -0,0 +1,4 @@ +package com.example.brzodolokacije.Adapters + +class FollowersAdapter { +}
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/MyPostsAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/MyPostsAdapter.kt new file mode 100644 index 0000000..1b57e5b --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/MyPostsAdapter.kt @@ -0,0 +1,75 @@ +package com.example.brzodolokacije.Adapters + +import android.app.Activity +import android.content.Intent +import android.graphics.BitmapFactory +import android.os.AsyncTask +import android.os.Bundle +import android.view.LayoutInflater +import android.view.ViewGroup +import android.widget.Toast +import androidx.recyclerview.widget.RecyclerView +import com.bumptech.glide.Glide +import com.example.brzodolokacije.Activities.ActivitySinglePost +import com.example.brzodolokacije.Interfaces.IBackendApi +import com.example.brzodolokacije.Models.LocationType +import com.example.brzodolokacije.Models.PostPreview +import com.example.brzodolokacije.Services.RetrofitHelper +import com.example.brzodolokacije.Services.SharedPreferencesHelper +import com.example.brzodolokacije.databinding.PostPreviewBinding +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.launch +import okhttp3.ResponseBody +import retrofit2.Call +import retrofit2.Response + + +class MyPostsAdapter (val activity:Activity,val items : MutableList<PostPreview>) +    : RecyclerView.Adapter<MyPostsAdapter.ViewHolder>() { +    private lateinit var token: String +    private lateinit var imageApi: IBackendApi + +    //constructer has one argument - list of objects that need to be displayed +    //it is bound to xml of single item +    private lateinit var binding: PostPreviewBinding +    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { +        val inflater = LayoutInflater.from(parent.context) +        imageApi= RetrofitHelper.getInstance() +        token= SharedPreferencesHelper.getValue("jwt", activity).toString() +        binding = PostPreviewBinding.inflate(inflater, parent, false) +        return ViewHolder(binding) +    } + + + + +    override fun getItemCount() = items.size +    inner class ViewHolder(itemView: PostPreviewBinding) : RecyclerView.ViewHolder(itemView.root) { +        fun bind(item: PostPreview) { +            binding.apply { +                tvTitle.text = item.location.name +                tvLocationParent.text = item.location.country +                tvLocationType.text = "TODO" +                if(item.images.isNotEmpty()) { +                    Glide.with(activity) +                        .load(RetrofitHelper.baseUrl + "/api/post/image/" + item.images[0]._id) +                        .into(locationImage) +                } + +            } +        } +    } + +    override fun onBindViewHolder(holder: ViewHolder, position: Int) { +        holder.bind(items[position]) +        holder.itemView.setOnClickListener { +            //Toast.makeText(activity,item._id,Toast.LENGTH_LONG).show() +            val intent:Intent = Intent(activity,ActivitySinglePost::class.java) +            var b=Bundle() +            items[position].location.type=LocationType.ADA +            b.putParcelable("selectedPost", items[position]) +            intent.putExtras(b) +            activity.startActivity(intent) +        } +    } +} diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/PostHistoryAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/PostHistoryAdapter.kt new file mode 100644 index 0000000..db3fc2e --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/PostHistoryAdapter.kt @@ -0,0 +1,61 @@ +package com.example.brzodolokacije.Adapters + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.view.LayoutInflater +import android.view.ViewGroup +import androidx.recyclerview.widget.RecyclerView +import com.example.brzodolokacije.Activities.ActivitySinglePost +import com.example.brzodolokacije.Interfaces.IBackendApi +import com.example.brzodolokacije.Models.LocationType +import com.example.brzodolokacije.Models.PostPreview +import com.example.brzodolokacije.Services.RetrofitHelper +import com.example.brzodolokacije.Services.SharedPreferencesHelper +import com.example.brzodolokacije.databinding.SinglePostHistoryBinding + + +class PostHistoryAdapter (val activity:Activity,val items : MutableList<PostPreview>) +    : RecyclerView.Adapter<PostHistoryAdapter.ViewHolder>() { +    private lateinit var token: String +    private lateinit var imageApi: IBackendApi + +    //constructer has one argument - list of objects that need to be displayed +    //it is bound to xml of single item +    private lateinit var binding: SinglePostHistoryBinding +    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { +        val inflater = LayoutInflater.from(parent.context) +        imageApi= RetrofitHelper.getInstance() +        token= SharedPreferencesHelper.getValue("jwt", activity).toString() +        binding = SinglePostHistoryBinding.inflate(inflater, parent, false) +        return ViewHolder(binding) +    } + + + + +    override fun getItemCount() = items.size +    inner class ViewHolder(itemView: SinglePostHistoryBinding) : RecyclerView.ViewHolder(itemView.root) { +        fun bind(item: PostPreview) { +            binding.apply { +                tvTitleSinglePostHistory.text = item.location.name +                tvLocationParentSinglePostHistory.text = "22.11.2022" +                tvLocationTypeSinglePostHistory.text = item.location.country + +            } +        } +    } + +    override fun onBindViewHolder(holder: ViewHolder, position: Int) { +        holder.bind(items[position]) +        holder.itemView.setOnClickListener { +            //Toast.makeText(activity,item._id,Toast.LENGTH_LONG).show() +            val intent:Intent = Intent(activity,ActivitySinglePost::class.java) +            var b=Bundle() +            items[position].location.type=LocationType.ADA +            b.putParcelable("selectedPost", items[position]) +            intent.putExtras(b) +            activity.startActivity(intent) +        } +    } +} diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt index e09cd06..0bd625f 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Adapters/ShowPostsAdapter.kt @@ -65,17 +65,6 @@ class ShowPostsAdapter (val activity:Activity,val items : MutableList<PostPrevie              var b=Bundle()              //getItem(position)!!.location.type=LocationType.ADA              //---------------------------------------------------------------  call back to add view tick -            val Api= RetrofitHelper.getInstance() -            val request=Api.addView("Bearer "+token,getItem(position)!!._id) -            request.enqueue(object : retrofit2.Callback<PostPreview?> { -                override fun onResponse(call: Call<PostPreview?>, response: Response<PostPreview?>) { - -                } - -                override fun onFailure(call: Call<PostPreview?>, t: Throwable) { - -                } -            })              //---------------------------------------------------------------              b.putParcelable("selectedPost",getItem(position)!!)              intent.putExtras(b) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt new file mode 100644 index 0000000..da480f1 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentFollowers.kt @@ -0,0 +1,69 @@ +package com.example.brzodolokacije.Fragments + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.Toast +import androidx.fragment.app.Fragment +import com.example.brzodolokacije.Interfaces.IBackendApi +import com.example.brzodolokacije.Models.PostPreview +import com.example.brzodolokacije.Models.UserReceive +import com.example.brzodolokacije.R +import com.example.brzodolokacije.Services.RetrofitHelper +import com.example.brzodolokacije.Services.SharedPreferencesHelper +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response +import retrofit2.Retrofit +import retrofit2.converter.gson.GsonConverterFactory + +class FragmentFollowers : Fragment() { +    private lateinit var userId:String +    private lateinit var followers: MutableList<UserReceive> +    override fun onCreateView( +        inflater: LayoutInflater, container: ViewGroup?, +        savedInstanceState: Bundle? +    ): View? { +        val view= inflater.inflate(R.layout.fragment_followers, container, false) + +        val bundle = this.arguments + +        if (bundle != null) { +            userId= bundle.getString("userId").toString() +            Toast.makeText( +                activity, bundle.getString("userId"), Toast.LENGTH_LONG +            ).show(); +        } + +        getPosts() + +        return view +    } + +    fun getPosts(){ +        val api = RetrofitHelper.getInstance() +        val data=api.getFollowers(userId) + + +        data.enqueue(object : Callback<MutableList<UserReceive>> { +            override fun onResponse( +                call: Call<MutableList<UserReceive>>, +                response: Response<MutableList<UserReceive>> +            ) { +                if (response.body() == null) { +                    return +                } + +                followers = response.body()!!.toMutableList<UserReceive>() + +            } + +            override fun onFailure(call: Call<MutableList<UserReceive>>, t: Throwable) { +                Toast.makeText( +                    activity,"nema objava", Toast.LENGTH_LONG +               ).show(); +            } +        }) +    } +}
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt index bde4dd2..cf811df 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentHomePageMainScroll.kt @@ -77,9 +77,6 @@ class FragmentHomePageMainScroll : Fragment() {          var fragment=FragmentShowPostsByLocation()          location_spa.setOnClickListener { -            Toast.makeText( -                activity, "BANJAAAAAAAAAAAAAAA", Toast.LENGTH_LONG -            ).show();              filter=LocationType.BANJA              filterString=filter.toString()              bundle.putString("data",filterString) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentMyRecensions.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentMyRecensions.kt index ce8679a..c5fa6ec 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentMyRecensions.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentMyRecensions.kt @@ -5,56 +5,69 @@ import androidx.fragment.app.Fragment  import android.view.LayoutInflater  import android.view.View  import android.view.ViewGroup +import androidx.recyclerview.widget.GridLayoutManager +import androidx.recyclerview.widget.RecyclerView +import com.example.brzodolokacije.Adapters.MyPostsAdapter +import com.example.brzodolokacije.Adapters.PostHistoryAdapter +import com.example.brzodolokacije.Models.PostPreview  import com.example.brzodolokacije.R +import com.example.brzodolokacije.Services.RetrofitHelper +import com.example.brzodolokacije.Services.SharedPreferencesHelper +import retrofit2.Call +import retrofit2.Callback +import retrofit2.Response -// TODO: Rename parameter arguments, choose names that match -// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER -private const val ARG_PARAM1 = "param1" -private const val ARG_PARAM2 = "param2" -/** - * A simple [Fragment] subclass. - * Use the [FragmentMyRecensions.newInstance] factory method to - * create an instance of this fragment. - */  class FragmentMyRecensions : Fragment() { -    // TODO: Rename and change types of parameters -    private var param1: String? = null -    private var param2: String? = null + +    private lateinit var posts : MutableList<PostPreview> +    private lateinit var rvPosts: RecyclerView      override fun onCreate(savedInstanceState: Bundle?) {          super.onCreate(savedInstanceState) -        arguments?.let { -            param1 = it.getString(ARG_PARAM1) -            param2 = it.getString(ARG_PARAM2) -        } +      }      override fun onCreateView(          inflater: LayoutInflater, container: ViewGroup?,          savedInstanceState: Bundle?      ): View? { -        // Inflate the layout for this fragment -        return inflater.inflate(R.layout.fragment_my_recensions, container, false) + +        val view =inflater.inflate(R.layout.fragment_my_recensions, container, false) + +        rvPosts=view.findViewById(R.id.rvFragmentMyRecensionPostHistory) as RecyclerView +        getPosts() + +        return view +      } +    fun getPosts(){ +        val api = RetrofitHelper.getInstance() +        val token= SharedPreferencesHelper.getValue("jwt", requireActivity()) +        val data=api.getMyHistory("Bearer "+token) -    companion object { -        /** -         * Use this factory method to create a new instance of -         * this fragment using the provided parameters. -         * -         * @param param1 Parameter 1. -         * @param param2 Parameter 2. -         * @return A new instance of fragment FragmentMyRecensions. -         */ -        // TODO: Rename and change types and number of parameters -        @JvmStatic -        fun newInstance(param1: String, param2: String) = -            FragmentMyRecensions().apply { -                arguments = Bundle().apply { -                    putString(ARG_PARAM1, param1) -                    putString(ARG_PARAM2, param2) +        data.enqueue(object : Callback<MutableList<PostPreview>> { +            override fun onResponse( +                call: Call<MutableList<PostPreview>>, +                response: Response<MutableList<PostPreview>> +            ) { +                if (response.body() == null) { +                    return                  } +                posts = response.body()!!.toMutableList<PostPreview>() +                loadPosts() +            } +            override fun onFailure(call: Call<MutableList<PostPreview>>, t: Throwable) { +              } +        })      } +    private fun loadPosts(){//most viewed +        rvPosts.apply { +            layoutManager= GridLayoutManager(requireContext(),1, GridLayoutManager.VERTICAL,false) +            adapter= PostHistoryAdapter(requireActivity(),posts) + +        } + +}  }
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt index a792598..03cb4fa 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentProfile.kt @@ -1,5 +1,6 @@  package com.example.brzodolokacije.Fragments +  import android.content.Intent  import android.net.Uri  import android.os.Bundle @@ -19,7 +20,6 @@ import com.example.brzodolokacije.R  import com.example.brzodolokacije.Services.RetrofitHelper  import com.example.brzodolokacije.Services.SharedPreferencesHelper  import com.google.android.material.button.MaterialButton -import com.google.android.material.imageview.ShapeableImageView  import okhttp3.MediaType.Companion.toMediaTypeOrNull  import okhttp3.MultipartBody  import okhttp3.RequestBody @@ -28,6 +28,7 @@ import retrofit2.Call  import retrofit2.Response  import java.io.File +  // TODO: Rename parameter arguments, choose names that match  // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER  private const val ARG_PARAM1 = "param1" @@ -38,7 +39,7 @@ private const val ARG_PARAM2 = "param2"   * Use the [FragmentProfile.newInstance] factory method to   * create an instance of this fragment.   */ -class FragmentProfile : Fragment(R.layout.fragment_profile) { +class FragmentProfile : Fragment(com.example.brzodolokacije.R.layout.fragment_profile) {      // TODO: Rename and change types of parameters      private lateinit var username: TextView      private lateinit var name: TextView @@ -55,22 +56,31 @@ class FragmentProfile : Fragment(R.layout.fragment_profile) {      private lateinit var showMyRecensions: Button      private lateinit var profilePicture: ImageView      private lateinit var profilePicturePlus: MaterialButton +    private lateinit var showFollowers: TextView + +    var userId:String = "1" + +      override fun onCreateView(          inflater: LayoutInflater, container: ViewGroup?,          savedInstanceState: Bundle?      ): View? { +        Toast.makeText( +            activity, "MOJ PROFILLLLLLLLLLLLLLL", Toast.LENGTH_LONG +        ).show();          // Inflate the layout for this fragment -        val view:View= inflater.inflate(R.layout.fragment_profile, container, false) -        name = view.findViewById<View>(R.id.tvFragmentProfileName) as TextView -        username = view.findViewById<View>(R.id.tvFragmentProfileUserName) as TextView -        postsCount = view.findViewById<View>(R.id.tvFragmentProfilePostsNo) as TextView -        followersCount = view.findViewById<View>(R.id.tvFragmentProfileFollowersNo) as TextView -        followingCount = view.findViewById<View>(R.id.tvFragmentProfileFollowNo) as TextView -        showMyPosts=view.findViewById<View>(R.id.btnFragmentProfileShowMyPosts) as Button -        showMyData=view.findViewById<View>(R.id.btnFragmentProfileShowMyData) as Button -        showMyRecensions=view.findViewById<View>(R.id.btnFragmentProfileShowMyRecensions) as Button -        profilePicture=view.findViewById<View>(R.id.tvFragmentProfileProfilePicture) as ImageView -        profilePicturePlus=view.findViewById<View>(R.id.btnFragmentProfileProfilePicturePlus) as MaterialButton +        val view:View= inflater.inflate(com.example.brzodolokacije.R.layout.fragment_profile, container, false) +        name = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileName) as TextView +        username = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileUserName) as TextView +        postsCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfilePostsNo) as TextView +        followersCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowersNo) as TextView +        followingCount = view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileFollowNo) as TextView +        showMyPosts=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyPosts) as Button +        showMyData=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyData) as Button +        showMyRecensions=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileShowMyRecensions) as Button +        profilePicture=view.findViewById<View>(com.example.brzodolokacije.R.id.tvFragmentProfileProfilePicture) as ImageView +        profilePicturePlus=view.findViewById<View>(com.example.brzodolokacije.R.id.btnFragmentProfileProfilePicturePlus) as MaterialButton +        showFollowers=view.findViewById(com.example.brzodolokacije.R.id.tvFragmentProfileFollowers)          //podaci iz baze @@ -85,7 +95,7 @@ class FragmentProfile : Fragment(R.layout.fragment_profile) {              var fm: FragmentTransaction =childFragmentManager.beginTransaction() -            fm.replace(R.id.flFragmentProfileFragmentContainer, FragmentMyProfileInfo()) +            fm.replace(com.example.brzodolokacije.R.id.flFragmentProfileFragmentContainer, FragmentMyProfileInfo())              fm.commit()          } @@ -93,12 +103,24 @@ class FragmentProfile : Fragment(R.layout.fragment_profile) {              getProfileInfo()              var fm: FragmentTransaction =childFragmentManager.beginTransaction() -            fm.replace(R.id.flFragmentProfileFragmentContainer, FragmentMyRecensions()) +            fm.replace(com.example.brzodolokacije.R.id.flFragmentProfileFragmentContainer, FragmentMyRecensions())              fm.commit()          }          profilePicturePlus.setOnClickListener{              addProfilePicture()          } + +        showFollowers.setOnClickListener { +            val bundle = Bundle() +            bundle.putString("userId",userId ) // Put anything what you want +            val fragmentFollowers = FragmentFollowers() +            fragmentFollowers.setArguments(bundle) + +            fragmentManager +                ?.beginTransaction() +                ?.replace(com.example.brzodolokacije.R.id.flNavigationFragment,fragmentFollowers) +                ?.commit() +        }          getProfileInfo()          openMyPosts()          return view @@ -106,7 +128,7 @@ class FragmentProfile : Fragment(R.layout.fragment_profile) {      fun openMyPosts(){          var fm: FragmentTransaction =childFragmentManager.beginTransaction() -        fm.replace(R.id.flFragmentProfileFragmentContainer, FragmentUserPosts()) +        fm.replace(com.example.brzodolokacije.R.id.flFragmentProfileFragmentContainer, FragmentUserPosts())          fm.commit()      } @@ -181,6 +203,8 @@ class FragmentProfile : Fragment(R.layout.fragment_profile) {          followersCount.setText("to do")          followingCount.setText("to do") +        userId=user._id +          //Add Profile image          if(user.pfp!=null) {              Glide.with(requireActivity()) diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserPosts.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserPosts.kt index f1f2257..d69a40c 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserPosts.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserPosts.kt @@ -34,6 +34,7 @@ import android.widget.TextView  import com.example.brzodolokacije.Activities.ActivityAddPost  import com.example.brzodolokacije.Activities.ActivityCapturePost  import com.example.brzodolokacije.Activities.ActivityForgottenPassword +import com.example.brzodolokacije.Adapters.MyPostsAdapter  import com.google.android.material.bottomsheet.BottomSheetDialog @@ -107,7 +108,7 @@ class FragmentUserPosts : Fragment() {      private fun loadPosts(){//most viewed          rvPosts.apply {              layoutManager= GridLayoutManager(requireContext(),2,GridLayoutManager.VERTICAL,false) -            adapter= ShowPostsAdapter(requireActivity(),posts) +            adapter= MyPostsAdapter(requireActivity(),posts)          }      } diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserProfile.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserProfile.kt index 8ab5276..6b1bac9 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserProfile.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Fragments/FragmentUserProfile.kt @@ -7,28 +7,8 @@ import android.view.View  import android.view.ViewGroup  import com.example.brzodolokacije.R -// TODO: Rename parameter arguments, choose names that match -// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER -private const val ARG_PARAM1 = "param1" -private const val ARG_PARAM2 = "param2" - -/** - * A simple [Fragment] subclass. - * Use the [FragmentUserProfile.newInstance] factory method to - * create an instance of this fragment. - */  class FragmentUserProfile : Fragment() { -    // TODO: Rename and change types of parameters -    private var param1: String? = null -    private var param2: String? = null -    override fun onCreate(savedInstanceState: Bundle?) { -        super.onCreate(savedInstanceState) -        arguments?.let { -            param1 = it.getString(ARG_PARAM1) -            param2 = it.getString(ARG_PARAM2) -        } -    }      override fun onCreateView(          inflater: LayoutInflater, container: ViewGroup?, @@ -38,23 +18,5 @@ class FragmentUserProfile : Fragment() {          return inflater.inflate(R.layout.fragment_user_profile, container, false)      } -    companion object { -        /** -         * Use this factory method to create a new instance of -         * this fragment using the provided parameters. -         * -         * @param param1 Parameter 1. -         * @param param2 Parameter 2. -         * @return A new instance of fragment FragmentUserProfile. -         */ -        // TODO: Rename and change types and number of parameters -        @JvmStatic -        fun newInstance(param1: String, param2: String) = -            FragmentUserProfile().apply { -                arguments = Bundle().apply { -                    putString(ARG_PARAM1, param1) -                    putString(ARG_PARAM2, param2) -                } -            } -    } +  }
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt index 1ba6b53..f7bb9b6 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Interfaces/IBackendApi.kt @@ -65,6 +65,18 @@ interface IBackendApi {                          ):PagedPosts      @POST("/api/message/add")      fun sendMessage(@Header("Authorization") authHeader:String,@Body message:MessageSend):Call<Message> +    @GET("/api/user/history") +    fun getMyHistory(@Header("Authorization") authHeader:String):Call<MutableList<PostPreview>>  //@POST("putanja")      //fun add(@Body obj:Post,@Header("Authorization") authHeader:String):Call<Post> + +    @POST("/api/user/{id}/followers") +    fun getFollowers(@Path("id") id:String):Call <MutableList<UserReceive>> + +    @POST("/api/user{id}/following") +    fun getFollowing(@Path("id") id:String):Call <MutableList<UserReceive>> + +    @POST("/api/user{id}/addFollower") +    fun addFollower(@Header("Authorization") authHeader:String,@Path("id") id:String):Call<UserReceive> +  }
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Post.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Post.kt index a292160..e2e9209 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Post.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/Post.kt @@ -34,7 +34,8 @@ data class PostPreview (      var views:Int,      var ratings:Float,      var comments:List<CommentSend>?, -    var images:List<PostImage> +    var images:List<PostImage>, +    var tags:List<String>?      //nedostaju datum i vreme kreiranja  ):Parcelable diff --git a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/User.kt b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/User.kt index c726978..46338b3 100644 --- a/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/User.kt +++ b/Client/BrzoDoLokacije/app/src/main/java/com/example/brzodolokacije/Models/User.kt @@ -14,9 +14,9 @@ data class User (      //profil      var followers:List<User>, -    var followersNumber:Int, +    var followersCount:Int,      var following:List<User>, -    var followingNumber:Int, +    var followingCount:Int,      var postIds:List<Int>,      var postNumber:Int @@ -28,5 +28,11 @@ data class UserReceive(      var email:String,      var creationDate: Date,      var pfp:PostImage?, -    var postcount:Int +    var postcount:Int, +    var followers:List<User>, +    var followersNumber:Int, +    var following:List<User>, +    var followingNumber:Int, +    var postIds:List<Int>, +    var postNumber:Int  )
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml new file mode 100644 index 0000000..deef1f8 --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_followers.xml @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="utf-8"?> +<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +    xmlns:tools="http://schemas.android.com/tools" +    android:layout_width="match_parent" +    android:layout_height="match_parent" +    tools:context=".Fragments.FragmentFollowers"> + +    <LinearLayout +        android:layout_width="match_parent" +        android:layout_height="match_parent" +        android:orientation="vertical"> + +        <TextView +            android:layout_width="wrap_content" +            android:layout_height="wrap_content" +            android:layout_gravity="left" +            android:text="Pratioci" +            android:textSize="20sp" +            android:textStyle="bold" /> + +        <androidx.recyclerview.widget.RecyclerView +            android:id="@+id/rvFragmentShowFollowers" +            android:layout_width="match_parent" +            android:layout_height="match_parent" /> +    </LinearLayout> +</FrameLayout>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_my_recensions.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_my_recensions.xml index d5452b9..72706e0 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_my_recensions.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_my_recensions.xml @@ -1,14 +1,28 @@  <?xml version="1.0" encoding="utf-8"?> -<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" +<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:layout_width="match_parent"      android:layout_height="match_parent"      tools:context=".Fragments.FragmentMyRecensions"> -    <!-- TODO: Update blank fragment layout --> -    <TextView + +    <com.google.android.material.divider.MaterialDivider +        android:id="@+id/materialDivider" +        android:layout_width="match_parent" +        android:layout_height="50dp" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="parent" +        android:visibility="invisible"/> + +    <androidx.recyclerview.widget.RecyclerView +        android:id="@+id/rvFragmentMyRecensionPostHistory"          android:layout_width="match_parent" -        android:layout_height="match_parent" -        android:text="Moje recenzije" /> +        android:layout_height="wrap_content" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toBottomOf="@+id/materialDivider" +        android:layout_marginHorizontal="16dp"/> -</FrameLayout>
\ No newline at end of file +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml index c75e1e4..ec78de6 100644 --- a/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/fragment_profile.xml @@ -151,6 +151,7 @@                  <TextView                      android:id="@+id/tvFragmentProfileFollowers"                      android:gravity="center" +                    android:clickable="true"                      android:text="PRATIOCI" />                  <TextView @@ -231,7 +232,7 @@              android:layout_marginTop="4dp"              android:backgroundTint="#FFFFFF"              android:stateListAnimator="@null" -            android:text="Recenzije" +            android:text="Istorija"              android:textColor="@color/cardview_dark_background"              app:layout_constraintStart_toEndOf="@+id/btnFragmentProfileShowMyPosts"              app:layout_constraintTop_toBottomOf="@+id/tvFragmentProfileInfoContainer" /> diff --git a/Client/BrzoDoLokacije/app/src/main/res/layout/single_post_history.xml b/Client/BrzoDoLokacije/app/src/main/res/layout/single_post_history.xml new file mode 100644 index 0000000..12c29ee --- /dev/null +++ b/Client/BrzoDoLokacije/app/src/main/res/layout/single_post_history.xml @@ -0,0 +1,75 @@ +<?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:layout_width="match_parent" +    android:layout_height="wrap_content" +    android:layout_margin="0dp" +    android:background="@drawable/rounded_picture_background" +    android:clipToOutline="true" +    > + + + + +    <View +        android:id="@+id/vBannerSinglePostHistory" +        android:layout_width="match_parent" +        android:layout_height="80dp" +        android:background="@color/dark_blue_transparent" +        android:outlineProvider="background" +        app:layout_constraintBottom_toBottomOf="parent" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintHorizontal_bias="0.0" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="parent" +        app:layout_constraintVertical_bias="0.0" +        tools:layout_editor_absoluteX="10dp" +        android:layout_marginTop="5dp" +        > + + +    </View> + +    <TextView +        android:id="@+id/tvTitleSinglePostHistory" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:gravity="top|left" +        android:text="Naslov" +        android:textColor="@color/white" +        app:layout_constraintBottom_toBottomOf="parent" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintHorizontal_bias="0.076" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="@+id/vBannerSinglePostHistory" +        app:layout_constraintVertical_bias="0.18" /> + +    <TextView +        android:id="@+id/tvLocationTypeSinglePostHistory" +        android:layout_width="wrap_content" +        android:layout_height="wrap_content" +        android:text="Tip lokacije" +        android:textColor="@color/white" +        app:layout_constraintBottom_toBottomOf="@+id/vBannerSinglePostHistory" +        app:layout_constraintEnd_toStartOf="@+id/tvLocationParentSinglePostHistory" +        app:layout_constraintHorizontal_bias="0.112" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="@+id/vBannerSinglePostHistory" +        app:layout_constraintVertical_bias="0.721" /> + +    <TextView +        android:id="@+id/tvLocationParentSinglePostHistory" +        android:layout_width="wrap_content" +        android:layout_height="match_parent" +        android:text="22.11.2022" +        android:textAlignment="viewEnd" +        android:textColor="@color/white" +        app:layout_constraintBottom_toBottomOf="parent" +        app:layout_constraintEnd_toEndOf="parent" +        app:layout_constraintHorizontal_bias="0.952" +        app:layout_constraintStart_toStartOf="parent" +        app:layout_constraintTop_toTopOf="@+id/vBannerSinglePostHistory" +        app:layout_constraintVertical_bias="0.737" /> + +</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file | 
