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

Commit a43c678d authored by blong's avatar blong Committed by Steve Kondik
Browse files

Add call log search in dialer

- add a menu to support search call log by name and number in
  the calllog screen

Change-Id: I80c85a9bdea962296ea39dab7ce689df06e8159e
parent 5ff9e4fc
Loading
Loading
Loading
Loading
+50 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
 * Copyright (c) 2014, The Linux Foundation. All Rights Reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 *       copyright notice, this list of conditions and the following
 *       disclaimer in the documentation and/or other materials provided
 *       with the distribution.
 *     * Neither the name of The Linux Foundation nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 -->

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dip"
    android:layout_height="0dip" >

    <!-- To prevent the search view from getting the initial focus.  -->
    <View
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:layout_width="1px"
        android:layout_height="1px" >
        <requestFocus />
    </View>
    <SearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:iconifiedByDefault="false"
        android:inputType="textFilter" />
</FrameLayout>
+6 −1
Original line number Diff line number Diff line
@@ -14,9 +14,14 @@
     limitations under the License.
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/search_calllog"
        android:title="@string/calllog_search_hint"
        android:showAsAction="never"
        android:orderInCategory="1"/>
    <item
        android:id="@+id/delete_all"
        android:title="@string/recentCalls_deleteAll"
        android:showAsAction="never"
        android:orderInCategory="1"/>
        android:orderInCategory="2"/>
</menu>
+3 −0
Original line number Diff line number Diff line
@@ -218,4 +218,7 @@
    <string name="dialog_speed_dial_airplane_mode_message" >"要呼叫快速拨号,请先关闭飞行模式。"</string>
    <string name="assignSpeedDialFailToast">此号码已分配了快速拨号键,请选择其它号码。</string>

    <string name="call_log_show_all_slots">"所有卡"</string>
    <string name="call_log_all_calls_header">"所有通话"</string>
    <string name="calllog_search_hint">"搜索通话记录"</string>
</resources>
+3 −0
Original line number Diff line number Diff line
@@ -827,4 +827,7 @@
    <string name="dialog_speed_dial_airplane_mode_message" >"To call Speed dial, first turn off Airplane mode."</string>
    <string name="assignSpeedDialFailToast">The number has already been assigned to a speed dial key, please select another number.</string>

    <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>
</resources>
+32 −3
Original line number Diff line number Diff line
@@ -21,8 +21,12 @@ import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.telephony.SubscriptionManager;
import android.graphics.Typeface;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.text.style.StyleSpan;
import android.view.View;
import android.widget.TextView;

@@ -72,7 +76,13 @@ public class PhoneCallDetailsHelper {
    }

    /** Fills the call details views with content. */
    public void setPhoneCallDetails(PhoneCallDetailsViews views, PhoneCallDetails details) {
    public void setPhoneCallDetails(PhoneCallDetailsViews views,
            PhoneCallDetails details) {
        setPhoneCallDetails(views, details, null);
    }

    public void setPhoneCallDetails(PhoneCallDetailsViews views,
            PhoneCallDetails details, String filter) {
        // Display up to a given number of icons.
        views.callTypeIcons.clear();
        int count = details.callTypes.length;
@@ -111,16 +121,35 @@ public class PhoneCallDetailsHelper {
            views.callAccountIcon.setVisibility(View.GONE);
        }

        final CharSequence nameText;
        final CharSequence displayNumber =
        CharSequence nameText;
        CharSequence displayNumber =
            mPhoneNumberHelper.getDisplayNumber(details.accountId, details.number,
                    details.numberPresentation, details.formattedNumber);
        String phoneNum = (String) details.number;
        if (!TextUtils.isEmpty(filter) && phoneNum.contains(filter)) {
            int start, end;
            start = phoneNum.indexOf(filter);
            end = start + filter.length();
            SpannableString result = new SpannableString(phoneNum);
            result.setSpan(new StyleSpan(Typeface.BOLD), start, end,
                    Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
            displayNumber = result;
        }
        if (TextUtils.isEmpty(details.name)) {
            nameText = displayNumber;
            // We have a real phone number as "nameView" so make it always LTR
            views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);
        } else {
            nameText = details.name;
            if (!TextUtils.isEmpty(filter) && nameText.toString().contains(filter)) {
                int start,end;
                start = nameText.toString().indexOf(filter);
                end = start + filter.length();
                SpannableString style = new SpannableString(nameText);
                style.setSpan(new StyleSpan(Typeface.BOLD), start, end,
                        Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
                nameText = style;
            }
        }

        views.nameView.setText(nameText);
Loading