android 切换到阿拉伯语电话号码+号显示在右侧及顺序错乱的处理

1.来电通知栏电话号码+号显示在右侧的修改

位置:packages/apps/InCallUI/src/com/android/incallui/StatusBarNotifier.java

刚开始修改的时候,在方法buildAndSendNotification()中添加:

//add by chensenquan20160727

Configuration con =mContext.getResources().getConfiguration();

 String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

if(contentTitle.charAt(0)=='+'){

String newChar =contentTitle.toString().substring(1)+"+";

 contentTitle =contentTitle.toString().replace(contentTitle, newChar);

}

 }

 //add end

虽然这种办法可以解决+号能显示在左侧,但是当电话号码中间有空格的时候,他会显示顺序错乱问题

后来经分析,是有一个属性可以专门解决这种问题:setTextDirection(View.TEXT_DIRECTION_LTR)

经修改为:

Configuration con =mContext.getResources().getConfiguration();

 String l = con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

if(contentTitle.charAt(0)=='+'){

contentTitle =BidiFormatter.getInstance().unicodeWrap(contactInfo.number.toString(),TextDirectionHeuristics.LTR);

}

 }

这是判断如果有+号的号码,才会做一次LTR属性布局,验证没问题,快速代码提交

最后一次修改,这也是我无意中发现的问题,当有+号的号码显示没有问题,如果没有+号的号码且没有添加LTR这种属性该如何显示,后来经验证,这种判断+号的做法是不可取的,只是解决了+号的问题,并没有解决号码顺序错乱的问题

又经修改为:

private String getContentTitle(ContactCacheEntrycontactInfo, Call call) {

        if (call.isConferenceCall()&& !call.hasProperty(Details.PROPERTY_GENERIC_CONFERENCE)) {

            /// M: [VoLTEconference]incoming volte conference @{

            /*

             * Googlecode:

            returnmContext.getResources().getString(R.string.card_title_conf_call);

             */

            if(!isIncomingVolteConference(call)) {

               return mContext.getResources().getString(R.string.card_title_conf_call);

            }

            /// @}

        }

        if(TextUtils.isEmpty(contactInfo.name)) {

            returnTextUtils.isEmpty(contactInfo.number) ? null

                   : BidiFormatter.getInstance().unicodeWrap(

                           contactInfo.number.toString(),TextDirectionHeuristics.LTR);

        }

        returnBidiFormatter.getInstance().unicodeWrap(

                           contactInfo.number.toString(),TextDirectionHeuristics.LTR);

    }

在getContentTitle里面直接返回可以设置LTR布局属性的名称。问题解决。终于捏了一把汗

其他的+号显示问题如下:

2.未接来电号码+号显示在右侧及顺序错乱

代码位置:packages/services/Telecomm/src/com/android/server/telecom/ui/MissedCallNotifierImpl.java

方法:showMissedCallNotification()

同上,最后修改为:

在方法:getNameForCall()

if (mMissedCallCount == 1) {

      BidiFormatterbidiFormatter = BidiFormatter.getInstance();

       returnbidiFormatter.unicodeWrap(name, TextDirectionHeuristics.LTR);

}

3.呼叫记录和通话记录号码+号显示在右侧

位置:packages/apps/Dialer/src/com/android/dialer/calllog/PhoneCallDetailsHelper.java

方法:setPhoneCallDetails()

同上,最后修改为:

CharSequence nameText;

final CharSequence displayNumber = details.displayNumber;

 if (TextUtils.isEmpty(details.name)) {

nameText = displayNumber;

// We have a real phone number as "nameView" somake it always LTR

views.nameView.setTextDirection(View.TEXT_DIRECTION_LTR);

} else {

  nameText = details.name;

  views.nameView.setTextDirection(View.LAYOUT_DIRECTION_LOCALE);//addby chensenquan 20160801

}

4.通话记录电话详细号码+号显示在右侧

位置:packages/apps/Dialer/src/com/android/dialer/CallDetailActivity.java

方法:onGetCallDetails()

同上,最后修改为:
if (!TextUtils.isEmpty(firstDetails.name)) {

            //add by chensenquan 20160727

            mCallerName.setTextDirection(View.LAYOUT_DIRECTION_LOCALE);

               mCallerName.setText(firstDetails.name);

               mCallerNumber.setText(callLocationOrType +" " + getPhoneNumber(displayNumberStr));

           } else {

            mCallerName.setTextDirection(View.TEXT_DIRECTION_LTR);

              mCallerName.setText(getPhoneNumber(displayNumberStr));

               //add end

               if (!TextUtils.isEmpty(callLocationOrType)){

                  mCallerNumber.setText(callLocationOrType);

                  mCallerNumber.setVisibility(View.VISIBLE);

               } else {

                   mCallerNumber.setVisibility(View.GONE);

               }

           }

如果号码中有字串连接,需如下处理:

private String getPhoneNumber(String phoneNumber){

        Configuration con = mContext.getResources().getConfiguration();

           String l = con.locale.getLanguage();

           if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

             if(phoneNumber.charAt(0)=='+'){

              if(mCallerName==null){

                       String newChar =phoneNumber.toString().substring(1)+"+";

                        phoneNumber= phoneNumber.toString().replace(phoneNumber, newChar);

              }

                }

           }

           return phoneNumber;

       }

