org.telegram.messenger.LocaleController Java Examples

The following examples show how to use org.telegram.messenger.LocaleController. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlockingUpdateView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkApkInstallPermissions(final Context context) {
    if (Build.VERSION.SDK_INT >= 26 && !ApplicationLoader.applicationContext.getPackageManager().canRequestPackageInstalls()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.getString("ApkRestricted", R.string.ApkRestricted));
        builder.setPositiveButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialogInterface, i) -> {
            try {
                context.startActivity(new Intent(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES, Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName())));
            } catch (Exception e) {
                FileLog.e(e);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        builder.show();
        return false;
    }
    return true;
}
 
Example #2
Source File: DialogsEmptyCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setType(int value) {
    currentType = value;
    String help;
    if (currentType == 0) {
        help = LocaleController.getString("NoChatsHelp", R.string.NoChatsHelp);
        if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
            help = help.replace('\n', ' ');
        }
    } else {
        help = LocaleController.getString("NoChatsContactsHelp", R.string.NoChatsContactsHelp);
        if (AndroidUtilities.isTablet() && !AndroidUtilities.isSmallTablet()) {
            help = help.replace('\n', ' ');
        }
    }
    emptyTextView2.setText(help);
}
 
Example #3
Source File: CallLogActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public CustomCell(Context context) {
	super(context);

	setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));

	profileSearchCell = new ProfileSearchCell(context);
	profileSearchCell.setPadding(LocaleController.isRTL ? AndroidUtilities.dp(32) : 0, 0, LocaleController.isRTL ? 0 : AndroidUtilities.dp(32), 0);
	profileSearchCell.setSublabelOffset(AndroidUtilities.dp(LocaleController.isRTL ? 2 : -2), -AndroidUtilities.dp(4));
	addView(profileSearchCell, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));

	imageView = new ImageView(context);
	imageView.setImageResource(R.drawable.profile_phone);
	imageView.setAlpha(214);
	imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addButton), PorterDuff.Mode.MULTIPLY));
	imageView.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 1));
	imageView.setScaleType(ImageView.ScaleType.CENTER);
	imageView.setOnClickListener(callBtnClickListener);
	imageView.setContentDescription(LocaleController.getString("Call", R.string.Call));
	addView(imageView, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 8, 0, 8, 0));
}
 
Example #4
Source File: TextCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    int height = bottom - top;
    int width = right - left;

    int viewTop = (height - valueTextView.getTextHeight()) / 2;
    int viewLeft = LocaleController.isRTL ? AndroidUtilities.dp(24) : 0;
    valueTextView.layout(viewLeft, viewTop, viewLeft + valueTextView.getMeasuredWidth(), viewTop + valueTextView.getMeasuredHeight());

    viewTop = (height - textView.getTextHeight()) / 2;
    if (LocaleController.isRTL) {
        viewLeft = getMeasuredWidth() - textView.getMeasuredWidth() - AndroidUtilities.dp(71);
    } else {
        viewLeft = AndroidUtilities.dp(71);
    }
    textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());

    viewTop = AndroidUtilities.dp(5);
    viewLeft = !LocaleController.isRTL ? AndroidUtilities.dp(16) : width - imageView.getMeasuredWidth() - AndroidUtilities.dp(16);
    imageView.layout(viewLeft, viewTop, viewLeft + imageView.getMeasuredWidth(), viewTop + imageView.getMeasuredHeight());

    viewTop = (height - valueImageView.getMeasuredHeight()) / 2;
    viewLeft = LocaleController.isRTL ? AndroidUtilities.dp(24) : width - valueImageView.getMeasuredWidth() - AndroidUtilities.dp(24);
    valueImageView.layout(viewLeft, viewTop, viewLeft + valueImageView.getMeasuredWidth(), viewTop + valueImageView.getMeasuredHeight());
}
 
Example #5
Source File: TextCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public TextCell(Context context) {
    super(context);

    textView = new SimpleTextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(16);
    textView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
    addView(textView);

    valueTextView = new SimpleTextView(context);
    valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteValueText));
    valueTextView.setTextSize(16);
    valueTextView.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
    addView(valueTextView);

    imageView = new ImageView(context);
    imageView.setScaleType(ImageView.ScaleType.CENTER);
    imageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayIcon), PorterDuff.Mode.MULTIPLY));
    addView(imageView);

    valueImageView = new ImageView(context);
    valueImageView.setScaleType(ImageView.ScaleType.CENTER);
    addView(valueImageView);
}
 
