Skip to content

Commit

Permalink
actual setting to show last message content in notification, and also…
Browse files Browse the repository at this point in the history
… show the sender
  • Loading branch information
zoff99 committed Mar 9, 2024
1 parent 1989e58 commit 32abb02
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ protected void onResume()
// Log.i(TAG, "onResume:001:conf_id=" + conf_id);
}

change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, conf_id, null);
change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, conf_id, null, null);

MainActivity.conference_message_list_activity = this;
wakeup_tox_thread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,7 @@ protected void onResume()
// Log.i(TAG, "onResume:001:conf_id=" + conf_id);
}

change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, group_id, null);
change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, group_id, null, null);

MainActivity.group_message_list_activity = this;
wakeup_tox_thread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ static void conference_message_add_from_sync(long conference_number, long peer_n
boolean do_badge_update = true;
String conf_id = "-1";
ConferenceDB conf_temp = null;
String conference_name = null;

try
{
Expand All @@ -402,6 +403,7 @@ static void conference_message_add_from_sync(long conference_number, long peer_n
conference_number).and().conference_activeEq(true).toList().get(0);
conf_id = conf_temp.conference_identifier;
// Log.i(TAG, "conference_message_add_from_sync:conf_id=" + conf_id);
conference_name = conf_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -482,7 +484,7 @@ static void conference_message_add_from_sync(long conference_number, long peer_n

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.conference_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.conference_identifier, conference_name, m.text);
}
}

Expand Down Expand Up @@ -2722,6 +2724,7 @@ static void receive_incoming_message(int msg_type, int tox_message_type, long fr
return;
}

String friend_name = null;
try
{
// update "new" status on friendlist fragment
Expand All @@ -2733,6 +2736,8 @@ static void receive_incoming_message(int msg_type, int tox_message_type, long fr
{
do_notification = false;
}

friend_name = f.alias_name;
}
catch (Exception e)
{
Expand All @@ -2742,7 +2747,7 @@ static void receive_incoming_message(int msg_type, int tox_message_type, long fr

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, friend_name, m.text);
}

if (msgV3hash_hex_string != null)
Expand Down Expand Up @@ -2851,7 +2856,7 @@ else if (msg_type == 1)

HelperFriend.send_friend_msg_receipt_v2_wrapper(friend_number, msg_type, msg_id_buffer,
(pin_timestamp / 1000));

String friendname = null;
try
{
// update "new" status on friendlist fragment
Expand All @@ -2863,6 +2868,8 @@ else if (msg_type == 1)
{
do_notification = false;
}

friendname = f.alias_name;
}
catch (Exception e)
{
Expand All @@ -2872,7 +2879,7 @@ else if (msg_type == 1)

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, friendname, m.text);
}
}
else if (msg_type == 2)
Expand Down Expand Up @@ -2984,6 +2991,7 @@ else if (msg_type == 2)
HelperFriend.send_friend_msg_receipt_v2_wrapper(friend_number_real_sender, msg_type, msg_id_buffer,
(pin_timestamp / 1000));

String friendname = null;
try
{
// update "new" status on friendlist fragment
Expand All @@ -2995,6 +3003,8 @@ else if (msg_type == 2)
{
do_notification = false;
}

friendname = f.alias_name;
}
catch (Exception e)
{
Expand All @@ -3004,7 +3014,7 @@ else if (msg_type == 2)

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, friendname, m.text);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,12 +896,14 @@ static void android_tox_callback_group_message_cb_method_wrapper(long group_numb
return;
}

String groupname = null;
try
{
if (group_temp.notification_silent)
{
do_notification = false;
}
groupname = group_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -979,7 +981,7 @@ static void android_tox_callback_group_message_cb_method_wrapper(long group_numb

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, groupname, m.text);
}
}

Expand Down Expand Up @@ -1067,12 +1069,14 @@ static void group_message_add_from_sync(final String group_identifier, final Str
return;
}

