本文整理汇总了Java中org.telegram.PhoneFormat.PhoneFormat类的典型用法代码示例。如果您正苦于以下问题:Java PhoneFormat类的具体用法?Java PhoneFormat怎么用?Java PhoneFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PhoneFormat类属于org.telegram.PhoneFormat包,在下文中一共展示了PhoneFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAndPutChipForUser
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
private ChipSpan createAndPutChipForUser(TLRPC.User user) {
LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View textView = lf.inflate(R.layout.group_create_bubble, null);
TextView text = (TextView)textView.findViewById(R.id.bubble_text_view);
String name = UserObject.getUserName(user);
if (name.length() == 0 && user.phone != null && user.phone.length() != 0) {
name = PhoneFormat.getInstance().format("+" + user.phone);
}
text.setText(name + ", ");
int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
textView.measure(spec, spec);
textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight());
Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(b);
canvas.translate(-textView.getScrollX(), -textView.getScrollY());
textView.draw(canvas);
textView.setDrawingCacheEnabled(true);
Bitmap cacheBmp = textView.getDrawingCache();
Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true);
textView.destroyDrawingCache();
final BitmapDrawable bmpDrawable = new BitmapDrawable(b);
bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight());
SpannableStringBuilder ssb = new SpannableStringBuilder("");
ChipSpan span = new ChipSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE);
allSpans.add(span);
selectedContacts.put(user.id, span);
for (ImageSpan sp : allSpans) {
ssb.append("<<");
ssb.setSpan(sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE);
}
userSelectEditText.setText(ssb);
userSelectEditText.setSelection(ssb.length());
return span;
}
示例2: shareMyContact
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
public void shareMyContact(final MessageObject messageObject) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("ShareYouPhoneNumberTitle", R.string.ShareYouPhoneNumberTitle));
if (currentUser != null) {
if (currentUser.bot) {
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfoBot", R.string.AreYouSureShareMyContactInfoBot));
} else {
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureShareMyContactInfoUser", R.string.AreYouSureShareMyContactInfoUser, PhoneFormat.getInstance().format("+" + UserConfig.getCurrentUser().phone), ContactsController.formatName(currentUser.first_name, currentUser.last_name))));
}
} else {
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo));
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id, messageObject, null, null);
moveScrollToLastMessage();
showReplyPanel(false, null, null, null, false, true);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}
示例3: updateTitle
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
public void updateTitle() {
if (avatarContainer == null) {
return;
}
if (currentChat != null) {
avatarContainer.setTitle(currentChat.title);
} else if (currentUser != null) {
if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) {
if (currentUser.phone != null && currentUser.phone.length() != 0) {
avatarContainer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
}
}
示例4: updateAvatarLayout
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
private void updateAvatarLayout() {
if (nameTextView == null) {
return;
}
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) {
return;
}
nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
onlineTextView.setText(LocaleController.formatUserStatus(user));
TLRPC.FileLocation photo = null;
if (user.photo != null) {
photo = user.photo.photo_small;
}
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
}
示例5: setUser
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
public void setUser(TLRPC.User user) {
if (user == null) {
return;
}
TLRPC.FileLocation photo = null;
if (user.photo != null) {
photo = user.photo.photo_small;
}
String name= SkinMan.currentSkin.drawerProfileTitle();
String phon= SkinMan.currentSkin.drawerProfileSubtitle();
nameTextView.setText(name == null ? UserObject.getUserName(user) : name);
phoneTextView.setText(phon == null ? PhoneFormat.getInstance().format("+" + user.phone) : phon);
AvatarDrawable avatarDrawable = new AvatarDrawable(user);
avatarDrawable.setColor(Theme.ACTION_BAR_MAIN_AVATAR_COLOR);
avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
示例6: updateTitle
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
private void updateTitle() {
if (avatarContainer == null) {
return;
}
if (currentChat != null) {
avatarContainer.setTitle(currentChat.title);
} else if (currentUser != null) {
if (currentUser.self) {
avatarContainer.setTitle(LocaleController.getString("ChatYourSelfName", R.string.ChatYourSelfName));
} else if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) {
if (currentUser.phone != null && currentUser.phone.length() != 0) {
avatarContainer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
}
}
示例7: setParams
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
@Override
public void setParams(Bundle params) {
if (params == null) {
return;
}
currentParams = params;
requestPhone = params.getString("phoneFormated");
phoneHash = params.getString("phoneHash");
phoneCode = params.getString("code");
startTime = params.getInt("startTime");
waitTime = params.getInt("waitTime");
confirmTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ResetAccountInfo", R.string.ResetAccountInfo, PhoneFormat.getInstance().format("+" + requestPhone))));
updateTimeText();
timeRunnable = new Runnable() {
@Override
public void run() {
if (timeRunnable != this) {
return;
}
updateTimeText();
AndroidUtilities.runOnUIThread(timeRunnable, 1000);
}
};
AndroidUtilities.runOnUIThread(timeRunnable, 1000);
}
示例8: checkPhonePattern
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
public static boolean checkPhonePattern(String pattern, String phone) {
if (TextUtils.isEmpty(pattern) || pattern.equals("*")) {
return true;
}
String args[] = pattern.split("\\*");
phone = PhoneFormat.stripExceptNumbers(phone);
int checkStart = 0;
int index;
for (int a = 0; a < args.length; a++) {
String arg = args[a];
if (!TextUtils.isEmpty(arg)) {
if ((index = phone.indexOf(arg, checkStart)) == -1) {
return false;
}
checkStart = index + arg.length();
}
}
return true;
}
示例9: onReceive
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
if (intent.getAction().equals("android.intent.action.PHONE_STATE")) {
String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (TelephonyManager.EXTRA_STATE_RINGING.equals(phoneState)) {
String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(phoneNumber));
}
}
/*TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == 1 && incomingNumber != null && incomingNumber.length() > 0) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(incomingNumber));
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);*/
}
示例10: onBindViewHolder
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == 0) {
TLRPC.User user = MessagesController.getInstance().getUser(MessagesController.getInstance().blockedUsers.get(position));
if (user != null) {
String number;
if (user.bot) {
number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
} else if (user.phone != null && user.phone.length() != 0) {
number = PhoneFormat.getInstance().format("+" + user.phone);
} else {
number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
}
((UserCell) holder.itemView).setData(user, null, number, 0);
}
}
}
示例11: shareMyContact
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
public void shareMyContact(final MessageObject messageObject) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("ShareYouPhoneNumberTitle", R.string.ShareYouPhoneNumberTitle));
if (currentUser != null) {
if (currentUser.bot) {
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfoBot", R.string.AreYouSureShareMyContactInfoBot));
} else {
builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureShareMyContactInfoUser", R.string.AreYouSureShareMyContactInfoUser, PhoneFormat.getInstance().format("+" + UserConfig.getCurrentUser().phone), ContactsController.formatName(currentUser.first_name, currentUser.last_name))));
}
} else {
builder.setMessage(LocaleController.getString("AreYouSureShareMyContactInfo", R.string.AreYouSureShareMyContactInfo));
}
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
SendMessagesHelper.getInstance().sendMessage(UserConfig.getCurrentUser(), dialog_id, messageObject, null, null);
moveScrollToLastMessage();
showReplyPanel(false, null, null, null, false);
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
showDialog(builder.create());
}
示例12: updateTitle
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
private void updateTitle() {
if (avatarContainer == null) {
return;
}
if (currentChat != null) {
avatarContainer.setTitle(currentChat.title);
} else if (currentUser != null) {
if (currentUser.self) {
avatarContainer.setTitle(LocaleController.getString("SavedMessages", R.string.SavedMessages));
} else if (!MessagesController.isSupportId(currentUser.id) && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) {
if (!TextUtils.isEmpty(currentUser.phone)) {
avatarContainer.setTitle(PhoneFormat.getInstance().format("+" + currentUser.phone));
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
} else {
avatarContainer.setTitle(UserObject.getUserName(currentUser));
}
}
}
示例13: updateAvatarLayout
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
private void updateAvatarLayout() {
if (nameTextView == null) {
return;
}
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
if (user == null) {
return;
}
nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
onlineTextView.setText(LocaleController.formatUserStatus(user));
TLRPC.FileLocation photo = null;
if (user.photo != null) {
photo = user.photo.photo_small;
}
avatarImage.setImage(photo, "50_50", avatarDrawable = new AvatarDrawable(user));
}
示例14: setParams
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
@Override
public void setParams(Bundle params, boolean restore) {
if (params == null) {
return;
}
currentParams = params;
requestPhone = params.getString("phoneFormated");
phoneHash = params.getString("phoneHash");
phoneCode = params.getString("code");
startTime = params.getInt("startTime");
waitTime = params.getInt("waitTime");
confirmTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("ResetAccountInfo", R.string.ResetAccountInfo, PhoneFormat.getInstance().format("+" + requestPhone))));
updateTimeText();
timeRunnable = new Runnable() {
@Override
public void run() {
if (timeRunnable != this) {
return;
}
updateTimeText();
AndroidUtilities.runOnUIThread(timeRunnable, 1000);
}
};
AndroidUtilities.runOnUIThread(timeRunnable, 1000);
}
示例15: onReceive
import org.telegram.PhoneFormat.PhoneFormat; //导入依赖的package包/类
@Override
public void onReceive(final Context context, Intent intent) {
TelephonyManager telephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
telephony.listen(new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
if (state == 1 && incomingNumber != null && incomingNumber.length() > 0) {
NotificationCenter.getInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(incomingNumber));
}
}
}, PhoneStateListener.LISTEN_CALL_STATE);
}