Example #6
Source File: ThemeTypeCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public ThemeTypeCell(Context context) {
    super(context);

    setWillNotDraw(false);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 + 48 : 17, 0, LocaleController.isRTL ? 17 : 23, 0));

    checkImage = new ImageView(context);
    checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
    checkImage.setImageResource(R.drawable.sticker_added);
    addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 23, 0, 23, 0));
}
 
Example #7
Source File: AlertsCreator.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static void showFloodWaitAlert(String error, final BaseFragment fragment) {
    if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null) {
        return;
    }
    int time = Utilities.parseInt(error);
    String timeString;
    if (time < 60) {
        timeString = LocaleController.formatPluralString("Seconds", time);
    } else {
        timeString = LocaleController.formatPluralString("Minutes", time / 60);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    fragment.showDialog(builder.create(), true, null);
}
 
Example #8
Source File: RecyclerListView.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (fastScroll != null) {
        selfOnLayout = true;
        t += getPaddingTop();
        if (LocaleController.isRTL) {
            fastScroll.layout(0, t, fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        } else {
            int x = getMeasuredWidth() - fastScroll.getMeasuredWidth();
            fastScroll.layout(x, t, x + fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        }
        selfOnLayout = false;
    }
    checkSection();
    if (pendingHighlightPosition != null) {
        highlightRowInternal(pendingHighlightPosition, false);
    }
}
 
Example #9
Source File: DialogOrContactPickerActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void showBlockAlert(TLRPC.User user) {
    if (user == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("BlockUser", R.string.BlockUser));
    builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("AreYouSureBlockContact2", R.string.AreYouSureBlockContact2, ContactsController.formatName(user.first_name, user.last_name))));
    builder.setPositiveButton(LocaleController.getString("BlockContact", R.string.BlockContact), (dialogInterface, i) -> {
        if (MessagesController.isSupportUser(user)) {
            AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("ErrorOccurred", R.string.ErrorOccurred));
        } else {
            MessagesController.getInstance(currentAccount).blockUser(user.id);
            AlertsCreator.showSimpleToast(DialogOrContactPickerActivity.this, LocaleController.getString("UserBlocked", R.string.UserBlocked));
        }
        finishFragment();
    });
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    AlertDialog dialog = builder.create();
    showDialog(dialog);
    TextView button = (TextView) dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    if (button != null) {
        button.setTextColor(Theme.getColor(Theme.key_dialogTextRed2));
    }
}
 
Example #10
Source File: EditTextSettingsCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public EditTextSettingsCell(Context context) {
    super(context);

    textView = new EditText(context);
    textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
    textView.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    textView.setBackgroundDrawable(null);
    textView.setPadding(0, 0, 0, 0);
    textView.setInputType(textView.getInputType() |EditorInfo.TYPE_TEXT_FLAG_CAP_SENTENCES);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 17, 0, 17, 0));
}
 
Example #11
Source File: LocationActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void showPermissionAlert(boolean byButton) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    if (byButton) {
        builder.setMessage(LocaleController.getString("PermissionNoLocationPosition", R.string.PermissionNoLocationPosition));
    } else {
        builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation));
    }
    builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
        if (getParentActivity() == null) {
            return;
        }
        try {
            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            getParentActivity().startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    });
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
Example #12
Source File: ChatUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean checkDiscard() {
    String newBannedRights = ChatObject.getBannedRightsString(defaultBannedRights);
    if (!newBannedRights.equals(initialBannedRights) || initialSlowmode != selectedSlowmode) {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("UserRestrictionsApplyChanges", R.string.UserRestrictionsApplyChanges));
        if (isChannel) {
            builder.setMessage(LocaleController.getString("ChannelSettingsChangedAlert", R.string.ChannelSettingsChangedAlert));
        } else {
            builder.setMessage(LocaleController.getString("GroupSettingsChangedAlert", R.string.GroupSettingsChangedAlert));
        }
        builder.setPositiveButton(LocaleController.getString("ApplyTheme", R.string.ApplyTheme), (dialogInterface, i) -> processDone());
        builder.setNegativeButton(LocaleController.getString("PassportDiscard", R.string.PassportDiscard), (dialog, which) -> finishFragment());
        showDialog(builder.create());
        return false;
    }
    return true;
}
 
