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

Commit c8af761f authored by Chiao Cheng's avatar Chiao Cheng Committed by Android (Google) Code Review
Browse files

Merge "Adjusting call log filter look and feel." into jb-mr1-dev

parents b8f69516 9e0aa86f
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -33,6 +33,30 @@
        <include layout="@layout/call_log_voicemail_status"
    />
    </FrameLayout>

    <FrameLayout>
        <TextView
            android:id="@+id/filter_status"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingLeft="@dimen/call_log_outer_margin"
            android:paddingRight="@dimen/call_log_outer_margin"
            android:paddingTop="@dimen/call_log_inner_margin"
            android:paddingBottom="@dimen/call_log_inner_margin"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            android:visibility="gone"
            />
        <View
            android:id="@+id/call_log_divider"
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:layout_marginLeft="@dimen/call_log_outer_margin"
            android:layout_marginRight="@dimen/call_log_outer_margin"
            android:layout_gravity="bottom"
            android:background="#55ffffff"
            />
    </FrameLayout>
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
+24 −29
Original line number Diff line number Diff line
@@ -18,42 +18,37 @@
    <item
        android:id="@+id/show_all_calls"
        android:title="@string/menu_show_all_calls"
            android:icon="@drawable/quickcon_background_texture"
            android:showAsAction="ifRoom"
        android:showAsAction="never"
        android:orderInCategory="1"/>

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

    <item
        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:showAsAction="never"
        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:showAsAction="never"
        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:showAsAction="never"
        android:orderInCategory="1"/>


    <item
        android:id="@+id/delete_all"
        android:title="@string/recentCalls_deleteAll"
            android:showAsAction="withText"
        android:showAsAction="never"
        android:orderInCategory="1"/>
</menu>
+14 −2
Original line number Diff line number Diff line
@@ -1609,6 +1609,18 @@
    <!-- The header in the call log used to identify items that have been already consumed [CHAR LIMIT=10] -->
    <string name="call_log_old_header">Older</string>

    <!-- The header to show that call log is only showing voicemail calls. [CHAR LIMIT=40] -->
    <string name="call_log_voicemail_header">Calls with voicemail</string>

    <!-- The header to show that call log is only showing incoming calls. [CHAR LIMIT=40] -->
    <string name="call_log_incoming_header">Incoming calls</string>

    <!-- The header to show that call log is only showing outgoing calls. [CHAR LIMIT=40] -->
    <string name="call_log_outgoing_header">Outgoing calls</string>

    <!-- The header to show that call log is only showing missed calls. [CHAR LIMIT=40] -->
    <string name="call_log_missed_header">Missed calls</string>

    <!--  Voicemail status message shown at the top of call log to notify the user that no new
voicemails are currently available. This can happen when both notification as well as data
connection to the voicemail server is lost. [CHAR LIMIT=64] -->
+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(false);
            emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
        } 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(false);
        searchMenuItem.setVisible(true);
        filterOptionMenuItem.setVisible(false);
        addContactOptionMenuItem.setVisible(false);
        callSettingsMenuItem.setVisible(true);
        emptyRightMenuItem.setVisible(false);
        emptyRightMenuItem.setVisible(ViewConfiguration.get(this).hasPermanentMenuKey());
    }

    private void prepareOptionsMenuForFavoritesTab(Menu menu) {
+66 −15
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.app.KeyguardManager;
import android.app.ListFragment;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.database.ContentObserver;
import android.database.Cursor;
import android.net.Uri;
@@ -28,6 +29,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.preference.PreferenceManager;
import android.provider.CallLog;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
@@ -69,6 +71,8 @@ public class CallLogFragment extends ListFragment
     */
    private static final int EMPTY_LOADER_ID = 0;

    private static final String PREF_CALL_LOG_FILTER_LAST_CALL_TYPE = "CallLogFragment_last_filter";

    private CallLogAdapter mAdapter;
    private CallLogQueryHandler mCallLogQueryHandler;
    private boolean mScrollToTop;
@@ -82,6 +86,7 @@ public class CallLogFragment extends ListFragment
    private View mStatusMessageView;
    private TextView mStatusMessageText;
    private TextView mStatusMessageAction;
    private TextView mFilterStatusView;
    private KeyguardManager mKeyguardManager;

    private boolean mEmptyLoaderRunning;
@@ -108,6 +113,9 @@ public class CallLogFragment extends ListFragment
    // Exactly same variable is in Fragment as a package private.
    private boolean mMenuVisible = true;

    // Default to all calls.
    private int mCallTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);
@@ -120,6 +128,11 @@ public class CallLogFragment extends ListFragment
        getActivity().getContentResolver().registerContentObserver(
                ContactsContract.Contacts.CONTENT_URI, true, mContactsObserver);
        setHasOptionsMenu(true);

        // Load the last filter used.
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        mCallTypeFilter = prefs.getInt(PREF_CALL_LOG_FILTER_LAST_CALL_TYPE,
                CallLogQueryHandler.CALL_TYPE_ALL);
    }

    /** Called by the CallLogQueryHandler when the list of calls has been fetched or updated. */
