Picture in missed call view, polish close button

pull/14/head
Sam Bosley 13 years ago
parent 9fe310972f
commit 29555b08a4

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

@ -10,6 +10,7 @@ import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import com.timsu.astrid.R;
@ -29,6 +30,7 @@ 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$
public static final String EXTRA_TIME = "time"; //$NON-NLS-1$
public static final String EXTRA_PHOTO = "photo"; //$NON-NLS-1$
private static final String PREF_IGNORE_PRESSES = "missedCallsIgnored"; //$NON-NLS-1$
@ -96,6 +98,7 @@ public class MissedCallActivity extends Activity {
name = intent.getStringExtra(EXTRA_NAME);
number = intent.getStringExtra(EXTRA_NUMBER);
timeString = intent.getStringExtra(EXTRA_TIME);
String picture = intent.getStringExtra(EXTRA_PHOTO);
int color = ThemeService.getThemeColor();
@ -103,7 +106,15 @@ public class MissedCallActivity extends Activity {
callLaterButton = (TextView) findViewById(R.id.call_later);
ignoreButton = (TextView) findViewById(R.id.call_ignore);
dismissButton = findViewById(R.id.dismiss);
((TextView) findViewById(R.id.reminder_title)).setText(getString(R.string.MCA_title, timeString));
((TextView) findViewById(R.id.reminder_title))
.setText(getString(R.string.MCA_title,
TextUtils.isEmpty(name) ? number : name, timeString));
ImageView pictureView = ((ImageView) findViewById(R.id.contact_picture));
if (TextUtils.isEmpty(picture))
pictureView.setImageDrawable(getResources().getDrawable(R.drawable.none));
else
pictureView.setImageURI(Uri.parse(picture));
Resources r = getResources();
returnCallButton.setBackgroundColor(r.getColor(color));

@ -6,7 +6,9 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.provider.CallLog.Calls;
import android.provider.ContactsContract;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
@ -49,9 +51,7 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
);
try {
if (calls.getCount() > 0) {
calls.moveToFirst();
if (calls.moveToFirst()) {
int numberIndex = calls.getColumnIndex(Calls.NUMBER);
String number = calls.getString(numberIndex);
@ -65,7 +65,7 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
// and will be processed again.
int dateIndex = calls.getColumnIndex(Calls.DATE);
long date = calls.getLong(dateIndex);
if (DateUtilities.now() - date > 2 * DateUtilities.ONE_MINUTE)
if (DateUtilities.now() - date < 2 * DateUtilities.ONE_MINUTE)
return;
int nameIndex = calls.getColumnIndex(Calls.CACHED_NAME);
@ -75,11 +75,13 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
long time = calls.getLong(timeIndex);
String timeString = DateUtilities.getTimeString(context, new Date(time));
String photo = getContactPhotoFromNumber(context, number);
Intent missedCallIntent = new Intent(context, MissedCallActivity.class);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_NUMBER, number);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_NAME, name);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_TIME, timeString);
missedCallIntent.putExtra(MissedCallActivity.EXTRA_PHOTO, photo);
missedCallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
context.startActivity(missedCallIntent);
}
@ -101,4 +103,40 @@ public class PhoneStateChangedReceiver extends BroadcastReceiver {
return builder.toString();
}
private String getContactPhotoFromNumber(Context context, String number) {
return getPhotoForContactId(context, getContactIdFromNumber(context, number));
}
private long getContactIdFromNumber(Context context, String number) {
Uri contactUri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
Cursor c = context.getContentResolver().query(contactUri, new String[] { ContactsContract.PhoneLookup._ID }, null, null, null);
try {
if (c.moveToFirst()) {
long id = c.getLong(c.getColumnIndex(ContactsContract.PhoneLookup._ID));
return id;
}
} finally {
c.close();
}
return -1;
}
private String getPhotoForContactId(Context context, long contactId) {
if (contactId < 0)
return "";
Cursor c = context.getContentResolver().query(ContactsContract.Contacts.CONTENT_FILTER_URI,
new String[] { ContactsContract.Contacts.PHOTO_URI },
ContactsContract.Contacts._ID + " = ?", new String[] { Long.toString(contactId) }, null);
try {
if (c.moveToFirst()) {
String uri = c.getString(c.getColumnIndex(ContactsContract.Contacts.PHOTO_URI));
return uri;
}
} finally {
c.close();
}
return "";
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -53,7 +53,7 @@
android:scaleType="fitCenter"
android:layout_gravity="right"
android:layout_marginBottom="10dip"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
android:src="@drawable/close_clear_cancel"/>
<Button
android:id="@+id/reminder_edit"
android:layout_width="fill_parent"

@ -17,6 +17,11 @@
android:layout_marginBottom="20dip"
android:layout_marginLeft="5dip">
<ImageView
android:id="@+id/contact_picture"
android:layout_width="30dip"
android:layout_height="30dip" />
<TextView
android:id="@+id/reminder_title"
android:layout_width="fill_parent"
@ -30,11 +35,10 @@
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
android:src="@drawable/close_clear_cancel"/>
</LinearLayout>
<include layout="@layout/astrid_speech_bubble"/>
<TextView
android:id="@+id/call_now"
@ -71,4 +75,6 @@
android:text="@string/MCA_ignore"
android:background="#707070"/>
<include layout="@layout/astrid_speech_bubble"/>
</LinearLayout>

@ -28,7 +28,7 @@
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
android:src="@drawable/close_clear_cancel"/>
</LinearLayout>

@ -28,7 +28,7 @@
android:layout_width="25dip"
android:layout_height="25dip"
android:scaleType="fitCenter"
android:src="@android:drawable/ic_menu_close_clear_cancel"/>
android:src="@drawable/close_clear_cancel"/>
</LinearLayout>

@ -33,7 +33,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:background="@android:color/transparent"
android:src="@android:drawable/ic_menu_close_clear_cancel" />
android:src="@drawable/close_clear_cancel" />
<ImageButton
android:id="@+id/save"

@ -43,7 +43,7 @@
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:background="@android:color/transparent"
android:src="@android:drawable/ic_menu_close_clear_cancel" />
android:src="@drawable/close_clear_cancel" />
<ImageButton
android:id="@+id/save"

@ -465,8 +465,8 @@
<!-- ===================================================== MissedCallActivity == -->
<!-- Missed call: return call (%s -> time of call)-->
<string name="MCA_title">Missed call at %s</string>
<!-- Missed call: return call (%1$s -> caller, %2$s -> time of call)-->
<string name="MCA_title"> %1$s called at %2$s</string>
<!-- Missed call: return call -->
<string name="MCA_return_call">Call now</string>

@ -1014,7 +1014,7 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener {
AstridActivity activity = (AstridActivity) getActivity();
if (activity instanceof TaskListActivity && activity.fragmentLayout != AstridActivity.LAYOUT_DOUBLE || activity instanceof TaskEditActivity) {
item = menu.add(Menu.NONE, MENU_DISCARD_ID, 0, R.string.TEA_menu_discard);
item.setIcon(android.R.drawable.ic_menu_close_clear_cancel);
item.setIcon(R.drawable.close_clear_cancel);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
item = menu.add(Menu.NONE, MENU_SAVE_ID, 0, R.string.TEA_menu_save);

@ -203,6 +203,8 @@ public final class UpgradeService {
newVersionString(changeLog, "4.1.0 (4/16/12)", new String[] {
"Swipe between lists! Swipe left and right to move through your lists. Enable or adjust " +
"in Settings > Performance",
"Respond to or set reminders for missed calls. This feature requires a new permission to read " +
"the phone state.",
"Assign tasks to contacts without typing",
"Links to tasks in comments",
"Astrid.com sync improvements",

@ -117,12 +117,15 @@ public class ABTests {
private void initialize() { // Set up
//Calls to addTest go here
addTest(AB_TEST_SWIPE_ENABLED_KEY, new int[] { 1, 1 },
new int[] { 1, 1 }, new String[] { "swipe-lists-disabled", "swipe-lists-enabled" }); //$NON-NLS-1$//$NON-NLS-2$
new int[] { 9, 1 }, new String[] { "swipe-lists-disabled", "swipe-lists-enabled" }); //$NON-NLS-1$//$NON-NLS-2$
addTest(AB_TEST_CONTACTS_PICKER_ENABLED, new int[] { 1, 1 },
new int[] { 1, 1 }, new String[] { "contacts-disabled", "contacts-enabled" }); //$NON-NLS-1$//$NON-NLS-2$
new int[] { 9, 1 }, new String[] { "contacts-disabled", "contacts-enabled" }); //$NON-NLS-1$//$NON-NLS-2$
addTest(AB_TEST_MISSED_CALLS_ENABLED, new int[] { 1, 1 },
new int[] { 9, 1 }, new String[] { "missed-calls-disabled", "missed-calls-enabled" }); //$NON-NLS-1$//$NON-NLS-2$
}
public static final String AB_TEST_SWIPE_ENABLED_KEY = "swipeEnabled"; //$NON-NLS-1$
public static final String AB_TEST_CONTACTS_PICKER_ENABLED = "contactsEnabled"; //$NON-NLS-1$
public static final String AB_TEST_MISSED_CALLS_ENABLED = "missedCalls"; //$NON-NLS-1$
}

@ -48,7 +48,6 @@ 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);
@ -56,6 +55,9 @@ public class AstridPreferences {
boolean contactsPickerEnabled = (ABChooser.readChoiceForTest(ABTests.AB_TEST_CONTACTS_PICKER_ENABLED) == 1);
Preferences.setIfUnset(prefs, editor, r, R.string.p_use_contact_picker, contactsPickerEnabled);
boolean missedCallsEnabled = (ABChooser.readChoiceForTest(ABTests.AB_TEST_MISSED_CALLS_ENABLED) == 1);
Preferences.setIfUnset(prefs, editor, r, R.string.p_field_missed_calls, missedCallsEnabled);
if ("white-blue".equals(Preferences.getStringValue(R.string.p_theme))) { //$NON-NLS-1$ migrate from when white-blue wasn't the default
Preferences.setString(R.string.p_theme, ThemeService.THEME_WHITE);
}

Loading…
Cancel
Save