Example #13
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateCurrentConnectionState() {
    String title = null;
    if (currentConnectionState == ConnectionsManager.ConnectionStateWaitingForNetwork) {
        title = LocaleController.getString("WaitingForNetwork", R.string.WaitingForNetwork);
    } else if (currentConnectionState == ConnectionsManager.ConnectionStateConnecting) {
        title = LocaleController.getString("Connecting", R.string.Connecting);
    } else if (currentConnectionState == ConnectionsManager.ConnectionStateUpdating) {
        title = LocaleController.getString("Updating", R.string.Updating);
    } else if (currentConnectionState == ConnectionsManager.ConnectionStateConnectingToProxy) {
        title = LocaleController.getString("ConnectingToProxy", R.string.ConnectingToProxy);
    }
    if (title == null) {
        if (lastSubtitle != null) {
            subtitleTextView.setText(lastSubtitle);
            lastSubtitle = null;
        }
    } else {
        lastSubtitle = subtitleTextView.getText();
        subtitleTextView.setText(title);
    }
}
 
Example #14
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateEmptyPlaceholder() {
    if (emptyView == null) {
        return;
    }
    if (!TextUtils.isEmpty(searchQuery)) {
        emptyView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(5), AndroidUtilities.dp(8), AndroidUtilities.dp(5));
        emptyView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("EventLogEmptyTextSearch", R.string.EventLogEmptyTextSearch, searchQuery)));
    } else if (selectedAdmins != null || currentFilter != null) {
        emptyView.setPadding(AndroidUtilities.dp(8), AndroidUtilities.dp(5), AndroidUtilities.dp(8), AndroidUtilities.dp(5));
        emptyView.setText(AndroidUtilities.replaceTags(LocaleController.getString("EventLogEmptySearch", R.string.EventLogEmptySearch)));
    } else {
        emptyView.setPadding(AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16), AndroidUtilities.dp(16));
        if (currentChat.megagroup) {
            emptyView.setText(AndroidUtilities.replaceTags(LocaleController.getString("EventLogEmpty", R.string.EventLogEmpty)));
        } else {
            emptyView.setText(AndroidUtilities.replaceTags(LocaleController.getString("EventLogEmptyChannel", R.string.EventLogEmptyChannel)));
        }
    }
}
 
Example #15
Source File: ChannelAdminLogActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url, null) || !ask) {
        Browser.openUrl(getParentActivity(), url, true);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert", R.string.OpenUrlAlert, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                Browser.openUrl(getParentActivity(), url, true);
            }
        });
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}
 
Example #16
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateKeyView() {
    if (VoIPService.getSharedInstance() == null)
        return;
    IdenticonDrawable img = new IdenticonDrawable();
    img.setColors(new int[]{0x00FFFFFF, 0xFFFFFFFF, 0x99FFFFFF, 0x33FFFFFF});
    TLRPC.EncryptedChat encryptedChat = new TLRPC.TL_encryptedChat();
    try {
        ByteArrayOutputStream buf = new ByteArrayOutputStream();
        buf.write(VoIPService.getSharedInstance().getEncryptionKey());
        buf.write(VoIPService.getSharedInstance().getGA());
        encryptedChat.auth_key = buf.toByteArray();
    } catch (Exception checkedExceptionsAreBad) {
    }
    byte[] sha256 = Utilities.computeSHA256(encryptedChat.auth_key, 0, encryptedChat.auth_key.length);
    String[] emoji = EncryptionKeyEmojifier.emojifyForCall(sha256);
    //keyEmojiText.setText(Emoji.replaceEmoji(TextUtils.join(" ", emoji), keyEmojiText.getPaint().getFontMetricsInt(), AndroidUtilities.dp(32), false));
    emojiWrap.setContentDescription(LocaleController.getString("EncryptionKey", R.string.EncryptionKey) + ", " + TextUtils.join(", ", emoji));
    for (int i = 0; i < 4; i++) {
        Drawable drawable = Emoji.getEmojiDrawable(emoji[i]);
        if (drawable != null) {
            drawable.setBounds(0, 0, AndroidUtilities.dp(22), AndroidUtilities.dp(22));
            keyEmojiViews[i].setImageDrawable(drawable);
        }
    }
}
 
