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

Commit 0b854596 authored by qqzhou's avatar qqzhou Committed by Steve Kondik
Browse files

Dialer: support "add to black/white list" in call detail

- add the "add to black list" and "add to white list" into options
  menu of call detail activity.
- remove the "IP call" options in call detail activity.

Change-Id: I2139d670213e94629c1fcabb1e53110609693859
CRs-Fixed: 746722
parent 3bdc8342
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -21,14 +21,16 @@
        android:onClick="onMenuVideoCall"
    />
    <item
        android:id="@+id/menu_ip_call_by_slot1"
        android:id="@+id/menu_add_to_black_list"
        android:showAsAction="withText"
        android:onClick="onMenuIpCallBySlot1"
        android:title="@string/add_to_black_list"
        android:onClick="onMenuAddToBlackList"
    />
    <item
        android:id="@+id/menu_ip_call_by_slot2"
        android:id="@+id/menu_add_to_white_list"
        android:showAsAction="withText"
        android:onClick="onMenuIpCallBySlot2"
        android:title="@string/add_to_white_list"
        android:onClick="onMenuAddToWhiteList"
    />
    <item
        android:id="@+id/menu_trash"

res/values-zh-rCN/strings.xml

100755 → 100644
+3 −0
Original line number Diff line number Diff line
@@ -223,4 +223,7 @@
    <string name="call_log_show_all_slots">"所有卡"</string>
    <string name="call_log_all_calls_header">"所有通话"</string>
    <string name="calllog_search_hint">"搜索通话记录"</string>

    <string name="add_to_white_list">加入白名单</string>
    <string name="add_to_black_list">加入黑名单</string>
</resources>

res/values/strings.xml

100755 → 100644
+3 −0
Original line number Diff line number Diff line
@@ -834,4 +834,7 @@
    <string name="call_log_show_all_slots">All SIMs</string>
    <string name="call_log_all_calls_header">All calls</string>
    <string name="calllog_search_hint">"Search call log"</string>

    <string name="add_to_white_list">Add to white list</string>
    <string name="add_to_black_list">Add to black list</string>
</resources>
+46 −69
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@ import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.Resources;
import android.database.Cursor;
import android.net.Uri;
@@ -153,10 +156,13 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe
    private boolean mHasTrashOption;
    /** Whether we should show "remove from call log" in the options menu. */
    private boolean mHasRemoveFromCallLogOption;
    /** Whether we should show "Ip Call by SIM1" in the options menu. */
    private boolean mHasSub1IpCallOption;
    /** Whether we should show "Ip Call by SIM2" in the options menu. */
    private boolean mHasSub2IpCallOption;

    /** Add for black/white list. */
    private boolean mHasInstallFireWallOption = false;
    private static final String NUMBER_KEY = "number";
    private static final String MODE_KEY = "mode";
    private static final String FIREWALL_APK_NAME = "com.android.firewall";
    private static final String FIREWALL_BLACK_WHITE_LIST = "com.android.firewall.FirewallListPage";

    private ProximitySensorManager mProximitySensorManager;
    private final ProximitySensorListener mProximitySensorListener = new ProximitySensorListener();
