Browse Source

Added translations. Implemented enable/disable notifications

pull/1/head v0.9
Nareshkumar Rao 4 years ago
parent
commit
c2a7aabfaa
  1. 23
      app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt
  2. 6
      app/src/main/java/com/nareshkumarrao/eiweblog/UpdateWorker.kt
  3. 30
      app/src/main/res/drawable-v24/ic_launcher_foreground.xml
  4. 170
      app/src/main/res/drawable/ic_launcher_background.xml
  5. 5
      app/src/main/res/layout/activity_notification_settings.xml
  6. 2
      app/src/main/res/menu/toolbar_menu.xml
  7. 20
      app/src/main/res/values-de/strings.xml
  8. 23
      app/src/main/res/values-en/strings.xml
  9. 1
      app/src/main/res/values-w820dp/dimens.xml
  10. 2
      app/src/main/res/values/colors.xml
  11. 4
      app/src/main/res/values/dimens.xml
  12. 27
      app/src/main/res/values/strings.xml
  13. 1
      app/src/main/res/values/themes.xml

23
app/src/main/java/com/nareshkumarrao/eiweblog/NotificationSettingsActivity.kt

@ -1,9 +1,14 @@
package com.nareshkumarrao.eiweblog package com.nareshkumarrao.eiweblog
import androidx.appcompat.app.AppCompatActivity
import android.content.Context
import android.os.Bundle 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 import androidx.appcompat.widget.Toolbar
class NotificationSettingsActivity : AppCompatActivity() { class NotificationSettingsActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -13,5 +18,21 @@ class NotificationSettingsActivity : AppCompatActivity() {
setSupportActionBar(notificationsToolbar) setSupportActionBar(notificationsToolbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true) supportActionBar?.setDisplayHomeAsUpEnabled(true)
supportActionBar?.setDisplayShowTitleEnabled(false) 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<SwitchCompat>(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()
})
}
} }