Example #17
Source File: LocationDirectionCell.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public LocationDirectionCell(Context context) {
    super(context);

    frameLayout = new FrameLayout(context);
    frameLayout.setBackgroundDrawable(Theme.createSimpleSelectorRoundRectDrawable(AndroidUtilities.dp(4), Theme.getColor(Theme.key_featuredStickers_addButton), Theme.getColor(Theme.key_featuredStickers_addButtonPressed)));
    addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.LEFT | Gravity.TOP, 16, 10, 16, 0));

    buttonTextView = new SimpleTextView(context);
    buttonTextView.setPadding(AndroidUtilities.dp(34), 0, AndroidUtilities.dp(34), 0);
    buttonTextView.setGravity(Gravity.CENTER);
    buttonTextView.setDrawablePadding(AndroidUtilities.dp(8));
    buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText));
    buttonTextView.setTextSize(14);
    buttonTextView.setText(LocaleController.getString("Directions", R.string.Directions));
    buttonTextView.setLeftDrawable(R.drawable.navigate);
    buttonTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    frameLayout.addView(buttonTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
 
Example #18
Source File: CheckBoxUserCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public CheckBoxUserCell(Context context, boolean alert) {
    super(context);

    textView = new TextView(context);
    textView.setTextColor(Theme.getColor(alert ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setLines(1);
    textView.setMaxLines(1);
    textView.setSingleLine(true);
    textView.setEllipsize(TextUtils.TruncateAt.END);
    textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
    addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 94), 0, (LocaleController.isRTL ? 94 : 17), 0));

    avatarDrawable = new AvatarDrawable();
    imageView = new BackupImageView(context);
    imageView.setRoundRadius(AndroidUtilities.dp(36));
    addView(imageView, LayoutHelper.createFrame(36, 36, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 48, 6, 48, 0));

    checkBox = new CheckBoxSquare(context, alert);
    addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 15, (LocaleController.isRTL ? 17 : 0), 0));
}
 
Example #19
Source File: ContactAddActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
    if (user == null) {
        return;
    }
    nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));

    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    avatarImage.setImage(photo, "50_50", avatarDrawable = new AvatarDrawable(user));
}
 
Example #20
Source File: PasscodeActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void processNext() {
    if (passwordEditText.getText().length() == 0 || currentPasswordType == 0 && passwordEditText.getText().length() != 4) {
        onPasscodeError();
        return;
    }
    if (currentPasswordType == 0) {
        actionBar.setTitle(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
    } else {
        actionBar.setTitle(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
    }
    dropDownContainer.setVisibility(View.GONE);
    titleTextView.setText(LocaleController.getString("ReEnterYourPasscode", R.string.ReEnterYourPasscode));
    firstPassword = passwordEditText.getText().toString();
    passwordEditText.setText("");
    passcodeSetStep = 1;
}
 
Example #21
Source File: ProfileActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void leaveChatPressed()
{
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    if (ChatObject.isChannel(chat_id, currentAccount) && !currentChat.megagroup)
    {
        builder.setMessage(ChatObject.isChannel(chat_id, currentAccount) ? LocaleController.getString("ChannelLeaveAlert", R.string.ChannelLeaveAlert) : LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
    }
    else
    {
        builder.setMessage(LocaleController.getString("AreYouSureDeleteAndExit", R.string.AreYouSureDeleteAndExit));
    }
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> kickUser(0));
    builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
    showDialog(builder.create());
}
 
Example #22
Source File: UserCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public void setAvatarPadding(int padding) {
    LayoutParams layoutParams = (LayoutParams) avatarImageView.getLayoutParams();
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 7 + padding);
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 7 + padding : 0);
    avatarImageView.setLayoutParams(layoutParams);

    layoutParams = (LayoutParams) nameTextView.getLayoutParams();
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 28 + (checkBoxBig != null ? 18 : 0) : (64 + padding));
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (64 + padding) : 28 + (checkBoxBig != null ? 18 : 0));

    layoutParams = (FrameLayout.LayoutParams) statusTextView.getLayoutParams();
    layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 28 : (64 + padding));
    layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? (64 + padding) : 28);

    if (checkBox != null) {
        layoutParams = (FrameLayout.LayoutParams) checkBox.getLayoutParams();
        layoutParams.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 37 + padding);
        layoutParams.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 37 + padding : 0);
    }
}
 
Example #23
Source File: SettingsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateUserData() {
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
    TLRPC.FileLocation photo = null;
    TLRPC.FileLocation photoBig = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
        photoBig = user.photo.photo_big;
    }
    avatarDrawable = new AvatarDrawable(user, true);

    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    if (avatarImage != null) {
        avatarImage.setImage(photo, "50_50", avatarDrawable);
        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);

        nameTextView.setText(UserObject.getUserName(user));
        onlineTextView.setText(LocaleController.getString("Online", R.string.Online));

        avatarImage.getImageReceiver().setVisible(!PhotoViewer.isShowingImage(photoBig), false);
    }
}
 
