Skip to content

Commit 47d52e1

Browse files
committed
feat: Add chat info dialog to message list activity and ensure message loading on resume and view creation.
1 parent ab680ce commit 47d52e1

3 files changed

Lines changed: 35 additions & 2 deletions

File tree

app/src/main/java/com/wmods/wppenhacer/activities/MessageListActivity.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ protected void onCreate(Bundle savedInstanceState) {
4141
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
4242
String title = chatJid;
4343
if (title != null) {
44-
title = title.replace("@s.whatsapp.net", "").replace("@g.us", "");
45-
if (title.contains("@")) title = title.split("@")[0];
44+
title = title.replace("@s.whatsapp.net", "").replace("@g.us", "");
45+
if (title.contains("@"))
46+
title = title.split("@")[0];
4647
}
4748
getSupportActionBar().setTitle(title);
4849
}
@@ -72,11 +73,33 @@ private void loadMessages() {
7273
}).start();
7374
}
7475

76+
@Override
77+
protected void onResume() {
78+
super.onResume();
79+
loadMessages();
80+
}
81+
82+
@Override
83+
public boolean onCreateOptionsMenu(android.view.Menu menu) {
84+
getMenuInflater().inflate(R.menu.menu_message_list, menu);
85+
return true;
86+
}
87+
7588
@Override
7689
public boolean onOptionsItemSelected(MenuItem item) {
7790
if (item.getItemId() == android.R.id.home) {
7891
onBackPressed();
7992
return true;
93+
} else if (item.getItemId() == R.id.action_info) {
94+
new androidx.appcompat.app.AlertDialog.Builder(this)
95+
.setTitle("Chat Info")
96+
.setMessage(
97+
"This identifier (JID) or number is shown because the contact name could not be resolved at the time of deletion.\n\n"
98+
+
99+
"This happens if the contact is not saved in your address book or if the name wasn't available in the database when the message was processed.")
100+
.setPositiveButton("OK", null)
101+
.show();
102+
return true;
80103
}
81104
return super.onOptionsItemSelected(item);
82105
}

app/src/main/java/com/wmods/wppenhacer/ui/fragments/DeletedMessagesFragment.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public void onResume() {
104104
if (adapter != null)
105105
adapter.notifyDataSetChanged();
106106
}
107+
loadMessages();
107108
}
108109

109110
private void loadMessages() {
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<menu xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto">
4+
<item
5+
android:id="@+id/action_info"
6+
android:icon="@android:drawable/ic_dialog_info"
7+
android:title="Info"
8+
app:showAsAction="ifRoom" />
9+
</menu>

0 commit comments

Comments
 (0)