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) return CardViewHolder(v)
} }
fun getSubstAt(i: Int): Subst {
return mSubst[i]
} // do I need this in Kotlin?
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)
@@ -95,6 +91,19 @@ class CardAdapter(private var mSubst: List<Subst>) : RecyclerView.Adapter<CardAd
} 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) {
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 override fun getItemCount(): Int = mSubst.size
@@ -42,6 +42,14 @@ class ColourAdapter(private var mColours: List<Colour>, onClickListener: OnClick
R.color.colorBackgroundLight R.color.colorBackgroundLight
} }
holder.cardView.setCardBackgroundColor(ContextCompat.getColor(holder.image.context, colour)) 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 override fun getItemCount(): Int = mColours.size
@@ -11,6 +11,7 @@ import android.preference.PreferenceManager
import android.view.View import android.view.View
import android.widget.RemoteViews import android.widget.RemoteViews
import androidx.core.app.NotificationCompat import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.google.android.material.snackbar.Snackbar import com.google.android.material.snackbar.Snackbar
import org.jsoup.Jsoup import org.jsoup.Jsoup
@@ -41,7 +42,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
private val edit = prefs.edit() private val edit = prefs.edit()
private var currentTime = "" private var currentTime = ""
private var currentFoodTime = "" 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" private val foodUrl = "https://djd4rkn355.github.io/food.html"
override fun doInBackground(vararg params: Void?): Void? { override fun doInBackground(vararg params: Void?): Void? {
@@ -224,7 +225,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
} catch (e: Exception) { } catch (e: Exception) {
mView?.let { v: View -> mView?.let { v: View ->
val snackBarView = v.findViewById<View>(R.id.coordination) 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 return null
@@ -307,8 +307,20 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
colourPickerBuilder.setView(pickerDialogView) colourPickerBuilder.setView(pickerDialogView)
val colourPickerDialog: AlertDialog = colourPickerBuilder.create() 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 buttons = arrayOf<MaterialButton>(picker.findViewById(R.id.def), picker.findViewById(R.id.red),
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) 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) { for (i2 in 0 until buttons.size) {
buttons[i2].setOnClickListener { buttons[i2].setOnClickListener {
@@ -122,4 +122,122 @@
</TableRow> </TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/pureWhite"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgPureWhite"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/salmon"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgSalmon"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/tangerine"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgTangerine"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/banana"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgBanana"
app:cornerRadius="16dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/flora"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgFlora"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/spindrift"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgSpindrift"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/sky"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgSky"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/orchid"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgOrchid"
app:cornerRadius="16dp"/>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/lavender"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgLavender"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/carnation"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgCarnation"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/brown2"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgBrown2"
app:cornerRadius="16dp"/>
<com.google.android.material.button.MaterialButton
style="@style/Widget.MaterialComponents.Button.UnelevatedButton"
android:id="@+id/pureBlack"
android:layout_margin="8dp"
android:layout_weight="1"
android:backgroundTint="@color/bgPureBlack"
app:cornerRadius="16dp"/>
</TableRow>
<!-- 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.bgLavender, R.color.bgCarnation,-->
<!-- R.color.bgBrown2, R.color.bgPureBlack)-->
</TableLayout> </TableLayout>
+13
View File
@@ -19,5 +19,18 @@
<color name="bgBrown">#442F1B</color> <color name="bgBrown">#442F1B</color>
<color name="bgGrey">#3C3F43</color> <color name="bgGrey">#3C3F43</color>
<color name="bgSalmon">#7F3E3C</color>
<color name="bgTangerine">#7F4900</color>
<color name="bgBanana">#7F7D3C</color> <!-- hmm -->
<color name="bgFlora">#397C3C</color>
<color name="bgSpindrift">#397D6A</color>
<color name="bgSky">#3A6A7F</color>
<color name="bgOrchid">#3C407F</color>
<color name="bgLavender">#6B417F</color>
<color name="bgCarnation">#7F446B</color>
<color name="bgBrown2">#554633</color>
<color name="colorError">#CF6679</color>
<color name="colorSplashLogo">@color/colorText</color> <color name="colorSplashLogo">@color/colorText</color>
</resources> </resources>
+18
View File
@@ -22,6 +22,24 @@
<color name="bgBrown">#E6C9A8</color> <color name="bgBrown">#E6C9A8</color>
<color name="bgGrey">#BDBDBD</color> <color name="bgGrey">#BDBDBD</color>
<color name="bgPureWhite">#FFFFFF</color>
<color name="bgSalmon">#FF7E79</color>
<color name="bgTangerine">#FF9300</color>
<color name="bgBanana">#FFFC79</color>
<color name="bgFlora">#73FA79</color>
<color name="bgSpindrift">#73FCD6</color>
<color name="bgSky">#76D6FF</color>
<color name="bgOrchid">#7A81FF</color>
<color name="bgLavender">#D783FF</color>
<color name="bgCarnation">#FF8AD8</color>
<color name="bgBrown2">#AC8E68</color>
<color name="bgPureBlack">#000000</color>
<color name="colorTextDark">#212121</color>
<color name="colorTextLight">#e0e0e0</color>
<color name="colorError">#B00020</color>
<color name="mtrl_textinput_default_box_stroke_color" tools:override="true">#757575</color> <color name="mtrl_textinput_default_box_stroke_color" tools:override="true">#757575</color>
<color name="colorSplashLogo">@color/colorAccent</color> <color name="colorSplashLogo">@color/colorAccent</color>