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
|
||||
|
||||
import android.content.ActivityNotFoundException
|
||||
import android.net.Uri
|
||||
import android.preference.PreferenceManager
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.browser.customtabs.CustomTabsIntent
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
@@ -34,68 +38,92 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
|
||||
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
|
||||
val currentItem = mSubst[position]
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(holder.mImageView.context)
|
||||
var psa = false
|
||||
|
||||
holder.mImageView.setImageResource(currentItem.icon)
|
||||
holder.mGroup.text = currentItem.group
|
||||
holder.mDate.text = currentItem.date
|
||||
holder.mTime.text = currentItem.time
|
||||
holder.mCourse.text = currentItem.course
|
||||
holder.mRoom.text = currentItem.room
|
||||
holder.mAdditional.text = currentItem.additional
|
||||
|
||||
try {
|
||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
||||
colour = when (colorCheck) {
|
||||
"deu", "dep", "daz", "fda" -> prefs.getInt("bgGerman", 0)
|
||||
"mat", "map" -> prefs.getInt("bgMaths", 0)
|
||||
"eng", "enp", "ena" -> prefs.getInt("bgEnglish", 0)
|
||||
"spo", "spp", "spth" -> prefs.getInt("bgPhysEd", 0)
|
||||
"pol", "pop" -> prefs.getInt("bgPolitics", 0)
|
||||
"dar", "dap" -> prefs.getInt("bgTheatre", 0)
|
||||
"phy", "php" -> prefs.getInt("bgPhysics", 0)
|
||||
"bio", "bip", "nw1", "nw2", "nw3", "nw4" -> prefs.getInt("bgBiology", 0)
|
||||
"che", "chp" -> prefs.getInt("bgChemistry", 0)
|
||||
"phi", "psp" -> prefs.getInt("bgPhilosophy", 0)
|
||||
"laa", "laf", "lat" -> prefs.getInt("bgLatin", 0)
|
||||
"spa", "spf" -> prefs.getInt("bgSpanish", 0)
|
||||
"fra", "frf", "frz" -> prefs.getInt("bgFrench", 0)
|
||||
"inf" -> prefs.getInt("bgCompsci", 0)
|
||||
"ges" -> prefs.getInt("bgHistory", 0)
|
||||
"rel" -> prefs.getInt("bgReligion", 0)
|
||||
"geg" -> prefs.getInt("bgGeography", 0)
|
||||
"kun" -> prefs.getInt("bgArts", 0)
|
||||
"mus" -> prefs.getInt("bgMusic", 0)
|
||||
"tue" -> prefs.getInt("bgTurkish", 0)
|
||||
"chi" -> prefs.getInt("bgChinese", 0)
|
||||
"gll" -> prefs.getInt("bgGLL", 0)
|
||||
"wat" -> prefs.getInt("bgWAT", 0)
|
||||
"för" -> prefs.getInt("bgForder", 0)
|
||||
"met", "wpb" -> prefs.getInt("bgWP", 0)
|
||||
else -> 0
|
||||
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()
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: StringIndexOutOfBoundsException) {
|
||||
} else {
|
||||
holder.mDate.text = currentItem.date
|
||||
}
|
||||
|
||||
if (!psa) {
|
||||
try {
|
||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 2)
|
||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
||||
colour = when (colorCheck) {
|
||||
"nw" -> prefs.getInt("bgBiology", 0)
|
||||
"wp" -> prefs.getInt("bgWP", 0)
|
||||
"deu", "dep", "daz", "fda" -> prefs.getInt("bgGerman", 0)
|
||||
"mat", "map" -> prefs.getInt("bgMaths", 0)
|
||||
"eng", "enp", "ena" -> prefs.getInt("bgEnglish", 0)
|
||||
"spo", "spp", "spth" -> prefs.getInt("bgPhysEd", 0)
|
||||
"pol", "pop" -> prefs.getInt("bgPolitics", 0)
|
||||
"dar", "dap" -> prefs.getInt("bgTheatre", 0)
|
||||
"phy", "php" -> prefs.getInt("bgPhysics", 0)
|
||||
"bio", "bip", "nw1", "nw2", "nw3", "nw4" -> prefs.getInt("bgBiology", 0)
|
||||
"che", "chp" -> prefs.getInt("bgChemistry", 0)
|
||||
"phi", "psp" -> prefs.getInt("bgPhilosophy", 0)
|
||||
"laa", "laf", "lat" -> prefs.getInt("bgLatin", 0)
|
||||
"spa", "spf" -> prefs.getInt("bgSpanish", 0)
|
||||
"fra", "frf", "frz" -> prefs.getInt("bgFrench", 0)
|
||||
"inf" -> prefs.getInt("bgCompsci", 0)
|
||||
"ges" -> prefs.getInt("bgHistory", 0)
|
||||
"rel" -> prefs.getInt("bgReligion", 0)
|
||||
"geg" -> prefs.getInt("bgGeography", 0)
|
||||
"kun" -> prefs.getInt("bgArts", 0)
|
||||
"mus" -> prefs.getInt("bgMusic", 0)
|
||||
"tue" -> prefs.getInt("bgTurkish", 0)
|
||||
"chi" -> prefs.getInt("bgChinese", 0)
|
||||
"gll" -> prefs.getInt("bgGLL", 0)
|
||||
"wat" -> prefs.getInt("bgWAT", 0)
|
||||
"för" -> prefs.getInt("bgForder", 0)
|
||||
"met", "wpb" -> prefs.getInt("bgWP", 0)
|
||||
else -> 0
|
||||
}
|
||||
} catch (e2: StringIndexOutOfBoundsException) {
|
||||
colour = 0
|
||||
} catch (e: StringIndexOutOfBoundsException) {
|
||||
try {
|
||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 2)
|
||||
colour = when (colorCheck) {
|
||||
"nw" -> prefs.getInt("bgBiology", 0)
|
||||
"wp" -> prefs.getInt("bgWP", 0)
|
||||
else -> 0
|
||||
}
|
||||
} catch (e2: StringIndexOutOfBoundsException) {
|
||||
colour = 0
|
||||
}
|
||||
}
|
||||
if (colour != 0) {
|
||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour))
|
||||
} else {
|
||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight))
|
||||
}
|
||||
}
|
||||
|
||||
if (colour != 0) {
|
||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour))
|
||||
val textColor = if (psa) {
|
||||
R.color.colorBackground
|
||||
} else {
|
||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight))
|
||||
}
|
||||
|
||||
val textColor = when (colour) {
|
||||
R.color.bgPureWhite -> R.color.colorTextDark
|
||||
R.color.bgPureBlack -> R.color.colorTextLight
|
||||
else -> R.color.colorText
|
||||
when (colour) {
|
||||
R.color.bgPureWhite -> R.color.colorTextDark
|
||||
R.color.bgPureBlack -> R.color.colorTextLight
|
||||
else -> R.color.colorText
|
||||
}
|
||||
}
|
||||
holder.mImageView.setColorFilter(ContextCompat.getColor(holder.mImageView.context, textColor))
|
||||
holder.mGroup.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
|
||||
|
||||
@@ -21,7 +21,9 @@ class PersonalPlanFragment : PlanFragment() {
|
||||
persPlanEmpty = true
|
||||
recyclerView.visibility = View.VISIBLE
|
||||
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 ((prefs.getString("classes", "") ?: "").contains(it[i].group) || it[i].group.contains((prefs.getString("classes", "") ?: "").toString())) {
|
||||
planCardList.add(it[i])
|
||||
@@ -45,7 +47,7 @@ class PersonalPlanFragment : PlanFragment() {
|
||||
|
||||
handler.postDelayed({
|
||||
if (persPlanEmpty) {
|
||||
recyclerView.visibility = View.GONE
|
||||
// recyclerView.visibility = View.GONE
|
||||
smileydown.visibility = View.VISIBLE
|
||||
smileydowntext.visibility = View.VISIBLE
|
||||
linearsmiley.visibility = View.VISIBLE
|
||||
|
||||
Reference in New Issue
Block a user