@@ -280,6 +286,20 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe
    public void onResume() {
        super.onResume();
        updateData(getCallLogEntryUris());

        mHasInstallFireWallOption = isFireWallInstalled();
    }

    private boolean isFireWallInstalled() {
        boolean installed = false;
        try {
            ApplicationInfo info = getPackageManager().getApplicationInfo(
                    FIREWALL_APK_NAME, PackageManager.GET_PROVIDERS);
            installed = (info != null);
        } catch (NameNotFoundException e) {
        }
        Log.d(TAG, "Is Firewall installed ? " + installed);
        return installed;
    }

    /**
@@ -477,16 +497,6 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe
                        canPlaceCallsTo && !isSipNumber && !isVoicemailNumber;
                mHasTrashOption = hasVoicemail();
                mHasRemoveFromCallLogOption = !hasVoicemail();
                mHasSub1IpCallOption = canPlaceCallsTo
                        && !isSipNumber
                        && !isVoicemailNumber
                        && MoreContactUtils
                                .isMultiSimEnable(CallDetailActivity.this, PhoneConstants.SUB1);
                mHasSub2IpCallOption = canPlaceCallsTo
                        && !isSipNumber
                        && !isVoicemailNumber
                        && MoreContactUtils
                                .isMultiSimEnable(CallDetailActivity.this, PhoneConstants.SUB2);
                invalidateOptionsMenu();

                ListView historyList = (ListView) findViewById(R.id.history);
@@ -751,19 +761,8 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe

        menu.findItem(R.id.menu_video_call).setVisible(CallUtil.isCSVTEnabled());

        menu.findItem(R.id.menu_ip_call_by_slot1).setVisible(mHasSub1IpCallOption);
        menu.findItem(R.id.menu_ip_call_by_slot2).setVisible(mHasSub2IpCallOption);

        if (mHasSub1IpCallOption) {
            String sub1Name = MoreContactUtils.getMultiSimAliasesName(this, PhoneConstants.SUB1);
            menu.findItem(R.id.menu_ip_call_by_slot1).setTitle(getString(
                    com.android.contacts.common.R.string.ip_call_by_slot, sub1Name));
        }
        if (mHasSub2IpCallOption) {
            String sub2Name = MoreContactUtils.getMultiSimAliasesName(this, PhoneConstants.SUB2);
            menu.findItem(R.id.menu_ip_call_by_slot2).setTitle(getString(
                    com.android.contacts.common.R.string.ip_call_by_slot, sub2Name));
        }
        menu.findItem(R.id.menu_add_to_black_list).setVisible(mHasInstallFireWallOption);
        menu.findItem(R.id.menu_add_to_white_list).setVisible(mHasInstallFireWallOption);

        return super.onPrepareOptionsMenu(menu);
    }
@@ -776,50 +775,28 @@ public class CallDetailActivity extends AnalyticsActivity implements ProximitySe
        }
    }

    public void onMenuIpCallBySlot1(MenuItem menuItem) {
        String prefix = MoreContactUtils.getIPCallPrefix(this, PhoneConstants.SUB1);
        if (!TextUtils.isEmpty(prefix)) {
            long[] subId = SubscriptionManager.getSubId(PhoneConstants.SUB1);
            if (subId != null && subId.length >= 1) {
                ComponentName serviceName =
                        new ComponentName("com.android.phone",
                        "com.android.services.telephony.TelephonyConnectionService");
                PhoneAccountHandle account = new PhoneAccountHandle(serviceName,
                        String.valueOf(subId[0]));
                Intent callIntent = new Intent(CallUtil.getCallIntent(
                        prefix + mNumber, account));
                startActivity(callIntent);
            } else {
                Intent callIntent = new Intent(CallUtil.getCallIntent(
                        prefix + mNumber));
                startActivity(callIntent);
            }
        } else {
            MoreContactUtils.showNoIPNumberDialog(this, PhoneConstants.SUB1);
        }
    }

    public void onMenuIpCallBySlot2(MenuItem menuItem) {
        String prefix = MoreContactUtils.getIPCallPrefix(this, PhoneConstants.SUB2);
        if (!TextUtils.isEmpty(prefix)) {
            long[] subId = SubscriptionManager.getSubId(PhoneConstants.SUB2);
            if (subId != null && subId.length >= 1) {
                ComponentName serviceName =
                        new ComponentName("com.android.phone",
                        "com.android.services.telephony.TelephonyConnectionService");
                PhoneAccountHandle account = new PhoneAccountHandle(serviceName,
                        String.valueOf(subId[0]));
                Intent callIntent = new Intent(CallUtil.getCallIntent(
                        prefix + mNumber, account));
                startActivity(callIntent);
            } else {
                Intent callIntent = new Intent(CallUtil.getCallIntent(
                        prefix + mNumber));
                startActivity(callIntent);
            }
        } else {
            MoreContactUtils.showNoIPNumberDialog(this, PhoneConstants.SUB2);
    public void onMenuAddToBlackList(MenuItem menuItem) {
        Bundle blackBundle = new Bundle();
        blackBundle.putString(NUMBER_KEY, mNumber);
        blackBundle.putString(MODE_KEY, "blacklist");

        Intent blackIntent = new Intent();
        blackIntent.setClassName(FIREWALL_APK_NAME, FIREWALL_BLACK_WHITE_LIST);
        blackIntent.setAction(Intent.ACTION_INSERT);
        blackIntent.putExtras(blackBundle);
        startActivity(blackIntent);
    }

    public void onMenuAddToWhiteList(MenuItem menuItem) {
        Bundle whiteBundle = new Bundle();
        whiteBundle.putString(NUMBER_KEY, mNumber);
        whiteBundle.putString(MODE_KEY, "whitelist");

        Intent whiteIntent = new Intent();
        whiteIntent.setClassName(FIREWALL_APK_NAME, FIREWALL_BLACK_WHITE_LIST);
        whiteIntent.setAction(Intent.ACTION_INSERT);
        whiteIntent.putExtras(whiteBundle);
        startActivity(whiteIntent);
    }

    public void onMenuRemoveFromCallLog(MenuItem menuItem) {