@@ -148,7 +161,9 @@ public class CallLogFragment extends ListFragment
            mHandler.post(new Runnable() {
               @Override
               public void run() {
                   if (getActivity() == null || getActivity().isFinishing()) return;
                   if (getActivity() == null || getActivity().isFinishing()) {
                       return;
                   }
                   listView.smoothScrollToPosition(0);
               }
            });
@@ -202,6 +217,7 @@ public class CallLogFragment extends ListFragment
        mStatusMessageView = view.findViewById(R.id.voicemail_status);
        mStatusMessageText = (TextView) view.findViewById(R.id.voicemail_status_message);
        mStatusMessageAction = (TextView) view.findViewById(R.id.voicemail_status_action);
        mFilterStatusView = (TextView) view.findViewById(R.id.filter_status);
        return view;
    }

@@ -213,6 +229,8 @@ public class CallLogFragment extends ListFragment
                new ContactInfoHelper(getActivity(), currentCountryIso));
        setListAdapter(mAdapter);
        getListView().setItemsCanFocus(true);

        updateFilterHeader();
    }

    /**
@@ -279,6 +297,11 @@ public class CallLogFragment extends ListFragment
        super.onPause();
        // Kill the requests thread
        mAdapter.stopRequestProcessing();

        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
        prefs.edit()
                .putInt(PREF_CALL_LOG_FILTER_LAST_CALL_TYPE, mCallTypeFilter)
                .apply();
    }

    @Override
@@ -298,16 +321,12 @@ public class CallLogFragment extends ListFragment

    @Override
    public void fetchCalls() {
        if (mShowingVoicemailOnly) {
            mCallLogQueryHandler.fetchVoicemailOnly();
        } else {
            mCallLogQueryHandler.fetchAllCalls();
        }
        mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
    }

    public void startCallsQuery() {
        mAdapter.setLoading(true);
        mCallLogQueryHandler.fetchAllCalls();
        mCallLogQueryHandler.fetchCalls(mCallTypeFilter);
        if (mShowingVoicemailOnly) {
            mShowingVoicemailOnly = false;
            getActivity().invalidateOptionsMenu();
@@ -343,27 +362,34 @@ public class CallLogFragment extends ListFragment
                return true;

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

                mCallLogQueryHandler.fetchCalls(Calls.OUTGOING_TYPE);
                mCallTypeFilter = Calls.OUTGOING_TYPE;
                updateFilterHeader();
                return true;

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

                mCallLogQueryHandler.fetchCalls(Calls.INCOMING_TYPE);
                mCallTypeFilter = Calls.INCOMING_TYPE;
                updateFilterHeader();
                return true;

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

                mCallLogQueryHandler.fetchCalls(Calls.MISSED_TYPE);
                mCallTypeFilter = Calls.MISSED_TYPE;
                updateFilterHeader();
                return true;

            case R.id.show_voicemails_only:
                mCallLogQueryHandler.fetchVoicemailOnly();
                mCallLogQueryHandler.fetchCalls(Calls.VOICEMAIL_TYPE);
                mCallTypeFilter = Calls.VOICEMAIL_TYPE;
                updateFilterHeader();
                mShowingVoicemailOnly = true;
                return true;

            case R.id.show_all_calls:
                mCallLogQueryHandler.fetchAllCalls();
                mCallLogQueryHandler.fetchCalls(CallLogQueryHandler.CALL_TYPE_ALL);
                mCallTypeFilter = CallLogQueryHandler.CALL_TYPE_ALL;
                updateFilterHeader();
                mShowingVoicemailOnly = false;
                return true;

@@ -372,6 +398,31 @@ public class CallLogFragment extends ListFragment
        }
    }

    private void updateFilterHeader() {
        switch (mCallTypeFilter) {
            case CallLogQueryHandler.CALL_TYPE_ALL:
                mFilterStatusView.setVisibility(View.GONE);
                break;
            case Calls.INCOMING_TYPE:
                showFilterStatus(R.string.call_log_incoming_header);
                break;
            case Calls.OUTGOING_TYPE:
                showFilterStatus(R.string.call_log_outgoing_header);
                break;
            case Calls.MISSED_TYPE:
                showFilterStatus(R.string.call_log_missed_header);
                break;
            case Calls.VOICEMAIL_TYPE:
                showFilterStatus(R.string.call_log_voicemail_header);
                break;
        }
    }

    private void showFilterStatus(int resId) {
        mFilterStatusView.setText(resId);
        mFilterStatusView.setVisibility(View.VISIBLE);
    }

    public void callSelectedEntry() {
        int position = getListView().getSelectedItemPosition();
        if (position < 0) {
Loading