mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 11:38:51 +01:00
@@ -0,0 +1,172 @@
|
||||
package com.moez.QKSMS.common;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.provider.Telephony;
|
||||
import android.util.Log;
|
||||
import android.view.MenuItem;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.utils.PhoneNumberUtils;
|
||||
import com.moez.QKSMS.data.Conversation;
|
||||
import com.moez.QKSMS.data.Message;
|
||||
import com.moez.QKSMS.transaction.SmsHelper;
|
||||
import com.moez.QKSMS.ui.messagelist.MessageColumns;
|
||||
import com.moez.QKSMS.ui.settings.SettingsFragment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* A set of helper methods to group the logic related to blocked conversation
|
||||
*/
|
||||
public class BlockedConversationHelper {
|
||||
|
||||
public static boolean isConversationBlocked(SharedPreferences prefs, long threadId) {
|
||||
Set<String> idStrings = prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||
return (idStrings.contains(String.valueOf(threadId)));
|
||||
}
|
||||
|
||||
public static void blockConversation(SharedPreferences prefs, long threadId) {
|
||||
Set<String> idStrings = prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||
idStrings.add(String.valueOf(threadId));
|
||||
prefs.edit().putStringSet(SettingsFragment.BLOCKED_SENDERS, idStrings).apply();
|
||||
}
|
||||
|
||||
public static void unblockConversation(SharedPreferences prefs, long threadId) {
|
||||
Set<String> idStrings = prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||
idStrings.remove(String.valueOf(threadId));
|
||||
prefs.edit().putStringSet(SettingsFragment.BLOCKED_SENDERS, idStrings).apply();
|
||||
}
|
||||
|
||||
public static Set<Long> getBlockedConversationIds(SharedPreferences prefs) {
|
||||
Set<String> conversations = getBlockedConversations(prefs);
|
||||
Set<Long> ids = new HashSet<>();
|
||||
for (String id : conversations) {
|
||||
ids.add(Long.parseLong(id));
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static Set<String> getBlockedConversations(SharedPreferences prefs) {
|
||||
return prefs.getStringSet(SettingsFragment.BLOCKED_SENDERS, new HashSet<String>());
|
||||
}
|
||||
|
||||
public static void blockFutureConversation(SharedPreferences prefs, String address) {
|
||||
Set<String> idStrings = prefs.getStringSet(SettingsFragment.BLOCKED_FUTURE, new HashSet<String>());
|
||||
idStrings.add(address);
|
||||
prefs.edit().putStringSet(SettingsFragment.BLOCKED_FUTURE, idStrings).apply();
|
||||
}
|
||||
|
||||
public static void unblockFutureConversation(SharedPreferences prefs, String address) {
|
||||
Set<String> idStrings2 = prefs.getStringSet(SettingsFragment.BLOCKED_FUTURE, new HashSet<String>());
|
||||
idStrings2.remove(address);
|
||||
prefs.edit().putStringSet(SettingsFragment.BLOCKED_FUTURE, idStrings2).apply();
|
||||
}
|
||||
|
||||
public static Set<String> getFutureBlockedConversations(SharedPreferences prefs) {
|
||||
return prefs.getStringSet(SettingsFragment.BLOCKED_FUTURE, new HashSet<String>());
|
||||
}
|
||||
|
||||
public static boolean isFutureBlocked(SharedPreferences prefs, String address) {
|
||||
for (String s : getFutureBlockedConversations(prefs)) {
|
||||
if (PhoneNumberUtils.compareLoosely(s, address)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String[] getBlockedConversationArray(SharedPreferences prefs) {
|
||||
Set<String> idStrings = getBlockedConversations(prefs);
|
||||
return idStrings.toArray(new String[idStrings.size()]);
|
||||
}
|
||||
|
||||
public static String getCursorSelection(SharedPreferences prefs, boolean blocked) {
|
||||
StringBuilder selection = new StringBuilder();
|
||||
selection.append(Telephony.Threads.MESSAGE_COUNT);
|
||||
selection.append(" != 0");
|
||||
selection.append(" AND ");
|
||||
selection.append(Telephony.Threads._ID);
|
||||
if (!blocked) selection.append(" NOT");
|
||||
selection.append(" IN (");
|
||||
|
||||
Set<String> idStrings = getBlockedConversations(prefs);
|
||||
for (int i = 0; i < idStrings.size(); i++) {
|
||||
selection.append("?");
|
||||
if (i < idStrings.size() - 1) {
|
||||
selection.append(",");
|
||||
}
|
||||
}
|
||||
selection.append(")");
|
||||
|
||||
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(final Context context, final SharedPreferences prefs, final MenuItem item, boolean showBlocked) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
new BindMenuItemTask(context, prefs, item, showBlocked).execute((Void[]) null);
|
||||
}
|
||||
|
||||
private static class BindMenuItemTask extends AsyncTask<Void, Void, Integer> {
|
||||
|
||||
private Context mContext;
|
||||
private SharedPreferences mPrefs;
|
||||
private MenuItem mMenuItem;
|
||||
private boolean mShowBlocked;
|
||||
|
||||
private BindMenuItemTask(Context context, SharedPreferences prefs, MenuItem item, boolean showBlocked) {
|
||||
mContext = context;
|
||||
mPrefs = prefs;
|
||||
mMenuItem = item;
|
||||
mShowBlocked = showBlocked;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
super.onPreExecute();
|
||||
mMenuItem.setVisible(mPrefs.getBoolean(SettingsFragment.BLOCKED_ENABLED, false));
|
||||
mMenuItem.setTitle(mContext.getString(mShowBlocked ? R.string.menu_messages : R.string.menu_blocked));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(Void... params) {
|
||||
int unreadCount = 0;
|
||||
|
||||
// Create a cursor for the conversation list
|
||||
Cursor conversationCursor = mContext.getContentResolver().query(
|
||||
SmsHelper.CONVERSATIONS_CONTENT_PROVIDER, Conversation.ALL_THREADS_PROJECTION,
|
||||
getCursorSelection(mPrefs, !mShowBlocked), getBlockedConversationArray(mPrefs), SmsHelper.sortDateDesc);
|
||||
|
||||
if (conversationCursor.moveToFirst()) {
|
||||
do {
|
||||
Uri threadUri = Uri.withAppendedPath(Message.MMS_SMS_CONTENT_PROVIDER, conversationCursor.getString(Conversation.ID));
|
||||
Cursor messageCursor = mContext.getContentResolver().query(threadUri, MessageColumns.PROJECTION,
|
||||
SmsHelper.UNREAD_SELECTION, null, SmsHelper.sortDateDesc);
|
||||
unreadCount += messageCursor.getCount();
|
||||
messageCursor.close();
|
||||
} while (conversationCursor.moveToNext());
|
||||
}
|
||||
|
||||
conversationCursor.close();
|
||||
return unreadCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Integer integer) {
|
||||
super.onPostExecute(integer);
|
||||
Log.d("BindMenuItemTask", "onPostExecute: " + integer);
|
||||
mMenuItem.setTitle(mContext.getString(mShowBlocked ? R.string.menu_unblocked_conversations : R.string.menu_blocked_conversations, integer));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@ package com.moez.QKSMS.receiver;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.net.Uri;
|
||||
import android.os.PowerManager;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.telephony.SmsMessage;
|
||||
import android.util.Log;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.data.Message;
|
||||
import com.moez.QKSMS.service.NotificationService;
|
||||
@@ -52,9 +55,16 @@ public class MessagingReceiver extends BroadcastReceiver {
|
||||
uri = SmsHelper.addMessageToInbox(context, address, body, date);
|
||||
|
||||
Message message = new Message(context, uri);
|
||||
ConversationPrefsHelper prefs = new ConversationPrefsHelper(context, message.getThreadId());
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
ConversationPrefsHelper conversationPrefs = new ConversationPrefsHelper(context, message.getThreadId());
|
||||
|
||||
if (prefs.getNotificationsEnabled()) {
|
||||
if (BlockedConversationHelper.isFutureBlocked(prefs, address)) {
|
||||
BlockedConversationHelper.unblockFutureConversation(prefs, address);
|
||||
BlockedConversationHelper.blockConversation(prefs, message.getThreadId());
|
||||
message.markSeen();
|
||||
|
||||
} else if (conversationPrefs.getNotificationsEnabled() && !BlockedConversationHelper.getBlockedConversationIds(
|
||||
PreferenceManager.getDefaultSharedPreferences(context)).contains(message.getThreadId())) {
|
||||
Intent messageHandlerIntent = new Intent(context, NotificationService.class);
|
||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_POPUP, true);
|
||||
messageHandlerIntent.putExtra(NotificationService.EXTRA_URI, uri.toString());
|
||||
@@ -66,7 +76,7 @@ public class MessagingReceiver extends BroadcastReceiver {
|
||||
message.markSeen();
|
||||
}
|
||||
|
||||
if (prefs.getWakePhoneEnabled()) {
|
||||
if (conversationPrefs.getWakePhoneEnabled()) {
|
||||
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
|
||||
PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "MessagingReceiver");
|
||||
wakeLock.acquire();
|
||||
|
||||
@@ -263,8 +263,7 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
|
||||
if (mSlidingMenu.isMenuShowing() || mContent == null) {
|
||||
showBackButton(false);
|
||||
setTitle(getString(R.string.title_conversation_list));
|
||||
inflater.inflate(R.menu.coversation_list, menu);
|
||||
mConversationList.inflateToolbar(menu, inflater, this);
|
||||
} else {
|
||||
showBackButton(true);
|
||||
mContent.inflateToolbar(menu, inflater, this);
|
||||
@@ -366,18 +365,19 @@ public class MainActivity extends QKActivity implements SlidingMenu.OnOpenListen
|
||||
public boolean onKeyUp(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||||
if (!mSlidingMenu.isMenuShowing()) {
|
||||
Fragment category = getFragmentManager()
|
||||
.findFragmentByTag(SettingsFragment.CATEGORY_TAG);
|
||||
Fragment category = getFragmentManager().findFragmentByTag(SettingsFragment.CATEGORY_TAG);
|
||||
if (category != null) {
|
||||
getFragmentManager().beginTransaction()
|
||||
.remove(category)
|
||||
.commit();
|
||||
getFragmentManager().beginTransaction().remove(category).commit();
|
||||
} else {
|
||||
mSlidingMenu.showMenu();
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
finish();
|
||||
if (mConversationList.isShowingBlocked()) {
|
||||
mConversationList.setShowingBlocked(false);
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+57
-10
@@ -2,13 +2,15 @@ package com.moez.QKSMS.ui.conversationlist;
|
||||
|
||||
import android.app.Fragment;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Context;
|
||||
import android.content.CursorLoader;
|
||||
import android.content.Loader;
|
||||
import android.content.SharedPreferences;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Telephony;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -20,6 +22,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import com.melnykov.fab.FloatingActionButton;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.common.ConversationPrefsHelper;
|
||||
import com.moez.QKSMS.common.DialogHelper;
|
||||
import com.moez.QKSMS.common.LiveViewManager;
|
||||
@@ -54,12 +57,17 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
private final int MENU_DELETE_FAILED = 6;
|
||||
private final int MENU_DELETE_CONVERSATION = 7;
|
||||
private final int MENU_MULTI_SELECT = 8;
|
||||
private final int MENU_BLOCK_CONVERSATION = 9;
|
||||
private final int MENU_UNBLOCK_CONVERSATION = 10;
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private FloatingActionButton mFab;
|
||||
private ConversationListAdapter mAdapter;
|
||||
private LinearLayoutManager mLayoutManager;
|
||||
private ConversationDetailsDialog mConversationDetailsDialog;
|
||||
private SharedPreferences mPrefs;
|
||||
private MenuItem mBlockedItem;
|
||||
private boolean mShowBlocked = false;
|
||||
|
||||
// This does not hold the current position of the list, rather the position the list is pending being set to
|
||||
private int mPosition;
|
||||
@@ -68,6 +76,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
mPrefs = PreferenceManager.getDefaultSharedPreferences(mContext);
|
||||
setHasOptionsMenu(true);
|
||||
|
||||
mAdapter = new ConversationListAdapter(mContext);
|
||||
@@ -113,9 +122,9 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
return view;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
public void inflateToolbar(Menu menu, MenuInflater inflater, Context context) {
|
||||
inflater.inflate(R.menu.coversation_list, menu);
|
||||
mContext.setTitle(mShowBlocked ? R.string.title_blocked : R.string.title_conversation_list);
|
||||
|
||||
// Make sure we're only touching the conversation menu
|
||||
if (menu.findItem(R.id.menu_search) != null) {
|
||||
@@ -131,6 +140,11 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
} else {
|
||||
mAdapter.disableMultiSelectMode(false);
|
||||
}
|
||||
|
||||
mBlockedItem = menu.findItem(R.id.menu_blocked);
|
||||
BlockedConversationHelper.bindBlockedMenuItem(mContext, mPrefs, mBlockedItem, mShowBlocked);
|
||||
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,17 +153,33 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
case R.id.menu_delete:
|
||||
DialogHelper.showDeleteConversationsDialog((MainActivity) mContext, mAdapter);
|
||||
return true;
|
||||
|
||||
case R.id.menu_mark_read:
|
||||
for (long threadId : mAdapter.getSelectedItems()) {
|
||||
new ConversationLegacy(mContext, threadId).markRead();
|
||||
}
|
||||
mAdapter.disableMultiSelectMode(true);
|
||||
return true;
|
||||
|
||||
case R.id.menu_blocked:
|
||||
setShowingBlocked(!mShowBlocked);
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
|
||||
public boolean isShowingBlocked() {
|
||||
return mShowBlocked;
|
||||
}
|
||||
|
||||
public void setShowingBlocked(boolean showBlocked) {
|
||||
mShowBlocked = showBlocked;
|
||||
mContext.setTitle(mShowBlocked ? R.string.title_blocked : R.string.title_conversation_list);
|
||||
BlockedConversationHelper.bindBlockedMenuItem(mContext, mPrefs, mBlockedItem, mShowBlocked);
|
||||
initLoaderManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(Conversation conversation, View view) {
|
||||
if (mAdapter.isInMultiSelectMode()) {
|
||||
@@ -186,6 +216,14 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
dialog.addMenuItem(R.string.menu_mute_conversation, MENU_MUTE_CONVERSATION);
|
||||
}
|
||||
|
||||
if (mPrefs.getBoolean(SettingsFragment.BLOCKED_ENABLED, false)) {
|
||||
if (BlockedConversationHelper.isConversationBlocked(mPrefs, conversation.getThreadId())) {
|
||||
dialog.addMenuItem(R.string.menu_unblock_conversation, MENU_UNBLOCK_CONVERSATION);
|
||||
} else {
|
||||
dialog.addMenuItem(R.string.menu_block_conversation, MENU_BLOCK_CONVERSATION);
|
||||
}
|
||||
}
|
||||
|
||||
if (conversation.hasUnreadMessages()) {
|
||||
dialog.addMenuItem(R.string.menu_mark_read, MENU_MARK_READ);
|
||||
} else {
|
||||
@@ -224,6 +262,16 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
mConversationDetailsDialog.showDetails(conversation);
|
||||
break;
|
||||
|
||||
case MENU_BLOCK_CONVERSATION:
|
||||
BlockedConversationHelper.blockConversation(mPrefs, conversation.getThreadId());
|
||||
initLoaderManager();
|
||||
break;
|
||||
|
||||
case MENU_UNBLOCK_CONVERSATION:
|
||||
BlockedConversationHelper.unblockConversation(mPrefs, conversation.getThreadId());
|
||||
initLoaderManager();
|
||||
break;
|
||||
|
||||
case MENU_MARK_READ:
|
||||
new ConversationLegacy(mContext, threadId).markRead();
|
||||
break;
|
||||
@@ -239,6 +287,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
case MENU_DELETE_CONVERSATION:
|
||||
DialogHelper.showDeleteConversationDialog((MainActivity) mContext, threadId);
|
||||
break;
|
||||
|
||||
case MENU_DELETE_FAILED:
|
||||
//Deletes all failed messages from all conversations
|
||||
DialogHelper.showDeleteFailedMessagesDialog((MainActivity) mContext, threadId);
|
||||
@@ -260,7 +309,7 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
}
|
||||
|
||||
private void initLoaderManager() {
|
||||
getLoaderManager().initLoader(0, null, this);
|
||||
getLoaderManager().restartLoader(0, null, this);
|
||||
}
|
||||
|
||||
private void switchFragment(ContentFragment fragment) {
|
||||
@@ -270,15 +319,13 @@ public class ConversationListFragment extends QKFragment implements LoaderManage
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
|
||||
LiveViewManager.unregisterView(this);
|
||||
|
||||
}
|
||||
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
final String SELECTION = Telephony.Threads.MESSAGE_COUNT + "!= 0";
|
||||
return new CursorLoader(mContext, SmsHelper.CONVERSATIONS_CONTENT_PROVIDER,
|
||||
Conversation.ALL_THREADS_PROJECTION, SELECTION, null, "date DESC");
|
||||
return new CursorLoader(mContext, SmsHelper.CONVERSATIONS_CONTENT_PROVIDER, Conversation.ALL_THREADS_PROJECTION,
|
||||
BlockedConversationHelper.getCursorSelection(mPrefs, mShowBlocked),
|
||||
BlockedConversationHelper.getBlockedConversationArray(mPrefs), "date DESC");
|
||||
}
|
||||
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.moez.QKSMS.ui.dialog;
|
||||
|
||||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.TextView;
|
||||
import com.moez.QKSMS.R;
|
||||
import com.moez.QKSMS.common.BlockedConversationHelper;
|
||||
import com.moez.QKSMS.ui.base.QKActivity;
|
||||
import com.moez.QKSMS.ui.view.QKEditText;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class BlockedNumberDialog {
|
||||
|
||||
public static void showDialog(final QKActivity context) {
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
Set<String> addresses = BlockedConversationHelper.getFutureBlockedConversations(prefs);
|
||||
|
||||
new QKDialog()
|
||||
.setContext(context)
|
||||
.setTitle(R.string.pref_block_future)
|
||||
.setItems(addresses.toArray(new String[addresses.size()]), new AdapterView.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, final View view, int position, long id) {
|
||||
new QKDialog()
|
||||
.setContext(context)
|
||||
.setTitle(R.string.title_unblock_address)
|
||||
.setMessage(((TextView) view).getText().toString())
|
||||
.setPositiveButton(R.string.yes, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
BlockedConversationHelper.unblockFutureConversation(prefs, ((TextView) view).getText().toString());
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show(context.getFragmentManager(), "remove from future blocked");
|
||||
}
|
||||
})
|
||||
.setPositiveButton(R.string.add, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
final QKEditText editText = new QKEditText(context);
|
||||
new QKDialog()
|
||||
.setContext(context)
|
||||
.setTitle(R.string.title_block_address)
|
||||
.setCustomView(editText)
|
||||
.setPositiveButton(R.string.add, new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (editText.getText().length() > 0) {
|
||||
BlockedConversationHelper.blockFutureConversation(prefs, editText.getText().toString());
|
||||
}
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show(context.getFragmentManager(), "add to future blocked");
|
||||
}
|
||||
})
|
||||
.setNegativeButton(R.string.cancel, null)
|
||||
.show(context.getFragmentManager(), "future blocked conversations");
|
||||
}
|
||||
}
|
||||
@@ -44,6 +44,7 @@ import com.moez.QKSMS.transaction.SmsHelper;
|
||||
import com.moez.QKSMS.ui.ContentFragment;
|
||||
import com.moez.QKSMS.ui.MainActivity;
|
||||
import com.moez.QKSMS.ui.ThemeManager;
|
||||
import com.moez.QKSMS.ui.dialog.BlockedNumberDialog;
|
||||
import com.moez.QKSMS.ui.dialog.BubblePreferenceDialog;
|
||||
import com.moez.QKSMS.ui.dialog.QKDialog;
|
||||
import com.moez.QKSMS.ui.dialog.mms.MMSSetupFragment;
|
||||
@@ -107,6 +108,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
||||
public static final String DELIVERY_TOAST = "pref_key_delivery_toast";
|
||||
public static final String DELIVERY_VIBRATE = "pref_key_delivery_vibrate";
|
||||
public static final String YAPPY = "pref_key_endlessjabber";
|
||||
public static final String BLOCKED_ENABLED = "pref_key_blocked_enabled";
|
||||
public static final String BLOCKED_SENDERS = "pref_key_blocked_senders";
|
||||
public static final String BLOCKED_FUTURE = "pref_key_block_future";
|
||||
public static final String MOBILE_ONLY = "pref_key_mobile_only";
|
||||
public static final String COMPOSE_GROUP = "pref_key_compose_group";
|
||||
public static final String SPLIT_SMS = "pref_key_split";
|
||||
@@ -546,6 +550,9 @@ public class SettingsFragment extends PreferenceFragment implements Preference.O
|
||||
case ICON:
|
||||
ThemeManager.setIcon(mContext);
|
||||
break;
|
||||
case BLOCKED_FUTURE:
|
||||
BlockedNumberDialog.showDialog(mContext);
|
||||
break;
|
||||
case NOTIFICATION_LED_COLOR:
|
||||
mLedColorPickerDialog.show(getActivity().getFragmentManager(), "colorpicker");
|
||||
break;
|
||||
|
||||
@@ -25,6 +25,11 @@
|
||||
android:id="@+id/menu_settings"
|
||||
android:title="@string/menu_settings" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_blocked"
|
||||
android:title="@string/pref_blocked_conversations"
|
||||
android:visible="false" />
|
||||
|
||||
<item
|
||||
android:id="@+id/menu_changelog"
|
||||
android:title="@string/menu_changelog" />
|
||||
|
||||
@@ -168,6 +168,10 @@
|
||||
<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_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_block_future">Block future messages</string>
|
||||
<string name="pref_block_future_summary">Add additional phone numbers to block</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>
|
||||
@@ -299,6 +303,7 @@
|
||||
<string name="title_compose">Compose</string>
|
||||
<!--Conversations screen title-->
|
||||
<string name="title_conversation_list">Conversations</string>
|
||||
<string name="title_blocked">Blocked</string>
|
||||
<!--Changelog screen title-->
|
||||
<string name="title_changelog">Changelog</string>
|
||||
<!--QuickReply picker dialog title (shows up when you press reply from notification, but there are multiple senders)-->
|
||||
@@ -307,6 +312,8 @@
|
||||
<string name="title_donate">Donate</string>
|
||||
<!--QK Response dialog title-->
|
||||
<string name="title_qk_responses">QK Responses</string>
|
||||
<string name="title_block_address">Block number</string>
|
||||
<string name="title_unblock_address">Unblock number</string>
|
||||
|
||||
<!-- Menu shown in the context menu when long pressing on a message when the message contains
|
||||
one or more phone numbers and/or email addresses and the number or email is new to
|
||||
@@ -371,6 +378,7 @@
|
||||
<string name="call">Call</string>
|
||||
<!--Positive action button-->
|
||||
<string name="yes">Yes</string>
|
||||
<string name="add">Add</string>
|
||||
<!--Positive action button-->
|
||||
<string name="save">Save</string>
|
||||
<!--Positive action button-->
|
||||
@@ -636,6 +644,12 @@
|
||||
<string name="menu_mute_conversation">Mute conversation</string>
|
||||
<!--Menu option to mute conversation-->
|
||||
<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_messages">Messages</string>
|
||||
<string name="menu_blocked">Blocked</string>
|
||||
<string name="menu_blocked_conversations">Blocked (%s new)</string>
|
||||
<string name="menu_unblocked_conversations">Messages (%s new)</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>
|
||||
|
||||
@@ -89,6 +89,20 @@
|
||||
<PreferenceCategory
|
||||
android:layout="@layout/list_item_preference_category"
|
||||
android:title="@string/pref_category_general">
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_key_blocked_enabled"
|
||||
android:layout="@layout/list_item_preference"
|
||||
android:summary="@string/pref_blocked_conversations_summary"
|
||||
android:title="@string/pref_blocked_conversations"
|
||||
android:widgetLayout="@layout/view_checkbox" />
|
||||
<Preference
|
||||
android:defaultValue="false"
|
||||
android:dependency="pref_key_blocked_enabled"
|
||||
android:key="pref_key_block_future"
|
||||
android:layout="@layout/list_item_preference"
|
||||
android:summary="@string/pref_block_future_summary"
|
||||
android:title="@string/pref_block_future" />
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
android:key="pref_key_mobile_only"
|
||||
|
||||
Reference in New Issue
Block a user