5.通话界面号码+号显示在右侧

位置:packages/apps/InCallUI/src/com/android/incallui/CallCardFragment.java

方法:setPrimaryName()

同上,最后修改为:

 //Set direction of the name field

 intnameDirection = View.LAYOUT_DIRECTION_LOCALE;

if(nameIsNumber) {

     nameDirection = View.TEXT_DIRECTION_LTR;

 }

mPrimaryName.setTextDirection(nameDirection);

6.呼叫记录和通话记录长按弹出菜单框号码+号显示在右侧

位置:packages/apps/Dialer/src/com/android/dialer/calllog/CallLogAdapter.java

 privatefinal View.OnCreateContextMenuListener mOnCreateContextMenuListener =

           new View.OnCreateContextMenuListener() {

               @Override

               public voidonCreateContextMenu(ContextMenu menu, View v,

                      ContextMenuInfo menuInfo) {

                   finalCallLogListItemViewHolder vh =

                          (CallLogListItemViewHolder) v.getTag();

                   if(TextUtils.isEmpty(vh.number)) {

                      return;

                   }

                   //addby chensenquan 20160729

                   Configurationcon = mContext.getResources().getConfiguration();

                   String l =con.locale.getLanguage();

                  if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

                    if(vh.number.charAt(0)=='+'){

                           String newChar = vh.number.toString().substring(1)+"+";

                        vh.number = vh.number.toString().replace(vh.number, newChar);

                       }

                   }

                   //add end

                  menu.setHeaderTitle(vh.number);

                   final MenuItemcopyItem = menu.add(

                          ContextMenu.NONE,

                          R.id.context_menu_copy_to_clipboard,

                          ContextMenu.NONE,

                          R.string.copy_text);

}

7.来电转接号码+号显示在右侧

位置:packages/services/Telephony/src/com/android/phone/CallForwardEditPreference.java

方法:updateSummaryText()

//addby chensenquan 20160727

Configurationcon = getContext().getResources().getConfiguration();

Stringl = con.locale.getLanguage();

     if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

              if(summaryOn.charAt(0)=='+'){

                 StringnewChar = summaryOn.toString().substring(1)+"+";

                 summaryOn =summaryOn.toString().replace(summaryOn, newChar);

      }

}

 setSummaryOn(summaryOn);

//addend

8.来电转接编辑框号码+号显示在右侧

位置:packages/services/Telephony/src/com/android/phone/EditPhoneNumberPreference.java

方法:onBindDialogView()

//add by chensenquan20160726

Configuration con = getContext().getResources().getConfiguration();

           String l = con.locale.getLanguage();

          if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

             if(mPhoneNumber.charAt(0)=='+'){

                    String newChar =mPhoneNumber.toString().substring(1)+"+";

                    mPhoneNumber =mPhoneNumber.toString().replace(mPhoneNumber, newChar);

             }

}

editText.setText(mPhoneNumber);

//add end

9.联系人收藏界面号码+号显示在右侧

位置:packages/apps/ContactsCommon/src/com/android/contacts/common/list/ContactTileView.java

方法:loadFromContact()

mName.setTextDirection(View.LAYOUT_DIRECTION_LOCALE);//addby chensenquan 20160801

 mName.setText(getNameForView(entry.name));

备注:跟phone应用中收藏是一个界面

10.所有联系人界面号码+号显示在右侧

位置:packages/apps/ContactsCommon/src/com/android/contacts/common/list/ContactListItemView.java

方法:getNameTextView()

mNameTextView.setElegantTextHeight(false);

mNameTextView.setTextDirection(View.LAYOUT_DIRECTION_LOCALE);//addby chensenquan 20160801 for bug9453

addView(mNameTextView);

备注:跟phone应用中联系人界面是同一界面

11.短信+号应该出现在左边的数字(对话框)

位置:packages/apps/Contacts/src/com/android/contacts/activities/ShowOrCreateActivity.java

方法:onCreateDialog()

String m_Message =message.toString();

BidiFormatter.getInstance().unicodeWrap(

m_Message .toString(),TextDirectionHeuristics.LTR);

12.短信+号应该出现在左边的数字

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java 

mTopTitle = (TextView)mActionBarCustomView.findViewById(R.id.tv_top_title); 

//zyh add 2016-08-01(z702 bug 9450:Set the textdirection)

if(Locale.getDefault().getLanguage().equals("ar")){

  mTopTitle.setTextDirection(View.TEXT_DIRECTION_LTR);

}

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ConversationListItem.java

方法:onFinishInflate()

mFromView = (TextView)findViewById(R.id.from); 

//zyh add 2016-08-01(z702 bug 9450:Setthe text direction)

if(Locale.getDefault().getLanguage().equals("ar")){ 

    mFromView.setTextDirection(TEXT_DIRECTION_LTR);

}

位置:

vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/setting/SmsPreferenceActivity.java

 mNumberText.setText(gotScNumber); 

//zyh add 2016-08-01(z702 bug 9452:Setthe mNumberText direction) 

if(Locale.getDefault().getLanguage().equals("ar")){

     mNumberText.setGravity(Gravity.RIGHT);

      mNumberText.setTextDirection(View.TEXT_DIRECTION_LTR);

}

13. call 来电转接编辑框内号码显示错乱且输入号码+号显示在右边