String groupname = null;
try
{
if (group_temp.notification_silent)
{
do_notification = false;
}
groupname = group_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -1144,7 +1148,7 @@ static void group_message_add_from_sync(final String group_identifier, final Str

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, groupname, m.text);
}
}

Expand Down Expand Up @@ -1517,12 +1521,14 @@ static void handle_incoming_group_file(long group_number, long peer_id, byte[] d
return;
}

String groupname = null;
try
{
if (group_temp.notification_silent)
{
do_notification = false;
}
groupname = group_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -1675,7 +1681,7 @@ static void handle_incoming_group_file(long group_number, long peer_id, byte[] d

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, groupname, m.text);
}
}
catch (Exception e)
Expand Down Expand Up @@ -2596,13 +2602,15 @@ private static void group_file_add_from_sync(final String group_identifier, fina
return;
}


String groupname = null;
try
{
if (group_temp.notification_silent)
{
do_notification = false;
}

groupname = group_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -2675,7 +2683,7 @@ private static void group_file_add_from_sync(final String group_identifier, fina

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.group_identifier, groupname, m.text);
}
}
catch (Exception e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public class HelperMsgNotification
* action: NOTIFICATION_EDIT_ACTION
* key: either a friend pubkey or a conference id or a group id, both as hex string representation
*/
static synchronized void change_msg_notification(final int action, final String key, final String notification_text)
static synchronized void change_msg_notification(final int action, final String key,
final String notification_title, final String notification_text)
{
if (action == NOTIFICATION_EDIT_ACTION_CLEAR.value)
{
Expand All @@ -82,7 +83,7 @@ else if (action == NOTIFICATION_EDIT_ACTION_ADD.value)
global_active_notifications.add(key);
}
}
show_msg_notification(notification_text);
show_msg_notification(notification_title, notification_text);
}
else if (action == NOTIFICATION_EDIT_ACTION_REMOVE.value)
{
Expand Down Expand Up @@ -135,7 +136,7 @@ public void run()
}
}

static void show_msg_notification(final String nf_text)
static void show_msg_notification(final String nf_title, final String nf_text)
{
Log.i(TAG, "noti_and_badge:show_notification:");
Runnable myRunnable = new Runnable()
Expand Down Expand Up @@ -208,8 +209,24 @@ else if ((!PREF__notification_sound) && (PREF__notification_vibrate))
b.setVibrate(vibrate_pattern);
}

b.setContentTitle("TRIfA");
if (PREF__notification_show_content)
{
if ((nf_title != null) && (!nf_title.isEmpty()))
{
b.setContentTitle(nf_title);
}
else
{
b.setContentTitle("TRIfA");
}
}
else
{
b.setContentTitle("TRIfA");
}

b.setAutoCancel(true);

