diff --git a/astrid/plugin-src/com/todoroo/astrid/calls/MissedCallActivity.java b/astrid/plugin-src/com/todoroo/astrid/calls/MissedCallActivity.java index fd1844ec4..32a302334 100644 --- a/astrid/plugin-src/com/todoroo/astrid/calls/MissedCallActivity.java +++ b/astrid/plugin-src/com/todoroo/astrid/calls/MissedCallActivity.java @@ -1,6 +1,10 @@ package com.todoroo.astrid.calls; +import java.util.Date; + import android.app.Activity; +import android.app.AlertDialog; +import android.content.DialogInterface; import android.content.Intent; import android.content.res.Resources; import android.net.Uri; @@ -12,6 +16,10 @@ import android.widget.TextView; import com.timsu.astrid.R; import com.todoroo.andlib.utility.AndroidUtilities; +import com.todoroo.andlib.utility.DialogUtilities; +import com.todoroo.andlib.utility.Preferences; +import com.todoroo.astrid.reminders.NotificationFragment.SnoozeDialog; +import com.todoroo.astrid.reminders.SnoozeCallback; import com.todoroo.astrid.service.ThemeService; public class MissedCallActivity extends Activity { @@ -19,6 +27,8 @@ public class MissedCallActivity extends Activity { public static final String EXTRA_NUMBER = "number"; //$NON-NLS-1$ public static final String EXTRA_NAME = "name"; //$NON-NLS-1$ + private static final String PREF_IGNORE_PRESSES = "missedCallsIgnored"; + private final OnClickListener dismissListener = new OnClickListener() { @Override public void onClick(View v) { @@ -27,6 +37,39 @@ public class MissedCallActivity extends Activity { } }; + private final OnClickListener ignoreListener = new OnClickListener() { + @Override + public void onClick(final View v) { + // Check for number of ignore presses + int ignorePresses = Preferences.getInt(PREF_IGNORE_PRESSES, 0); + ignorePresses++; + if (ignorePresses % 3 == 0) { + DialogUtilities.okCancelCustomDialog(MissedCallActivity.this, + getString(R.string.MCA_ignore_title), + getString(R.string.MCA_ignore_body), + R.string.MCA_ignore_all, + R.string.MCA_ignore_this, + 0, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + Preferences.setBoolean(R.string.p_field_missed_calls, false); + dismissListener.onClick(v); + } + }, + new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + dismissListener.onClick(v); + } + }); + } else { + dismissListener.onClick(v); + } + Preferences.setInt(PREF_IGNORE_PRESSES, ignorePresses); + } + }; + private String name; private String number; @@ -72,7 +115,7 @@ public class MissedCallActivity extends Activity { } private void addListeners() { - ignoreButton.setOnClickListener(dismissListener); + ignoreButton.setOnClickListener(ignoreListener); dismissButton.setOnClickListener(dismissListener); returnCallButton.setOnClickListener(new OnClickListener() { @@ -85,5 +128,25 @@ public class MissedCallActivity extends Activity { finish(); } }); + + callLaterButton.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + SnoozeDialog sd = new SnoozeDialog(MissedCallActivity.this, new SnoozeCallback() { + @Override + public void snoozeForTime(long time) { + // Create task with due time 'time' + System.err.println("Should create a task for: " + new Date(time)); + finish(); + } + }); + new AlertDialog.Builder(MissedCallActivity.this) + .setTitle(R.string.rmd_NoA_snooze) + .setView(sd) + .setPositiveButton(android.R.string.ok, sd) + .setNegativeButton(android.R.string.cancel, null) + .show().setOwnerActivity(MissedCallActivity.this); + } + }); } } diff --git a/astrid/plugin-src/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java b/astrid/plugin-src/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java index 5deaf6737..e98d26212 100644 --- a/astrid/plugin-src/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java +++ b/astrid/plugin-src/com/todoroo/astrid/calls/PhoneStateChangedReceiver.java @@ -8,6 +8,7 @@ import android.provider.CallLog.Calls; import android.telephony.TelephonyManager; import android.text.TextUtils; +import com.timsu.astrid.R; import com.todoroo.andlib.utility.Preferences; @SuppressWarnings("nls") @@ -17,6 +18,11 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { + if (!Preferences.getBoolean(R.string.p_field_missed_calls, true)) { + Preferences.clear(PREF_LAST_INCOMING_NUMBER); + return; + } + String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); if (TelephonyManager.EXTRA_STATE_RINGING.equals(state)) { diff --git a/astrid/res/values/keys.xml b/astrid/res/values/keys.xml index 966ba9664..17c6ea356 100644 --- a/astrid/res/values/keys.xml +++ b/astrid/res/values/keys.xml @@ -45,6 +45,9 @@ notif_default_reminder + + + field_missed_calls diff --git a/astrid/res/values/strings-core.xml b/astrid/res/values/strings-core.xml index dcc9c8c91..fde4d98df 100644 --- a/astrid/res/values/strings-core.xml +++ b/astrid/res/values/strings-core.xml @@ -483,6 +483,24 @@ Someone just called you from %s. + + Ignore all missed calls? + + + You\'ve ignored several missed calls. Should Astrid stop asking you about them? + + + Ignore all calls + + + Ignore this call only + + + Field missed calls + + + Astrid will notify you about missed calls and offer to remind you to call back + diff --git a/astrid/res/xml/preferences_labs.xml b/astrid/res/xml/preferences_labs.xml index ac0e07add..e5798c091 100644 --- a/astrid/res/xml/preferences_labs.xml +++ b/astrid/res/xml/preferences_labs.xml @@ -13,4 +13,8 @@ android:key="@string/p_use_contact_picker" android:title="@string/EPr_use_contact_picker" android:summary="@string/EPr_use_contact_picker_desc"/> + diff --git a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java index a647ddd73..1bfbce5d8 100644 --- a/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java +++ b/astrid/src/com/todoroo/astrid/utility/AstridPreferences.java @@ -48,6 +48,7 @@ public class AstridPreferences { Preferences.setIfUnset(prefs, editor, r, R.string.p_rmd_default_random_hours, 0); Preferences.setIfUnset(prefs, editor, r, R.string.p_fontSize, 18); Preferences.setIfUnset(prefs, editor, r, R.string.p_showNotes, false); + Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, true); boolean swipeEnabled = (ABChooser.readChoiceForTest(ABTests.AB_TEST_SWIPE_ENABLED_KEY) == 1); Preferences.setIfUnset(prefs, editor, r, R.string.p_swipe_lists_performance_key, swipeEnabled ? 3 : 0);