位置:packages/services/Telephony/src/com/android/phone/EditPhoneNumberPreference.java

方法:onBindDialogView()

editText.setText(mPhoneNumber);

//add by chensenquan 20160726

Configuration con =getContext().getResources().getConfiguration();

String l = con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

editText.setGravity(Gravity.RIGHT); //控制+号在左边,右边输入号码

editText.setTextDirection(View.TEXT_DIRECTION_LTR);

editText.setSelection(editText.getText().toString().length());//光标显示在号码最后面

}

//add end

14.短信+新消息弹出dialog框+号显示在右边

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/mms/ui/DialogModeActivity.java

方法:setDialogView()

//zyh add 2016-08-01(z702 bug 9451:Setthe number direction)

String str_temp = getSenderString();

if(Locale.getDefault().getLanguage().equals("ar")){

str_temp =BidiFormatter.getInstance().unicodeWrap(str_temp, TextDirectionHeuristics.LTR);

}

mSender.setText(str_temp);

15.短信号码+号应该出现在左边的数字

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java 

方法:addCallAndContactMenuItems()

//zyh add2016-08-01(z702 bug 9795:Set the number direction)

String temp_uriString =uriString;

if(Locale.getDefault().getLanguage().equals("ar")){

temp_uriString =BidiFormatter.getInstance().unicodeWrap(temp_uriString,TextDirectionHeuristics.LTR);

}        

String addContactString= getString(R.string.menu_add_address_to_contacts,

emp_uriString);

menu.add(0,MENU_ADD_ADDRESS_TO_CONTACTS, 0, addContactString)

.setOnMenuItemClickListener(l)

.setIntent(intent);
位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/MessageUtils.java

方法:getTextMessageDetails()

//zyh add2016-08-01(z702 bug 9795:Set the number direction)

String temp_mAddress =msgItem.mAddress;

if(Locale.getDefault().getLanguage().equals("ar")){

temp_mAddress =BidiFormatter.getInstance().unicodeWrap(temp_mAddress,TextDirectionHeuristics.LTR);

}

details.append(temp_mAddress);

 

//zyh add 2016-08-01(z702bug 9795:Set the number direction)

if(msgItem.mServiceCenter== null){

details.append("");

}else{

String str_temp =msgItem.mServiceCenter;

if(Locale.getDefault().getLanguage().equals("ar")){

str_temp =BidiFormatter.getInstance().unicodeWrap(str_temp, TextDirectionHeuristics.LTR);

}

details.append(str_temp);

}

16.阿拉伯语短信发送成功后返回发送报告时的号码国际字冠需靠左。(bug 9813)

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.java

方法:

private static voidupdateDeliveryNotification(final Context context,

booleanisStatusMessage,

 finalCharSequence message,

final longtimeMillis) {

       if (!isStatusMessage) {

           return;

       }

 

 

       if (!NotificationPreferenceActivity.getNotificationEnabled(context)) {

           return;

       }

 

       sToastHandler.post(new Runnable() {

           @Override

           public void run() {

           if(SystemProperties.getBoolean("ro.custom.sms_report", false)){

             //zyh add 2016-08-12 update

             //CharSequence ticker="Deliveryreport";

          CharSequence ticker =context.getResources().getString(R.string.delivery_report_activity);

    Notification notification = new Notification(R.drawable.stat_notify_sms,message, System.currentTimeMillis());

    notification.flags |= Notification.FLAG_SHOW_LIGHTS;

    notification.flags |= Notification.FLAG_AUTO_CANCEL;

          notification.ledARGB = 0xff00ff00;

          notification.ledOnMS = 500;

          notification.ledOffMS = 2000;

     Intent intent = new Intent();

          notification.defaults |=Notification.DEFAULT_ALL;

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,intent,

                       PendingIntent.FLAG_UPDATE_CURRENT);

   

    notification.setLatestEventInfo(context, ticker, message, pendingIntent);

          NotificationManager nm = (NotificationManager)

            context.getSystemService(context.NOTIFICATION_SERVICE);

   

          nm.notify(NOTIFICATION_ID, notification);

          //zyh add 2016-08-10(z702/z703 bug 9813:Set thetext direction)

         //if(Locale.getDefault().getLanguage().equals("ar")){

          // String str_temp = message.toString();

          // str_temp=BidiFormatter.getInstance().unicodeWrap(str_temp,TextDirectionHeuristics.LTR);

          // Toast.makeText(context, str_temp,(int)timeMillis).show();

          //}else{

           Toast.makeText(context, message, (int)timeMillis).show();

          //}

            }else{

             Toast.makeText(context, message,(int)timeMillis).show();

            }

           }

       });

    }

17.设置阿拉伯语/打开短信发送报告/发送 一条短信/查看短信回执报告 +号显示在数字右边。(bug 9813)

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.java

方法:getSmsNewDeliveryInfo()

//zyhadd 2016-08-12(z702/z703 bug 9813:Set the text direction)

if(Locale.getDefault().getLanguage().equals("ar")){

name=BidiFormatter.getInstance().unicodeWrap(name,TextDirectionHeuristics.LTR);

}

        

returnnew MmsSmsDeliveryInfo(context.getString(R.string.delivery_toast_body, name),

timeMillis);

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ConversationListItem.java

