diff options
3 files changed, 97 insertions, 70 deletions
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 efe2ac2..450fa41 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 @@ -9,6 +9,7 @@ import android.net.Uri import android.os.Bundle import android.util.Log import android.util.TypedValue +import android.view.KeyEvent import android.view.View import android.widget.* import androidx.appcompat.app.AppCompatActivity @@ -109,41 +110,18 @@ class ActivityAddPost : AppCompatActivity() { } //dodavanje i brisanje tagova tagButtonAdd.setOnClickListener { - tagText.isGone=false - tagText.isVisible=true - - if(tagList.count()<4 && tagText.text.toString().length>=3) { - var tagstr = tagText.text.toString() - var newbtn = Button(this) - newbtn.setId(tagidcounter) - newbtn.text = tagstr - var layoutParams = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - 50 - ) - layoutParams.setMargins(3) - newbtn.layoutParams=layoutParams - newbtn.setBackgroundColor(Color.parseColor("#1C789A")) - newbtn.setTextColor(Color.WHITE) - newbtn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10F) - newbtn.setPadding(3,1,3,1) - - newbtn.setOnClickListener { - var btntext = newbtn.text.toString() - tagList.remove(btntext) - tagButtons.remove(newbtn) - tagLayout.removeView(newbtn) - } - - tagList.add(tagstr) - tagButtons.add(newbtn) - tagLayout.addView(newbtn) - tagText.text.clear() - } - else{ - Toast.makeText(this,"Maksimalno 4 tagova ( duzine + karaktera)",Toast.LENGTH_LONG) - } + addTag() } + tagText.setOnKeyListener(View.OnKeyListener { v1, keyCode, event -> // If the event is a key-down event on the "enter" button + if (event.action === KeyEvent.ACTION_DOWN && + keyCode == KeyEvent.KEYCODE_ENTER + ) { + // Perform action on key press + addTag() + return@OnKeyListener true + } + false + }) //dodavanje iz galerije uploadFromGallery.setOnClickListener{ @@ -208,7 +186,42 @@ class ActivityAddPost : AppCompatActivity() { } } } + fun addTag(){ + tagText.isGone=false + tagText.isVisible=true + + if(tagList.count()<4 && tagText.text.toString().length>=3) { + var tagstr = tagText.text.toString() + var newbtn = Button(this) + newbtn.setId(tagidcounter) + newbtn.text = tagstr + var layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + 50 + ) + layoutParams.setMargins(3) + newbtn.layoutParams=layoutParams + newbtn.setBackgroundColor(Color.parseColor("#1C789A")) + newbtn.setTextColor(Color.WHITE) + newbtn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10F) + newbtn.setPadding(3,1,3,1) + + newbtn.setOnClickListener { + var btntext = newbtn.text.toString() + tagList.remove(btntext) + tagButtons.remove(newbtn) + tagLayout.removeView(newbtn) + } + tagList.add(tagstr) + tagButtons.add(newbtn) + tagLayout.addView(newbtn) + tagText.text.clear() + } + else{ + Toast.makeText(this,"Maksimalno 4 tagova ( duzine + karaktera)",Toast.LENGTH_LONG) + } + } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { 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 0221241..f012da0 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 @@ -11,6 +11,7 @@ import android.os.Bundle import android.provider.MediaStore import android.util.Log import android.util.TypedValue +import android.view.KeyEvent import android.view.View import android.widget.* import androidx.activity.result.contract.ActivityResultContracts @@ -95,42 +96,18 @@ class ActivityCapturePost : AppCompatActivity() { } //dodavanje i brisanje tagova tagButtonAdd.setOnClickListener { - tagText.isGone=false - tagText.isVisible=true - - if(tagList.count()<4 && tagText.text.toString().length>=3) { - var tagstr = tagText.text.toString() - var newbtn = Button(this) - newbtn.setId(tagidcounter) - newbtn.text = tagstr - var layoutParams = LinearLayout.LayoutParams( - LinearLayout.LayoutParams.WRAP_CONTENT, - 50 - ) - layoutParams.setMargins(3) - newbtn.layoutParams=layoutParams - newbtn.setBackgroundColor(Color.parseColor("#1C789A")) - newbtn.setTextColor(Color.WHITE) - newbtn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10F) - newbtn.setPadding(3,1,3,1) - - newbtn.setOnClickListener { - var btntext = newbtn.text.toString() - tagList.remove(btntext) - tagButtons.remove(newbtn) - tagLayout.removeView(newbtn) - } - - tagList.add(tagstr) - tagButtons.add(newbtn) - tagLayout.addView(newbtn) - tagText.text.clear() - } - else{ - Toast.makeText(this,"Maksimalno 4 tagova (duzine 3+ karaktera)",Toast.LENGTH_LONG) - } + addTag() } - + tagText.setOnKeyListener(View.OnKeyListener { v1, keyCode, event -> // If the event is a key-down event on the "enter" button + if (event.action === KeyEvent.ACTION_DOWN && + keyCode == KeyEvent.KEYCODE_ENTER + ) { + // Perform action on key press + addTag() + return@OnKeyListener true + } + false + }) //dodavanje sa kamere @@ -225,6 +202,42 @@ class ActivityCapturePost : AppCompatActivity() { } } + fun addTag(){ + tagText.isGone=false + tagText.isVisible=true + + if(tagList.count()<4 && tagText.text.toString().length>=3) { + var tagstr = tagText.text.toString() + var newbtn = Button(this) + newbtn.setId(tagidcounter) + newbtn.text = tagstr + var layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + 50 + ) + layoutParams.setMargins(3) + newbtn.layoutParams=layoutParams + newbtn.setBackgroundColor(Color.parseColor("#1C789A")) + newbtn.setTextColor(Color.WHITE) + newbtn.setTextSize(TypedValue.COMPLEX_UNIT_SP, 10F) + newbtn.setPadding(3,1,3,1) + + newbtn.setOnClickListener { + var btntext = newbtn.text.toString() + tagList.remove(btntext) + tagButtons.remove(newbtn) + tagLayout.removeView(newbtn) + } + + tagList.add(tagstr) + tagButtons.add(newbtn) + tagLayout.addView(newbtn) + tagText.text.clear() + } + else{ + Toast.makeText(this,"Maksimalno 4 tagova ( duzine + karaktera)",Toast.LENGTH_LONG) + } + } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if(requestCode==LOCATIONREQCODE && resultCode== RESULT_OK){ 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 index db3fc2e..79f0af2 100644 --- 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 @@ -13,6 +13,7 @@ import com.example.brzodolokacije.Models.PostPreview import com.example.brzodolokacije.Services.RetrofitHelper import com.example.brzodolokacije.Services.SharedPreferencesHelper import com.example.brzodolokacije.databinding.SinglePostHistoryBinding +import java.text.SimpleDateFormat class PostHistoryAdapter (val activity:Activity,val items : MutableList<PostPreview>) @@ -39,7 +40,7 @@ class PostHistoryAdapter (val activity:Activity,val items : MutableList<PostPrev fun bind(item: PostPreview) { binding.apply { tvTitleSinglePostHistory.text = item.location.name - tvLocationParentSinglePostHistory.text = "22.11.2022" + tvLocationParentSinglePostHistory.text = SimpleDateFormat("dd/MM/yyyy").format(item.lastViewed) tvLocationTypeSinglePostHistory.text = item.location.country } |