Permalink
Browse files

merge from froyo version for Chinese Phone location

  • Loading branch information...
cytown committed Jan 18, 2011
1 parent f21f863 commit e10497629732231a4956fb933aa0f918667de8d5
@@ -124,6 +124,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<!-- City, used in Chinese version, originally from Geesun -->
<TextView android:id="@+id/city"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="14sp"
android:textColor="?android:attr/textColorSecondary"
android:singleLine="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="6dip"
/>
</LinearLayout>
<!-- Call type indication: a special label and/or branding
@@ -47,6 +47,7 @@
import java.util.ArrayList;
import android.provider.ContactsContract;
import com.android.phone.location.PhoneLocation;
/**
* "Call card" UI element: the in-call screen contains a tiled layout of call
@@ -120,6 +121,7 @@
// add by cytown
private CallFeaturesSetting mSettings;
private TextView mOrganization;
private TextView mCity;
public CallCard(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -199,6 +201,7 @@ protected void onFinishInflate() {
mCallTypeLabel = (TextView) findViewById(R.id.callTypeLabel);
mSocialStatus = (TextView) findViewById(R.id.socialStatus);
mOrganization = (TextView) findViewById(R.id.organization);
mCity = (TextView) findViewById(R.id.city);
// "Other call" info area
mSecondaryCallName = (TextView) findViewById(R.id.secondaryCallName);
@@ -546,6 +549,7 @@ private void displayMainCallStatus(CallManager cm, Call call) {
mPhoneNumber.setTextColor(getResources().getColor(mRotarySelectorHintColorResId));
mPhoneNumber.setVisibility(View.VISIBLE);
mLabel.setVisibility(View.GONE);
mCity.setVisibility(View.GONE);
}
// If we don't have a hint to display, just don't touch
// mPhoneNumber and mLabel. (Their text / color / visibility have
@@ -1073,6 +1077,7 @@ private void updateDisplayForPerson(CallerInfo info,
Drawable socialStatusBadge = null;
boolean updateName = false;
String city = null;
if (info != null) {
// It appears that there is a small change in behaviour with the
@@ -1138,6 +1143,9 @@ private void updateDisplayForPerson(CallerInfo info,
}
}
personUri = ContentUris.withAppendedId(Contacts.CONTENT_URI, info.person_id);
if(!TextUtils.isEmpty(info.phoneNumber)){
city = PhoneLocation.getCityFromPhone(info.phoneNumber);
}
} else {
displayName = getPresentationString(presentation);
}
@@ -1156,6 +1164,13 @@ private void updateDisplayForPerson(CallerInfo info,
}
mName.setVisibility(View.VISIBLE);
if(city != null){
mCity.setText(city);
mCity.setVisibility(View.VISIBLE);
}else{
mCity.setVisibility(View.GONE);
}
// Update mPhoto
// if the temporary flag is set, we know we'll be getting another call after
// the CallerInfo has been correctly updated. So, we can skip the image
@@ -1292,6 +1307,9 @@ private void updateDisplayForConference(Call call) {
updateCallTypeLabel(call);
updateSocialStatus(null, null, null); // socialStatus is never visible in this state
// add for Chinese city funciton
mCity.setVisibility(View.GONE);
// TODO: for a GSM conference call, since we do actually know who
// you're talking to, consider also showing names / numbers /
// photos of some of the people on the conference here, so you can
@@ -0,0 +1,52 @@
package com.android.phone.location;
/*
* Usage:
* String s = PhoneLocation.getLocationFromPhone("13501340000");
* String[] loc = null;
* if (s != null && !s.equals(" ")) {
* loc = s.split(",");
* }
* if (loc != null) {
* System.out.println("location code: " + loc[0]);
* System.out.println("location name: " + loc[1]);
* }
*/
public final class PhoneLocation {
static {
System.loadLibrary("phoneloc-jni");
}
static native String getPhoneLocationJni(String phone);
private static String _phone, _location;
public synchronized static String getLocationFromPhone(String num) {
if (num == null) return null;
if (num.equals(_phone)) return _location;
_phone = num;
_location = getPhoneLocationJni(num);
return _location;
}
private static String _getPosFromPhone(String num, int i) {
String s = getLocationFromPhone(num);
String[] loc = (s != null) ? s.split(",") : new String[0];
if (loc.length == 2) {
return loc[i];
}
return null;
}
public static String getCityFromPhone(String num) {
return _getPosFromPhone(num, 1);
}
public static String getCodeFromPhone(String num) {
return _getPosFromPhone(num, 0);
}
}

0 comments on commit e104976

Please sign in to comment.