6
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) { class UpdateWorker(private val context: Context, workerParams: WorkerParameters) : Worker(context, workerParams) {
override fun doWork(): Result { 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 -> Utilities.weblogList(context) { articles ->
val lastArticle = Utilities.getLatestRelevantArticle(articles)!! val lastArticle = Utilities.getLatestRelevantArticle(articles)!!
val hashString = lastArticle.title + lastArticle.content + lastArticle.date val hashString = lastArticle.title + lastArticle.content + lastArticle.date

30
app/src/main/res/drawable-v24/ic_launcher_foreground.xml

@ -1,30 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>

170
app/src/main/res/drawable/ic_launcher_background.xml

@ -1,170 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path
android:fillColor="#3DDC84"
android:pathData="M0,0h108v108h-108z" />
<path
android:fillColor="#00000000"
android:pathData="M9,0L9,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,0L19,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,0L29,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,0L39,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,0L49,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,0L59,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,0L69,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,0L79,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M89,0L89,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M99,0L99,108"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,9L108,9"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,19L108,19"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,29L108,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,39L108,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,49L108,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,59L108,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,69L108,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,79L108,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,89L108,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M0,99L108,99"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,29L89,29"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,39L89,39"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,49L89,49"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,59L89,59"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,69L89,69"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M19,79L89,79"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M29,19L29,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M39,19L39,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M49,19L49,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M59,19L59,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M69,19L69,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
<path
android:fillColor="#00000000"
android:pathData="M79,19L79,89"
android:strokeWidth="0.8"
android:strokeColor="#33FFFFFF" />
</vector>

5
app/src/main/res/layout/activity_notification_settings.xml

@ -35,11 +35,12 @@
</androidx.appcompat.widget.Toolbar> </androidx.appcompat.widget.Toolbar>
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/switch1"
android:id="@+id/notification_switch"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="32dp" android:layout_marginEnd="32dp"
android:layout_marginRight="32dp" android:layout_marginRight="32dp"
android:checked="false"
app:layout_constraintBottom_toBottomOf="@+id/textView4" app:layout_constraintBottom_toBottomOf="@+id/textView4"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView4" /> app:layout_constraintTop_toTopOf="@+id/textView4" />
@ -56,7 +57,7 @@
android:text="@string/enable_notifications" android:text="@string/enable_notifications"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="18sp" android:textSize="18sp"
app:layout_constraintEnd_toStartOf="@+id/switch1"
app:layout_constraintEnd_toStartOf="@+id/notification_switch"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/notification_toolbar" /> app:layout_constraintTop_toBottomOf="@+id/notification_toolbar" />

2
app/src/main/res/menu/toolbar_menu.xml

@ -3,7 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"> xmlns:android="http://schemas.android.com/apk/res/android">
<item <item
android:onClick="showNotificationSettings" android:onClick="showNotificationSettings"
android:title="@string/notifications"
android:title="@string/notifications_title"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:onClick="showAbout" android:onClick="showAbout"

20
app/src/main/res/values-de/strings.xml

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="about">Information</string>
<string name="about_title">Info</string>
<string name="send_beer">Shick mir €5 für ein Bier über PayPal</string>
<string name="notifications_title">Benachrichtigung</string>
<string name="enable_notifications">Benachrichtige mich über Neuerungen auf der Weblog</string>
<string name="about_text">
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.
</string>
<string name="license_info">
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.
</string>
</resources>

23
app/src/main/res/values-en/strings.xml

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="about">About</string>
<string name="license_info">
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.
</string>
<string name="app_name" translatable="false">" "</string>
<string name="preference_file_key" translatable="false">" "</string>
<string name="about_title">About</string>
<string name="send_beer">Send me €5 for beer on PayPal</string>
<string name="notifications_title">Notifications</string>
<string name="enable_notifications">Notify me when new updates are posted to the weblog</string>
<string name="about_text">
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.
</string>
</resources>

1
app/src/main/res/values-w820dp/dimens.xml

@ -2,5 +2,4 @@
<!-- Example customization of dimensions originally defined in res/values/dimens.xml <!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This (such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). --> would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources> </resources>

2
app/src/main/res/values/colors.xml

@ -1,12 +1,10 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<color name="fh_red">#E60028</color> <color name="fh_red">#E60028</color>
<color name="purple_200">#FFBB86FC</color>
<color name="purple_500">#FF6200EE</color> <color name="purple_500">#FF6200EE</color>
<color name="purple_700">#FF3700B3</color> <color name="purple_700">#FF3700B3</color>
<color name="teal_200">#FF03DAC5</color> <color name="teal_200">#FF03DAC5</color>
<color name="teal_700">#FF018786</color> <color name="teal_700">#FF018786</color>
<color name="black">#FF000000</color> <color name="black">#FF000000</color>
<color name="white">#FFFFFFFF</color> <color name="white">#FFFFFFFF</color>
<color name="off_white">#DDDDDD</color>
</resources> </resources>

4
app/src/main/res/values/dimens.xml

@ -1,8 +1,4 @@
<resources> <resources>
<!-- Default screen margins, per the Android Design guidelines. --> <!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="appbar_padding">16dp</dimen> <dimen name="appbar_padding">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen>
</resources> </resources>

27
app/src/main/res/values/strings.xml

@ -1,17 +1,15 @@
<resources> <resources>
<string name="app_name">EI Weblog</string>
<string name="tab_lehre">Lehre</string>
<string name="tab_pruefungen">Prüfungen</string>
<string name="tab_sonstiges">Sonstiges</string>
<string name="hsd_symbol">HSD</string>
<string name="weblog_xml_url"><![CDATA[
<string name="app_name" translatable="false">EI Weblog</string>
<string name="tab_lehre" translatable="false">Lehre</string>
<string name="tab_pruefungen" translatable="false">Prüfungen</string>
<string name="tab_sonstiges" translatable="false">Sonstiges</string>
<string name="hsd_symbol" translatable="false">HSD</string>
<string name="weblog_xml_url" translatable="false"><![CDATA[
https://ei.hs-duesseldorf.de/weblog/_vti_bin/owssvr.dll?Cmd=Display&List=%7B169417ED-6982-4CDA-9CAC-F63FCB1757EF%7D&XMLDATA=TRUE&RowLimit=0&Query=* https://ei.hs-duesseldorf.de/weblog/_vti_bin/owssvr.dll?Cmd=Display&List=%7B169417ED-6982-4CDA-9CAC-F63FCB1757EF%7D&XMLDATA=TRUE&RowLimit=0&Query=*
]]></string> ]]></string>
<string name="notifications">Benachrichtigungen</string>
<string name="about">Information</string> <string name="about">Information</string>
<string name="preference_file_key">com.nareshkumarrao.eiweblog.preferences</string>
<string name="weblog_response_key">weblog_response</string>
<string name="tab_veranstaltungen">Veranstaltungen</string>
<string name="preference_file_key" translatable="false">com.nareshkumarrao.eiweblog.preferences</string>
<string name="weblog_response_key" translatable="false">weblog_response</string>
<string name="about_text"> <string name="about_text">
My name is Naresh and I am doing my Master\'s in Automation at the HSD.\n 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 \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 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. source code of this project can be found on its GitHub repository.
</string> </string>
<string name="channel_name">EI Weblog Notifications</string>
<string name="channel_description">Latest updates from the EI Weblog</string>
<string name="channel_id">com.nareshkumarrao.eiweblog.update</string>
<string name="notifications_title">Benachrichtigungen</string>
<string name="channel_name" translatable="false">EI Weblog Notifications</string>
<string name="channel_description" translatable="false">Latest updates from the EI Weblog</string>
<string name="channel_id" translatable="false">com.nareshkumarrao.eiweblog.update</string>
<string name="notifications_title">Benachrichtigung</string>
<string name="enable_notifications">Notify me when new updates are posted to the weblog</string> <string name="enable_notifications">Notify me when new updates are posted to the weblog</string>
<string name="enable_notifications_key">com.nareshkumarrao.notifications.key</string>
</resources> </resources>

1
app/src/main/res/values/themes.xml

@ -24,5 +24,4 @@
<style name="Theme.EIWeblog.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light" /> <style name="Theme.EIWeblog.AppBarOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="Theme.EIWeblog.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources> </resources>
Loading…
Cancel
Save