// set mSubjectViewtext before mIpConvListItem.onIpBind()

       if (mConversation.hasUnreadMessages()) {

           String subject = conversation.getSnippet();

           SpannableStringBuilder buf = new SpannableStringBuilder(subject);

           buf.setSpan(STYLE_BOLD, 0, buf.length(),

                  Spannable.SPAN_INCLUSIVE_EXCLUSIVE);

           //zyh add 2016-08-10(z702/z703 bug 9797:Set thetext direction)

           String str_temp = buf.toString();

          if(Locale.getDefault().getLanguage().equals("ar")){

            str_temp =BidiFormatter.getInstance().unicodeWrap(str_temp, TextDirectionHeuristics.LTR);

           }

           mSubjectView.setText(str_temp);

           //mSubjectView.setText(buf);

       } else {

        //zyh add 2016-08-10(z702/z703 bug 9797:Set thetext direction)

        String subject = conversation.getSnippet();

        Configuration con = mContext.getResources().getConfiguration();

           if(Locale.getDefault().getLanguage().equals("ar")){

            subject =BidiFormatter.getInstance().unicodeWrap(subject, TextDirectionHeuristics.LTR);

           }

           mSubjectView.setText(subject);

       }

18.短信添加联系人列表号码+号显示在数字右边。(bug 9791)

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java

//zyh add2016-08-13(z702/z703 bug 9795:Set the number direction) 

  if(Locale.getDefault().getLanguage().equals("ar")){

 mTopSubtitle.setText(BidiFormatter.getInstance().unicodeWrap(

 subTitle,TextDirectionHeuristics.LTR)); 

   }else{

mTopSubtitle.setText(subTitle); 

   }

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/setting/NotificationPreferenceActivity.java 

private voidrestoreDefaultPreferences() {

       SharedPreferences.Editor editor =

                      PreferenceManager.getDefaultSharedPreferences(

                              NotificationPreferenceActivity.this).edit();

       editor.putBoolean(NOTIFICATION_ENABLED, true);

       editor.putString(NOTIFICATION_MUTE, "0");

       editor.putString(NOTIFICATION_RINGTONE, DEFAULT_RINGTONE);

       editor.putBoolean(NOTIFICATION_VIBRATE, true);

       //zyh update 2016-08-13(z702/z703 bug 9835:sms popup default close)

       editor.putBoolean(POPUP_NOTIFICATION, false);//true

       editor.apply();

       setPreferenceScreen(null);

       setMessagePreferences();

       setListPrefSummary();

    }

public static booleanisPopupNotificationEnable() {

       if (!isNotificationEnable()) {

           return false;

       }

       SharedPreferences prefs

               =PreferenceManager.getDefaultSharedPreferences(MmsApp.getApplication());

       //zyh update 2016-08-13(z702/z703 bug 9835:sms popup default close)

       boolean enable =prefs.getBoolean(NotificationPreferenceActivity.POPUP_NOTIFICATION,false);//true

       return enable;

    }

19.修改短信选择联系人列表对话框选项时号码+号显示在数字右边。(bug 9791)

位置:vendor/mediatek/proprietary/packages/apps/Mms/res/layout-ar/mms_chips_recipient_dropdown_item.xml

添加对应的android:textDirection="ltr"

20.阿拉伯语下,收到一个MMS,detail里面号码的显示错误。(bug 10657)

位置:vendor/mediatek/proprietary/packages/apps/Mms/res/layout-ar-finger-1080X720/compose_message_activity.xml 

添加对应的android:textDirection="ltr"

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java

//zyh add2016-08-01(z703 bug 10654:Set the text direction)

  if(Locale.getDefault().getLanguage().equals("ar")){

 mTextEditor.setTextDirection(View.TEXT_DIRECTION_LTR); 

  mTextEditor.setGravity(Gravity.RIGHT|Gravity.CENTER_VERTICAL);

   }

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/MessageUtils.java

private static voidinitializeMsgDetails(Context context,

           StringBuilder details, Resources res, MultimediaMessagePdumsg) {

       details.append(res.getString(R.string.message_type_label));

       details.append(res.getString(R.string.multimedia_message));

 

       if (msg instanceof RetrieveConf) {

           // From: ***

           String from = extractEncStr(context, ((RetrieveConf)msg).getFrom());

           //zyh add 2016-08-23(z702/z703 bug 10657:Set thenumber direction)

           if(Locale.getDefault().getLanguage().equals("ar")&& !TextUtils.isEmpty(from)){

            from = BidiFormatter.getInstance().unicodeWrap(from,TextDirectionHeuristics.LTR);

           }

           details.append('\n');

           details.append(res.getString(R.string.from_label));

           details.append(!TextUtils.isEmpty(from)? from:

                                res.getString(R.string.hidden_sender_address));

       }

 

       // To: ***

       details.append('\n');

       details.append(res.getString(R.string.to_address_label));

       EncodedStringValue[] to = msg.getTo();

       if (to != null) {

        String str_temp = EncodedStringValue.concat(to);

           //zyh add 2016-08-23(z702/z703 bug 10657:Setthe number direction)

          if(Locale.getDefault().getLanguage().equals("ar")){

            str_temp =BidiFormatter.getInstance().unicodeWrap(str_temp, TextDirectionHeuristics.LTR);

           }

           //details.append(EncodedStringValue.concat(to));

           details.append(str_temp);

       }

       else {

           Log.w(TAG, "recipient list is empty!");

       }

 

       // Bcc: ***

       if (msg instanceof SendReq) {

           EncodedStringValue[] values = ((SendReq) msg).getBcc();

           if ((values != null) && (values.length > 0)) {

               details.append('\n');

              details.append(res.getString(R.string.bcc_label));

              details.append(EncodedStringValue.concat(values));

           }

       }

    }