if (PREF__notification_show_content)
{
if ((nf_text != null) && (!nf_text.isEmpty()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@ protected void onCreate(Bundle savedInstanceState)
PREF__UV_reversed = settings.getBoolean("video_uv_reversed", true);
PREF__notification_sound = settings.getBoolean("notifications_new_message_sound", true);
PREF__notification_vibrate = settings.getBoolean("notifications_new_message_vibrate", false);
PREF__notification_show_content = settings.getBoolean("notification_show_content", false);
PREF__notification = settings.getBoolean("notifications_new_message", true);
PREF__software_echo_cancel = settings.getBoolean("software_echo_cancel", false);
PREF__fps_half = settings.getBoolean("fps_half", false);
Expand Down Expand Up @@ -2228,6 +2229,7 @@ protected void onResume()
PREF__UV_reversed = settings.getBoolean("video_uv_reversed", true);
PREF__notification_sound = settings.getBoolean("notifications_new_message_sound", true);
PREF__notification_vibrate = settings.getBoolean("notifications_new_message_vibrate", true);
PREF__notification_show_content = settings.getBoolean("notification_show_content", false);
PREF__notification = settings.getBoolean("notifications_new_message", true);
PREF__software_echo_cancel = settings.getBoolean("software_echo_cancel", false);
PREF__fps_half = settings.getBoolean("fps_half", false);
Expand Down Expand Up @@ -6051,6 +6053,7 @@ else if (a_TOX_FILE_KIND == TOX_FILE_KIND_FTV2.value)
f.message_id = new_msg_id;
HelperFiletransfer.update_filetransfer_db_full(f);

String friendname = null;
try
{
// update "new" status on friendlist fragment
Expand All @@ -6062,6 +6065,8 @@ else if (a_TOX_FILE_KIND == TOX_FILE_KIND_FTV2.value)
{
do_notification = false;
}

friendname = f2.alias_name;
}
catch (Exception e)
{
Expand All @@ -6074,7 +6079,7 @@ else if (a_TOX_FILE_KIND == TOX_FILE_KIND_FTV2.value)
// --- notification ---
if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, friendname, "incoming file");
}
// --- notification ---
// --- notification ---
Expand Down Expand Up @@ -6198,6 +6203,7 @@ public void run()
f.message_id = new_msg_id;
HelperFiletransfer.update_filetransfer_db_full(f);

String friendname = null;
try
{
// update "new" status on friendlist fragment
Expand All @@ -6209,6 +6215,8 @@ public void run()
{
do_notification = false;
}

friendname = f2.alias_name;
}
catch (Exception e)
{
Expand All @@ -6221,7 +6229,7 @@ public void run()
// --- notification ---
if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.tox_friendpubkey, friendname, "incoming file");
}
// --- notification ---
// --- notification ---
Expand Down Expand Up @@ -6629,12 +6637,14 @@ static void android_tox_callback_conference_message_cb_method(long conference_nu
// e.printStackTrace();
}

String conferencename = null;
try
{
if (conf_temp.notification_silent)
{
do_notification = false;
}
conferencename = conf_temp.name;
}
catch (Exception e)
{
Expand Down Expand Up @@ -6717,7 +6727,7 @@ static void android_tox_callback_conference_message_cb_method(long conference_nu

if (do_notification)
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.conference_identifier, m.text);
change_msg_notification(NOTIFICATION_EDIT_ACTION_ADD.value, m.conference_identifier, conferencename, m.text);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ protected void onResume()
// Log.i(TAG, "onResume:001:friendnum(-->friendnum_prev)=" + friendnum);
}

change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, tox_friend_get_public_key__wrapper(friendnum), null);
change_msg_notification(NOTIFICATION_EDIT_ACTION_REMOVE.value, tox_friend_get_public_key__wrapper(friendnum), null, null);

// ----- convert old messages which did not contain a sent timestamp -----
try
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected void onCreate(Bundle savedInstanceState)
{
if (should_clear_notification_list.equalsIgnoreCase("1"))
{
change_msg_notification(NOTIFICATION_EDIT_ACTION_EMPTY_THE_LIST.value, "", null);
change_msg_notification(NOTIFICATION_EDIT_ACTION_EMPTY_THE_LIST.value, "", null, null);
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions android-refimpl-app/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,9 @@
<string name="pref_title_compact_chatlist">Compact Chatlist</string>
<string name="pref_description_compact_chatlist">Display Chatmessage more compact saving space</string>

<string name="pref_title_notification_show_content">Show Notification Content</string>
<string name="pref_description_notification_show_content">Display the Messagetext and Sender in Notifications</string>

<string name="pref_title_use_push_service">Use Push Service</string>
<string name="pref_description_use_push_service">WARNING: This will use Google FCM or Unified Push to save Battery and Bandwidth.\nThe app will make HTTPS: connections to some PUSH servers directly (not via Tox).\nOnly activate this if you accept that.\nThis feature needs the Tox Push Message App installed.</string>

Expand Down
Loading

0 comments on commit 32abb02

Please sign in to comment.