More awesomeness. All that's left is the snooze scheduling

pull/14/head
Sam Bosley 13 years ago
parent 29c41bcffe
commit e19fa0819c

@ -34,6 +34,7 @@
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<!-- for missed call reminders --> <!-- for missed call reminders -->
<uses-permission android:name="android.permission.READ_PHONE_STATE"/> <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<!-- ============================================== Exported Permissions = --> <!-- ============================================== Exported Permissions = -->

@ -1,8 +1,11 @@
package com.todoroo.astrid.calls; package com.todoroo.astrid.calls;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.text.TextUtils;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.widget.TextView; import android.widget.TextView;
@ -14,6 +17,7 @@ import com.todoroo.astrid.service.ThemeService;
public class MissedCallActivity extends Activity { public class MissedCallActivity extends Activity {
public static final String EXTRA_NUMBER = "number"; //$NON-NLS-1$ public static final String EXTRA_NUMBER = "number"; //$NON-NLS-1$
public static final String EXTRA_NAME = "name"; //$NON-NLS-1$
private final OnClickListener dismissListener = new OnClickListener() { private final OnClickListener dismissListener = new OnClickListener() {
@Override @Override
@ -23,25 +27,63 @@ public class MissedCallActivity extends Activity {
} }
}; };
private String name;
private String number;
private TextView returnCallButton;
private TextView callLaterButton;
private TextView ignoreButton;
private View dismissButton;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.missed_call_activity); setContentView(R.layout.missed_call_activity);
Intent intent = getIntent();
name = intent.getStringExtra(EXTRA_NAME);
number = intent.getStringExtra(EXTRA_NUMBER);
int color = ThemeService.getThemeColor(); int color = ThemeService.getThemeColor();
TextView returnCallButton = (TextView) findViewById(R.id.call_return); returnCallButton = (TextView) findViewById(R.id.call_now);
TextView addTaskButton = (TextView) findViewById(R.id.call_add); callLaterButton = (TextView) findViewById(R.id.call_later);
TextView ignoreButton = (TextView) findViewById(R.id.call_ignore); ignoreButton = (TextView) findViewById(R.id.call_ignore);
View dismissView = findViewById(R.id.dismiss); dismissButton = findViewById(R.id.dismiss);
Resources r = getResources(); Resources r = getResources();
returnCallButton.setBackgroundColor(r.getColor(color)); returnCallButton.setBackgroundColor(r.getColor(color));
addTaskButton.setBackgroundColor(r.getColor(color)); callLaterButton.setBackgroundColor(r.getColor(color));
addListeners();
String dialog;
if (TextUtils.isEmpty(name)) {
dialog = getString(R.string.MCA_dialog_without_name, number);
} else {
dialog = getString(R.string.MCA_dialog_with_name, name);
}
TextView dialogView = (TextView) findViewById(R.id.reminder_message);
dialogView.setText(dialog);
}
private void addListeners() {
ignoreButton.setOnClickListener(dismissListener); ignoreButton.setOnClickListener(dismissListener);
dismissView.setOnClickListener(dismissListener); dismissButton.setOnClickListener(dismissListener);
returnCallButton.setOnClickListener(new OnClickListener() {
System.err.println("Should display notification for number: " + getIntent().getStringExtra(EXTRA_NUMBER)); @Override
public void onClick(View v) {
Intent call = new Intent(Intent.ACTION_CALL);
call.setData(Uri.parse("tel:" + number)); //$NON-NLS-1$
startActivity(call);
finish();
}
});
} }
} }

@ -42,8 +42,14 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
try { try {
if (calls.getCount() > 0) { if (calls.getCount() > 0) {
calls.moveToFirst();
int nameIndex = calls.getColumnIndex(Calls.CACHED_NAME);
String name = "";
if (nameIndex > -1)
name = calls.getString(nameIndex);
Intent missedCallIntent = new Intent(context, MissedCallActivity.class); Intent missedCallIntent = new Intent(context, MissedCallActivity.class);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_NUMBER, lastNumber); missedCallIntent.putExtra(MissedCallActivity.EXTRA_NUMBER, lastNumber);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_NAME, name);
missedCallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); missedCallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(missedCallIntent); context.startActivity(missedCallIntent);
} }

@ -37,7 +37,7 @@
<include layout="@layout/astrid_speech_bubble"/> <include layout="@layout/astrid_speech_bubble"/>
<TextView <TextView
android:id="@+id/call_return" android:id="@+id/call_now"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="35dip" android:layout_height="35dip"
android:layout_marginLeft="10dip" android:layout_marginLeft="10dip"
@ -48,7 +48,7 @@
android:gravity="center" android:gravity="center"
android:text="@string/MCA_return_call"/> android:text="@string/MCA_return_call"/>
<TextView <TextView
android:id="@+id/call_add" android:id="@+id/call_later"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="35dip" android:layout_height="35dip"
android:layout_marginLeft="10dip" android:layout_marginLeft="10dip"

@ -469,14 +469,19 @@
<string name="MCA_title">Missed call!</string> <string name="MCA_title">Missed call!</string>
<!-- Missed call: return call --> <!-- Missed call: return call -->
<string name="MCA_return_call">Call back</string> <string name="MCA_return_call">Call now</string>
<!-- Missed call: return call --> <!-- Missed call: return call -->
<string name="MCA_add_task">Add to task list</string> <string name="MCA_add_task">Call later</string>
<!-- Missed call: return call --> <!-- Missed call: return call -->
<string name="MCA_ignore">Ignore</string> <string name="MCA_ignore">Ignore</string>
<!-- Missed call: dialog with name. %s->caller name -->
<string name="MCA_dialog_with_name">%s just called you!</string>
<!-- Missed call: dialog without name. %s->phone number -->
<string name="MCA_dialog_without_name">Someone just called you from %s.</string>
<!-- ===================================================== HelpActivity == --> <!-- ===================================================== HelpActivity == -->

Loading…
Cancel
Save