21.修改短信通知,新消息+号应该显示在左侧 (bug 9813)

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/transaction/MessagingNotification.java 

方法:updateNotification()

添加跟号码有关的处理,如:

//add by chensenquan20160808 for bug9813

String message=BidiFormatter.getInstance().unicodeWrap(

mostRecentNotification.formatBigMessage(context).toString(),TextDirectionHeuristics.LTR);

noti.setContentText(message);

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/mms/ui/DialogModeActivity.java

//add by chensenquan20160808 for bug9813

              mSmsContentText.setText(BidiFormatter.getInstance().unicodeWrap(content,TextDirectionHeuristics.LTR));

               //add end

 

 //add bychensenquan 20160808 for bug9813

              mSmsContentText.setText(BidiFormatter.getInstance().unicodeWrap(

               buf.toString(),TextDirectionHeuristics.LTR));

               mSmsContentText.setVisibility(View.VISIBLE);

               //add end

 

22.处理拨号盘内搜索列表号码+号应该显示在左侧

位置:packages/apps/Dialer/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java

 //add by chensenquan20160810

Configuration con =mContext.getResources().getConfiguration(); 

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage 

displayName=mBidiFormatter.unicodeWrap(displayName.toString(),TextDirection

Heuristics.LTR); 

//add end 

viewHolder.name.setText(displayName);      

23.修改阿拉伯语下,SMS里面添加一个保存的联系人,+86显示错误(BUG 10650)

位置:frameworks/ex/chips/res/layout/chips_recipient_dropdown_item.xml

添加对应的android:textDirection="ltr"

24.信息内插入联系人号码后,+号显示在数字的右边。(bug 10896)

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/mms/ui/VCardAttachment.java 

if(!mNumbers.isEmpty()) {

           if (mNumbers.size() > 1) {

               i = 1;

               StringBuffer buf = newStringBuffer();

               buf.append(textVCardString);

               for (String number : mNumbers){

                  buf.append(mContext.getString(R.string.contact_tel) + i + ": " +number + "\n");

                   i++;

               }

               textVCardString = buf.toString();

           } else {

            String str_numbers = mNumbers.get(0);

            //zyh add 2016-08-25(z702 bug10896:Set the number direction)

              if(Locale.getDefault().getLanguage().equals("ar")){

                str_numbers =BidiFormatter.getInstance().unicodeWrap(str_numbers,TextDirectionHeuristics.LTR);

               }

               textVCardString +=mContext.getString(R.string.contact_tel) + ": " +str_numbers/*mNumbers.get(0)*/

                       +"\n";

           }

       }

25.查看彩信里面的+号显示在数字的右边 (bug 10914)

主题内容:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/MessageListItem.java

private CharSequenceformatMessage(MessageItem msgItem, String body,

                                     String subject, Pattern highlight,

                                     String contentType) {

       SpannableStringBuilder buf = new SpannableStringBuilder();

 

       boolean hasSubject = !TextUtils.isEmpty(subject);

      

       //zyh add 2016-08-26(z702/z703 bug 10908:Set the number direction)

       if(Locale.getDefault().getLanguage().equals("ar")){

        subject = BidiFormatter.getInstance().unicodeWrap(subject,TextDirectionHeuristics.LTR);

        body = BidiFormatter.getInstance().unicodeWrap(body,TextDirectionHeuristics.LTR);

       }

      

       if (hasSubject) {

          buf.append(mContext.getResources().getString(R.string.inline_subject,subject));

       }

      

       if (!TextUtils.isEmpty(body)) {

           // Converts html to spannable if MmsContentType is"text/html".

           if (contentType != null &&MmsContentType.TEXT_HTML.equals(contentType)) {

               buf.append("\n");

               buf.append(Html.fromHtml(body));

           } else {

               if (hasSubject) {

                   buf.append(" - ");

               }

               buf.append(body);

           }

       }

       。。。

       return buf;

}

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/MmsPlayerActivityAdapter.java

if(text != null) {

   /// M: ALPS00619099, highlight matched search string in mms player @ {

   if (mHighlight != null) {

       setHighlightText(mText, text);

   } else {

       //zyh add 2016-08-26(z702/z703 bug10914:Set the number direction)

      if(Locale.getDefault().getLanguage().equals("ar")){

        text = BidiFormatter.getInstance().unicodeWrap(text,TextDirectionHeuristics.LTR);

       }

       SpannableString ss = new SpannableString(text);

       mText.setText(ss);

   }

   /// @}

   if (textSize != 0) {

       mText.setTextSize(textSize);

   }

   mText.setVisibility(View.VISIBLE);

   /// M: ALPS00527989, Extend TextView URL handling @ {

   mOpMmsPlayerActivityAdapterExt.setExtendUrlSpan(mText);

   /// @}

   itemView.setCurrentTextView(mText);

}

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/SlideView.java

