码迷,mamicode.com
首页 > 移动开发 > 详细

android 匈牙利语环境下,联系人的姓名顺序颠倒

时间:2014-09-25 10:30:48      阅读:254      评论:0      收藏:0      [点我收藏+]

标签:android   style   io   java   ar   for   sp   on   c   

联系人姓名由prefix / given name / middle name / family name / suffix组成。世界各地对于姓名显示的顺利是不同的。
例如中国习惯是:family name +  middle name + given name
     西方习惯是:given name + middle name + family name
Google定义了这几种类型:
FullNameStyle.UNDEFINED  //未定义
FullNameStyle.CHINESE   //中国
FullNameStyle.KOREAN     //韩国
FullNameStyle.JAPANESE   //日本
FullNameStyle.CJK     //中日韩之一
FullNameStyle.WESTERN    //西方
      匈牙利这个国家比较特殊,按照传统观念是属于西方的,但是姓名显示习惯却是family name +  given name + middle name
 [SOLUTION]
1、请先保证有添加匈牙利语(请参考FAQ04326\FAQ03761)
2、修改DataRowHandlerForStructuredName.java (alps\packages\providers\contactsprovider\src\com\android\providers\contacts)
修改    public void fixStructuredNameComponents(ContentValues augmented, ContentValues update) {
        final String unstruct = update.getAsString(StructuredName.DISPLAY_NAME);
        final boolean touchedUnstruct = !TextUtils.isEmpty(unstruct);
        final boolean touchedStruct = !areAllEmpty(update, STRUCTURED_FIELDS);
        if (touchedUnstruct && !touchedStruct) {
            NameSplitter.Name name = new NameSplitter.Name();
            mSplitter.split(name, unstruct);
            name.toValues(update);
        } else if (!touchedUnstruct
                && (touchedStruct || areAnySpecified(update, STRUCTURED_FIELDS))) {
            // We need to update the display name when any structured components
            // are specified, even when they are null, which is why we are checking
            // areAnySpecified.  The touchedStruct in the condition is an optimization:
            // if there are non-null values, we know for a fact that some values are present.
            NameSplitter.Name name = new NameSplitter.Name();
            name.fromValues(augmented);
            // As the name could be changed, let‘s guess the name style again.
            name.fullNameStyle = FullNameStyle.UNDEFINED;
            mSplitter.guessNameStyle(name);
            int unadjustedFullNameStyle = name.fullNameStyle;
            name.fullNameStyle = mSplitter.getAdjustedFullNameStyle(name.fullNameStyle);
            
            //XT and
            //final String joined = mSplitter.join(name, true, true);
            String mLanguage = mSplitter.getLanguage();
            if ((name.fullNameStyle == FullNameStyle.UNDEFINED || name.fullNameStyle == FullNameStyle.WESTERN) && mLanguage.equals("hu")){
                 final String joined = mSplitter.join(name, false, true);   //中间的参数为false,即为boolean givenNameFirst,决定是否givenName在最前面
            }else{
                 final String joined = mSplitter.join(name, true, true);
            }
            //XT and end
            update.put(StructuredName.DISPLAY_NAME, joined);
            update.put(StructuredName.FULL_NAME_STYLE, unadjustedFullNameStyle);
            update.put(StructuredName.PHONETIC_NAME_STYLE, name.phoneticNameStyle);
        } else if (touchedUnstruct && touchedStruct){
            if (!update.containsKey(StructuredName.FULL_NAME_STYLE)) {
                update.put(StructuredName.FULL_NAME_STYLE,
                        mSplitter.guessFullNameStyle(unstruct));
            }
            if (!update.containsKey(StructuredName.PHONETIC_NAME_STYLE)) {
                update.put(StructuredName.PHONETIC_NAME_STYLE,
                        mSplitter.guessPhoneticNameStyle(unstruct));
            }
        }
    }
    
3、修改NameSplitter.java (alps\packages\providers\contactsprovider\src\com\android\providers\contacts)
新增函数
public String getLanguage(){
   return mLanguage;
}

android 匈牙利语环境下,联系人的姓名顺序颠倒

标签:android   style   io   java   ar   for   sp   on   c   

原文地址:http://blog.csdn.net/sergeycao/article/details/39395405

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!