Archived
Fixed some visual and UX bugs in the colour picker
This commit is contained in:
@@ -5,12 +5,9 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.material.button.MaterialButton
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
|
||||
class ColourAdapter(private var mColours: List<Colour>, onClickListener: OnClickListener) : RecyclerView.Adapter<ColourAdapter.ColourViewHolder>() {
|
||||
@@ -21,6 +18,7 @@ class ColourAdapter(private var mColours: List<Colour>, onClickListener: OnClick
|
||||
val title: TextView = view.findViewById(R.id.item_text)
|
||||
var image: ImageView = view.findViewById(R.id.item_image)
|
||||
val titleNoLang: TextView = view.findViewById(R.id.item_text_no_lang)
|
||||
val cardView: MaterialCardView = view.findViewById(R.id.cardView)
|
||||
val mClickListener = clickListener
|
||||
init { view.setOnClickListener(this) }
|
||||
|
||||
@@ -40,9 +38,12 @@ class ColourAdapter(private var mColours: List<Colour>, onClickListener: OnClick
|
||||
holder.title.text = currentItem.title
|
||||
holder.titleNoLang.text = currentItem.titleNoLang
|
||||
holder.image.setImageDrawable(ContextCompat.getDrawable(holder.image.context, currentItem.icon))
|
||||
if (currentItem.colour != 0) {
|
||||
holder.image.drawable.setTint(ContextCompat.getColor(holder.image.context, currentItem.colour))
|
||||
val colour = if (currentItem.colour != 0) {
|
||||
currentItem.colour
|
||||
} else {
|
||||
R.color.lightbackground
|
||||
}
|
||||
holder.cardView.setCardBackgroundColor(ContextCompat.getColor(holder.image.context, colour))
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = mColours.size
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.denizd.substitutionplan
|
||||
import android.app.*
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Color
|
||||
import android.media.RingtoneManager
|
||||
import android.os.AsyncTask
|
||||
@@ -20,11 +19,9 @@ import androidx.core.app.NotificationCompat
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import org.jsoup.Jsoup
|
||||
import org.jsoup.nodes.Document
|
||||
import org.jsoup.select.Elements
|
||||
import java.lang.IndexOutOfBoundsException
|
||||
import java.net.URL
|
||||
import java.net.URLConnection
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
@@ -48,18 +45,10 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
private var priority = 200
|
||||
private var notifText = ""
|
||||
private var informational = ""
|
||||
private lateinit var connection: URLConnection
|
||||
private lateinit var rows: Elements
|
||||
private lateinit var paragraphs: Elements
|
||||
private lateinit var foodElements: Elements
|
||||
private lateinit var doc: Document
|
||||
private lateinit var docFood: Document
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext) as SharedPreferences
|
||||
private val edit = prefs.edit() as SharedPreferences.Editor
|
||||
private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
|
||||
private val edit = prefs.edit()
|
||||
private lateinit var pullToRefresh: SwipeRefreshLayout
|
||||
private lateinit var progressBar: ProgressBar
|
||||
private val substViewModel = SubstViewModel(mApplication)
|
||||
private val foodViewModel = FoodViewModel(mApplication)
|
||||
private val oldDateFormat = "EEE, dd MMM yyyy HH:mm:ss zzz"
|
||||
private val newDateFormat = "yyyy-MM-dd, HH:mm:ss"
|
||||
private var sdf = SimpleDateFormat(oldDateFormat)
|
||||
@@ -75,8 +64,9 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
progressBar.progress = 0
|
||||
}
|
||||
if (menu) {
|
||||
docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get()
|
||||
foodElements = docFood.select("th")
|
||||
val foodViewModel = FoodViewModel(mApplication)
|
||||
val docFood = Jsoup.connect("https://djd4rkn355.github.io/food.html").get()
|
||||
val foodElements = docFood.select("th")
|
||||
|
||||
mView?.let {
|
||||
progressBar.max = foodElements.size
|
||||
@@ -150,12 +140,13 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
}
|
||||
|
||||
if (plan) {
|
||||
doc = Jsoup.connect("https://djd4rkn355.github.io/subst").get()
|
||||
connection = URL("https://djd4rkn355.github.io/subst").openConnection()
|
||||
val substViewModel = SubstViewModel(mApplication)
|
||||
val doc = Jsoup.connect("https://djd4rkn355.github.io/subst_test").get()
|
||||
val connection = URL("https://djd4rkn355.github.io/subst").openConnection()
|
||||
edit.putString("time", connection.getHeaderField("Last-Modified")).apply()
|
||||
d = sdf.parse(connection.getHeaderField("Last-Modified"))
|
||||
rows = doc.select("tr")
|
||||
paragraphs = doc.select("p")
|
||||
val rows = doc.select("tr")
|
||||
val paragraphs = doc.select("p")
|
||||
|
||||
val groupS = ArrayList<String>()
|
||||
val dateS = ArrayList<String>()
|
||||
@@ -179,8 +170,6 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
|
||||
substViewModel.deleteAllSubst()
|
||||
|
||||
val md = MiscData()
|
||||
|
||||
for (i in 0 until rows.size) {
|
||||
val row = rows[i]
|
||||
val cols = row.select("th") as Elements
|
||||
@@ -197,7 +186,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
}
|
||||
}
|
||||
|
||||
val drawable = md.getIcon(courseS[i])
|
||||
val drawable = MiscData.getIcon(courseS[i])
|
||||
val subst = Subst(drawable, groupS[i], dateS[i], timeS[i], courseS[i],
|
||||
roomS[i], additionalS[i], priority)
|
||||
priority--
|
||||
@@ -231,7 +220,7 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
val openApp = Intent(mContext, Main::class.java)
|
||||
openApp.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
openApp.flags += Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
val openAppPending = PendingIntent.getActivity(mContext, 0, openApp, 0) // PendingIntent.FLAG_ONE_SHOT
|
||||
val openAppPending = PendingIntent.getActivity(mContext, 0, openApp, 0)
|
||||
|
||||
val notificationLayout = RemoteViews(mContext.packageName, R.layout.notification)
|
||||
notificationLayout.setTextViewText(R.id.notification_title, mContext.getString(R.string.subst))
|
||||
@@ -241,10 +230,9 @@ class DataFetcher(isplan: Boolean, ismenu: Boolean, isjobservice: Boolean, conte
|
||||
val manager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||
val channelId = "general"
|
||||
val channelName = mContext.getString(R.string.general)
|
||||
lateinit var channel: NotificationChannel
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
channel = NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT)
|
||||
val channel = NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_DEFAULT)
|
||||
channel.enableLights(true)
|
||||
channel.lightColor = Color.BLUE
|
||||
manager.createNotificationChannel(channel)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.denizd.substitutionplan
|
||||
|
||||
class MiscData {
|
||||
object MiscData {
|
||||
|
||||
fun emoji(unicode: Int): String { return String(Character.toChars(unicode)) }
|
||||
|
||||
|
||||
@@ -4,12 +4,7 @@ import android.app.job.JobParameters
|
||||
import android.app.job.JobService
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkInfo
|
||||
import android.preference.PreferenceManager
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import java.io.IOException
|
||||
import java.lang.NullPointerException
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URL
|
||||
|
||||
class NotificationService : JobService() {
|
||||
@@ -31,13 +26,10 @@ class NotificationService : JobService() {
|
||||
val prefs = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
val edit = prefs.edit()
|
||||
val connectivityManager = getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||
val statusMobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).state
|
||||
val statusWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).state
|
||||
val networkStatus = connectivityManager.activeNetworkInfo
|
||||
|
||||
Thread(Runnable {
|
||||
if (jobCancelled) {
|
||||
return@Runnable
|
||||
} else if (statusMobile != NetworkInfo.State.CONNECTED && statusWifi != NetworkInfo.State.CONNECTED) {
|
||||
if (jobCancelled || networkStatus == null) {
|
||||
return@Runnable
|
||||
}
|
||||
if (prefs.getBoolean("notif", false)) {
|
||||
@@ -45,7 +37,7 @@ class NotificationService : JobService() {
|
||||
try {
|
||||
val url = URL("https://djd4rkn355.github.io/subst.html")
|
||||
val connection = url.openConnection()
|
||||
if (!connection.getHeaderField("Last-Modified").equals(prefs.getString("time", ""))) {
|
||||
if (connection.getHeaderField("Last-Modified") != prefs.getString("time", "")) {
|
||||
DataFetcher(true, true, true, context, application, null).execute()
|
||||
edit.putString("time", connection.getHeaderField("Last-Modified")).apply()
|
||||
}
|
||||
|
||||
@@ -325,7 +325,9 @@ class SettingsFragment : Fragment(R.layout.content_settings), View.OnClickListen
|
||||
for (i2 in 0 until buttons.size) {
|
||||
buttons[i2].setOnClickListener {
|
||||
prefs.edit().putInt("bg$titleNoLang", colours[i2]).apply()
|
||||
val recyclerViewState = colourRecycler.layoutManager?.onSaveInstanceState()
|
||||
colourRecycler.adapter = ColourAdapter(getColourList(), this)
|
||||
colourRecycler.layoutManager?.onRestoreInstanceState(recyclerViewState)
|
||||
colourPickerDialog.dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@
|
||||
android:layout_marginEnd="8dp"
|
||||
app:layout_anchor="@+id/bottom_sheet"
|
||||
android:layout_gravity="top"
|
||||
android:background="@color/lighthintcolor"/>
|
||||
android:background="@color/lighthintcolor"
|
||||
android:clickable="false"
|
||||
android:focusable="false"/>
|
||||
|
||||
<com.google.android.material.bottomnavigation.BottomNavigationView
|
||||
android:id="@+id/bottom_nav"
|
||||
|
||||
@@ -1,30 +1,57 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="horizontal" android:layout_width="match_parent"
|
||||
<com.google.android.material.card.MaterialCardView xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/cardView"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:cardBackgroundColor="@color/lightbackground"
|
||||
app:cardCornerRadius="8dp"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
style="@style/SelectableItemBackground"
|
||||
android:id="@+id/item_layout">
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginTop="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
app:cardElevation="1dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_image"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_margin="16dp"
|
||||
android:tint="@color/textcolor"/>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_text"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/textcolor"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
<ImageView
|
||||
android:id="@+id/item_image"
|
||||
android:layout_width="24dp"
|
||||
android:layout_height="24dp"
|
||||
android:layout_margin="16dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:tint="@color/textcolor"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/item_text"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@+id/item_text" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/item_text_no_lang"
|
||||
android:visibility="gone"/>
|
||||
<TextView
|
||||
android:id="@+id/item_text"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="8dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:textAlignment="viewStart"
|
||||
android:textColor="@color/textcolor"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/item_image"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
</LinearLayout>
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:id="@+id/item_text_no_lang"
|
||||
android:visibility="gone"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
@@ -12,7 +12,7 @@
|
||||
<color name="bgyellow">#635C1F</color>
|
||||
<color name="bggreen">#355823</color>
|
||||
<color name="bgteal">#19504B</color>
|
||||
<color name="bgcyan">#2F555D</color>
|
||||
<color name="bgcyan">#125a6d</color>
|
||||
<color name="bgblue">#1F3B5E</color>
|
||||
<color name="bgpurple">#42295D</color>
|
||||
<color name="bgpink">#5A2345</color>
|
||||
|
||||
Reference in New Issue
Block a user