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

Commit 2f05af35 authored by Andrew Lee's avatar Andrew Lee
Browse files

Move "Report" to CallDetailActivity.

- Delete old report button/handling code.
+ Convert menu click listeners into single onMenuItemClick method.
+ Add and populate objectId on PhoneCallDetails, to be able to
tell from the CallDetailActivity whether to enable reporting.

Change-Id: Ie4b9a3c1835792cbba04dc826f71fd2e53071400
parent a74ebca7
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -98,18 +98,4 @@

    </LinearLayout>

    <LinearLayout
        android:id="@+id/report_action"
        style="@style/CallLogActionStyle">

        <ImageView
            style="@style/CallLogActionIconStyle"
            android:src="@drawable/ic_report_problem_24dp" />

        <TextView
            style="@style/CallLogActionTextStyle"
            android:text="@string/call_log_action_report" />

    </LinearLayout>

</LinearLayout>
+6 −6
Original line number Diff line number Diff line
@@ -18,17 +18,17 @@
    <item android:id="@+id/menu_trash"
        android:icon="@drawable/ic_delete_24dp"
        android:showAsAction="ifRoom"
        android:title="@string/recentCalls_trashVoicemail"
        android:onClick="onMenuTrashVoicemail" />
        android:title="@string/recentCalls_trashVoicemail" />

    <item android:id="@+id/menu_remove_from_call_log"
        android:icon="@drawable/ic_delete_24dp"
        android:showAsAction="ifRoom"
        android:title="@string/recentCalls_removeFromRecentList"
        android:onClick="onMenuRemoveFromCallLog" />
        android:title="@string/recentCalls_removeFromRecentList" />

    <item android:id="@+id/menu_edit_number_before_call"
        android:title="@string/recentCalls_editNumberBeforeCall"
        android:onClick="onMenuEditNumberBeforeCall" />
        android:title="@string/recentCalls_editNumberBeforeCall" />

    <item android:id="@+id/menu_report"
        android:title="@string/call_detail_menu_report" />

</menu>
+4 −11
Original line number Diff line number Diff line
@@ -47,6 +47,10 @@
        <xliff:g id="name">%s</xliff:g>
    </string>

    <!-- Text for a menu item to report a call as having been incorrectly identified.
         [CHAR LIMIT=30] -->
    <string name="call_detail_menu_report">Report inaccurate number</string>

    <!-- Menu item used to copy a number from the call log to the dialer so it can be edited before calling it -->
    <string name="recentCalls_editNumberBeforeCall">Edit number before call</string>

@@ -631,21 +635,10 @@
        Call details for <xliff:g id="nameOrNumber" example="John Smith">^1</xliff:g>
    </string>

    <!-- Description for the "report" action for an entry in the call log. This action reports that
         the phone number lookup performed for the entry was inaccurate. [CHAR LIMIT=NONE] -->
    <string name="description_report_action">
        Report <xliff:g id="nameOrNumber" example="John Smith">^1</xliff:g>
    </string>

    <!-- Toast message which appears when a call log entry is deleted.
         [CHAR LIMIT=NONE] -->
    <string name="toast_entry_removed">Deleted from call history</string>

    <!-- Button text for the "report" button displayed underneath an entry in the call log.
         Tapping causes the call log entry to be reported to Google as a bad id.
         [CHAR LIMIT=30] -->
    <string name="call_log_action_report">Report</string>

    <!-- String used as a header in the call log above calls which occurred today.
         [CHAR LIMIT=65] -->
    <string name="call_log_header_today">Today</string>