Example #24
Source File: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom)
{
    if (currentDialogId == 0 && customDialog == null)
    {
        return;
    }
    if (checkBox != null)
    {
        int x = LocaleController.isRTL ? (right - left) - AndroidUtilities.dp(42) : AndroidUtilities.dp(42);
        int y = AndroidUtilities.dp(43);
        checkBox.layout(x, y, x + checkBox.getMeasuredWidth(), y + checkBox.getMeasuredHeight());
    }
    if (changed)
    {
        try
        {
            buildLayout();
        }
        catch (Exception e)
        {
            FileLog.e(e);
        }
    }
}
 
Example #25
Source File: RecyclerListView.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    super.onLayout(changed, l, t, r, b);
    if (fastScroll != null) {
        selfOnLayout = true;
        t += getPaddingTop();
        if (LocaleController.isRTL) {
            fastScroll.layout(0, t, fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        } else {
            int x = getMeasuredWidth() - fastScroll.getMeasuredWidth();
            fastScroll.layout(x, t, x + fastScroll.getMeasuredWidth(), t + fastScroll.getMeasuredHeight());
        }
        selfOnLayout = false;
    }
    checkSection();
    if (pendingHighlightPosition != null) {
        highlightRowInternal(pendingHighlightPosition, false);
    }
}
 
Example #26
Source File: ThemeActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void showPermissionAlert(boolean byButton) {
    if (getParentActivity() == null) {
        return;
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    if (byButton) {
        builder.setMessage(LocaleController.getString("PermissionNoLocationPosition", R.string.PermissionNoLocationPosition));
    } else {
        builder.setMessage(LocaleController.getString("PermissionNoLocation", R.string.PermissionNoLocation));
    }
    builder.setNegativeButton(LocaleController.getString("PermissionOpenSettings", R.string.PermissionOpenSettings), (dialog, which) -> {
        if (getParentActivity() == null) {
            return;
        }
        try {
            Intent intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
            intent.setData(Uri.parse("package:" + ApplicationLoader.applicationContext.getPackageName()));
            getParentActivity().startActivity(intent);
        } catch (Exception e) {
            FileLog.e(e);
        }
    });
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    showDialog(builder.create());
}
 
Example #27
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static void showFloodWaitAlert(String error, final BaseFragment fragment)
{
    if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null)
    {
        return;
    }
    int time = Utilities.parseInt(error);
    String timeString;
    if (time < 60)
    {
        timeString = LocaleController.formatPluralString("Seconds", time);
    }
    else
    {
        timeString = LocaleController.formatPluralString("Minutes", time / 60);
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity());
    builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
    builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString));
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
    fragment.showDialog(builder.create(), true, null);
}
 
Example #28
Source File: AboutLinkCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    canvas.save();
    canvas.translate(textX = AndroidUtilities.dp(LocaleController.isRTL ? 16 : 71), textY = AndroidUtilities.dp(8));
    if (pressedLink != null) {
        canvas.drawPath(urlPath, Theme.linkSelectionPaint);
    }
    try {
        if (textLayout != null) {
            textLayout.draw(canvas);
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    canvas.restore();
}
 
Example #29
Source File: TextCheckCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
    super.onInitializeAccessibilityNodeInfo(info);
    info.setClassName("android.widget.Switch");
    info.setCheckable(true);
    info.setChecked(checkBox.isChecked());
    info.setContentDescription(checkBox.isChecked() ? LocaleController.getString("NotificationsOn", R.string.NotificationsOn) : LocaleController.getString("NotificationsOff", R.string.NotificationsOff));
}
 
Example #30
Source File: ChannelAdminLogActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void showOpenUrlAlert(final String url, boolean ask) {
    if (Browser.isInternalUrl(url, null) || !ask) {
        Browser.openUrl(getParentActivity(), url, true);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
        builder.setTitle(LocaleController.getString("OpenUrlTitle", R.string.OpenUrlTitle));
        builder.setMessage(LocaleController.formatString("OpenUrlAlert2", R.string.OpenUrlAlert2, url));
        builder.setPositiveButton(LocaleController.getString("Open", R.string.Open), (dialogInterface, i) -> Browser.openUrl(getParentActivity(), url, true));
        builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
        showDialog(builder.create());
    }
}