From d06625785de67bf27ba9ad4ff02dfd20011edb74 Mon Sep 17 00:00:00 2001 From: calderwoodra Date: Tue, 20 Jun 2017 16:29:03 -0700 Subject: Added privacty snackbar for deleting calls with EC data. When a user deletes a call from the call log, it might not be clear that they aren't deleting the attachments they made with the call. So we present them with a snackbar letting them know to open android messages to delete attachments. screenshot: http://screen/TSoWmNhjcn4 screenshot: http://screen/vUXShdYpXem PiperOrigin-RevId: 159631807 Change-Id: Iaad903258160dc789e0c6a524adba56299523636 --- java/com/android/dialer/app/DialtactsActivity.java | 16 ++++++++++ .../dialer/app/calllog/CallLogActivity.java | 35 ++++++++++++++++++++-- .../app/calllog/CallLogListItemViewHolder.java | 9 +++--- .../dialer/app/calllog/ClearCallLogDialog.java | 12 +++++++- java/com/android/dialer/app/res/values/strings.xml | 10 +++++++ .../dialer/calldetails/CallDetailsActivity.java | 20 +++++++++++-- .../dialer/enrichedcall/EnrichedCallManager.java | 4 +++ .../enrichedcall/stub/EnrichedCallManagerStub.java | 6 ++++ 8 files changed, 102 insertions(+), 10 deletions(-) (limited to 'java/com/android') diff --git a/java/com/android/dialer/app/DialtactsActivity.java b/java/com/android/dialer/app/DialtactsActivity.java index fd685816e..e093aa9b7 100644 --- a/java/com/android/dialer/app/DialtactsActivity.java +++ b/java/com/android/dialer/app/DialtactsActivity.java @@ -74,6 +74,7 @@ import com.android.dialer.app.calllog.CallLogActivity; import com.android.dialer.app.calllog.CallLogAdapter; import com.android.dialer.app.calllog.CallLogFragment; import com.android.dialer.app.calllog.CallLogNotificationsService; +import com.android.dialer.app.calllog.IntentProvider; import com.android.dialer.app.dialpad.DialpadFragment; import com.android.dialer.app.list.DialtactsPagerAdapter; import com.android.dialer.app.list.DialtactsPagerAdapter.TabIndex; @@ -90,6 +91,7 @@ import com.android.dialer.app.settings.DialerSettingsActivity; import com.android.dialer.app.widget.ActionBarController; import com.android.dialer.app.widget.SearchEditTextLayout; import com.android.dialer.callcomposer.CallComposerActivity; +import com.android.dialer.calldetails.CallDetailsActivity; import com.android.dialer.callintent.CallIntentBuilder; import com.android.dialer.callintent.CallSpecificAppData; import com.android.dialer.common.Assert; @@ -173,6 +175,7 @@ public class DialtactsActivity extends TransactionSafeActivity private static final int ACTIVITY_REQUEST_CODE_VOICE_SEARCH = 1; public static final int ACTIVITY_REQUEST_CODE_CALL_COMPOSE = 2; public static final int ACTIVITY_REQUEST_CODE_LIGHTBRINGER = 3; + public static final int ACTIVITY_REQUEST_CODE_CALL_DETAILS = 4; private static final int FAB_SCALE_IN_DELAY_MS = 300; @@ -789,6 +792,19 @@ public class DialtactsActivity extends TransactionSafeActivity } else { LogUtil.i("DialtactsActivity.onActivityResult", "returned from call composer, no error"); } + } else if (requestCode == ACTIVITY_REQUEST_CODE_CALL_DETAILS) { + if (resultCode == RESULT_OK + && data != null + && data.getBooleanExtra(CallDetailsActivity.EXTRA_HAS_ENRICHED_CALL_DATA, false)) { + String number = data.getStringExtra(CallDetailsActivity.EXTRA_PHONE_NUMBER); + int snackbarDurationMillis = 5_000; + Snackbar.make(mParentLayout, getString(R.string.ec_data_deleted), snackbarDurationMillis) + .setAction( + R.string.view_conversation, + v -> startActivity(IntentProvider.getSendSmsIntentProvider(number).getIntent(this))) + .setActionTextColor(getResources().getColor(R.color.dialer_snackbar_action_text_color)) + .show(); + } } super.onActivityResult(requestCode, resultCode, data); } diff --git a/java/com/android/dialer/app/calllog/CallLogActivity.java b/java/com/android/dialer/app/calllog/CallLogActivity.java index 6433af9a6..35e05bc39 100644 --- a/java/com/android/dialer/app/calllog/CallLogActivity.java +++ b/java/com/android/dialer/app/calllog/CallLogActivity.java @@ -21,6 +21,7 @@ import android.content.Intent; import android.os.Bundle; import android.provider.CallLog; import android.provider.CallLog.Calls; +import android.support.design.widget.Snackbar; import android.support.v13.app.FragmentPagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.ActionBar; @@ -31,7 +32,10 @@ import android.view.ViewGroup; import com.android.contacts.common.list.ViewPagerTabs; import com.android.dialer.app.DialtactsActivity; import com.android.dialer.app.R; +import com.android.dialer.app.calllog.ClearCallLogDialog.Listener; +import com.android.dialer.calldetails.CallDetailsActivity; import com.android.dialer.database.CallLogQueryHandler; +import com.android.dialer.enrichedcall.EnrichedCallComponent; import com.android.dialer.logging.Logger; import com.android.dialer.logging.ScreenEvent; import com.android.dialer.logging.UiAction; @@ -42,7 +46,7 @@ import com.android.dialer.util.ViewUtil; /** Activity for viewing call history. */ public class CallLogActivity extends TransactionSafeActivity - implements ViewPager.OnPageChangeListener { + implements ViewPager.OnPageChangeListener, Listener { private static final int TAB_INDEX_ALL = 0; private static final int TAB_INDEX_MISSED = 1; @@ -144,7 +148,7 @@ public class CallLogActivity extends TransactionSafeActivity startActivity(intent); return true; } else if (item.getItemId() == R.id.delete_all) { - ClearCallLogDialog.show(getFragmentManager()); + ClearCallLogDialog.show(getFragmentManager(), this); return true; } return super.onOptionsItemSelected(item); @@ -179,6 +183,15 @@ public class CallLogActivity extends TransactionSafeActivity return position; } + @Override + public void callHistoryDeleted() { + if (EnrichedCallComponent.get(this).getEnrichedCallManager().hasStoredData()) { + Snackbar.make( + findViewById(R.id.calllog_frame), getString(R.string.multiple_ec_data_deleted), 5_000) + .show(); + } + } + @Override public void onBackPressed() { PerformanceReport.recordClick(UiAction.Type.PRESS_ANDROID_BACK_BUTTON); @@ -229,4 +242,22 @@ public class CallLogActivity extends TransactionSafeActivity return TAB_INDEX_COUNT; } } + + @Override + protected void onActivityResult(int requestCode, int resultCode, Intent data) { + if (requestCode == DialtactsActivity.ACTIVITY_REQUEST_CODE_CALL_DETAILS) { + if (resultCode == RESULT_OK + && data != null + && data.getBooleanExtra(CallDetailsActivity.EXTRA_HAS_ENRICHED_CALL_DATA, false)) { + String number = data.getStringExtra(CallDetailsActivity.EXTRA_PHONE_NUMBER); + Snackbar.make(findViewById(R.id.calllog_frame), getString(R.string.ec_data_deleted), 5_000) + .setAction( + R.string.view_conversation, + v -> startActivity(IntentProvider.getSendSmsIntentProvider(number).getIntent(this))) + .setActionTextColor(getResources().getColor(R.color.dialer_snackbar_action_text_color)) + .show(); + } + } + super.onActivityResult(requestCode, resultCode, data); + } } diff --git a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java index c59f0dd61..79c00e483 100644 --- a/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java +++ b/java/com/android/dialer/app/calllog/CallLogListItemViewHolder.java @@ -879,12 +879,11 @@ public final class CallLogListItemViewHolder extends RecyclerView.ViewHolder String packageName = intent.getPackage(); if (getLightbringer().getPackageName().equals(packageName)) { startLightbringerActivity(intent); + } else if (CallDetailsActivity.isLaunchIntent(intent)) { + PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); + ((Activity) mContext) + .startActivityForResult(intent, DialtactsActivity.ACTIVITY_REQUEST_CODE_CALL_DETAILS); } else { - if (intent.getComponent() != null - && CallDetailsActivity.class.getName().equals(intent.getComponent().getClassName())) { - // We are going to open call detail - PerformanceReport.recordClick(UiAction.Type.OPEN_CALL_DETAIL); - } DialerUtils.startActivityWithErrorToast(mContext, intent); } } diff --git a/java/com/android/dialer/app/calllog/ClearCallLogDialog.java b/java/com/android/dialer/app/calllog/ClearCallLogDialog.java index 155a91618..5c3d4d9fa 100644 --- a/java/com/android/dialer/app/calllog/ClearCallLogDialog.java +++ b/java/com/android/dialer/app/calllog/ClearCallLogDialog.java @@ -29,16 +29,21 @@ import android.content.DialogInterface.OnClickListener; import android.os.AsyncTask; import android.os.Bundle; import android.provider.CallLog.Calls; +import android.support.annotation.NonNull; import com.android.dialer.app.R; +import com.android.dialer.common.Assert; import com.android.dialer.phonenumbercache.CachedNumberLookupService; import com.android.dialer.phonenumbercache.PhoneNumberCache; /** Dialog that clears the call log after confirming with the user */ public class ClearCallLogDialog extends DialogFragment { + private Listener listener; + /** Preferred way to show this dialog */ - public static void show(FragmentManager fragmentManager) { + public static void show(FragmentManager fragmentManager, @NonNull Listener listener) { ClearCallLogDialog dialog = new ClearCallLogDialog(); + dialog.listener = Assert.isNotNull(listener); dialog.show(fragmentManager, "deleteCallLog"); } @@ -76,6 +81,7 @@ public class ClearCallLogDialog extends DialogFragment { return; } + listener.callHistoryDeleted(); if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); } @@ -96,4 +102,8 @@ public class ClearCallLogDialog extends DialogFragment { .setCancelable(true) .create(); } + + interface Listener { + void callHistoryDeleted(); + } } diff --git a/java/com/android/dialer/app/res/values/strings.xml b/java/com/android/dialer/app/res/values/strings.xml index e02c6fb30..5549881c3 100644 --- a/java/com/android/dialer/app/res/values/strings.xml +++ b/java/com/android/dialer/app/res/values/strings.xml @@ -930,4 +930,14 @@ About + + View + + + Call deleted. View and delete attachments shared during this call in Messages. + + + Calls deleted. View and delete attachments shared during calls in Messages. diff --git a/java/com/android/dialer/calldetails/CallDetailsActivity.java b/java/com/android/dialer/calldetails/CallDetailsActivity.java index 70cb61adc..411006c46 100644 --- a/java/com/android/dialer/calldetails/CallDetailsActivity.java +++ b/java/com/android/dialer/calldetails/CallDetailsActivity.java @@ -45,12 +45,20 @@ import java.util.List; public class CallDetailsActivity extends AppCompatActivity implements OnMenuItemClickListener, CallDetailsFooterViewHolder.ReportCallIdListener { + public static final String EXTRA_PHONE_NUMBER = "phone_number"; + public static final String EXTRA_HAS_ENRICHED_CALL_DATA = "has_enriched_call_data"; private static final String EXTRA_CALL_DETAILS_ENTRIES = "call_details_entries"; private static final String EXTRA_CONTACT = "contact"; private static final String EXTRA_CAN_REPORT_CALLER_ID = "can_report_caller_id"; private static final String TASK_DELETE = "task_delete"; private List entries; + private DialerContact contact; + + public static boolean isLaunchIntent(Intent intent) { + return intent.getComponent() != null + && CallDetailsActivity.class.getName().equals(intent.getComponent().getClassName()); + } public static Intent newInstance( Context context, @@ -104,8 +112,7 @@ public class CallDetailsActivity extends AppCompatActivity } private void onHandleIntent(Intent intent) { - DialerContact contact = - ProtoParsers.getTrusted(intent, EXTRA_CONTACT, DialerContact.getDefaultInstance()); + contact = ProtoParsers.getTrusted(intent, EXTRA_CONTACT, DialerContact.getDefaultInstance()); entries = ProtoParsers.getTrusted( intent, EXTRA_CALL_DETAILS_ENTRIES, CallDetailsEntries.getDefaultInstance()) @@ -169,6 +176,15 @@ public class CallDetailsActivity extends AppCompatActivity @Override public void onPostExecute(Void result) { + Intent data = new Intent(); + data.putExtra(EXTRA_PHONE_NUMBER, contact.getNumber()); + for (CallDetailsEntry entry : entries) { + if (entry.getHistoryResultsCount() > 0) { + data.putExtra(EXTRA_HAS_ENRICHED_CALL_DATA, true); + break; + } + } + setResult(RESULT_OK, data); finish(); } } diff --git a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java index b97e6adaf..d341b43f9 100644 --- a/java/com/android/dialer/enrichedcall/EnrichedCallManager.java +++ b/java/com/android/dialer/enrichedcall/EnrichedCallManager.java @@ -221,6 +221,10 @@ public interface EnrichedCallManager { Map> getAllHistoricalData( @NonNull String number, @NonNull CallDetailsEntries entries); + /** Returns true if any enriched calls have been made or received. */ + @MainThread + boolean hasStoredData(); + /** * Unregisters the given {@link StateChangedListener}. * diff --git a/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java b/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java index 65d440cb8..1f2b00514 100644 --- a/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java +++ b/java/com/android/dialer/enrichedcall/stub/EnrichedCallManagerStub.java @@ -115,6 +115,12 @@ public final class EnrichedCallManagerStub implements EnrichedCallManager { return null; } + @Override + public boolean hasStoredData() { + Assert.isMainThread(); + return false; + } + @MainThread @Override public void requestAllHistoricalData( -- cgit v1.2.3