Archived
Renamed HelperFunctions to SubstUtil, played around with Kotlin extensions
This commit is contained in:
@@ -20,7 +20,7 @@ import androidx.appcompat.app.AppCompatActivity
|
|||||||
import androidx.constraintlayout.widget.ConstraintLayout
|
import androidx.constraintlayout.widget.ConstraintLayout
|
||||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
import com.denizd.substitutionplan.R
|
import com.denizd.substitutionplan.R
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
import com.google.android.material.textfield.TextInputEditText
|
import com.google.android.material.textfield.TextInputEditText
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -44,7 +44,7 @@ internal class FirstTime : AppCompatActivity(R.layout.activity_first_time) {
|
|||||||
val parentLayout = findViewById<ConstraintLayout>(R.id.coordinatorLayout)
|
val parentLayout = findViewById<ConstraintLayout>(R.id.coordinatorLayout)
|
||||||
parentLayout.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
parentLayout.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
|
||||||
|
|
||||||
HelperFunctions.setTheme(window = window, context = context)
|
SubstUtil.setTheme(window = window, context = context)
|
||||||
|
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences
|
prefs = PreferenceManager.getDefaultSharedPreferences(context) as SharedPreferences
|
||||||
val edit = prefs.edit()
|
val edit = prefs.edit()
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
|
|||||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat
|
||||||
import com.denizd.substitutionplan.R
|
import com.denizd.substitutionplan.R
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.data.LoginWebViewClient
|
import com.denizd.substitutionplan.data.LoginWebViewClient
|
||||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
@@ -48,7 +48,7 @@ internal class Login : AppCompatActivity(R.layout.activity_login_webview), Login
|
|||||||
val title = findViewById<TextView>(R.id.txtWelcome)
|
val title = findViewById<TextView>(R.id.txtWelcome)
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
prefs = PreferenceManager.getDefaultSharedPreferences(this)
|
||||||
|
|
||||||
HelperFunctions.setTheme(window = window, context = this)
|
SubstUtil.setTheme(window = window, context = this)
|
||||||
|
|
||||||
logInButton = findViewById(R.id.loginFab)
|
logInButton = findViewById(R.id.loginFab)
|
||||||
logInButton.setOnClickListener {
|
logInButton.setOnClickListener {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import androidx.core.widget.NestedScrollView
|
|||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.FragmentTransaction
|
import androidx.fragment.app.FragmentTransaction
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.R
|
import com.denizd.substitutionplan.R
|
||||||
import com.denizd.substitutionplan.fragments.FoodFragment
|
import com.denizd.substitutionplan.fragments.FoodFragment
|
||||||
import com.denizd.substitutionplan.fragments.GeneralPlanFragment
|
import com.denizd.substitutionplan.fragments.GeneralPlanFragment
|
||||||
@@ -70,7 +70,7 @@ internal class Main : AppCompatActivity(R.layout.app_bar_main) {
|
|||||||
else -> { // launch the app
|
else -> { // launch the app
|
||||||
|
|
||||||
if (!prefs.getBoolean("colourTransferred", false)) {
|
if (!prefs.getBoolean("colourTransferred", false)) {
|
||||||
HelperFunctions.transferOldColourIntsToString(prefs, context)
|
SubstUtil.transferOldColourIntsToString(prefs, context)
|
||||||
edit.putBoolean("colourTransferred", true).apply()
|
edit.putBoolean("colourTransferred", true).apply()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import android.widget.Toast
|
|||||||
import androidx.browser.customtabs.CustomTabsIntent
|
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.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.R
|
import com.denizd.substitutionplan.R
|
||||||
import com.denizd.substitutionplan.models.Substitution
|
import com.denizd.substitutionplan.models.Substitution
|
||||||
import com.google.android.material.card.MaterialCardView
|
import com.google.android.material.card.MaterialCardView
|
||||||
@@ -89,16 +89,16 @@ internal class SubstitutionAdapter(private var substitutions: List<Substitution>
|
|||||||
val add = currentItem.additional
|
val add = currentItem.additional
|
||||||
val type = currentItem.type.toLowerCase(Locale.ROOT)
|
val type = currentItem.type.toLowerCase(Locale.ROOT)
|
||||||
if (add.isNotEmpty()) {
|
if (add.isNotEmpty()) {
|
||||||
if (HelperFunctions.checkStringForArray(add, HelperFunctions.cancellations, true)) {
|
if (SubstUtil.checkStringForArray(add, SubstUtil.cancellations, true)) {
|
||||||
strikeThrough(strings)
|
strings.strikeThrough()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HelperFunctions.checkStringForArray(type, HelperFunctions.cancellations, true)) {
|
if (SubstUtil.checkStringForArray(type, SubstUtil.cancellations, true)) {
|
||||||
strikeThrough(strings)
|
strings.strikeThrough()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var icon = HelperFunctions.getIconForCourse(currentItem.course)
|
var icon = SubstUtil.getIconForCourse(currentItem.course)
|
||||||
holder.group.setText(strings[0], TextView.BufferType.SPANNABLE)
|
holder.group.setText(strings[0], TextView.BufferType.SPANNABLE)
|
||||||
holder.time.setText(strings[1], TextView.BufferType.SPANNABLE)
|
holder.time.setText(strings[1], TextView.BufferType.SPANNABLE)
|
||||||
holder.course.setText(strings[2], TextView.BufferType.SPANNABLE)
|
holder.course.setText(strings[2], TextView.BufferType.SPANNABLE)
|
||||||
@@ -113,13 +113,13 @@ internal class SubstitutionAdapter(private var substitutions: List<Substitution>
|
|||||||
cardBackgroundColour = R.color.colorAccent
|
cardBackgroundColour = R.color.colorAccent
|
||||||
View.GONE
|
View.GONE
|
||||||
} else {
|
} else {
|
||||||
val colourString = HelperFunctions.getColourString(holder.course.text.toString())
|
val colourString = SubstUtil.getColourString(holder.course.text.toString())
|
||||||
val colourPrefsInt = if (colourString.isNotEmpty()) {
|
val colourPrefsInt = if (colourString.isNotEmpty()) {
|
||||||
prefs.getString("card$colourString", "") ?: ""
|
prefs.getString("card$colourString", "") ?: ""
|
||||||
} else {
|
} else {
|
||||||
""
|
""
|
||||||
}
|
}
|
||||||
colour = HelperFunctions.getColourForString(colourPrefsInt, holder.context)
|
colour = SubstUtil.getColourForString(colourPrefsInt, holder.context)
|
||||||
cardBackgroundColour = if (colour != 0) {
|
cardBackgroundColour = if (colour != 0) {
|
||||||
colour
|
colour
|
||||||
} else {
|
} else {
|
||||||
@@ -171,7 +171,7 @@ internal class SubstitutionAdapter(private var substitutions: List<Substitution>
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Strikes through the strings for course, room and teacher
|
/// Strikes through the strings for course, room and teacher
|
||||||
private fun strikeThrough(strings: Array<SpannableString>) {
|
private fun Array<SpannableString>.strikeThrough() {
|
||||||
for (i in 2..4) { strings[i].setSpan(StrikethroughSpan(), 0, strings[i].length, 0) }
|
for (i in 2..4) { this[i].setSpan(StrikethroughSpan(), 0, this[i].length, 0) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,8 +11,6 @@ import android.util.Log
|
|||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
import android.widget.TextView
|
|
||||||
import androidx.appcompat.app.AlertDialog
|
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||||
@@ -137,7 +135,7 @@ internal class DataFetcher(
|
|||||||
val indices = ArrayList<Int>()
|
val indices = ArrayList<Int>()
|
||||||
val daysAndVon = arrayOf("montag", "dienstag", "mittwoch", "donnerstag", "freitag", "von", "wünschen")
|
val daysAndVon = arrayOf("montag", "dienstag", "mittwoch", "donnerstag", "freitag", "von", "wünschen")
|
||||||
for (i in 0 until foodElements.size) {
|
for (i in 0 until foodElements.size) {
|
||||||
if (HelperFunctions.checkStringForArray(foodElements[i].text(), daysAndVon, true)) indices.add(i)
|
if (SubstUtil.checkStringForArray(foodElements[i].text(), daysAndVon, true)) indices.add(i)
|
||||||
}
|
}
|
||||||
indices.add(foodElements.size)
|
indices.add(foodElements.size)
|
||||||
|
|
||||||
@@ -194,8 +192,8 @@ internal class DataFetcher(
|
|||||||
additional = cols[5].text(),
|
additional = cols[5].text(),
|
||||||
teacher = cols[6].text(),
|
teacher = cols[6].text(),
|
||||||
type = cols[7].text(),
|
type = cols[7].text(),
|
||||||
priority = HelperFunctions.assignRanking(group, (date.length > 2 && date.substring(0, 3) == "psa")),
|
priority = SubstUtil.assignRanking(group, (date.length > 2 && date.substring(0, 3) == "psa")),
|
||||||
date_priority = HelperFunctions.assignDatePriority(date),
|
date_priority = SubstUtil.assignDatePriority(date),
|
||||||
website_priority = websitePriority
|
website_priority = websitePriority
|
||||||
)
|
)
|
||||||
substArray.add(subst)
|
substArray.add(subst)
|
||||||
@@ -206,7 +204,7 @@ internal class DataFetcher(
|
|||||||
var countOfMoreNotificationItems = 0
|
var countOfMoreNotificationItems = 0
|
||||||
if (jobService && prefs.getBoolean("notif", true)) {
|
if (jobService && prefs.getBoolean("notif", true)) {
|
||||||
substArray.filter { substItem ->
|
substArray.filter { substItem ->
|
||||||
HelperFunctions.checkPersonalSubstitutions(
|
SubstUtil.checkPersonalSubstitutions(
|
||||||
substItem,
|
substItem,
|
||||||
coursePreference,
|
coursePreference,
|
||||||
classPreference,
|
classPreference,
|
||||||
@@ -249,10 +247,10 @@ internal class DataFetcher(
|
|||||||
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
val manager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
HelperFunctions.getNotificationChannel(context, prefs)
|
SubstUtil.getNotificationChannel(context, prefs)
|
||||||
}
|
}
|
||||||
|
|
||||||
val notification = NotificationCompat.Builder(context, HelperFunctions.notificationChannelId)
|
val notification = NotificationCompat.Builder(context, SubstUtil.notificationChannelId)
|
||||||
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
.setStyle(NotificationCompat.DecoratedCustomViewStyle())
|
||||||
.setCustomContentView(notificationLayout)
|
.setCustomContentView(notificationLayout)
|
||||||
.setContentIntent(openAppPending)
|
.setContentIntent(openAppPending)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ internal class LoginWebViewClient(private val successListener: OnLoginSuccessLis
|
|||||||
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
override fun onPageStarted(view: WebView?, url: String?, favicon: Bitmap?) {
|
||||||
super.onPageStarted(view, url, favicon)
|
super.onPageStarted(view, url, favicon)
|
||||||
|
|
||||||
if (!HelperFunctions.checkStringForArray(url.toString(), schoolUrls, false)) {
|
if (!SubstUtil.checkStringForArray(url.toString(), schoolUrls, false)) {
|
||||||
reloadLoginPage(webView = view)
|
reloadLoginPage(webView = view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -34,7 +34,7 @@ import javax.xml.parsers.DocumentBuilderFactory
|
|||||||
* An object class used for declaring functions and variables used by multiple classes throughout
|
* An object class used for declaring functions and variables used by multiple classes throughout
|
||||||
* the project. As it is an object class, it can be accessed statically without initialisation
|
* the project. As it is an object class, it can be accessed statically without initialisation
|
||||||
*/
|
*/
|
||||||
internal object HelperFunctions {
|
internal object SubstUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A language-independent list of all courses that is used to save the custom colours of any
|
* A language-independent list of all courses that is used to save the custom colours of any
|
||||||
@@ -401,20 +401,20 @@ internal object HelperFunctions {
|
|||||||
private val prefTypes = arrayOf("string", "string", "string", "bool", "int", "bool", "bool", "bool",
|
private val prefTypes = arrayOf("string", "string", "string", "bool", "int", "bool", "bool", "bool",
|
||||||
"string", "int", "int", "bool", "bool")
|
"string", "int", "int", "bool", "bool")
|
||||||
|
|
||||||
private fun getPrefValue(prefs: SharedPreferences, type: String, key: String): Any {
|
private fun SharedPreferences.getPrefValue(type: String, key: String): Any {
|
||||||
return when (type) {
|
return when (type) {
|
||||||
"string" -> prefs.getString(key, "") ?: ""
|
"string" -> getString(key, "") ?: ""
|
||||||
"int" -> prefs.getInt(key, 0)
|
"int" -> getInt(key, 0)
|
||||||
"bool" -> prefs.getBoolean(key, false)
|
"bool" -> getBoolean(key, false)
|
||||||
else -> ""
|
else -> ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setPrefValue(prefs: SharedPreferences, key: String, value: String, type: String) {
|
private fun SharedPreferences.setPrefValue(key: String, value: String, type: String) {
|
||||||
when (type) {
|
when (type) {
|
||||||
"int" -> prefs.edit().putInt(key, value.toInt()).apply()
|
"int" -> edit().putInt(key, value.toInt()).apply()
|
||||||
"string" -> prefs.edit().putString(key, value).apply()
|
"string" -> edit().putString(key, value).apply()
|
||||||
"bool" -> prefs.edit().putBoolean(key, value.toBoolean()).apply()
|
"bool" -> edit().putBoolean(key, value.toBoolean()).apply()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,7 +439,7 @@ internal object HelperFunctions {
|
|||||||
var input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<items>"
|
var input = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<items>"
|
||||||
for (i in localPrefKeys.indices) {
|
for (i in localPrefKeys.indices) {
|
||||||
input += "\n\t<key>${localPrefKeys[i]}</key>" +
|
input += "\n\t<key>${localPrefKeys[i]}</key>" +
|
||||||
"\n\t<value>${getPrefValue(prefs, localPrefTypes[i], localPrefKeys[i])}</value>"
|
"\n\t<value>${prefs.getPrefValue(localPrefTypes[i], localPrefKeys[i])}</value>"
|
||||||
}
|
}
|
||||||
input += "\n</items>"
|
input += "\n</items>"
|
||||||
out.apply {
|
out.apply {
|
||||||
@@ -471,7 +471,7 @@ internal object HelperFunctions {
|
|||||||
for (i in localPrefTypes.indices) {
|
for (i in localPrefTypes.indices) {
|
||||||
val key = document.getElementsByTagName("key").item(i).textContent
|
val key = document.getElementsByTagName("key").item(i).textContent
|
||||||
val value = document.getElementsByTagName("value").item(i).textContent
|
val value = document.getElementsByTagName("value").item(i).textContent
|
||||||
setPrefValue(prefs, key, value, localPrefTypes[i])
|
prefs.setPrefValue(key, value, localPrefTypes[i])
|
||||||
}
|
}
|
||||||
Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_LONG).show()
|
Toast.makeText(context, context.getString(R.string.success), Toast.LENGTH_LONG).show()
|
||||||
} else {
|
} else {
|
||||||
@@ -16,7 +16,6 @@ internal abstract class SubstDatabase : RoomDatabase() {
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
private var instance: SubstDatabase? = null
|
|
||||||
private val addTeacherColumn = object : Migration(5, 6) {
|
private val addTeacherColumn = object : Migration(5, 6) {
|
||||||
override fun migrate(database: SupportSQLiteDatabase) {
|
override fun migrate(database: SupportSQLiteDatabase) {
|
||||||
database.execSQL("ALTER TABLE subst_table ADD COLUMN teacher TEXT NOT NULL DEFAULT ''")
|
database.execSQL("ALTER TABLE subst_table ADD COLUMN teacher TEXT NOT NULL DEFAULT ''")
|
||||||
@@ -38,6 +37,8 @@ internal abstract class SubstDatabase : RoomDatabase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var instance: SubstDatabase? = null
|
||||||
|
|
||||||
fun getInstance(context: Context): SubstDatabase? {
|
fun getInstance(context: Context): SubstDatabase? {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
synchronized (SubstDatabase::class) {
|
synchronized (SubstDatabase::class) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import androidx.lifecycle.Observer
|
|||||||
import androidx.lifecycle.ViewModelProviders
|
import androidx.lifecycle.ViewModelProviders
|
||||||
import androidx.recyclerview.widget.GridLayoutManager
|
import androidx.recyclerview.widget.GridLayoutManager
|
||||||
import com.denizd.substitutionplan.adapters.FoodAdapter
|
import com.denizd.substitutionplan.adapters.FoodAdapter
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.database.FoodViewModel
|
import com.denizd.substitutionplan.database.FoodViewModel
|
||||||
import com.denizd.substitutionplan.databinding.FoodLayoutBinding
|
import com.denizd.substitutionplan.databinding.FoodLayoutBinding
|
||||||
import com.denizd.substitutionplan.models.Food
|
import com.denizd.substitutionplan.models.Food
|
||||||
@@ -50,7 +50,7 @@ internal class FoodFragment : Fragment() {
|
|||||||
foodViewModel.allFoods?.observe(this, Observer<List<Food>> { foodList ->
|
foodViewModel.allFoods?.observe(this, Observer<List<Food>> { foodList ->
|
||||||
binding.recyclerView.scheduleLayoutAnimation()
|
binding.recyclerView.scheduleLayoutAnimation()
|
||||||
mAdapter.setFood(if (foodList.isEmpty()) {
|
mAdapter.setFood(if (foodList.isEmpty()) {
|
||||||
HelperFunctions.getEmptyFoodMenu(mContext)
|
SubstUtil.getEmptyFoodMenu(mContext)
|
||||||
} else {
|
} else {
|
||||||
foodList
|
foodList
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.denizd.substitutionplan.fragments
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.models.Substitution
|
import com.denizd.substitutionplan.models.Substitution
|
||||||
|
|
||||||
internal class GeneralPlanFragment : PlanFragment() {
|
internal class GeneralPlanFragment : PlanFragment() {
|
||||||
@@ -13,7 +13,7 @@ internal class GeneralPlanFragment : PlanFragment() {
|
|||||||
|
|
||||||
substitutionPlan?.observe(this, Observer<List<Substitution>> { substitutions ->
|
substitutionPlan?.observe(this, Observer<List<Substitution>> { substitutions ->
|
||||||
mAdapter.setSubst(if (substitutions.isEmpty()) {
|
mAdapter.setSubst(if (substitutions.isEmpty()) {
|
||||||
HelperFunctions.getEmptyGeneralSubstitution(mContext)
|
SubstUtil.getEmptyGeneralSubstitution(mContext)
|
||||||
} else {
|
} else {
|
||||||
substitutions
|
substitutions
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package com.denizd.substitutionplan.fragments
|
|||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.models.Substitution
|
import com.denizd.substitutionplan.models.Substitution
|
||||||
|
|
||||||
internal class PersonalPlanFragment : PlanFragment() {
|
internal class PersonalPlanFragment : PlanFragment() {
|
||||||
@@ -20,7 +20,7 @@ internal class PersonalPlanFragment : PlanFragment() {
|
|||||||
binding.recyclerView.visibility = View.VISIBLE
|
binding.recyclerView.visibility = View.VISIBLE
|
||||||
|
|
||||||
substitutions.filter { substItem ->
|
substitutions.filter { substItem ->
|
||||||
HelperFunctions.checkPersonalSubstitutions(
|
SubstUtil.checkPersonalSubstitutions(
|
||||||
substItem,
|
substItem,
|
||||||
coursePreference,
|
coursePreference,
|
||||||
classPreference,
|
classPreference,
|
||||||
@@ -31,7 +31,7 @@ internal class PersonalPlanFragment : PlanFragment() {
|
|||||||
}
|
}
|
||||||
isPersonalPlanEmpty = (planCardList.size == 1 && planCardList[0].date.substring(0, 3) == "psa") || planCardList.isEmpty()
|
isPersonalPlanEmpty = (planCardList.size == 1 && planCardList[0].date.substring(0, 3) == "psa") || planCardList.isEmpty()
|
||||||
if (isPersonalPlanEmpty) {
|
if (isPersonalPlanEmpty) {
|
||||||
planCardList.add(HelperFunctions.getEmptyPersonalSubstitution(mContext))
|
planCardList.add(SubstUtil.getEmptyPersonalSubstitution(mContext))
|
||||||
}
|
}
|
||||||
binding.recyclerView.scheduleLayoutAnimation()
|
binding.recyclerView.scheduleLayoutAnimation()
|
||||||
mAdapter.setSubst(planCardList)
|
mAdapter.setSubst(planCardList)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.denizd.substitutionplan.adapters.ColourPickerAdapter
|
|||||||
import com.denizd.substitutionplan.adapters.CourseColourAdapter
|
import com.denizd.substitutionplan.adapters.CourseColourAdapter
|
||||||
import com.denizd.substitutionplan.adapters.RingtoneAdapter
|
import com.denizd.substitutionplan.adapters.RingtoneAdapter
|
||||||
import com.denizd.substitutionplan.data.DataFetcher
|
import com.denizd.substitutionplan.data.DataFetcher
|
||||||
import com.denizd.substitutionplan.data.HelperFunctions
|
import com.denizd.substitutionplan.data.SubstUtil
|
||||||
import com.denizd.substitutionplan.data.Topic
|
import com.denizd.substitutionplan.data.Topic
|
||||||
import com.denizd.substitutionplan.databinding.ContentSettingsBinding
|
import com.denizd.substitutionplan.databinding.ContentSettingsBinding
|
||||||
import com.denizd.substitutionplan.models.Colour
|
import com.denizd.substitutionplan.models.Colour
|
||||||
@@ -325,7 +325,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
colourRecycler.apply {
|
colourRecycler.apply {
|
||||||
hasFixedSize()
|
hasFixedSize()
|
||||||
layoutManager = GridLayoutManager(mContext, 1)
|
layoutManager = GridLayoutManager(mContext, 1)
|
||||||
adapter = ColourPickerAdapter(HelperFunctions.getColourArray(mContext).toList(), this@SettingsFragment)
|
adapter = ColourPickerAdapter(SubstUtil.getColourArray(mContext).toList(), this@SettingsFragment)
|
||||||
}
|
}
|
||||||
colourPickerDialog = colourPickerBuilder.setView(dialogView).create()
|
colourPickerDialog = colourPickerBuilder.setView(dialogView).create()
|
||||||
colourPickerDialog.show()
|
colourPickerDialog.show()
|
||||||
@@ -376,7 +376,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
|
|
||||||
private fun createRingtoneDialog() {
|
private fun createRingtoneDialog() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
HelperFunctions.getNotificationChannel(mContext, prefs)
|
SubstUtil.getNotificationChannel(mContext, prefs)
|
||||||
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
|
val intent = Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS).apply {
|
||||||
putExtra(Settings.EXTRA_APP_PACKAGE, mContext.applicationContext.packageName)
|
putExtra(Settings.EXTRA_APP_PACKAGE, mContext.applicationContext.packageName)
|
||||||
putExtra(Settings.EXTRA_CHANNEL_ID, "general")
|
putExtra(Settings.EXTRA_CHANNEL_ID, "general")
|
||||||
@@ -487,8 +487,8 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
this == "_viewstacktrace" -> {
|
this == "_viewstacktrace" -> {
|
||||||
createDialog("Debug Stack Trace", prefs.getString("debug_recent_exception", "") ?: "")
|
createDialog("Debug Stack Trace", prefs.getString("debug_recent_exception", "") ?: "")
|
||||||
}
|
}
|
||||||
this == "_write" -> HelperFunctions.writePrefsToXml(prefs, mContext, activity!!)
|
this == "_write" -> SubstUtil.writePrefsToXml(prefs, mContext, activity!!)
|
||||||
this == "_read" -> HelperFunctions.readPrefsFromXml(prefs, mContext, activity!!)
|
this == "_read" -> SubstUtil.readPrefsFromXml(prefs, mContext, activity!!)
|
||||||
else -> makeToast(getString(R.string.invalid_code))
|
else -> makeToast(getString(R.string.invalid_code))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -501,7 +501,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
// Functions for retrieving data
|
// Functions for retrieving data
|
||||||
private fun getColourList(): ArrayList<Colour> {
|
private fun getColourList(): ArrayList<Colour> {
|
||||||
val colours = ArrayList<Colour>()
|
val colours = ArrayList<Colour>()
|
||||||
val coursesNoLang = HelperFunctions.languageIndependentCourses
|
val coursesNoLang = SubstUtil.languageIndependentCourses
|
||||||
val courses = arrayOf(
|
val courses = arrayOf(
|
||||||
getString(R.string.course_deu),
|
getString(R.string.course_deu),
|
||||||
getString(R.string.course_eng),
|
getString(R.string.course_eng),
|
||||||
@@ -563,7 +563,7 @@ internal class SettingsFragment : Fragment(), View.OnClickListener, View.OnLongC
|
|||||||
courses[i],
|
courses[i],
|
||||||
coursesNoLang[i],
|
coursesNoLang[i],
|
||||||
coursesIcons[i],
|
coursesIcons[i],
|
||||||
HelperFunctions.getColourForString(prefs.getString("card${coursesNoLang[i]}", "") ?: "", mContext)
|
SubstUtil.getColourForString(prefs.getString("card${coursesNoLang[i]}", "") ?: "", mContext)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user