Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/res/menu/menu_connect.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_messaging"
android:icon="@drawable/ic_connect_messaging_base"
android:title="@string/personalid_messaging_menu_title"
app:showAsAction="always" />

<item
android:id="@+id/action_bell"
Expand Down
43 changes: 0 additions & 43 deletions app/src/org/commcare/activities/connect/ConnectActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ public class ConnectActivity extends NavigationHostCommCareActivity<ConnectActiv
private boolean waitDialogEnabled = true;
private String redirectionAction = "";
private ConnectJobRecord job;
private MenuItem messagingMenuItem = null;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Expand Down Expand Up @@ -116,28 +115,6 @@ private int handleSecureRedirect(Bundle startArgs) {
return R.id.connect_unlock_fragment;
}

@Override
protected void onResume() {
super.onResume();
updateMessagingIcon();

LocalBroadcastManager.getInstance(this).registerReceiver(messagingUpdateReceiver,
new IntentFilter(FirebaseMessagingUtil.MESSAGING_UPDATE_BROADCAST));
}

@Override
public void onPause() {
super.onPause();
LocalBroadcastManager.getInstance(this).unregisterReceiver(messagingUpdateReceiver);
}

private final BroadcastReceiver messagingUpdateReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
updateMessagingIcon();
}
};

@Override
public void setTitle(CharSequence title) {
super.setTitle(title);
Expand All @@ -151,9 +128,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
MenuItem notification = menu.findItem(R.id.action_sync);
notification.getIcon().setColorFilter(getResources().getColor(R.color.white), PorterDuff.Mode.SRC_ATOP);

messagingMenuItem = menu.findItem(R.id.action_messaging);
updateMessagingIcon();

MenuItem notiificationsMenuItem = menu.findItem(R.id.action_bell);
notiificationsMenuItem.setVisible(PersonalIdFeatureFlagChecker.isFeatureEnabled(NOTIFICATIONS));

Expand All @@ -163,7 +137,6 @@ public boolean onCreateOptionsMenu(Menu menu) {
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
menu.findItem(R.id.action_sync).setVisible(backButtonAndActionBarEnabled);
menu.findItem(R.id.action_messaging).setVisible(backButtonAndActionBarEnabled);
return super.onPrepareOptionsMenu(menu);
}

Expand All @@ -176,27 +149,11 @@ public void setActiveJob(ConnectJobRecord job) {

private void retrieveMessages(){
MessageManager.retrieveMessages(this, success -> {
updateMessagingIcon();
});
}
Comment on lines 150 to 153
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good to remove retrieveMessages also? I think app must be syncing for current messages in drawer activity to update the icon status?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Semms like app doesn't sync in drawer today but just shows the icon status based on the local db, so think we still need to have it here for the moment (we should replace this with a background worker task in future)


public void updateMessagingIcon() {
if(messagingMenuItem != null) {
int icon = R.drawable.ic_connect_messaging_base;
if(ConnectMessagingDatabaseHelper.getUnviewedMessages(this).size() > 0) {
icon = R.drawable.ic_connect_messaging_unread;
}
messagingMenuItem.setIcon(ResourcesCompat.getDrawable(getResources(), icon, null));
}
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_messaging) {
ConnectNavHelper.INSTANCE.goToMessaging(this);
return true;
}

if (item.getItemId() == R.id.action_bell) {
ConnectNavHelper.goToNotification(this);
return true;
Expand Down
Loading