+43 −28
Original line number Diff line number Diff line
@@ -70,7 +70,8 @@ import java.util.List;
 * This activity can be either started with the URI of a single call log entry, or with the
 * {@link #EXTRA_CALL_LOG_IDS} extra to specify a group of call log entries.
 */
public class CallDetailActivity extends Activity {
public class CallDetailActivity extends Activity
        implements MenuItem.OnMenuItemClickListener {
    private static final String TAG = "CallDetail";

     /** A long array extra containing ids of call log entries to display. */
@@ -152,8 +153,8 @@ public class CallDetailActivity extends Activity {

            mHasEditNumberBeforeCallOption =
                    canPlaceCallsTo && !isSipNumber && !mIsVoicemailNumber;
            mHasTrashOption = hasVoicemail();
            mHasRemoveFromCallLogOption = !hasVoicemail();
            mHasReportMenuOption = mContactInfoHelper.canReportAsInvalid(
                    firstDetails.sourceType, firstDetails.objectId);
            invalidateOptionsMenu();

            ListView historyList = (ListView) findViewById(R.id.history);
@@ -208,7 +209,7 @@ public class CallDetailActivity extends Activity {
    private View mCallButton;
    private ContactInfoHelper mContactInfoHelper;

    private String mNumber;
    protected String mNumber;
    private boolean mIsVoicemailNumber;
    private String mDefaultCountryIso;

@@ -222,10 +223,7 @@ public class CallDetailActivity extends Activity {

    /** Whether we should show "edit number before call" in the options menu. */
    private boolean mHasEditNumberBeforeCallOption;
    /** Whether we should show "trash" in the options menu. */
    private boolean mHasTrashOption;
    /** Whether we should show "remove from call log" in the options menu. */
    private boolean mHasRemoveFromCallLogOption;
    private boolean mHasReportMenuOption;

    @Override
    protected void onCreate(Bundle icicle) {
@@ -270,7 +268,10 @@ public class CallDetailActivity extends Activity {
    @Override
    public void onResume() {
        super.onResume();
        getCallDetails();
    }

    public void getCallDetails() {
        CallLogAsyncTaskUtil.getCallDetails(this, getCallLogEntryUris(), mCallLogAsyncTaskListener);
    }

@@ -327,13 +328,25 @@ public class CallDetailActivity extends Activity {
    public boolean onPrepareOptionsMenu(Menu menu) {
        // This action deletes all elements in the group from the call log.
        // We don't have this action for voicemails, because you can just use the trash button.
        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_remove_from_call_log)
                .setVisible(!hasVoicemail())
                .setOnMenuItemClickListener(this);
        menu.findItem(R.id.menu_edit_number_before_call)
                .setVisible(mHasEditNumberBeforeCallOption)
                .setOnMenuItemClickListener(this);
        menu.findItem(R.id.menu_trash)
                .setVisible(hasVoicemail())
                .setOnMenuItemClickListener(this);
        menu.findItem(R.id.menu_report)
                .setVisible(mHasReportMenuOption)
                .setOnMenuItemClickListener(this);
        return super.onPrepareOptionsMenu(menu);
    }

    public void onMenuRemoveFromCallLog(MenuItem menuItem) {
    @Override
    public boolean onMenuItemClick(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_remove_from_call_log:
                final StringBuilder callIds = new StringBuilder();
                for (Uri callUri : getCallLogEntryUris()) {
                    if (callIds.length() != 0) {
@@ -341,16 +354,18 @@ public class CallDetailActivity extends Activity {
                    }
                    callIds.append(ContentUris.parseId(callUri));
                }

        CallLogAsyncTaskUtil.deleteCalls(this, callIds.toString(), mCallLogAsyncTaskListener);
    }

    public void onMenuEditNumberBeforeCall(MenuItem menuItem) {
                CallLogAsyncTaskUtil.deleteCalls(
                        this, callIds.toString(), mCallLogAsyncTaskListener);
                break;
            case R.id.menu_edit_number_before_call:
                startActivity(new Intent(Intent.ACTION_DIAL, CallUtil.getCallUri(mNumber)));
                break;
            case R.id.menu_trash:
                CallLogAsyncTaskUtil.deleteVoicemail(
                        this, mVoicemailUri, mCallLogAsyncTaskListener);
                break;
        }

    public void onMenuTrashVoicemail(MenuItem menuItem) {
        CallLogAsyncTaskUtil.deleteVoicemail(this, mVoicemailUri, mCallLogAsyncTaskListener);
        return true;
    }

    private void closeSystemDialogs() {
+4 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ public class PhoneCallDetails {
    public CharSequence numberLabel;
    // The URI of the contact associated with this phone call.
    public Uri contactUri;

    /**
     * The photo URI of the picture of the contact that is associated with this phone call or
     * null if there is none.
@@ -71,6 +72,9 @@ public class PhoneCallDetails {
    // The source type of the contact associated with this call.
    public int sourceType;

    // The object id type of the contact associated with this call.
    public String objectId;

    // The unique identifier for the account associated with the call.
    public PhoneAccountHandle accountHandle;

Loading