Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb9d22dd authored by Danny Baumann's avatar Danny Baumann
Browse files

Make contacts app aware of phone blacklist setting (3/3)

Change-Id: I46935ca140098ca3f1c1d714ac4a406dd9d7f52e
parent 40816512
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -115,6 +115,8 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
    private boolean mHasTrashOption;
    /** Whether we should show "remove from call log" in the options menu. */
    private boolean mHasRemoveFromCallLogOption;
    /** Whether we should show "add to blacklist" in the options menu */
    private boolean mHasBlacklistOption;

    private ProximitySensorManager mProximitySensorManager;
    private final ProximitySensorListener mProximitySensorListener = new ProximitySensorListener();
@@ -353,6 +355,8 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
                mHasEditNumberBeforeCallOption = mCallDetailHeader.canEditNumberBeforeCall();
                mHasTrashOption = hasVoicemail();
                mHasRemoveFromCallLogOption = !hasVoicemail();
                mHasBlacklistOption = mContactInfoHelper.canBlacklistCalls();

                invalidateOptionsMenu();

                ListView historyList = (ListView) findViewById(R.id.history);
@@ -510,6 +514,7 @@ public class CallDetailActivity extends Activity implements ProximitySensorAware
        menu.findItem(R.id.menu_remove_from_call_log).setVisible(mHasRemoveFromCallLogOption);
        menu.findItem(R.id.menu_edit_number_before_call).setVisible(mHasEditNumberBeforeCallOption);
        menu.findItem(R.id.menu_trash).setVisible(mHasTrashOption);
        menu.findItem(R.id.menu_add_to_blacklist).setVisible(mHasBlacklistOption);
        return super.onPrepareOptionsMenu(menu);
    }

+10 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract.Contacts;
import android.provider.ContactsContract.PhoneLookup;
import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
import android.text.TextUtils;
import android.widget.Toast;
@@ -234,4 +235,13 @@ public class ContactInfoHelper {
        String message = mContext.getString(R.string.toast_added_to_blacklist, number);
        Toast.makeText(mContext, message, Toast.LENGTH_SHORT).show();
    }

    /**
     * Checks whether calls can be blacklisted; that is, whether the
     * phone blacklist is enabled
     */
    public boolean canBlacklistCalls() {
        return Settings.System.getInt(mContext.getContentResolver(),
                Settings.System.PHONE_BLACKLIST_ENABLED, 1) != 0;
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -228,6 +228,8 @@ public class CallStatsDetailActivity extends Activity {
    public boolean onPrepareOptionsMenu(Menu menu) {
        menu.findItem(R.id.menu_edit_number_before_call).setVisible(
                mCallDetailHeader.canEditNumberBeforeCall());
        menu.findItem(R.id.menu_add_to_blacklist).setVisible(
                mContactInfoHelper.canBlacklistCalls());
        return super.onPrepareOptionsMenu(menu);
    }