More polish to missed call dialog, preference to activate/deactivate:

pull/14/head
Sam Bosley 14 years ago
parent e19fa0819c
commit b772c79bf9

@ -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);
}
});
}
}

@ -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)) {

@ -45,6 +45,9 @@
<!-- default random reminder setting (in hours) -->
<string name="p_rmd_default_random_hours">notif_default_reminder</string>
<!-- field missed calls preference -->
<string name="p_field_missed_calls">field_missed_calls</string>
<string-array name="TEA_reminder_random_hours">
<!-- values (in hours) associated with items above. -->

@ -483,6 +483,24 @@
<!-- Missed call: dialog without name. %s->phone number -->
<string name="MCA_dialog_without_name">Someone just called you from %s.</string>
<!-- Missed call: dialog to ignore all missed calls title -->
<string name="MCA_ignore_title">Ignore all missed calls?</string>
<!-- Missed call: dialog to ignore all missed calls body -->
<string name="MCA_ignore_body">You\'ve ignored several missed calls. Should Astrid stop asking you about them?</string>
<!-- Missed call: dialog to ignore all missed calls ignore all button -->
<string name="MCA_ignore_all">Ignore all calls</string>
<!-- Missed call: dialog to ignore all missed calls ignore just this button -->
<string name="MCA_ignore_this">Ignore this call only</string>
<!-- Missed call: preference title -->
<string name="MCA_missed_calls_pref_title">Field missed calls</string>
<!-- Missed call: preference description -->
<string name="MCA_missed_calls_pref_desc">Astrid will notify you about missed calls and offer to remind you to call back</string>
<!-- ===================================================== HelpActivity == -->
<!-- Help: Button to get support from our website -->

@ -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"/>
<CheckBoxPreference
android:key="@string/p_field_missed_calls"
android:title="@string/MCA_missed_calls_pref_title"
android:summary="@string/MCA_missed_calls_pref_desc" />
</PreferenceScreen>

@ -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);

Loading…
Cancel
Save