Added iOS colours for user customisation, "No internet available" snackbar now tinted red

This commit is contained in:
Deniz Düzgören
2019-08-06 11:56:44 +02:00
parent 6ed3257ca1
commit f9cac0b123
7 changed files with 187 additions and 8 deletions
@@ -31,10 +31,6 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
return CardViewHolder(v)
}
fun getSubstAt(i: Int): Subst {
return mSubst[i]
} // do I need this in Kotlin?
override fun onBindViewHolder(holder: CardViewHolder, position: Int) {
val currentItem = mSubst[position]
val prefs = PreferenceManager.getDefaultSharedPreferences(holder.mImageView.context)
@@ -95,6 +91,19 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
} 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
}
holder.mImageView.setColorFilter(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.mTime.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
holder.mCourse.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
holder.mRoom.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
holder.mAdditional.setTextColor(ContextCompat.getColor(holder.mImageView.context, textColor))
}
override fun getItemCount(): Int = mSubst.size
@@ -42,6 +42,14 @@ class ColourAdapter(private var mColours: List<Colour>, onClickListener: OnClick
R.color.colorBackgroundLight
}
holder.cardView.setCardBackgroundColor(ContextCompat.getColor(holder.image.context, colour))
val textColor = when (colour) {
R.color.bgPureWhite -> R.color.colorTextDark
R.color.bgPureBlack -> R.color.colorTextLight
else -> R.color.colorText
}
holder.image.setColorFilter(ContextCompat.getColor(holder.image.context, textColor))
holder.title.setTextColor(ContextCompat.getColor(holder.title.context, textColor))
}
override fun getItemCount(): Int = mColours.size
@@ -11,6 +11,7 @@ import android.preference.PreferenceManager
import android.view.View
import android.widget.RemoteViews
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar
import org.jsoup.Jsoup
@@ -41,7 +42,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
private val edit = prefs.edit()
private var currentTime = ""
private var currentFoodTime = ""
private val substUrl = "https://djd4rkn355.github.io/subst.html"
private val substUrl = "https://djd4rkn355.github.io/subst_test.html"
private val foodUrl = "https://djd4rkn355.github.io/food.html"
override fun doInBackground(vararg params: Void?): Void? {
@@ -224,7 +225,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} catch (e: Exception) {
mView?.let { v: View ->
val snackBarView = v.findViewById<View>(R.id.coordination)
Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).show()
Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).setBackgroundTint(ContextCompat.getColor(mContext, R.color.colorError)).show()
}
}
return null
@@ -307,8 +307,20 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
colourPickerBuilder.setView(pickerDialogView)
val colourPickerDialog: AlertDialog = colourPickerBuilder.create()
val buttons = arrayOf<MaterialButton>(picker.findViewById(R.id.def), picker.findViewById(R.id.red), picker.findViewById(R.id.orange), picker.findViewById(R.id.yellow), picker.findViewById(R.id.green), picker.findViewById(R.id.teal), picker.findViewById(R.id.cyan), picker.findViewById(R.id.blue), picker.findViewById(R.id.purple), picker.findViewById(R.id.pink), picker.findViewById(R.id.brown), picker.findViewById(R.id.grey))
val colours = intArrayOf(0, R.color.bgRed, R.color.bgOrange, R.color.bgYellow, R.color.bgGreen, R.color.bgTeal, R.color.bgCyan, R.color.bgBlue, R.color.bgPurple, R.color.bgPink, R.color.bgBrown, R.color.bgGrey)
val buttons = arrayOf<MaterialButton>(picker.findViewById(R.id.def), picker.findViewById(R.id.red),
picker.findViewById(R.id.orange), picker.findViewById(R.id.yellow), picker.findViewById(R.id.green),
picker.findViewById(R.id.teal), picker.findViewById(R.id.cyan), picker.findViewById(R.id.blue),
picker.findViewById(R.id.purple), picker.findViewById(R.id.pink), picker.findViewById(R.id.brown),
picker.findViewById(R.id.grey), picker.findViewById(R.id.pureWhite), picker.findViewById(R.id.salmon),
picker.findViewById(R.id.tangerine), picker.findViewById(R.id.banana), picker.findViewById(R.id.flora),
picker.findViewById(R.id.spindrift), picker.findViewById(R.id.sky), picker.findViewById(R.id.orchid),
picker.findViewById(R.id.lavender), picker.findViewById(R.id.carnation), picker.findViewById(R.id.brown2),
picker.findViewById(R.id.pureBlack))
val colours = intArrayOf(0, R.color.bgRed, R.color.bgOrange, R.color.bgYellow, R.color.bgGreen,
R.color.bgTeal, R.color.bgCyan, R.color.bgBlue, R.color.bgPurple, R.color.bgPink, R.color.bgBrown, R.color.bgGrey,
R.color.bgPureWhite, R.color.bgSalmon, R.color.bgTangerine, R.color.bgBanana, R.color.bgFlora, R.color.bgSpindrift,
R.color.bgSky, R.color.bgOrchid, R.color.bgLavender, R.color.bgCarnation, R.color.bgBrown2, R.color.bgPureBlack)
for (i2 in 0 until buttons.size) {
buttons[i2].setOnClickListener {