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,68 +38,92 @@ 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
|
||||||
|
|
||||||
try {
|
if (currentItem.date.isNotEmpty() && currentItem.date.substring(0, 3) == "psa") {
|
||||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
psa = true
|
||||||
colour = when (colorCheck) {
|
holder.mDate.text = ""
|
||||||
"deu", "dep", "daz", "fda" -> prefs.getInt("bgGerman", 0)
|
holder.mImageView.setImageResource(R.drawable.ic_idea)
|
||||||
"mat", "map" -> prefs.getInt("bgMaths", 0)
|
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mImageView.context, R.color.colorAccent))
|
||||||
"eng", "enp", "ena" -> prefs.getInt("bgEnglish", 0)
|
if (currentItem.date.substring(3, 7) == "http") {
|
||||||
"spo", "spp", "spth" -> prefs.getInt("bgPhysEd", 0)
|
holder.mCard.setOnClickListener {
|
||||||
"pol", "pop" -> prefs.getInt("bgPolitics", 0)
|
try {
|
||||||
"dar", "dap" -> prefs.getInt("bgTheatre", 0)
|
CustomTabsIntent.Builder().build().launchUrl(holder.mCard.context,
|
||||||
"phy", "php" -> prefs.getInt("bgPhysics", 0)
|
Uri.parse(currentItem.date.substring(3)))
|
||||||
"bio", "bip", "nw1", "nw2", "nw3", "nw4" -> prefs.getInt("bgBiology", 0)
|
} catch (e: ActivityNotFoundException) {
|
||||||
"che", "chp" -> prefs.getInt("bgChemistry", 0)
|
Toast.makeText(holder.mCard.context, holder.mCard.context.getString(R.string.chromeCompatibleNotFound), Toast.LENGTH_LONG).show()
|
||||||
"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 (e: StringIndexOutOfBoundsException) {
|
} else {
|
||||||
|
holder.mDate.text = currentItem.date
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!psa) {
|
||||||
try {
|
try {
|
||||||
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 2)
|
colorCheck = holder.mCourse.text.toString().toLowerCase().substring(0, 3)
|
||||||
colour = when (colorCheck) {
|
colour = when (colorCheck) {
|
||||||
"nw" -> prefs.getInt("bgBiology", 0)
|
"deu", "dep", "daz", "fda" -> prefs.getInt("bgGerman", 0)
|
||||||
"wp" -> prefs.getInt("bgWP", 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
|
else -> 0
|
||||||
}
|
}
|
||||||
} catch (e2: StringIndexOutOfBoundsException) {
|
} catch (e: StringIndexOutOfBoundsException) {
|
||||||
colour = 0
|
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) {
|
val textColor = if (psa) {
|
||||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, colour))
|
R.color.colorBackground
|
||||||
} else {
|
} else {
|
||||||
holder.mCard.setCardBackgroundColor(ContextCompat.getColor(holder.mCourse.context, R.color.colorBackgroundLight))
|
when (colour) {
|
||||||
}
|
R.color.bgPureWhite -> R.color.colorTextDark
|
||||||
|
R.color.bgPureBlack -> R.color.colorTextLight
|
||||||
val textColor = when (colour) {
|
else -> R.color.colorText
|
||||||
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.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))
|
||||||
|
|||||||
@@ -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