//zyhadd 2016-08-26(z702/z703 bug 10914:Set the number direction)

if(Locale.getDefault().getLanguage().equals("ar")){

 text= BidiFormatter.getInstance().unicodeWrap(text, TextDirectionHeuristics.LTR);

}

SpannableStringss = new SpannableString(text);

mTextView.setText(ss);

 

mOpSlideViewExt.setText(mActivity,mTextView, mConformanceMode);

26.阿拉伯语下短信联系人输入框,输入+86号码,顺序显示错误。(bug 10654)

位置: vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java

//zyh add2016-08-01(z703 bug 10654:Set the text direction)

if(Locale.getDefault().getLanguage().equals("ar")){

 mRecipientsEditor.setTextDirection(View.TEXT_DIRECTION_LTR);

 mRecipientsEditor.setGravity(Gravity.RIGHT|Gravity.CENTER_VERTICAL);

}

// M: fix bugALPS00355897

//PhoneNumberFormatter.setPhoneNumberFormattingTextWatcher(this,mRecipientsEditor);

位置:frameworks/ex/chips/src/com/android/mtkex/chips/MTKRecipientEditTextView.java

添加setTextDirection属性后,联系人不能点击处理:

protected booleanisTouchPointInChip(float posX, float posY) {

boolean isInChip =true;

Layout layout =getLayout();

if (layout != null)

{

    intoffsetForPosition = getOffsetForPosition(posX, posY);

    intline = layout.getLineForOffset(offsetForPosition);

    floatmaxX = layout.getPrimaryHorizontal(layout.getLineEnd(line) - 1);

    floatcurrentX = posX - getTotalPaddingLeft();

   currentX = Math.max(0.0f, currentX);

   currentX = Math.min(getWidth() - getTotalPaddingRight() - 1, currentX);

   currentX += getScrollX();

   Configuration config = getResources().getConfiguration();

   

    /*if(config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL && currentX< maxX) {

       isInChip = false;

    } elseif (currentX > maxX && config.getLayoutDirection() !=View.LAYOUT_DIRECTION_RTL) {

       isInChip = false;

    }*/

   

    //zyh add2016-08-25(z702/z703 bug 10654:Set the text direction)

   if(Locale.getDefault().getLanguage().equals("ar")){

       if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_LTR &¤tX < maxX) {

        isInChip = false;

       } else if (currentX > maxX && config.getLayoutDirection() !=View.LAYOUT_DIRECTION_LTR) {

        isInChip = false;

       }

    }else{

       if (config.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL &¤tX < maxX) {

        isInChip = false;

       } else if (currentX > maxX && config.getLayoutDirection() != View.LAYOUT_DIRECTION_RTL){

        isInChip = false;

       }

    }

}

return isInChip;

}

27.信息输入联系人号码的时候,匹配出未保存名称的联系人时+号显示在数字的左边

位置:frameworks/ex/chips/src/com/android/mtkex/chips/BaseRecipientAdapter.java

//addby chensenquan 20160825 for bug 10919

Configurationcon =getContext().getResources().getConfiguration();

Stringl = con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

if(displayName.charAt(0)=='+'){

displayName=BidiFormatter.getInstance().unicodeWrap(displayName,TextDirecti

onHeuristics.LTR);

}

displayNameView.setText(displayName);

}

//addend

28.阿拉伯语下,拨号盘内搜索号码,输入框内+号显示在数字的右边

位置:packages/apps/Dialer/src/com/android/dialer/DialtactsActivity.java

mSearchView= (EditText) searchEditTextLayout.findViewById(R.id.search_view);

mSearchView.addTextChangedListener(mPhoneSearchQueryTextListener);

 //addby chensenquan 20160825 for bug 10814 

Configurationcon = resources.getConfiguration();

Stringl = con.locale.getLanguage(); 

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

mSearchView.setTextDirection(View.TEXT_DIRECTION_LTR);

mSearchView.setGravity(Gravity.RIGHT);

}

//addend

29.搜索联系人,+86顺序显示错误

位置:packages/apps/Contacts/src/com/android/contacts/activities/ActionBarAdapter.java

 mSearchView =(EditText) mSearchContainer.findViewById(R.id.search_view);

 //add by chensenquan20160825 for bug 10814 

Configuration con =mActivity.getResources().getConfiguration();

String l = con.locale.getLanguage(); 

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

mSearchView.setTextDirection(View.TEXT_DIRECTION_LTR);

mSearchView.setGravity(Gravity.RIGHT); 

}

//add end

mSearchView.setHint(mActivity.getString(R.string.hint_findContacts));

30.阿拉伯语,拨号盘匹配出未保存名字的联系人,+号显示在数字的左边。

位置:packages/apps/Dialer/src/com/android/dialer/list/DialerPhoneNumberListAdapter.java

// empty name ?

if(!TextUtils.isEmpty(displayName)) {

// highlight name

String highlight =getNameHighlight(cursor);

if(!TextUtils.isEmpty(highlight)) {

   SpannableStringBuilder style = highlightString(highlight, displayName);

   //add bychensenquan 20160826

   viewHolder.name.setText(setTextDirectionLTR(context,style.toString()));

    if(isRegularSearch(cursor)) {

    //add by chensenquan 20160825 for bug 10883

      viewHolder.name.setText(setTextDirectionLTR(context,highlightName(highlight,displayName).toString()));

    }

} else {

 //add bychensenquan 20160810

   viewHolder.name.setText(setTextDirectionLTR(context,displayName.toString()));

    //add end

}

}

