当前位置: 首页>>代码示例>>Java>>正文


Java PhoneFormat类代码示例

本文整理汇总了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;
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:38,代码来源:GroupCreateActivity.java

示例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());
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:24,代码来源:ChatActivity.java

示例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));
        }
    }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:19,代码来源:ChatActivity.java

示例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));
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:18,代码来源:ContactAddActivity.java

示例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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:18,代码来源:DrawerProfileCell.java

示例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));
        }
    }
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:ChatActivity.java

示例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);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:26,代码来源:LoginActivity.java

示例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;
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:20,代码来源:AndroidUtilities.java

示例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);*/
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:20,代码来源:CallReceiver.java

示例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);
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:18,代码来源:BlockedUsersActivity.java

示例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());
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:24,代码来源:ChatActivity.java

示例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));
        }
    }
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:21,代码来源:ChatActivity.java

示例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));
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:18,代码来源:ContactAddActivity.java

示例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);
}
 
开发者ID:DrKLO,项目名称:Telegram,代码行数:26,代码来源:LoginActivity.java

示例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);
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:14,代码来源:CallReceiver.java


注:本文中的org.telegram.PhoneFormat.PhoneFormat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。