Skip to content

Commit

Permalink
BirthdayBroadcastReceiver.java changed, now notification fired.
Browse files Browse the repository at this point in the history
some little translations no layout only white background
  • Loading branch information
amarradi committed Jul 23, 2023
1 parent ee36590 commit 9f46ed2
Show file tree
Hide file tree
Showing 10 changed files with 63 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void createNotificationChannel() {
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.notificationChannelName);
String description = getString(R.string.notificationDescription);
int importance = NotificationManager.IMPORTANCE_DEFAULT;
int importance = NotificationManager.IMPORTANCE_HIGH;

NotificationChannel notificationChannel = new NotificationChannel(
CHANNEL_ID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ public class PreferenceWindow extends PreferenceActivity implements OnSharedPref
public static final String HIDE_NOTIFICATION = "hideNotificationAfterConfirmation";
public static final String UPDATE_TIME = "updateTime";


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.layout.preferences);
addPreferencesFromResource(R.xml.preferences);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.BitmapFactory;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.widget.Toast;


import androidx.annotation.RequiresApi;
import androidx.core.content.ContextCompat;

import java.sql.Time;
import java.util.ArrayList;
import java.util.Calendar;
Expand All @@ -34,6 +41,7 @@ public class BirthdayBroadcastReceiver extends BroadcastReceiver {

private static final String TIMED = "timed";

@RequiresApi(api = Build.VERSION_CODES.O)
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getBooleanExtra(TIMED, false)) {
Expand Down Expand Up @@ -81,6 +89,7 @@ public static void restart(Context context) {
start(context);
}

@RequiresApi(api = Build.VERSION_CODES.O)
private void notifyBirthdays(Context context) {
Calendar today = CalendarUtils.todaysCalendar();
Database db = new Database(context.getContentResolver());
Expand Down Expand Up @@ -141,21 +150,30 @@ private void notifyBirthdays(Context context) {
context, 0, intent, PendingIntent.FLAG_IMMUTABLE);

Notification.Builder builder = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
builder = new Notification.Builder(context,CHANNEL_ID);
}

assert builder != null;
builder.setContentIntent(pi);
builder.setSmallIcon(R.drawable.balloons);
builder.setTicker(titleText);
builder.setContentText(StringUtils.join(notificationTexts,", "));

builder.setShowWhen(true);
builder.setWhen(System.currentTimeMillis());
builder.setContentTitle(titleText);
builder.setColorized(true);
builder.setColor(res.getColor(R.color.br_blue_notification));
builder.setCategory(Notification.CATEGORY_REMINDER);
builder.setPriority(Notification.PRIORITY_HIGH);
builder.setVisibility(Notification.VISIBILITY_PUBLIC);
builder.setStyle(new Notification.BigTextStyle().bigText(
StringUtils.join(notificationTexts,"\n")));
if (countBirthdays > 1) {
builder.setNumber(countBirthdays);
}
builder.setTicker(String.format(String.valueOf(countBirthdays)));

Notification notification = builder.getNotification();
notificationManager.notify(0, notification);
notificationManager.notify(1, notification);
}
}

Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/birth_contact.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000"

android:orientation="vertical"
android:padding="5dp">

Expand All @@ -15,7 +15,6 @@
<TextView
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#22AA22" />
android:layout_height="wrap_content" />

</LinearLayout>
2 changes: 1 addition & 1 deletion app/src/main/res/layout/editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000"

android:orientation="vertical">

<TextView
Expand Down
5 changes: 2 additions & 3 deletions app/src/main/res/layout/editor_account.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#333333"

android:orientation="horizontal" >

<ImageView
Expand All @@ -16,7 +16,6 @@
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#333333"
android:orientation="vertical"
android:paddingLeft="5dp" >

Expand All @@ -36,7 +35,7 @@
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#333333"

android:gravity="right|center_vertical" >

<Button
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,18 @@
<item quantity="other">%d Geburtstage</item>
</plurals>

<string name="preferences">Einstellungen</string>

<string name="quit">Birthday Reminder beenden</string>
<string name="activate_reminder_service">Benachrichtigung aktivieren</string>

<string name="ok">OK</string>
<string name="cancel">Abbrechen</string>
<string name="new_birthday">+</string>
<string name="editor_phone">Telefon</string>
<string name="no_contacts_permission">Keine Berechtigung zum Lesen und Ändern von Kontakten</string>
<string name="daysbefore">Anzahl der Tage vor der Benachrichtigung</string>
<string name="hideNotification">Benachrichtigung nach dem öffnen verschwinden lassen</string>
<string name="notificationTime">Zeit der Benachrichtigung</string>

</resources>
4 changes: 4 additions & 0 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="br_blue_notification">#0d65c0</color>
</resources>
14 changes: 11 additions & 3 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">Birthday Reminder</string>
<string name="app_name" translatable="false">Birthday Reminder</string>
<string name="preferences_name">Birthday Reminder Preferences</string>
<string name="title">%s</string>
<string name="knownBirthdays">Next birthdays</string>
Expand All @@ -25,6 +25,7 @@

<string name="preferences">Settings</string>
<string name="quit">Quit service</string>
<string name="activate_reminder_service">Activate reminder service</string>
<string name="ok">OK</string>
<string name="cancel">Cancel</string>
<string name="account_icon">account icon</string>
Expand All @@ -34,6 +35,13 @@
<string name="no_contacts_permission">No permission to read and write contacts</string>


<string name="notificationChannelName">BirthdayReminderNotification</string>
<string name="notificationDescription">Notification to show the next birthdays</string>
<string name="notificationChannelName" translatable="false">BirthdayReminderNotification</string>
<string name="notificationDescription" translatable="false">Notification to show the next birthdays</string>
<string name="daysbefore">Days before reminder</string>
<string name="hideNotification">Hide notification after confirmation</string>
<string name="notificationTime">Notification time</string>
<string name="activate_summaryOff">The reminder service is inactive</string>
<string name="activate_summaryOn">The reminder service is active</string>
<string name="hideNotification_summaryOff"><![CDATA[The notification won&apos;t be hidden after confirmation]]></string>
<string name="hideNotification_summaryOn">The notification will be hidden after confirmation</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
<CheckBoxPreference
android:defaultValue="true"
android:key="activateService"
android:summaryOff="The reminder service is inactive"
android:summaryOn="The reminder service is active"
android:title="Activate reminder service" />
android:summaryOff="@string/activate_summaryOff"
android:summaryOn="@string/activate_summaryOn"
android:title="@string/activate_reminder_service" />

<de.ubuntix.android.birthdayreminder.view.preference.SummaryEditTextPreference
android:defaultValue="3"
android:inputType="number"
android:key="daysBeforeReminder"
android:summary="You will be informed @value days before"
android:title="Days before reminder" />
android:title="@string/daysbefore" />

<CheckBoxPreference
android:defaultValue="false"
android:key="hideNotificationAfterConfirmation"
android:summaryOff="The notification won&apos;t be hidden after confirmation"
android:summaryOn="The notification will be hidden after confirmation"
android:title="Hide notification after confirmation" />
android:summaryOff="@string/hideNotification_summaryOff"
android:summaryOn="@string/hideNotification_summaryOn"
android:title="@string/hideNotification" />

<de.ubuntix.android.birthdayreminder.view.preference.TimePickerPreference
android:defaultValue="09:00"
android:key="updateTime"
android:summary="You will be notified at @value o&apos;clock"
android:title="Notification time" />
android:title="@string/notificationTime" />

</PreferenceScreen>

0 comments on commit 9f46ed2

Please sign in to comment.