diff --git a/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java b/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java
deleted file mode 100644
index a16d79b..0000000
--- a/app/src/androidTest/java/com/denizd/substitutionplan/ExampleInstrumentedTest.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.denizd.substitutionplan;
-
-import android.content.Context;
-import androidx.test.InstrumentationRegistry;
-import androidx.test.runner.AndroidJUnit4;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-
-import static org.junit.Assert.*;
-
-/**
- * Instrumented test, which will execute on an Android device.
- *
- * @see Testing documentation
- */
-@RunWith(AndroidJUnit4.class)
-public class ExampleInstrumentedTest {
- @Test
- public void useAppContext() {
- // Context of the app under test.
- Context appContext = InstrumentationRegistry.getTargetContext();
-
- assertEquals("com.denizd.substitutionplan", appContext.getPackageName());
- }
-}
diff --git a/app/src/main/java/com/denizd/substitutionplan/adapters/ColourAdapter.kt b/app/src/main/java/com/denizd/substitutionplan/adapters/ColourAdapter.kt
index edc6e9d..8e59358 100644
--- a/app/src/main/java/com/denizd/substitutionplan/adapters/ColourAdapter.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/adapters/ColourAdapter.kt
@@ -13,14 +13,14 @@ import com.google.android.material.card.MaterialCardView
internal class ColourAdapter(private var mColours: List, onClickListener: OnClickListener) : RecyclerView.Adapter() {
- val mOnClickListener = onClickListener
+ private val mOnClickListener = onClickListener
class ColourViewHolder(view: View, clickListener: OnClickListener) : RecyclerView.ViewHolder(view), View.OnClickListener {
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
+ private val mClickListener = clickListener
init { view.setOnClickListener(this) }
override fun onClick(v: View?) { mClickListener.onClick(adapterPosition, title.text.toString(), titleNoLang.text.toString()) }
@@ -59,12 +59,7 @@ internal class ColourAdapter(private var mColours: List, onClickListener
override fun getItemCount(): Int = mColours.size
- fun setColours(colours: List) {
- mColours = colours
- notifyDataSetChanged()
- }
-
- public interface OnClickListener {
+ internal interface OnClickListener {
fun onClick(position: Int, title: String, titleNoLang: String)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/denizd/substitutionplan/adapters/FoodAdapter.kt b/app/src/main/java/com/denizd/substitutionplan/adapters/FoodAdapter.kt
index 43f28f7..facbea5 100644
--- a/app/src/main/java/com/denizd/substitutionplan/adapters/FoodAdapter.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/adapters/FoodAdapter.kt
@@ -26,10 +26,6 @@ internal class FoodAdapter(food: ArrayList) : RecyclerView.Adapter, onClickLi
override fun getItemCount(): Int = _ringtones.size
- fun setRingtones(ringtones: List) {
- _ringtones = ringtones
- notifyDataSetChanged()
- }
-
- public interface OnClickListener {
+ internal interface OnClickListener {
fun onRingtoneClick(position: Int, name: String, uri: String)
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/denizd/substitutionplan/data/DataFetcher.kt b/app/src/main/java/com/denizd/substitutionplan/data/DataFetcher.kt
index bb409fd..94b6bba 100644
--- a/app/src/main/java/com/denizd/substitutionplan/data/DataFetcher.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/data/DataFetcher.kt
@@ -21,6 +21,7 @@ import com.denizd.substitutionplan.models.Food
import com.denizd.substitutionplan.models.Subst
import com.google.android.material.snackbar.Snackbar
import org.jsoup.Jsoup
+import java.lang.ref.WeakReference
import kotlin.collections.ArrayList
/**
@@ -40,13 +41,13 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
private var menu = isMenu
private var forceRefresh = forced
- private var mContext = context
+ private var mContext = WeakReference(context)
private var mApplication = application
- private var mView = parentView
+ private var mView = WeakReference(parentView)
private var priority = 200
- private var notifText = ""
+ private var notificationText = ""
private var informational = ""
- private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext)
+ private val prefs = PreferenceManager.getDefaultSharedPreferences(mContext.get())
private val edit = prefs.edit()
private var currentTime = ""
private var currentFoodTime = ""
@@ -72,21 +73,21 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
}
if (plan || menu) {
- mView?.let { v: View ->
- var snackText = "${mContext.getText(R.string.lastUpdated)} ${when {
+ mView.get()?.let { v: View ->
+ var snackText = "${mContext.get()?.getText(R.string.lastUpdated)} ${when {
plan -> currentTime
menu -> currentFoodTime
else -> "---"
}}"
- snackText = if (forceRefresh) mContext.getString(R.string.forcedRefresh) else snackText
+ snackText = if (forceRefresh) mContext.get()?.getString(R.string.forcedRefresh) ?: "" else snackText
val snackBarView = v.findViewById(R.id.coordination)
Snackbar.make(snackBarView, snackText, Snackbar.LENGTH_LONG).show()
}
}
} catch (e: Exception) {
- mView?.let { v: View ->
+ mView.get()?.let { v: View ->
val snackBarView = v.findViewById(R.id.coordination)
- Snackbar.make(snackBarView, mContext.getString(R.string.noInternet), Snackbar.LENGTH_LONG).setBackgroundTint(ContextCompat.getColor(mContext,
+ Snackbar.make(snackBarView, mContext.get()?.getString(R.string.noInternet) ?: "", Snackbar.LENGTH_LONG).setBackgroundTint(ContextCompat.getColor(mContext.get()!!,
R.color.colorError
)).show()
}
@@ -95,11 +96,13 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
}
override fun onPostExecute(result: Void?) {
- mView?.let {
+ mView.get()?.let {
try {
it.findViewById(R.id.pullToRefresh).isRefreshing = false
} catch (ignored: Exception) {}
}
+ mView.clear()
+ mContext.clear()
}
private fun requestFoodMenuData() {
@@ -184,11 +187,11 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
false
)
}.forEach { substItem ->
- notifText += "${if (notifText.isNotEmpty()) ",\n" else ""}${substItem.course}: ${if (substItem.additional.isNotEmpty()) substItem.additional else "---"}"
+ notificationText += "${if (notificationText.isNotEmpty()) ",\n" else ""}${substItem.course}: ${if (substItem.additional.isNotEmpty()) substItem.additional else "---"}"
}
}
- if (notifText.isNotEmpty()) {
+ if (notificationText.isNotEmpty()) {
sendNotification()
}
@@ -197,40 +200,42 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
}
private fun sendNotification() {
- 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)
+ mContext.get()?.let { c ->
+ val openApp = Intent(c, Main::class.java)
+ openApp.flags = Intent.FLAG_ACTIVITY_NEW_TASK
+ openApp.flags += Intent.FLAG_ACTIVITY_CLEAR_TASK
+ val openAppPending = PendingIntent.getActivity(c, 0, openApp, 0)
- val notificationLayout = RemoteViews(mContext.packageName, R.layout.notification)
- notificationLayout.setTextViewText(R.id.notification_title, mContext.getString(
+ val notificationLayout = RemoteViews(c.packageName, R.layout.notification)
+ notificationLayout.setTextViewText(R.id.notification_title, c.getString(
R.string.substitutionPlan
))
- notificationLayout.setTextViewText(R.id.notification_textview, notifText)
+ notificationLayout.setTextViewText(R.id.notification_textview, notificationText)
- val manager = mContext.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
+ val manager = c.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
- HelperFunctions.getNotificationChannel(mContext, prefs)
- }
-
- val notification = NotificationCompat.Builder(mContext, HelperFunctions.notificationChannelId)
- .setStyle(NotificationCompat.DecoratedCustomViewStyle())
- .setCustomContentView(notificationLayout)
- .setSmallIcon(R.drawable.ic_avh)
- .setContentIntent(openAppPending)
- .setAutoCancel(true)
- .setColor(ContextCompat.getColor(mContext, R.color.colorAccent))
-
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
- val sound = if ((prefs.getString("ringtoneUri", "") ?: "").isNotEmpty()) {
- Uri.parse(prefs.getString("ringtoneUri", "") ?: "")
- } else {
- RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
+ HelperFunctions.getNotificationChannel(c, prefs)
}
- notification.setSound(sound)
- }
- manager.notify(1, notification.build())
+ val notification = NotificationCompat.Builder(c, HelperFunctions.notificationChannelId)
+ .setStyle(NotificationCompat.DecoratedCustomViewStyle())
+ .setCustomContentView(notificationLayout)
+ .setSmallIcon(R.drawable.ic_avh)
+ .setContentIntent(openAppPending)
+ .setAutoCancel(true)
+ .setColor(ContextCompat.getColor(c, R.color.colorAccent))
+
+ if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
+ val sound = if ((prefs.getString("ringtoneUri", "") ?: "").isNotEmpty()) {
+ Uri.parse(prefs.getString("ringtoneUri", "") ?: "")
+ } else {
+ RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)
+ }
+ notification.setSound(sound)
+ }
+
+ manager.notify(1, notification.build())
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/denizd/substitutionplan/database/FoodViewModel.kt b/app/src/main/java/com/denizd/substitutionplan/database/FoodViewModel.kt
index ed03c38..c42574b 100644
--- a/app/src/main/java/com/denizd/substitutionplan/database/FoodViewModel.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/database/FoodViewModel.kt
@@ -14,12 +14,4 @@ internal class FoodViewModel(application: Application) : AndroidViewModel(applic
init {
allFoods = repository.allFoods
}
-
- fun insert(food: Food) {
- repository.insert(food)
- }
-
- fun deleteAll() {
- repository.deleteAll()
- }
}
diff --git a/app/src/main/java/com/denizd/substitutionplan/database/SubstRepository.kt b/app/src/main/java/com/denizd/substitutionplan/database/SubstRepository.kt
index 8e8c59c..0589342 100644
--- a/app/src/main/java/com/denizd/substitutionplan/database/SubstRepository.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/database/SubstRepository.kt
@@ -22,14 +22,6 @@ internal class SubstRepository(application: Application) {
InsertSubstAsync(substDao).execute(subst)
}
- fun update(subst: Subst) {
- UpdateSubstAsync(substDao).execute(subst)
- }
-
- fun delete(subst: Subst) {
- DeleteSubstAsync(substDao).execute(subst)
- }
-
fun deleteAllSubst() {
DeleteAllSubstAsync(substDao).execute()
}
@@ -42,22 +34,6 @@ internal class SubstRepository(application: Application) {
}
}
- class UpdateSubstAsync(substDao: SubstDao?) : AsyncTask() {
- private val mSubstDao = substDao
- override fun doInBackground(vararg substs: Subst): Void? {
- mSubstDao?.updateSubst(substs[0])
- return null
- }
- }
-
- class DeleteSubstAsync(substDao: SubstDao?) : AsyncTask() {
- private val mSubstDao = substDao
- override fun doInBackground(vararg substs: Subst): Void? {
- mSubstDao?.deleteSubst(substs[0])
- return null
- }
- }
-
class DeleteAllSubstAsync(substDao: SubstDao?) : AsyncTask() {
private val mSubstDao = substDao
override fun doInBackground(vararg voids: Void): Void? {
diff --git a/app/src/main/java/com/denizd/substitutionplan/database/SubstViewModel.kt b/app/src/main/java/com/denizd/substitutionplan/database/SubstViewModel.kt
index 273e6cd..cefd0a6 100644
--- a/app/src/main/java/com/denizd/substitutionplan/database/SubstViewModel.kt
+++ b/app/src/main/java/com/denizd/substitutionplan/database/SubstViewModel.kt
@@ -14,20 +14,4 @@ internal class SubstViewModel(application: Application) : AndroidViewModel(appli
init {
allSubst = repository.allSubst
}
-
- fun insertSubst(subst: Subst) {
- repository.insert(subst)
- }
-
- fun updateSubst(subst: Subst) {
- repository.update(subst)
- }
-
- fun deleteSubst(subst: Subst) {
- repository.delete(subst)
- }
-
- fun deleteAllSubst() {
- repository.deleteAllSubst()
- }
}
diff --git a/app/src/main/res/anim/check_animation.xml b/app/src/main/res/anim/check_animation.xml
deleted file mode 100644
index 77b70da..0000000
--- a/app/src/main/res/anim/check_animation.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/anim/chip_slide_in.xml b/app/src/main/res/anim/chip_slide_in.xml
deleted file mode 100644
index 680f133..0000000
--- a/app/src/main/res/anim/chip_slide_in.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/anim/chip_slide_out.xml b/app/src/main/res/anim/chip_slide_out.xml
deleted file mode 100644
index c840530..0000000
--- a/app/src/main/res/anim/chip_slide_out.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml
deleted file mode 100644
index 301f935..0000000
--- a/app/src/main/res/anim/fade_out.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable-v21/avhbmp.png b/app/src/main/res/drawable-v21/avhbmp.png
deleted file mode 100644
index 813e902..0000000
Binary files a/app/src/main/res/drawable-v21/avhbmp.png and /dev/null differ
diff --git a/app/src/main/res/drawable-v21/ic_avhlogo_splash.xml b/app/src/main/res/drawable-v21/ic_avhlogo_splash.xml
deleted file mode 100644
index 276e8d5..0000000
--- a/app/src/main/res/drawable-v21/ic_avhlogo_splash.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
diff --git a/app/src/main/res/drawable-v21/launch_screen.xml b/app/src/main/res/drawable-v21/launch_screen.xml
deleted file mode 100644
index 4b5d11a..0000000
--- a/app/src/main/res/drawable-v21/launch_screen.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
- -
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/drawable/animated_check.xml b/app/src/main/res/drawable/animated_check.xml
index 5f57bfd..3ce2e2f 100644
--- a/app/src/main/res/drawable/animated_check.xml
+++ b/app/src/main/res/drawable/animated_check.xml
@@ -3,5 +3,5 @@
android:drawable="@drawable/check_mark">
+ android:animation="@animator/check_animation" />
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_first_time.xml b/app/src/main/res/layout/activity_first_time.xml
index 952ecaf..d10a61e 100644
--- a/app/src/main/res/layout/activity_first_time.xml
+++ b/app/src/main/res/layout/activity_first_time.xml
@@ -14,7 +14,6 @@
android:layout_height="match_parent">
@@ -215,7 +214,7 @@
app:layout_constraintStart_toStartOf="@+id/txtLayoutClasses"
app:layout_constraintTop_toBottomOf="@+id/txtLayoutCourses" />
-
@@ -642,8 +641,7 @@
app:layout_constraintBottom_toTopOf="@+id/txtPrivacyP"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/txtWhatittook"
- android:onClick="onClick"/>
+ app:layout_constraintTop_toBottomOf="@+id/txtWhatittook"/>
-
+ android:textColor="@color/colorText"
+ tools:ignore="HardcodedText" />
@@ -48,7 +49,8 @@
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:text="Reset launch counter"
- style="@style/Widget.MaterialComponents.Button.OutlinedButton"/>
+ style="@style/Widget.MaterialComponents.Button.OutlinedButton"
+ tools:ignore="HardcodedText" />
+ style="@style/Widget.MaterialComponents.Button.OutlinedButton"
+ tools:ignore="HardcodedText" />
diff --git a/app/src/main/res/layout/food_layout.xml b/app/src/main/res/layout/food_layout.xml
index fabf8ac..92fb919 100644
--- a/app/src/main/res/layout/food_layout.xml
+++ b/app/src/main/res/layout/food_layout.xml
@@ -3,8 +3,7 @@
android:id="@+id/pullToRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:background="@color/colorBackground">
+ xmlns:android="http://schemas.android.com/apk/res/android">
-
+ xmlns:app="http://schemas.android.com/apk/res-auto">
+ android:visibility="gone"
+ tools:ignore="HardcodedText,SpUsage" />
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/welcome_screen.xml b/app/src/main/res/layout/welcome_screen.xml
index d81ec1f..2822dc7 100644
--- a/app/src/main/res/layout/welcome_screen.xml
+++ b/app/src/main/res/layout/welcome_screen.xml
@@ -1,8 +1,6 @@
@@ -22,7 +20,6 @@
app:srcCompat="@drawable/animated_check" />
Vertretungsplan
Persönlich
Einstellungen
- Dunkler Hintergrund
Aktiviere Kursbenachrichtigungen
Hat keinen Einfluss auf Mitteilungen
- Persönlicher Plan
Personalisieren
Diverses
Standardmäßig ansonsten allgemeiner Plan
@@ -35,8 +33,6 @@
Viel Spaß!
Aktiviere Begrüßungen
Falls du möchtest, dass ich nett bin :)
- s Plan
- \' Plan
Lizenzen
Was die App ausmacht (Englisch)
Versionsnummer
@@ -44,11 +40,8 @@
AGB
Überprüfe die AGB der App (Englisch)
Überprüfe die Datenschutzerklärung der App (Englisch)
- Keine Informationen verfügbar
Informationen
Entwickelt von Deniz :)
- Öffne Info bei App-Start
- Öffnet automatisch ohne Nutzereingabe
Aktualisiere Plan bei App-Start
Falls Hintergrund-Sync nicht funktioniert
Wie du deine Kurse eintragen kannst
@@ -93,7 +86,6 @@
Kein Chrome-kompatibler Browser gefunden
YouTube-App nicht gefunden
Zuletzt aktualisiert:
- Aktiviert den Nachtmodus
Dein Plan
- Hallo, %s!
@@ -129,13 +121,10 @@
Benutzerdefinierter Benachrichtungston
Derzeit: %s
Wähle einen Benachrichtigungston
- Keine Klingeltöne gefunden
Öffnet Geräteinstellungen
Standard
Bitte erlaube Speicherzugriff
Erfolg
- von Datei wiederherstellen
- du kannst auch…
Benachrichtigungen kommen nicht an?
Klick hier um zu sehen, warum
Bemerke, dass diese Tipps insbesondere auf Huawei/Honor-Geräten nicht funktionieren könnten. Du kannst sie trotzdem ausprobieren.\n\nAkkusparfunktionen können dazu führen, dass Benachrichtigungen nicht ankommen. Versuche, Akkusparmodi auf deren Standardeinstellung zu setzen.\n\nEinige Geräte beschränken Apps im Hintergrund. Suche in deinen Geräteeinstellungen unter Apps die Vertretungsplan-App und schaue dann nach einer Einstellung namens \"Hintergrund-Services beschränken\" (oder ähnlich) und stelle sicher, dass diese ausgestellt ist.\n\nBei Schwierigkeiten kann ich auch gerne helfen.
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ab151a8..cbd1c78 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,11 +11,9 @@
Settings
- Dark background
Enable course notifications
This does not affect broadcasts
- Personal Plan
Personalise
Miscellaneous
Set personalised plan as default
@@ -40,8 +38,6 @@
Enable greeting
If you want me to be nice :)
- \'s Plan
- \' Plan
Licences
What it took to create this app
@@ -51,13 +47,10 @@
Review this app\'s Terms & Conditions
Privacy Policy
Review this app\'s Privacy Policy
- No information available
Information
Made by Deniz :)
- Open info panel on startup
- Opens automatically without user input
Refresh on startup
In case the background sync doesn\'t work
@@ -105,7 +98,6 @@
No Chrome-compatible browser found
YouTube app not found
Last updated:
- Enables night mode
Your Plan
@@ -142,13 +134,10 @@
Customise notification ringtone
Currently: %s
Pick a notification ringtone
- No ringtones found
Redirects to device settings
Default
Please enable storage permissions
Success
- Restore from file
- you may also…
Not receiving notifications?
Click to see why
Note: on Huawei/Honor devices, there may not be a solution to this problem. You\'re welcome to try the tips provided.\n\nBattery saver functions often cause notifications to be delayed or not be received at all. Try setting any battery saving options to their default setting.\n\nSome devices restrict background usage of apps. Please go to your device app settings, select the app and check for a toggle named \"Restrict background usage\" (or similar) and verify that the setting is turned off.\n\nYou\'re also welcome to ask me for help.
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 4c557f0..bedbc83 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -26,20 +26,6 @@
- @color/colorText
-
-
-
-
-
-