diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java index da5d102c2..e052cdf28 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/ConferenceMessageListActivity.java @@ -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(); diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupMessageListActivity.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupMessageListActivity.java index b40f40622..53739010d 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupMessageListActivity.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/GroupMessageListActivity.java @@ -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(); diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGeneric.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGeneric.java index 680c73336..8ac8a4518 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGeneric.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGeneric.java @@ -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 { @@ -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) { @@ -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); } } @@ -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 @@ -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) { @@ -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) @@ -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 @@ -2863,6 +2868,8 @@ else if (msg_type == 1) { do_notification = false; } + + friendname = f.alias_name; } catch (Exception e) { @@ -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) @@ -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 @@ -2995,6 +3003,8 @@ else if (msg_type == 2) { do_notification = false; } + + friendname = f.alias_name; } catch (Exception e) { @@ -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); } } } diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGroup.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGroup.java index 4c94559b5..345cd15b0 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGroup.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperGroup.java @@ -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) { @@ -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); } } @@ -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) { @@ -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); } } @@ -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) { @@ -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) @@ -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) { @@ -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) diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMsgNotification.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMsgNotification.java index 879d605fd..c341b6e2d 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMsgNotification.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMsgNotification.java @@ -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) { @@ -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) { @@ -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() @@ -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())) diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java index 459aed784..e1bb5c6c2 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MainActivity.java @@ -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); @@ -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); @@ -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 @@ -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) { @@ -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 --- @@ -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 @@ -6209,6 +6215,8 @@ public void run() { do_notification = false; } + + friendname = f2.alias_name; } catch (Exception e) { @@ -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 --- @@ -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) { @@ -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); } } diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java index 72ec470b7..877a38d58 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListActivity.java @@ -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 diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/StartMainActivityWrapper.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/StartMainActivityWrapper.java index e38009302..b05c8ee75 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/StartMainActivityWrapper.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/StartMainActivityWrapper.java @@ -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); } } } diff --git a/android-refimpl-app/app/src/main/res/values/strings.xml b/android-refimpl-app/app/src/main/res/values/strings.xml index 0d9f3d025..f7ab198b3 100644 --- a/android-refimpl-app/app/src/main/res/values/strings.xml +++ b/android-refimpl-app/app/src/main/res/values/strings.xml @@ -173,6 +173,9 @@ Compact Chatlist Display Chatmessage more compact saving space + Show Notification Content + Display the Messagetext and Sender in Notifications + 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. diff --git a/android-refimpl-app/app/src/main/res/xml/pref_general.xml b/android-refimpl-app/app/src/main/res/xml/pref_general.xml index bd3503d9b..e72371250 100644 --- a/android-refimpl-app/app/src/main/res/xml/pref_general.xml +++ b/android-refimpl-app/app/src/main/res/xml/pref_general.xml @@ -56,6 +56,12 @@ android:summary="@string/pref_description_window_security" android:title="@string/pref_title_window_security" /> + +