/**

* add by chensenquan20160825 for 10883

* @param context

* @param textName

* @return

*/

private StringsetTextDirectionLTR(Context context,String textName){

Configuration con =context.getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 if(textName.charAt(0)=='+'){

 textName=mBidiFormatter.unicodeWrap(textName.toString(),TextDirectionHeuristics.LTR);

 }

}

return textName;

}

31.阿拉伯语,联系人名字是号码,+号显示在数字的左边

位置:packages/apps/ContactsCommon/src/com/android/contacts/common/list/ContactListItemView.java

//add by chensenquan20160825 for bug10883

Configuration con =getContext().getResources().getConfiguration();

String l = con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

if(name.charAt(0)=='+'){ 

name=BidiFormatter.getInstance().unicodeWrap(name.toString(),TextDirectionH

euristics.LTR); 

//add end

setMarqueeText(getNameTextView(),name);

32.短信设置内添加新常用语、修改常用语、保存常用语、插入常用语的时候+号显示在数字的右边。

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/MmsConfig.java

public static intupdateAllQuicktexts() {

Cursor cursor =mContext.getContentResolver().query(Telephony.MmsSms.CONTENT_URI_QUICKTEXT,

       null, null, null, null);

allQuickTextIds.clear();

allQuickTexts.clear();

String[] defaultTexts= mContext.getResources().getStringArray(R.array.default_quick_texts);

int maxId =defaultTexts.length;

if (cursor != null) {

    try {

       while (cursor.moveToNext()) {

           int qtId = cursor.getInt(0);

           allQuickTextIds.add(qtId);

           String qtText = cursor.getString(1);

           if (qtText != null && !qtText.isEmpty()) {

              allQuickTexts.add(setTextDirectionLTR(qtText));//add by chensenquan 20160825for bug 10911

           } else {

              allQuickTexts.add(setTextDirectionLTR(defaultTexts[qtId - 1]));//add bychensenquan 20160825 for bug 10911

           }

           if (qtId > maxId) {

               maxId = qtId;

           }

       }

    }finally {

       cursor.close();

    }

}

return maxId;

}

 

/**

* add by chensenquan20160825 for bug 10911

* @param textName

* @return

*/

private static StringsetTextDirectionLTR(String textName){

Configuration con=mContext.getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 if(textName.charAt(0)=='+'|| textName.charAt(textName.length()-1)=='+'){

 textName=BidiFormatter.getInstance().unicodeWrap(

   textName, TextDirectionHeuristics.LTR);

 }

}

return textName;

}

位置: vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/ComposeMessageActivity.java

mSubjectTextEditor =(EditText)findViewById(R.id.subject);

//add by chensenquan20160825 for bug 10908

Configuration con=getResources().getConfiguration(); 

String l =con.locale.getLanguage(); 

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage 

mSubjectTextEditor.setTextDirection(View.TEXT_DIRECTION_LTR); 

mSubjectTextEditor.setGravity(Gravity.RIGHT); 

}

//add end

 

List> entries = new ArrayList>();

for (String text :quickTextsList) {

HashMapentry = new HashMap();

//add by chensenquan20160825 for bug 10911

Configuration con=getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 if(text.charAt(0)=='+'|| text.charAt(text.length()-1)=='+'){

 text=BidiFormatter.getInstance().unicodeWrap(

          text, TextDirectionHeuristics.LTR);

 }

}

//add end

entry.put("text",text);

entries.add(entry);

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/android/mms/ui/SmsTemplateEditActivity.java

mQuickTextId =MmsConfig.getQuicktextsId().get(Integer.valueOf((int) id));

mQuickText =MmsConfig.getQuicktexts().get(Integer.valueOf((int) id));

//add by chensenquan20160825 for bug 10911

Configuration con=getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 if(mQuickText.charAt(0)=='+'|| mQuickText.charAt(mQuickText.length()-1)=='+'){

  mQuickText=BidiFormatter.getInstance().unicodeWrap(

      mQuickText, TextDirectionHeuristics.LTR);

 }

}

//add end

showEditDialog();

 

mNewQuickText =(EditText) findViewById(R.id.new_quick_text);

//add by chensenquan20160825 for bug 10911

Configuration con=getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 mNewQuickText.setTextDirection(View.TEXT_DIRECTION_LTR);

    mNewQuickText.setGravity(Gravity.RIGHT);

}

//add end

mNewQuickText.setHint(R.string.type_to_quick_text);

 

adapter.notifyDataSetChanged();

//add by chensenquan20160825 for bug 10911

Configuration con=getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 if(currentText.charAt(0)=='+'|| currentText.charAt(currentText.length()-1)=='+'){

 currentText=BidiFormatter.getInstance().unicodeWrap(

      currentText, TextDirectionHeuristics.LTR);

 }

}

//add end

makeAToast(getString(R.string.add_quick_text_successful)+ " : \n" + currentText);

 

