From 880f12fdd5db55c03c52ee5a75a799bd1b9b0354 Mon Sep 17 00:00:00 2001 From: zoff99 Date: Sun, 10 Jul 2022 16:10:20 +0200 Subject: [PATCH] visually show "old" filetransfers. --- .../trifa/HelperFiletransfer.java | 5 +++ .../applications/trifa/HelperMessage.java | 15 ++++++++ .../applications/trifa/MainActivity.java | 3 ++ .../zoffcc/applications/trifa/Message.java | 9 ++++- .../trifa/MessageListActivity.java | 2 ++ ...ListHolder_file_incoming_state_cancel.java | 36 ++++++++++++++++++- ...ile_incoming_state_pause_has_accepted.java | 35 ++++++++++++++++++ ...incoming_state_pause_not_yet_accepted.java | 36 +++++++++++++++++++ ...ListHolder_file_incoming_state_resume.java | 35 ++++++++++++++++++ ...ListHolder_file_outgoing_state_cancel.java | 35 ++++++++++++++++++ ...ile_outgoing_state_pause_has_accepted.java | 36 +++++++++++++++++++ ...outgoing_state_pause_not_yet_accepted.java | 35 ++++++++++++++++++ ..._outgoing_state_pause_not_yet_started.java | 35 ++++++++++++++++++ ...ListHolder_file_outgoing_state_resume.java | 35 ++++++++++++++++++ .../applications/trifa/TrifaToxService.java | 15 +++++++- .../res/layout/message_list_ft_incoming.xml | 1 + .../message_list_ft_incoming_compact.xml | 1 + .../res/layout/message_list_ft_outgoing.xml | 1 + .../message_list_ft_outgoing_compact.xml | 2 ++ 19 files changed, 369 insertions(+), 3 deletions(-) diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperFiletransfer.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperFiletransfer.java index c878d4dc4..08ace3709 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperFiletransfer.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperFiletransfer.java @@ -45,6 +45,7 @@ import static com.zoffcc.applications.trifa.HelperMessage.set_message_queueing_from_id; import static com.zoffcc.applications.trifa.HelperMessage.set_message_start_sending_from_id; import static com.zoffcc.applications.trifa.HelperMessage.set_message_state_from_id; +import static com.zoffcc.applications.trifa.HelperMessage.update_message_in_db_filetransfer_kind; import static com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_messge_id; import static com.zoffcc.applications.trifa.Identicon.bytesToHex; import static com.zoffcc.applications.trifa.MainActivity.PREF__auto_accept_all_upto; @@ -966,6 +967,7 @@ static void start_outgoing_ft(Message m) ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2.value, ft.filesize, file_id_buffer, ft.file_name, ft.file_name.length()); ft.kind = ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2.value; + m.filetransfer_kind = TOX_FILE_KIND_FTV2.value; } else { @@ -973,9 +975,12 @@ static void start_outgoing_ft(Message m) ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_DATA.value, ft.filesize, file_id_buffer, ft.file_name, ft.file_name.length()); ft.kind = ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_DATA.value; + m.filetransfer_kind = TOX_FILE_KIND_DATA.value; } // TODO: handle errors from tox_file_send() here ------- + update_message_in_db_filetransfer_kind(m); + if (file_number < 0) { Log.i(TAG, "tox_file_send:EE:" + file_number); diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMessage.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMessage.java index 78a249202..79270057a 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMessage.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/HelperMessage.java @@ -182,6 +182,21 @@ static void update_message_in_db_messageid(final Message m) } } + static void update_message_in_db_filetransfer_kind(final Message m) + { + try + { + orma.updateMessage(). + idEq(m.id). + filetransfer_kind(m.filetransfer_kind). + execute(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + static void update_message_in_db_resend_count(final Message m) { try 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 aee1180be..083d22248 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 @@ -267,6 +267,7 @@ import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_RESUME; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_ID_LENGTH; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_AVATAR; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_DATA; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.ToxVars.TOX_GROUP_CHAT_ID_SIZE; import static com.zoffcc.applications.trifa.ToxVars.TOX_HASH_LENGTH; @@ -5869,6 +5870,7 @@ else if (a_TOX_FILE_KIND == TOX_FILE_KIND_FTV2.value) m.sent_timestamp = m.rcvd_timestamp; m.text = filename_corrected + "\n" + file_size + " bytes"; m.sent_push = 0; + m.filetransfer_kind = TOX_FILE_KIND_FTV2.value; long new_msg_id = -1; if (message_list_activity != null) @@ -6015,6 +6017,7 @@ public void run() m.sent_timestamp = m.rcvd_timestamp; m.text = filename_corrected + "\n" + file_size + " bytes"; m.sent_push = 0; + m.filetransfer_kind = TOX_FILE_KIND_DATA.value; long new_msg_id = -1; if (message_list_activity != null) diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/Message.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/Message.java index 5cea1eb21..38f58505c 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/Message.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/Message.java @@ -27,6 +27,8 @@ import static com.zoffcc.applications.trifa.TRIFAGlobals.TRIFA_MSG_TYPE.TRIFA_MSG_TYPE_TEXT; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_PAUSE; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_DATA; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; @Table public class Message @@ -128,6 +130,10 @@ public class Message @Nullable int sent_push = 0; + @Column(helpers = Column.Helpers.ALL, defaultExpr = "0") + @Nullable + int filetransfer_kind = TOX_FILE_KIND_DATA.value; + static Message deep_copy(Message in) { Message out = new Message(); @@ -160,6 +166,7 @@ static Message deep_copy(Message in) out.msg_at_relay = in.msg_at_relay; out.msg_idv3_hash = in.msg_idv3_hash; out.sent_push = in.sent_push; + out.filetransfer_kind = in.filetransfer_kind; return out; } @@ -175,6 +182,6 @@ public String toString() ", is_new=" + is_new + ", msg_id_hash=" + msg_id_hash + ", msg_version=" + msg_version + ", resend_count=" + resend_count + ", raw_msgv2_bytes=" + "xxxxxx" + ", storage_frame_work=" + storage_frame_work + ", ft_outgoing_queued=" + ft_outgoing_queued + ", msg_at_relay=" + msg_at_relay + - ", sent_push=" + sent_push; + ", sent_push=" + sent_push + ", filetransfer_kind=" + filetransfer_kind; } } 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 83095dc14..adbb0b8bd 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 @@ -1439,6 +1439,7 @@ static void add_outgoing_file(Context c, long friendnum, String filepath, String m.storage_frame_work = false; m.sent_push = 0; m.is_new = false; // no notification for outgoing filetransfers + m.filetransfer_kind = TOX_FILE_KIND_DATA.value; long new_msg_id = insert_into_message_db(m, update_message_view); m.id = new_msg_id; @@ -1509,6 +1510,7 @@ static void add_outgoing_file(Context c, long friendnum, String filepath, String m.text = filename + "\n" + file_size + " bytes"; m.storage_frame_work = true; m.is_new = false; // no notification for outgoing filetransfers + m.filetransfer_kind = TOX_FILE_KIND_DATA.value; long new_msg_id = insert_into_message_db(m, update_message_view); m.id = new_msg_id; diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_cancel.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_cancel.java index 7359cba55..d62fbf111 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_cancel.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_cancel.java @@ -34,7 +34,6 @@ import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; -import android.widget.Adapter; import android.widget.ImageButton; import android.widget.ImageView; import android.widget.LinearLayout; @@ -52,6 +51,7 @@ import java.net.URLConnection; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import info.guardianproject.iocipher.File; @@ -69,6 +69,7 @@ import static com.zoffcc.applications.trifa.MessageListActivity.onLongClick_message_helper; import static com.zoffcc.applications.trifa.TRIFAGlobals.MESSAGE_TEXT_SIZE; import static com.zoffcc.applications.trifa.TRIFAGlobals.MESSAGE_TEXT_SIZE_FT_NORMAL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_incoming_state_cancel extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -91,6 +92,7 @@ public class MessageListHolder_file_incoming_state_cancel extends RecyclerView.V de.hdodenhof.circleimageview.CircleImageView img_avatar; TextView date_time; ViewGroup layout_message_container; + ViewGroup rounded_bg_container; boolean is_selected = false; TextView message_text_date_string; ViewGroup message_text_date; @@ -109,6 +111,7 @@ public MessageListHolder_file_incoming_state_cancel(View itemView, Context c) ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_incoming_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -134,6 +137,37 @@ public void bindMessageList(Message m) message_ = m; + int drawable_id = R.drawable.rounded_orange_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_orange_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + is_selected = false; if (selected_messages.isEmpty()) { diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_has_accepted.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_has_accepted.java index 81764a4a9..702678a92 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_has_accepted.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_has_accepted.java @@ -37,6 +37,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.iconics.IconicsDrawable; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import static com.zoffcc.applications.trifa.HelperFiletransfer.get_filetransfer_filenum_from_id; @@ -49,6 +50,7 @@ import static com.zoffcc.applications.trifa.MainActivity.VFS_ENCRYPT; import static com.zoffcc.applications.trifa.MainActivity.tox_file_control; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_incoming_state_pause_has_accepted extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -67,6 +69,7 @@ public class MessageListHolder_file_incoming_state_pause_has_accepted extends Re ImageView imageView; de.hdodenhof.circleimageview.CircleImageView img_avatar; TextView date_time; + ViewGroup rounded_bg_container; TextView message_text_date_string; ViewGroup message_text_date; @@ -85,6 +88,7 @@ public MessageListHolder_file_incoming_state_pause_has_accepted(View itemView, C ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_incoming_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -104,6 +108,37 @@ public void bindMessageList(Message m) m = new Message(); } + int drawable_id = R.drawable.rounded_orange_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_orange_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + date_time.setText(long_date_time_format(m.rcvd_timestamp)); try diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_not_yet_accepted.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_not_yet_accepted.java index a772a0537..07eff36ba 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_not_yet_accepted.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_pause_not_yet_accepted.java @@ -22,6 +22,8 @@ import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; + +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.MotionEvent; @@ -49,6 +51,7 @@ import static com.zoffcc.applications.trifa.MainActivity.tox_file_control; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_RESUME; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_incoming_state_pause_not_yet_accepted extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -68,6 +71,7 @@ public class MessageListHolder_file_incoming_state_pause_not_yet_accepted extend TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_incoming_state_pause_not_yet_accepted(View itemView, Context c) { @@ -83,6 +87,7 @@ public MessageListHolder_file_incoming_state_pause_not_yet_accepted(View itemVie ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_incoming_rounded_bg); textView = (TextView) itemView.findViewById(R.id.m_text); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); date_time = (TextView) itemView.findViewById(R.id.date_time); @@ -113,6 +118,37 @@ public void bindMessageList(Message m) final Message message = m; + int drawable_id = R.drawable.rounded_orange_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_orange_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_resume.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_resume.java index 1c9b1f060..82e0a9ae5 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_resume.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_incoming_state_resume.java @@ -36,6 +36,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial; import com.mikepenz.iconics.IconicsDrawable; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import static com.zoffcc.applications.trifa.HelperFiletransfer.get_filetransfer_filenum_from_id; @@ -51,6 +52,7 @@ import static com.zoffcc.applications.trifa.TRIFAGlobals.MESSAGE_TEXT_SIZE; import static com.zoffcc.applications.trifa.TRIFAGlobals.MESSAGE_TEXT_SIZE_FT_SMALL; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_incoming_state_resume extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -70,6 +72,7 @@ public class MessageListHolder_file_incoming_state_resume extends RecyclerView.V TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_incoming_state_resume(View itemView, Context c) { @@ -85,6 +88,7 @@ public MessageListHolder_file_incoming_state_resume(View itemView, Context c) ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_incoming_rounded_bg); textView = (TextView) itemView.findViewById(R.id.m_text); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); date_time = (TextView) itemView.findViewById(R.id.date_time); @@ -115,6 +119,37 @@ public void bindMessageList(Message m) final Message message = m; + int drawable_id = R.drawable.rounded_orange_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_orange_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_cancel.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_cancel.java index 288394a26..b8679f824 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_cancel.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_cancel.java @@ -49,6 +49,7 @@ import java.net.URLConnection; +import androidx.core.content.ContextCompat; import androidx.core.content.FileProvider; import androidx.documentfile.provider.DocumentFile; import androidx.recyclerview.widget.RecyclerView; @@ -64,6 +65,7 @@ import static com.zoffcc.applications.trifa.MessageListActivity.onClick_message_helper; import static com.zoffcc.applications.trifa.MessageListActivity.onLongClick_message_helper; import static com.zoffcc.applications.trifa.TRIFAGlobals.MESSAGE_TEXT_SIZE; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; /* * @@ -88,6 +90,7 @@ public class MessageListHolder_file_outgoing_state_cancel extends RecyclerView.V de.hdodenhof.circleimageview.CircleImageView img_avatar; TextView date_time; ViewGroup layout_message_container; + ViewGroup rounded_bg_container; boolean is_selected = false; TextView message_text_date_string; ViewGroup message_text_date; @@ -106,6 +109,7 @@ public MessageListHolder_file_outgoing_state_cancel(View itemView, Context c) ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_outgoing_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -128,6 +132,37 @@ public void bindMessageList(Message m) message_ = m; + int drawable_id = R.drawable.rounded_blue_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_blue_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + is_selected = false; if (selected_messages.isEmpty()) { diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_has_accepted.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_has_accepted.java index 40879e798..a4470cdf8 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_has_accepted.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_has_accepted.java @@ -22,6 +22,8 @@ import android.content.Context; import android.graphics.Color; import android.graphics.drawable.Drawable; + +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import android.util.Log; import android.view.MotionEvent; @@ -49,6 +51,7 @@ import static com.zoffcc.applications.trifa.HelperFriend.tox_friend_by_public_key__wrapper; import static com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_messge_id; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_outgoing_state_pause_has_accepted extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -69,6 +72,7 @@ public class MessageListHolder_file_outgoing_state_pause_has_accepted extends Re TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_outgoing_state_pause_has_accepted(View itemView, Context c) { @@ -84,6 +88,7 @@ public MessageListHolder_file_outgoing_state_pause_has_accepted(View itemView, C ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_outgoing_rounded_bg); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); @@ -108,6 +113,37 @@ public void bindMessageList(Message m) final Message message = m; + int drawable_id = R.drawable.rounded_blue_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_blue_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_accepted.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_accepted.java index 5abc2bfba..a6a43f9dd 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_accepted.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_accepted.java @@ -24,6 +24,7 @@ import android.graphics.Color; import android.graphics.drawable.Drawable; +import androidx.core.content.ContextCompat; import androidx.documentfile.provider.DocumentFile; import androidx.recyclerview.widget.RecyclerView; @@ -60,6 +61,7 @@ import static com.zoffcc.applications.trifa.HelperFriend.tox_friend_by_public_key__wrapper; import static com.zoffcc.applications.trifa.HelperMessage.update_single_message_from_messge_id; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; public class MessageListHolder_file_outgoing_state_pause_not_yet_accepted extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { @@ -79,6 +81,7 @@ public class MessageListHolder_file_outgoing_state_pause_not_yet_accepted extend TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_outgoing_state_pause_not_yet_accepted(View itemView, Context c) { @@ -94,6 +97,7 @@ public MessageListHolder_file_outgoing_state_pause_not_yet_accepted(View itemVie ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_outgoing_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -117,6 +121,37 @@ public void bindMessageList(Message m) final Message message = m; + int drawable_id = R.drawable.rounded_blue_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_blue_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_started.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_started.java index 6995816f7..93abee0ac 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_started.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_pause_not_yet_started.java @@ -44,6 +44,7 @@ import java.net.URLConnection; +import androidx.core.content.ContextCompat; import androidx.documentfile.provider.DocumentFile; import androidx.recyclerview.widget.RecyclerView; @@ -60,6 +61,7 @@ import static com.zoffcc.applications.trifa.MainActivity.VFS_ENCRYPT; import static com.zoffcc.applications.trifa.MainActivity.tox_file_control; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; /* * @@ -85,6 +87,7 @@ public class MessageListHolder_file_outgoing_state_pause_not_yet_started extends TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_outgoing_state_pause_not_yet_started(View itemView, Context c) { @@ -100,6 +103,7 @@ public MessageListHolder_file_outgoing_state_pause_not_yet_started(View itemView ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_outgoing_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -133,6 +137,37 @@ public void bindMessageList(Message m) final Message message2 = message; + int drawable_id = R.drawable.rounded_blue_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_blue_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_resume.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_resume.java index f3a6ceba3..c1c873818 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_resume.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/MessageListHolder_file_outgoing_state_resume.java @@ -44,6 +44,7 @@ import java.net.URLConnection; +import androidx.core.content.ContextCompat; import androidx.documentfile.provider.DocumentFile; import androidx.recyclerview.widget.RecyclerView; @@ -59,6 +60,7 @@ import static com.zoffcc.applications.trifa.MainActivity.VFS_ENCRYPT; import static com.zoffcc.applications.trifa.MainActivity.tox_file_control; import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_CONTROL.TOX_FILE_CONTROL_CANCEL; +import static com.zoffcc.applications.trifa.ToxVars.TOX_FILE_KIND.TOX_FILE_KIND_FTV2; import static com.zoffcc.applications.trifa.TrifaToxService.orma; public class MessageListHolder_file_outgoing_state_resume extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener @@ -79,6 +81,7 @@ public class MessageListHolder_file_outgoing_state_resume extends RecyclerView.V TextView date_time; TextView message_text_date_string; ViewGroup message_text_date; + ViewGroup rounded_bg_container; public MessageListHolder_file_outgoing_state_resume(View itemView, Context c) { @@ -94,6 +97,7 @@ public MessageListHolder_file_outgoing_state_resume(View itemView, Context c) ft_preview_container = (ViewGroup) itemView.findViewById(R.id.ft_preview_container); ft_buttons_container = (ViewGroup) itemView.findViewById(R.id.ft_buttons_container); ft_preview_image = (ImageButton) itemView.findViewById(R.id.ft_preview_image); + rounded_bg_container = (ViewGroup) itemView.findViewById(R.id.ft_outgoing_rounded_bg); textView = (EmojiTextViewLinks) itemView.findViewById(R.id.m_text); imageView = (ImageView) itemView.findViewById(R.id.m_icon); img_avatar = (de.hdodenhof.circleimageview.CircleImageView) itemView.findViewById(R.id.img_avatar); @@ -117,6 +121,37 @@ public void bindMessageList(Message m) final Message message = m; + int drawable_id = R.drawable.rounded_blue_bg_with_border; + try + { + if (m.filetransfer_kind == TOX_FILE_KIND_FTV2.value) + { + drawable_id = R.drawable.rounded_blue_bg; + } + + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + catch (Exception e) + { + final int sdk = android.os.Build.VERSION.SDK_INT; + if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) + { + rounded_bg_container.setBackgroundDrawable(ContextCompat.getDrawable(context, drawable_id)); + } + else + { + rounded_bg_container.setBackground(ContextCompat.getDrawable(context, drawable_id)); + } + } + // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- // --------- message date header (show only if different from previous message) --------- diff --git a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/TrifaToxService.java b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/TrifaToxService.java index 94949eb5b..9bb27f83e 100644 --- a/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/TrifaToxService.java +++ b/android-refimpl-app/app/src/main/java/com/zoffcc/applications/trifa/TrifaToxService.java @@ -940,6 +940,19 @@ public void run() } // ----- convert old NULL's into 0 ----- + // ----- convert old NULL's into 0 ----- + try + { + orma.getConnection().execSQL( + "update Message set filetransfer_kind='0' where filetransfer_kind is NULL"); + Log.i(TAG, "onCreate:filetransfer_kind"); + } + catch (Exception e) + { + Log.i(TAG, "onCreate:filetransfer_kind:EE01"); + } + // ----- convert old NULL's into 0 ----- + // TODO -------- String my_tox_id_local = get_my_toxid(); global_my_toxid = my_tox_id_local; @@ -1684,7 +1697,7 @@ private void start_queued_filetransfers() } } } - catch (Exception e) + catch (Exception ignored) { } } diff --git a/android-refimpl-app/app/src/main/res/layout/message_list_ft_incoming.xml b/android-refimpl-app/app/src/main/res/layout/message_list_ft_incoming.xml index b2a3309ef..1b57931ce 100644 --- a/android-refimpl-app/app/src/main/res/layout/message_list_ft_incoming.xml +++ b/android-refimpl-app/app/src/main/res/layout/message_list_ft_incoming.xml @@ -42,6 +42,7 @@