diff options
author | Wysie <sohyuanchin@gmail.com> | 2010-01-30 01:34:51 +0800 |
---|---|---|
committer | ABAAKOUK Mehdi <theli48@gmail.com> | 2010-06-30 10:33:51 +0200 |
commit | 6ad98be5633889cf4cdaca31c132542d16607478 (patch) | |
tree | 788129e2620281351f8739639aa0602d8ec2ed47 /src | |
parent | 64139fa54fa9d87cc0b5f8f166d6ab9d7ae3420e (diff) | |
download | packages_apps_Contacts-6ad98be5633889cf4cdaca31c132542d16607478.tar.gz packages_apps_Contacts-6ad98be5633889cf4cdaca31c132542d16607478.tar.bz2 packages_apps_Contacts-6ad98be5633889cf4cdaca31c132542d16607478.zip |
Release 0.8:
Added navigation action beside the address of a contact
Added preference to hide sms action for all numbers except mobile
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/contacts/ViewContactActivity.java | 74 | ||||
-rw-r--r-- | src/com/android/contacts/model/FallbackSource.java | 7 |
2 files changed, 73 insertions, 8 deletions
diff --git a/src/com/android/contacts/ViewContactActivity.java b/src/com/android/contacts/ViewContactActivity.java index ead6a4aac..e8cfca3a6 100644 --- a/src/com/android/contacts/ViewContactActivity.java +++ b/src/com/android/contacts/ViewContactActivity.java @@ -93,6 +93,13 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +//Wysie +import android.content.pm.PackageManager; +import android.content.pm.ResolveInfo; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; +import java.util.List; + /** * Displays the details of a specific contact. */ @@ -189,11 +196,16 @@ public class ViewContactActivity extends Activity } private ListView mListView; - private boolean mShowSmsLinksForAllPhones; + private boolean mShowSmsLinksForAllPhones; + + //Wysie + private SharedPreferences ePrefs; @Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); + + ePrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); final Intent intent = getIntent(); Uri data = intent.getData(); @@ -241,12 +253,16 @@ public class ViewContactActivity extends Activity mSections.add(mOtherEntries); //TODO Read this value from a preference - mShowSmsLinksForAllPhones = true; + //mShowSmsLinksForAllPhones = true; } @Override protected void onResume() { super.onResume(); + + //Wysie: Read from preference + mShowSmsLinksForAllPhones = !ePrefs.getBoolean("contacts_show_text_mobile_only", false); + startEntityQuery(); } @@ -887,7 +903,6 @@ public class ViewContactActivity extends Activity mWritableRawContactIds.add(rawContactId); } - for (NamedContentValues subValue : entity.getSubValues()) { final ContentValues entryValues = subValue.values; entryValues.put(Data.RAW_CONTACT_ID, rawContactId); @@ -921,9 +936,12 @@ public class ViewContactActivity extends Activity entry.isPrimary = isSuperPrimary; mPhoneEntries.add(entry); - - if (entry.type == CommonDataKinds.Phone.TYPE_MOBILE - || mShowSmsLinksForAllPhones) { + + //Wysie: Workaround for the entry.type bug, since entry.type always returns -1 + final Integer type = entryValues.getAsInteger(Phone.TYPE); + + //Wysie: Bug here, entry.type always returns -1. + if (/*entry.type*/type == CommonDataKinds.Phone.TYPE_MOBILE || mShowSmsLinksForAllPhones) { // Add an SMS entry if (kind.iconAltRes > 0) { entry.secondaryActionIcon = kind.iconAltRes; @@ -951,8 +969,20 @@ public class ViewContactActivity extends Activity } else if (StructuredPostal.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { // Build postal entries entry.maxLines = 4; - entry.intent = new Intent(Intent.ACTION_VIEW, entry.uri); + entry.intent = new Intent(Intent.ACTION_VIEW, entry.uri); + + Intent i = startNavigation(entry.data); + + if (i != null) { + entry.secondaryIntent = i; + // Add a navigation entry + if (kind.iconAltRes > 0) { + entry.secondaryActionIcon = kind.iconAltRes; + } + } + mPostalEntries.add(entry); + } else if (Im.CONTENT_ITEM_TYPE.equals(mimeType) && hasData) { // Build IM entries entry.intent = ContactsUtils.buildImIntent(entryValues); @@ -1360,4 +1390,34 @@ public class ViewContactActivity extends Activity ContactsSearchManager.startSearch(this, initialQuery); } } + //Wysie + public boolean isIntentAvailable(Intent intent) { + final PackageManager packageManager = this.getPackageManager(); + List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); + return list.size() > 0; + } + + //Wysie: Navigation code. Adapted from rac2030's NavStarter. + //http://code.google.com/p/andrac/source/browse/trunk/NavWidget/src/ch/racic/android/gnav/NavSearch.java + public Intent startNavigation(String address) { + address = address.replace('#', ' '); + Intent i = new Intent(); + i.setAction(Intent.ACTION_VIEW); + i.setData(Uri.parse("http://maps.google.com/maps?myl=saddr&daddr=" + address + "&dirflg=d&nav=1")); + i.addFlags(0x10800000); + i.setClassName("com.google.android.apps.m4ps", "com.google.android.maps.driveabout.app.NavigationActivity"); + + if (isIntentAvailable(i)) { + return i; + } + else { + i.setClassName("com.google.android.apps.maps", "com.google.android.maps.driveabout.app.NavigationActivity"); + if (isIntentAvailable(i)) { + return i; + } + else { + return null; + } + } + } } diff --git a/src/com/android/contacts/model/FallbackSource.java b/src/com/android/contacts/model/FallbackSource.java index 9cc855cce..5ca99dce2 100644 --- a/src/com/android/contacts/model/FallbackSource.java +++ b/src/com/android/contacts/model/FallbackSource.java @@ -188,6 +188,7 @@ public class FallbackSource extends ContactsSource { if (inflateLevel >= ContactsSource.LEVEL_CONSTRAINTS) { kind.typeColumn = Phone.TYPE; + kind.typeList = Lists.newArrayList(); kind.typeList.add(buildPhoneType(Phone.TYPE_HOME)); kind.typeList.add(buildPhoneType(Phone.TYPE_MOBILE)); @@ -251,8 +252,12 @@ public class FallbackSource extends ContactsSource { if (kind == null) { kind = addKind(new DataKind(StructuredPostal.CONTENT_ITEM_TYPE, R.string.postalLabelsGroup, R.drawable.sym_action_map, 25, true)); + + //Wysie: Add navigation icon as alternate + kind.iconAltRes = R.drawable.sym_action_navi; + kind.actionHeader = new PostalActionInflater(); - kind.actionBody = new SimpleInflater(StructuredPostal.FORMATTED_ADDRESS); + kind.actionBody = new SimpleInflater(StructuredPostal.FORMATTED_ADDRESS); } if (inflateLevel >= ContactsSource.LEVEL_CONSTRAINTS) { |