Issue 2407: Show confirmation dialog before clearing call log.
Signed-off-by: David Sobreira Marques <dpsmarques@gmail.com>
Change-Id: I9c89eef6c4c940406e1238810f13959c41c07908
diff --git a/res/values/ids.xml b/res/values/ids.xml
index 5e287ad..8fe9d2f 100644
--- a/res/values/ids.xml
+++ b/res/values/ids.xml
@@ -52,4 +52,7 @@
<item type="id" name="dialog_exporting_vcard" />
<item type="id" name="dialog_fail_to_export_with_reason" />
+ <!-- For RecentCallsListActivity -->
+ <item type="id" name="dialog_clear_log" />
+
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e37c118..7c243d7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -173,6 +173,9 @@
<!-- Confirmation dialog title after users selects to delete a contact. -->
<string name="deleteConfirmation_title">Delete</string>
+ <!-- Confirmation dialog title after users selects clear log. -->
+ <string name="clearConfirmation_title">Clear call log</string>
+
<!-- Warning dialog contents after users selects to delete a ReadOnly contact. -->
<string name="readOnlyContactWarning">You cannot delete contacts from read-only accounts, but you can hide them in your contacts lists.</string>
@@ -185,6 +188,9 @@
<!-- Confirmation dialog contents after users selects to delete a Writable contact. -->
<string name="deleteConfirmation">This contact will be deleted.</string>
+ <!-- Confirmation dialog contents after users selects to clear call log. -->
+ <string name="clearLogConfirmation">All call log entries will be removed.</string>
+
<!-- Menu item to indicate you are done editing a contact and want to save the changes you've made -->
<string name="menu_done">Done</string>
diff --git a/src/com/android/contacts/RecentCallsListActivity.java b/src/com/android/contacts/RecentCallsListActivity.java
index 547cd45..2ca2096 100644
--- a/src/com/android/contacts/RecentCallsListActivity.java
+++ b/src/com/android/contacts/RecentCallsListActivity.java
@@ -16,13 +16,17 @@
package com.android.contacts;
+import android.app.AlertDialog;
+import android.app.Dialog;
import android.app.ListActivity;
import android.content.ActivityNotFoundException;
import android.content.AsyncQueryHandler;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
+import android.content.DialogInterface;
import android.content.Intent;
+import android.content.DialogInterface.OnClickListener;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabaseCorruptException;
import android.database.sqlite.SQLiteDiskIOException;
@@ -713,6 +717,31 @@
}
@Override
+ protected Dialog onCreateDialog(int id) {
+ Dialog dialog = null;
+ switch (id) {
+ case R.id.dialog_clear_log:
+ DialogInterface.OnClickListener clearLogDialogListener = new OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ getContentResolver().delete(Calls.CONTENT_URI, null, null);
+ startQuery();
+ }
+ };
+
+ dialog = new AlertDialog.Builder(this)
+ .setTitle(R.string.clearConfirmation_title)
+ .setIcon(android.R.drawable.ic_dialog_alert)
+ .setMessage(R.string.clearLogConfirmation)
+ .setNegativeButton(android.R.string.cancel, null)
+ .setPositiveButton(android.R.string.ok, clearLogDialogListener)
+ .setCancelable(false)
+ .create();
+ break;
+ }
+ return dialog;
+ }
+
+ @Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_ITEM_DELETE_ALL, 0, R.string.recentCalls_deleteAll)
.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
@@ -789,10 +818,7 @@
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_ITEM_DELETE_ALL: {
- getContentResolver().delete(Calls.CONTENT_URI, null, null);
- //TODO The change notification should do this automatically, but it isn't working
- // right now. Remove this when the change notification is working properly.
- startQuery();
+ showDialog(R.id.dialog_clear_log);
return true;
}