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) {
@@ -25,6 +25,11 @@
android:id="@+id/menu_settings"
android:title="@string/menu_settings" />
<item
android:id="@+id/blocked"
android:title="@string/pref_blocked_conversations"
android:visible="false" />
<item
android:id="@+id/menu_changelog"
android:title="@string/menu_changelog" />
+3 -2
View File
@@ -164,8 +164,8 @@
<string name="pref_delivery_vibrate_summary">Vibrate on message delivery</string>
<string name="pref_yappy">Yappy integration</string>
<string name="pref_endlessjabber_summary">Enable full support for Yappy</string>
<string name="pref_blocked_senders">Blocked senders</string>
<string name="pref_blocked_senders_summary">Long-press on a conversation to block messages</string>
<string name="pref_blocked_conversations">Blocked conversations</string>
<string name="pref_blocked_conversations_summary">Long-press on a conversation and block to move to blocked inbox and stop notifications</string>
<string name="pref_mobile_only">Mobile numbers</string>
<string name="pref_mobile_only_summary">Only show mobile numbers in contact suggestions</string>
<string name="pref_auto_emoji">Automatic emoji</string>
@@ -634,6 +634,7 @@
<string name="menu_unmute_conversation">Unmute conversation</string>
<string name="menu_block_conversation">Block conversation</string>
<string name="menu_unblock_conversation">Unblock conversation</string>
<string name="menu_blocked_conversations">Blocked (%s)</string>
<string name="menu_notification_settings">Notification settings</string>
<string name="menu_view_details">View details</string>
<string name="menu_mark_read">Mark read</string>
+2 -2
View File
@@ -93,8 +93,8 @@
android:defaultValue="false"
android:key="pref_key_blocked_enabled"
android:layout="@layout/list_item_preference"
android:summary="@string/pref_blocked_senders_summary"
android:title="@string/pref_blocked_senders"
android:summary="@string/pref_blocked_conversations_summary"
android:title="@string/pref_blocked_conversations"
android:widgetLayout="@layout/view_checkbox" />
<CheckBoxPreference
android:defaultValue="false"