Archived
Added PSA feature that allows for delivering a message or a link to users
This commit is contained in:
@@ -1,11 +1,15 @@
|
|||||||
package com.denizd.substitutionplan
|
package com.denizd.substitutionplan
|
||||||
|
|
||||||
|
import android.content.ActivityNotFoundException
|
||||||
|
import android.net.Uri
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
|
import androidx.browser.customtabs.CustomTabsIntent
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
@@ -34,15 +38,35 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
|||||||
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
|
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
|
||||||
val currentItem = mSubst[position]
|
val currentItem = mSubst[position]
|
||||||
val prefs = PreferenceManager.getDefaultSharedPreferences(holder.mImageView.context)
|
val prefs = PreferenceManager.getDefaultSharedPreferences(holder.mImageView.context)
|
||||||
|
var psa = false
|
||||||
|
|
||||||
holder.mImageView.setImageResource(currentItem.icon)
|
holder.mImageView.setImageResource(currentItem.icon)
|
||||||
holder.mGroup.text = currentItem.group
|
holder.mGroup.text = currentItem.group
|
||||||
holder.mDate.text = currentItem.date
|
|
||||||
holder.mTime.text = currentItem.time
|
holder.mTime.text = currentItem.time
|
||||||
holder.mCourse.text = currentItem.course
|
holder.mCourse.text = currentItem.course
|
||||||
holder.mRoom.text = currentItem.room
|
holder.mRoom.text = currentItem.room
|
||||||
holder.mAdditional.text = currentItem.additional
|
holder.mAdditional.text = currentItem.additional
|
||||||
|
|
||||||
|
if (currentItem.date.isNotEmpty() && currentItem.date.substring(0, 3) == "psa") {
|
||||||
|
psa = true
|
||||||
|
holder.mDate.text = ""
|
||||||
|
holder.mImageView.setImageResource(R.drawable.ic_idea)
|
||||||
|
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mImageView.context, R.color.colorAccent))
|
||||||
|
if (currentItem.date.substring(3, 7) == "http") {
|
||||||
|
holder.mCard.setOnClickListener {
|
||||||
|
try {
|
||||||
|
CustomTabsIntent.Builder().build().launchUrl(holder.mCard.context,
|
||||||
|
Uri.parse(currentItem.date.substring(3)))
|
||||||
|
} catch (e: ActivityNotFoundException) {
|
||||||
|
Toast.makeText(holder.mCard.context, holder.mCard.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
holder.mDate.text = currentItem.date
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!psa) {
|
||||||
try {
|
try {
|
||||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
||||||
colour = when (colorCheck) {
|
colour = when (colorCheck) {
|
||||||
@@ -85,18 +109,22 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
|||||||
colour = 0
|
colour = 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (colour != 0) {
|
if (colour != 0) {
|
||||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour))
|
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour))
|
||||||
} else {
|
} else {
|
||||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight))
|
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val textColor = when (colour) {
|
val textColor = if (psa) {
|
||||||
|
R.color.colorBackground
|
||||||
|
} else {
|
||||||
|
when (colour) {
|
||||||
R.color.bgPureWhite -> R.color.colorTextDark
|
R.color.bgPureWhite -> R.color.colorTextDark
|
||||||
R.color.bgPureBlack -> R.color.colorTextLight
|
R.color.bgPureBlack -> R.color.colorTextLight
|
||||||
else -> R.color.colorText
|
else -> R.color.colorText
|
||||||
}
|
}
|
||||||
|
}
|
||||||
holder.mImageView.setColorFilter(ContextCompat.getColor(holder.mImageView.context, textColor))
|
holder.mImageView.setColorFilter(ContextCompat.getColor(holder.mImageView.context, textColor))
|
||||||
holder.mGroup.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
|
holder.mGroup.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
|
||||||
holder.mDate.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
|
holder.mDate.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ class PersonalPlanFragment : PlanFragment() {
|
|||||||
persPlanEmpty = true
|
persPlanEmpty = true
|
||||||
recyclerView.visibility = View.VISIBLE
|
recyclerView.visibility = View.VISIBLE
|
||||||
for (i in 0 until it.size) {
|
for (i in 0 until it.size) {
|
||||||
if ((prefs.getString("courses", "") ?: "").isEmpty() && (prefs.getString("classes", "") ?: "").isNotEmpty()) {
|
if (it[i].date.isNotEmpty() && it[i].date.substring(0, 3) == "psa") {
|
||||||
|
planCardList.add(it[i])
|
||||||
|
} else if ((prefs.getString("courses", "") ?: "").isEmpty() && (prefs.getString("classes", "") ?: "").isNotEmpty()) {
|
||||||
if (it[i].group.isNotEmpty() && it[i].group != "") {
|
if (it[i].group.isNotEmpty() && it[i].group != "") {
|
||||||
if ((prefs.getString("classes", "") ?: "").contains(it[i].group) || it[i].group.contains((prefs.getString("classes", "") ?: "").toString())) {
|
if ((prefs.getString("classes", "") ?: "").contains(it[i].group) || it[i].group.contains((prefs.getString("classes", "") ?: "").toString())) {
|
||||||
planCardList.add(it[i])
|
planCardList.add(it[i])
|
||||||
@@ -45,7 +47,7 @@ class PersonalPlanFragment : PlanFragment() {
|
|||||||
|
|
||||||
handler.postDelayed({
|
handler.postDelayed({
|
||||||
if (persPlanEmpty) {
|
if (persPlanEmpty) {
|
||||||
recyclerView.visibility = View.GONE
|
// recyclerView.visibility = View.GONE
|
||||||
smileydown.visibility = View.VISIBLE
|
smileydown.visibility = View.VISIBLE
|
||||||
smileydowntext.visibility = View.VISIBLE
|
smileydowntext.visibility = View.VISIBLE
|
||||||
linearsmiley.visibility = View.VISIBLE
|
linearsmiley.visibility = View.VISIBLE
|
||||||
|
|||||||
@@ -37,7 +37,8 @@
|
|||||||
app:layout_anchor="@+id/smileydown"
|
app:layout_anchor="@+id/smileydown"
|
||||||
android:layout_gravity="bottom|center_horizontal"
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:textColor="@color/colorHint"
|
android:textColor="@color/colorHint"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user