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

Commit 8f66599e authored by Chiao Cheng's avatar Chiao Cheng
Browse files

Adding more call log filter buttons.

Adding missed, outgoing, incoming buttons to complement existing
voicemail button.

Change-Id: I43c2a5675783b8a32e4db45b39c64b5496f09e53
parent 8076f88c
Loading
Loading
Loading
Loading
+36 −12
Original line number Diff line number Diff line
@@ -15,18 +15,42 @@
-->
<menu xmlns:android="http://schemas.android.com/apk/res/android">

    <item
            android:id="@+id/show_all_calls"
            android:title="@string/menu_show_all_calls"
            android:icon="@drawable/quickcon_background_texture"
            android:showAsAction="ifRoom"
            android:orderInCategory="1"/>

    <item
            android:id="@+id/show_voicemails_only"
            android:title="@string/menu_show_voicemails_only"
        android:showAsAction="withText"
            android:icon="@drawable/ic_call_voicemail_holo_dark"
            android:showAsAction="ifRoom"
            android:orderInCategory="1"/>

    <item
        android:id="@+id/show_all_calls"
        android:title="@string/menu_show_all_calls"
        android:showAsAction="withText"
            android:id="@+id/show_missed_only"
            android:title="@string/menu_show_missed_only"
            android:icon="@drawable/ic_call_missed_holo_dark"
            android:showAsAction="ifRoom"
            android:orderInCategory="1"/>

    <item
            android:id="@+id/show_outgoing_only"
            android:title="@string/menu_show_outgoing_only"
            android:icon="@drawable/ic_call_outgoing_holo_dark"
            android:showAsAction="ifRoom"
            android:orderInCategory="1"/>

    <item
            android:id="@+id/show_incoming_only"
            android:title="@string/menu_show_incoming_only"
            android:icon="@drawable/ic_call_incoming_holo_dark"
            android:showAsAction="ifRoom"
            android:orderInCategory="1"/>


    <item
            android:id="@+id/delete_all"
            android:title="@string/recentCalls_deleteAll"
+9 −0
Original line number Diff line number Diff line
@@ -1651,6 +1651,15 @@
    <!-- The "file name" displayed for vCards received directly via NFC [CHAR LIMIT=16] -->
    <string name="nfc_vcard_file_name">Contact received over NFC</string>

    <!-- Menu item used to show only outgoing in the call log. [CHAR LIMIT=30] -->
    <string name="menu_show_outgoing_only">Show outgoing only</string>

    <!-- Menu item used to show only incoming in the call log. [CHAR LIMIT=30] -->
    <string name="menu_show_incoming_only">Show incoming only</string>

    <!-- Menu item used to show only missed in the call log. [CHAR LIMIT=30] -->
    <string name="menu_show_missed_only">Show missed only</string>

    <!-- Menu item used to show only voicemails in the call log. [CHAR LIMIT=30] -->
    <string name="menu_show_voicemails_only">Show voicemails only</string>

+3 −3
Original line number Diff line number Diff line
@@ -1017,7 +1017,7 @@ public class DialtactsActivity extends TransactionSafeActivity
            // When there is a permanent menu key, there is no overflow icon on the right of
            // the action bar which would force the search menu item (if it is visible) to the
            // left.  This is the purpose of showing the emptyRightMenuItem.
            emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
            emptyRightMenuItem.setVisible(false);
        } else {
            // This is when the user is looking at the dialer pad.  In this case, the real
            // ActionBar is hidden and fake menu items are shown.
@@ -1038,11 +1038,11 @@ public class DialtactsActivity extends TransactionSafeActivity
        final MenuItem emptyRightMenuItem = menu.findItem(R.id.empty_right_menu_item);

        // prepare the menu items
        searchMenuItem.setVisible(true);
        searchMenuItem.setVisible(false);
        filterOptionMenuItem.setVisible(false);
        addContactOptionMenuItem.setVisible(false);
        callSettingsMenuItem.setVisible(true);
        emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
        emptyRightMenuItem.setVisible(false);
    }

    private void prepareOptionsMenuForFavoritesTab(Menu menu) {
+16 −4
Original line number Diff line number Diff line
@@ -331,10 +331,7 @@ public class CallLogFragment extends ListFragment
        // menu items are ready if the first item is non-null.
        if (itemDeleteAll != null) {
            itemDeleteAll.setEnabled(mAdapter != null && !mAdapter.isEmpty());
            menu.findItem(R.id.show_voicemails_only).setVisible(
                    mVoicemailSourcesAvailable && !mShowingVoicemailOnly);
            menu.findItem(R.id.show_all_calls).setVisible(
                    mVoicemailSourcesAvailable && mShowingVoicemailOnly);
            menu.findItem(R.id.show_voicemails_only).setVisible(mVoicemailSourcesAvailable);
        }
    }