private voidshowEditDialog(String quickText) {

AlertDialog.Builderdialog = new AlertDialog.Builder(SmsTemplateEditActivity.this);

mOldQuickText = newEditText(dialog.getContext());

//add by chensenquan20160825 for bug 10911

Configuration con=getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 mOldQuickText.setTextDirection(View.TEXT_DIRECTION_LTR);

 mOldQuickText.setGravity(Gravity.RIGHT);

}

//add end

mOldQuickText.setHint(R.string.type_to_quick_text);

.show();

}

33.系统语言切换为阿拉伯语后,WiFi密码输入框的光标应该显示在右边

位置:packages/apps/Settings/src/com/android/settings/wifi/WifiConfigController.java

///M: modify to solveCR:ALPS01837742 @{

if (mPasswordView ==null) {

mPasswordView =(TextView) mView.findViewById(R.id.password);

mPasswordView.addTextChangedListener(this);

setTextLTRLanguage();//addby chensenquan 20160825 for bug 10768

((CheckBox)mView.findViewById(R.id.show_password))

   .setOnCheckedChangeListener(this);

}

 

if (mPasswordView ==null) {

   mPasswordView = (TextView) mView.findViewById(R.id.password);

   mPasswordView.addTextChangedListener(this);

    setTextLTRLanguage();//add by chensenquan 20160825 for bug 10768

   ((CheckBox) mView.findViewById(R.id.show_password))

       .setOnCheckedChangeListener(this);

 

    if(mAccessPoint != null && mAccessPoint.isSaved()) {

       mPasswordView.setHint(R.string.wifi_unchanged);

    }

}

 

/**

* add by chensenquan20160825 for bug 10768

*/

private voidsetTextLTRLanguage(){

Configuration con=mContext.getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

 mPasswordView.setTextDirection(View.TEXT_DIRECTION_LTR);

 mPasswordView.setGravity(Gravity.RIGHT);

}

}

34.进入设置查看sim cards,账号显示,然后点击此账号查看,号码显示中+在左侧

位置:packages/apps/Settings/src/com/android/settings/sim/SimDialogActivity.java

//add by chensenquan20160825 for bug 10930 

Configuration con=mContext.getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage

holder.summary.setTextDirection(View.TEXT_DIRECTION_LTR);

holder.summary.setGravity(Gravity.RIGHT);

}

//add end

 finalSubscriptionInfo sir = mSubInfoList.get(position);

 

位置:packages/apps/Settings/src/com/android/settings/sim/SimPreferenceDialog.java

numberView.setText(PhoneNumberUtils.formatNumber(rawNumber));

//add by chensenquan20160825 for bug 10930 

Configuration con=mContext.getResources().getConfiguration(); 

String l =con.locale.getLanguage(); 

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage 

numberView.setTextDirection(View.TEXT_DIRECTION_LTR); 

numberView.setGravity(Gravity.RIGHT); 

 //add end 

}

String simCarrierName= tm.getSimOperatorNameForSubscription(mSubInfoRecord.getSubscriptionId());

35.阿拉伯语下,设置中SIM卡信息MDN号码+86显示错误

位置:packages/apps/Settings/src/com/android/settings/deviceinfo/SimStatus.java

formattedNumber =PhoneNumberUtils.formatNumber(rawNumber);

//add by chensenquan20160827 for bug10951 

Configuration con =getResources().getConfiguration();

String l =con.locale.getLanguage();

if(l.equals("ar")||l.equals("fa")||l.equals("iw")){//RTLlanguage 

formattedNumber=BidiFormatter.getInstance().unicodeWrap(

formattedNumber.toString(),TextDirectionHeuristics.LTR); 

//add end

36.当联系人名字为号码时,信息内插入联系人+号显示在右边

位置:vendor/mediatek/proprietary/packages/apps/Mms/src/com/mediatek/mms/ui/VCardAttachment.java 

if (mName != null&& !mName.equals("")) {

//add by chensenquan20160827 for bug 10896 

if(Locale.getDefault().getLanguage().equals("ar")){ 

if(mName.charAt(0)=='+'){ 

mName =BidiFormatter.getInstance().unicodeWrap(mName,TextDirectionHeuristi cs.LTR);

}

//add end

textVCardString +=mContext.getString(R.string.contact_name) + ": " + mName +"\n"; 

}

}

37.搜索联系人ContentDescription+号显示在右边

位置:packages/apps/ContactsCommon/src/com/android/contacts/common/list/ContactListItemView.java

/**

* Adds or updates atext view for the search snippet.

*/

public voidsetSnippet(String text) {

if(TextUtils.isEmpty(text)) {

    if(mSnippetView != null) {

       mSnippetView.setVisibility(View.GONE);

    }

} else {

 //add by chensenquan20160828

 text=setTextDirectionLTR(text);

 //add end

   mTextHighlighter.setPrefixText(getSnippetView(), text, mHighlightedPrefix);

   mSnippetView.setVisibility(VISIBLE);

    if(ContactDisplayUtils.isPossiblePhoneNumber(text)) {

       // Give the text-to-speech engine a hint that it's a phone number

      mSnippetView.setContentDescription(PhoneNumberUtils.createTtsSpannable(text));

    } else{

       mSnippetView.setContentDescription(null);

    }

}

}

你可能感兴趣的:(android 切换到阿拉伯语电话号码+号显示在右侧及顺序错乱的处理)