diff --git a/app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt b/app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt index 4dd2d7a..f92a036 100644 --- a/app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt +++ b/app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt @@ -1,9 +1,14 @@ package com.nareshkumarrao.eiweblog -import androidx.appcompat.app.AppCompatActivity +import android.content.Context import android.os.Bundle +import android.widget.CompoundButton +import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity +import androidx.appcompat.widget.SwitchCompat import androidx.appcompat.widget.Toolbar + class NotificationSettingsActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -13,5 +18,21 @@ class NotificationSettingsActivity : AppCompatActivity() { setSupportActionBar(notificationsToolbar) supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayShowTitleEnabled(false) + + val sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE) + val weblogResponse = sharedPref?.getBoolean(getString(R.string.enable_notifications_key), true) + + val notificationSwitch = findViewById(R.id.notification_switch) + notificationSwitch.isChecked = weblogResponse!! + notificationSwitch.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener { _, isChecked -> + with (sharedPref.edit()) { + putBoolean(getString(R.string.enable_notifications_key), isChecked) + apply() + } + //Toast.makeText(this, "Notifications are set to $isChecked", Toast.LENGTH_SHORT).show() + }) + + } + } \ No newline at end of file diff --git a/app/src/main/java/com/nareshkumarrao/eiweblog/UpdateWorker.kt b/app/src/main/java/com/nareshkumarrao/eiweblog/UpdateWorker.kt index bbc3760..0db6903 100644 --- a/app/src/main/java/com/nareshkumarrao/eiweblog/UpdateWorker.kt +++ b/app/src/main/java/com/nareshkumarrao/eiweblog/UpdateWorker.kt @@ -9,6 +9,12 @@ import java.security.MessageDigest class UpdateWorker(private val context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) { override fun doWork(): Result { + val sharedPref = context.getSharedPreferences(context.getString(R.string.preference_file_key), Context.MODE_PRIVATE) + val notificationsEnabled = sharedPref?.getBoolean(context.getString(R.string.enable_notifications_key), true) + if(!notificationsEnabled!!){ + return Result.success(); + } + Utilities.weblogList(context) { articles -> val lastArticle = Utilities.getLatestRelevantArticle(articles)!! val hashString = lastArticle.title + lastArticle.content + lastArticle.date diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml deleted file mode 100644 index 2b068d1..0000000 --- a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml deleted file mode 100644 index 07d5da9..0000000 --- a/app/src/main/res/drawable/ic_launcher_background.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/layout/activity_notification_settings.xml b/app/src/main/res/layout/activity_notification_settings.xml index 2a70c2d..b0e9359 100644 --- a/app/src/main/res/layout/activity_notification_settings.xml +++ b/app/src/main/res/layout/activity_notification_settings.xml @@ -35,11 +35,12 @@ @@ -56,7 +57,7 @@ android:text="@string/enable_notifications" android:textColor="@color/black" android:textSize="18sp" - app:layout_constraintEnd_toStartOf="@+id/switch1" + app:layout_constraintEnd_toStartOf="@+id/notification_switch" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/notification_toolbar" /> diff --git a/app/src/main/res/menu/toolbar_menu.xml b/app/src/main/res/menu/toolbar_menu.xml index 68fe0f8..bd7cc32 100644 --- a/app/src/main/res/menu/toolbar_menu.xml +++ b/app/src/main/res/menu/toolbar_menu.xml @@ -3,7 +3,7 @@ xmlns:android="http://schemas.android.com/apk/res/android"> + + Information + Info + Shick mir €5 für ein Bier über PayPal + Benachrichtigung + Benachrichtige mich über Neuerungen auf der Weblog + + Ich bin Naresh und mache gerade mein Master in Automatisierungstechnik hier an der HSD.\n + \nIch habe diese App geschrieben, da die EI-Weblog für mich unzufriedenstellend war. Ich vergesse + halt immer diese Webseite zu checken, habe halt kein Disziplin dafür.\n + \nIch habe viele Stunden in diesem App reingesteckt, und falls du es magst, wäre es sehr lieb + wenn du mir ein Bierchen oder ein leckeres Döner kaufst. + + + Dieses Projekt wurde Open-Source entwickelt, damit es kostenlos und frei verbreitet werden kann. + Diese sind in der GPLv3-Lizenz dieses Projekts geregelt. Du kannst mehr über den Lizenz und auch + die Quellecode auf dem GitHub-Repository finden. + + \ No newline at end of file diff --git a/app/src/main/res/values-en/strings.xml b/app/src/main/res/values-en/strings.xml new file mode 100644 index 0000000..1955515 --- /dev/null +++ b/app/src/main/res/values-en/strings.xml @@ -0,0 +1,23 @@ + + + About + + This project is developed open-source and is to be distributed freely + as contained within the terms of the GPLv3 license. More information about the license and the + source code of this project can be found on its GitHub repository. + + " " + " " + About + Send me €5 for beer on PayPal + Notifications + Notify me when new updates are posted to the weblog + + My name is Naresh and I am doing my Master\'s in Automation at the HSD.\n + \nI wrote this app because I was unsatisfied with the EI weblog that was always silently being + updated. The other option would be to develop enough self-discipline to check it regulary. + Yeah no thanks.\n + \nI put too many hours of work into this app, and if you like it and found it useful, I would really + appreciate it if you bought me a beer, or maybe a tasty döner. + + \ No newline at end of file diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml index 9309de9..d147114 100644 --- a/app/src/main/res/values-w820dp/dimens.xml +++ b/app/src/main/res/values-w820dp/dimens.xml @@ -2,5 +2,4 @@ - 64dp \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c0dae61..8f4dff5 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -1,12 +1,10 @@ #E60028 - #FFBB86FC #FF6200EE #FF3700B3 #FF03DAC5 #FF018786 #FF000000 #FFFFFFFF - #DDDDDD \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 0a87b6e..957f288 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -1,8 +1,4 @@ - 16dp - 16dp 16dp - 16dp - 8dp \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e46f1ad..c304907 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,17 +1,15 @@ - EI Weblog - Lehre - Prüfungen - Sonstiges - HSD - EI Weblog + Lehre + Prüfungen + Sonstiges + HSD + - Benachrichtigungen Information - com.nareshkumarrao.eiweblog.preferences - weblog_response - Veranstaltungen + com.nareshkumarrao.eiweblog.preferences + weblog_response My name is Naresh and I am doing my Master\'s in Automation at the HSD.\n \nI wrote this app because I was unsatisfied with the EI weblog that was always silently being @@ -26,9 +24,10 @@ as contained within the terms of the GPLv3 license. More information about the license and the source code of this project can be found on its GitHub repository. - EI Weblog Notifications - Latest updates from the EI Weblog - com.nareshkumarrao.eiweblog.update - Benachrichtigungen + EI Weblog Notifications + Latest updates from the EI Weblog + com.nareshkumarrao.eiweblog.update + Benachrichtigung Notify me when new updates are posted to the weblog + com.nareshkumarrao.notifications.key \ No newline at end of file diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml index 050154c..917b396 100644 --- a/app/src/main/res/values/themes.xml +++ b/app/src/main/res/values/themes.xml @@ -24,5 +24,4 @@