diff --git a/app/src/main/java/com/uncmorfi/shared/Constants.kt b/app/src/main/java/com/uncmorfi/shared/Constants.kt index 66ca12a..fef8ebf 100644 --- a/app/src/main/java/com/uncmorfi/shared/Constants.kt +++ b/app/src/main/java/com/uncmorfi/shared/Constants.kt @@ -10,6 +10,10 @@ const val COCINA_URL = "http://comedor.unc.edu.ar/cocina.php" const val PROFILE_PIC_URL = "https://asiruws.unc.edu.ar/foto/" const val SANAVIRON_URL = "https://autogestion.sanaviron.unc.edu.ar/micuenta" +const val SEC_BIMO_INSTAGRAM = "bienestarunc" +const val SEC_BIMO = "Bienestar estudiantil" +const val SEC_BIMO_IMAGE_URL = "https://instagram.fcor11-2.fna.fbcdn.net/v/t51.2885-19/334511791_3355595628037957_747727577920527220_n.jpg?stp=dst-jpg_s150x150&_nc_ht=instagram.fcor11-2.fna.fbcdn.net&_nc_cat=101&_nc_ohc=Cy02AXv5WLgAX_LlPGF&edm=ACWDqb8BAAAA&ccb=7-5&oh=00_AfC8gq9Jf8t29S39wsBXMwX_huB8gDlq4eSYPsedDjqHhQ&oe=64DD41B1&_nc_sid=ee9879" + const val ARG_CARD = "card" const val ARG_USER = "user" diff --git a/app/src/main/java/com/uncmorfi/shared/Helper.kt b/app/src/main/java/com/uncmorfi/shared/Helper.kt index 59a4d7b..4736e1e 100644 --- a/app/src/main/java/com/uncmorfi/shared/Helper.kt +++ b/app/src/main/java/com/uncmorfi/shared/Helper.kt @@ -3,6 +3,7 @@ package com.uncmorfi.shared import android.app.Activity import android.app.PendingIntent import android.app.PendingIntent.FLAG_IMMUTABLE +import android.content.ActivityNotFoundException import android.content.ClipData import android.content.ClipboardManager import android.content.Context @@ -162,6 +163,25 @@ fun Activity.openFacebook() { } } +fun Activity.openInstagram(user : String){ + val userUrl = "http://instagram.com/stories/$user/" + val url = "http://instagram.com/$user" + + val uri = Uri.parse(userUrl) + val intent = Intent(Intent.ACTION_VIEW, uri) + intent.setPackage("com.instagram.android") + + try { + ContextCompat.startActivity(this,intent,null) + } catch (e: ActivityNotFoundException) { + ContextCompat.startActivity(this, + Intent( + Intent.ACTION_VIEW, + Uri.parse(url) + ),null) + } +} + fun Activity.shareText(subject: String, text: String, title: String = "UNCmorfi"): Boolean { val i = Intent(Intent.ACTION_SEND) i.type = "text/plain" @@ -231,4 +251,4 @@ fun TextView.updateVisibility() { inline fun LifecycleOwner.observe(liveData: LiveData, crossinline body: (T) -> Unit) { liveData.observe(this, { body.invoke(it) }) -} +} \ No newline at end of file diff --git a/app/src/main/java/com/uncmorfi/ui/menu/BiMoView.kt b/app/src/main/java/com/uncmorfi/ui/menu/BiMoView.kt new file mode 100644 index 0000000..4719cdd --- /dev/null +++ b/app/src/main/java/com/uncmorfi/ui/menu/BiMoView.kt @@ -0,0 +1,33 @@ +package com.uncmorfi.ui.menu + +import android.content.Context +import android.util.AttributeSet +import android.view.LayoutInflater +import com.bumptech.glide.Glide +import com.google.android.material.card.MaterialCardView +import com.uncmorfi.R +import kotlinx.android.synthetic.main.view_bimo.view.bimoImageView +import kotlinx.android.synthetic.main.view_bimo.view.bimoTextView + +class BiMoView @JvmOverloads constructor( + context: Context, + attr: AttributeSet? = null, + defStyleAttr: Int = 0 +) : MaterialCardView(context, attr, defStyleAttr) { + + init { + LayoutInflater.from(context).inflate(R.layout.view_bimo, this, true) + } + + fun setImage(url : String){ + Glide + .with(this) + .load(url) + .circleCrop() + .into(bimoImageView) + } + + fun setName(name : String){ + bimoTextView.setText(name) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/uncmorfi/ui/menu/MenuFragment.kt b/app/src/main/java/com/uncmorfi/ui/menu/MenuFragment.kt index 1bec3be..c385202 100644 --- a/app/src/main/java/com/uncmorfi/ui/menu/MenuFragment.kt +++ b/app/src/main/java/com/uncmorfi/ui/menu/MenuFragment.kt @@ -39,6 +39,7 @@ class MenuFragment : Fragment() { swipeRefresh.init { viewModel.forceRefreshMenu() } initRecyclerAndAdapter() initMenu() + initBiMoUnc() observe(viewModel.getMenu()) { menu -> adapter.updateMenu(menu) @@ -81,6 +82,14 @@ class MenuFragment : Fragment() { menuRecyclerView.adapter = adapter } + private fun initBiMoUnc() { + bimoCard.setImage(SEC_BIMO_IMAGE_URL) + bimoCard.setName(SEC_BIMO) + bimoCard.setOnClickListener { + requireActivity().openInstagram(SEC_BIMO_INSTAGRAM) + } + } + override fun onResume() { super.onResume() requireActivity().setTitle(R.string.navigation_menu) diff --git a/app/src/main/res/layout/fragment_menu.xml b/app/src/main/res/layout/fragment_menu.xml index 0f22747..1dc21f9 100644 --- a/app/src/main/res/layout/fragment_menu.xml +++ b/app/src/main/res/layout/fragment_menu.xml @@ -1,21 +1,36 @@ - + android:layout_height="match_parent" + tools:context=".ui.menu.MenuFragment"> + + + + - - - \ No newline at end of file + android:scrollbars="none" + tools:listitem="@layout/item_menu" /> + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_bimo.xml b/app/src/main/res/layout/view_bimo.xml new file mode 100644 index 0000000..c7be485 --- /dev/null +++ b/app/src/main/res/layout/view_bimo.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + \ No newline at end of file