@@ -345,6 +342,21 @@ public class CallLogFragment extends ListFragment
                ClearCallLogDialog.show(getFragmentManager());
                return true;

            case R.id.show_outgoing_only:
                mCallLogQueryHandler.fetchOutgoing();

                return true;

            case R.id.show_incoming_only:
                mCallLogQueryHandler.fetchIncoming();

                return true;

            case R.id.show_missed_only:
                mCallLogQueryHandler.fetchMissed();

                return true;

            case R.id.show_voicemails_only:
                mCallLogQueryHandler.fetchVoicemailOnly();
                mShowingVoicemailOnly = true;
+28 −7
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import android.database.sqlite.SQLiteFullException;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.VoicemailContract.Status;
import android.util.Log;
@@ -159,8 +160,8 @@ import javax.annotation.concurrent.GuardedBy;
    public void fetchAllCalls() {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, false /*voicemailOnly*/);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, false /*voicemailOnly*/);
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, -1 /*callType*/);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, -1 /*callType*/);
    }

    /**
@@ -171,10 +172,30 @@ import javax.annotation.concurrent.GuardedBy;
    public void fetchVoicemailOnly() {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, true /*voicemailOnly*/);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, true /*voicemailOnly*/);
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.VOICEMAIL_TYPE);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.VOICEMAIL_TYPE);
    }

    public void fetchOutgoing() {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.OUTGOING_TYPE);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.OUTGOING_TYPE);
    }

    public void fetchIncoming() {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.INCOMING_TYPE);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.INCOMING_TYPE);
    }

    public void fetchMissed() {
        cancelFetch();
        int requestId = newCallsRequest();
        fetchCalls(QUERY_NEW_CALLS_TOKEN, requestId, true /*isNew*/, Calls.MISSED_TYPE);
        fetchCalls(QUERY_OLD_CALLS_TOKEN, requestId, false /*isNew*/, Calls.MISSED_TYPE);
    }

    public void fetchVoicemailStatus() {
        startQuery(QUERY_VOICEMAIL_STATUS_TOKEN, null, Status.CONTENT_URI,
@@ -182,7 +203,7 @@ import javax.annotation.concurrent.GuardedBy;
    }

    /** Fetches the list of calls in the call log, either the new one or the old ones. */
    private void fetchCalls(int token, int requestId, boolean isNew, boolean voicemailOnly) {
    private void fetchCalls(int token, int requestId, boolean isNew, int callType) {
        // We need to check for NULL explicitly otherwise entries with where READ is NULL
        // may not match either the query or its negation.
        // We consider the calls that are not yet consumed (i.e. IS_READ = 0) as "new".
@@ -194,10 +215,10 @@ import javax.annotation.concurrent.GuardedBy;
            // Negate the query.
            selection = String.format("NOT (%s)", selection);
        }
        if (voicemailOnly) {
        if (callType > 0) {
            // Add a clause to fetch only items of type voicemail.
            selection = String.format("(%s) AND (%s = ?)", selection, Calls.TYPE);
            selectionArgs.add(Integer.toString(Calls.VOICEMAIL_TYPE));
            selectionArgs.add(Integer.toString(callType));
        }
        startQuery(token, requestId, Calls.CONTENT_URI_WITH_VOICEMAIL,
                CallLogQuery._PROJECTION, selection, selectionArgs.toArray(EMPTY_STRING_ARRAY),