Created dummy menu item for showing blocked messages in menu

This commit is contained in:
Moez Bhatti
2015-09-14 01:07:21 -04:00
parent 545ae250c1
commit d3c25b8ffc
5 changed files with 30 additions and 5 deletions
@@ -1,7 +1,10 @@
package com.moez.QKSMS.common;
import android.content.Context;
import android.content.SharedPreferences;
import android.provider.Telephony;
import android.view.MenuItem;
import com.moez.QKSMS.R;
import com.moez.QKSMS.ui.settings.SettingsFragment;
import java.util.HashSet;
@@ -66,4 +69,18 @@ public class BlockedConversationHelper {
return selection.toString();
}
/**
* If the user has message blocking enabled, then in the menu of the conversation list, there's an item that says
* Blocked (#). This method will find the number of blocked unread messages to show in that menu item and bind it
*/
public static void bindBlockedMenuItem(Context context, SharedPreferences prefs, MenuItem item) {
if (item == null) {
return;
}
item.setVisible(prefs.getBoolean(SettingsFragment.BLOCKED_ENABLED, false));
item.setTitle(context.getString(R.string.menu_blocked_conversations, 4));
}
}
@@ -139,6 +139,8 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
} else {
mAdapter.disableMultiSelectMode(false);
}
BlockedConversationHelper.bindBlockedMenuItem(mContext, mPrefs, menu.findItem(R.id.blocked));
}
@Override
@@ -284,7 +286,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
}
private void initLoaderManager() {
getLoaderManager().initLoader(0, null, this);
getLoaderManager().restartLoader(0, null, this);
}
private void switchFragment(Fragment fragment) {