org.telegram.messenger.SharedConfig Java Examples

The following examples show how to use org.telegram.messenger.SharedConfig. 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: ChatListCell.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public ListView(Context context, boolean threeLines) {
    super(context);
    setWillNotDraw(false);

    isThreeLines = threeLines;

    textPaint.setTextSize(AndroidUtilities.dp(13));

    button = new RadioButton(context) {
        @Override
        public void invalidate() {
            super.invalidate();
            ListView.this.invalidate();
        }
    };
    button.setSize(AndroidUtilities.dp(20));
    addView(button, LayoutHelper.createFrame(22, 22, Gravity.RIGHT | Gravity.TOP, 0, 26, 10, 0));
    button.setChecked(isThreeLines && SharedConfig.useThreeLinesLayout || !isThreeLines && !SharedConfig.useThreeLinesLayout, false);
}
 
Example #2
Source File: ProxyListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void checkProxyList() {
    for (int a = 0, count = SharedConfig.proxyList.size(); a < count; a++) {
        final SharedConfig.ProxyInfo proxyInfo = SharedConfig.proxyList.get(a);
        if (proxyInfo.checking || SystemClock.elapsedRealtime() - proxyInfo.availableCheckTime < 2 * 60 * 1000) {
            continue;
        }
        proxyInfo.checking = true;
        proxyInfo.proxyCheckPingId = ConnectionsManager.getInstance(currentAccount).checkProxy(proxyInfo.address, proxyInfo.port, proxyInfo.username, proxyInfo.password, proxyInfo.secret, time -> AndroidUtilities.runOnUIThread(() -> {
            proxyInfo.availableCheckTime = SystemClock.elapsedRealtime();
            proxyInfo.checking = false;
            if (time == -1) {
                proxyInfo.available = false;
                proxyInfo.ping = 0;
            } else {
                proxyInfo.ping = time;
                proxyInfo.available = true;
            }
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo);
        }));
    }
}
 
Example #3
Source File: LogoutActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();

    rowCount = 0;
    alternativeHeaderRow = rowCount++;
    if (UserConfig.getActivatedAccountsCount() < UserConfig.MAX_ACCOUNT_COUNT) {
        addAccountRow = rowCount++;
    } else {
        addAccountRow = -1;
    }
    if (SharedConfig.passcodeHash.length() <= 0) {
        passcodeRow = rowCount++;
    } else {
        passcodeRow = -1;
    }
    cacheRow = rowCount++;
    phoneRow = rowCount++;
    supportRow = rowCount++;
    alternativeSectionRow = rowCount++;
    logoutRow = rowCount++;
    logoutSectionRow = rowCount++;

    return true;
}
 
Example #4
Source File: StickersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void checkActionMode() {
    final int selectedCount = listAdapter.getSelectedCount();
    final boolean actionModeShowed = actionBar.isActionModeShowed();
    if (selectedCount > 0) {
        checkActionModeIcons();
        selectedCountTextView.setNumber(selectedCount, actionModeShowed);
        if (!actionModeShowed) {
            actionBar.showActionMode();
            notifyStickersItemsChanged(UPDATE_REORDERABLE);
            if (!SharedConfig.stickersReorderingHintUsed) {
                SharedConfig.setStickersReorderingHintUsed(true);
                final String stickersReorderHint = LocaleController.getString("StickersReorderHint", R.string.StickersReorderHint);
                Bulletin.make(parentLayout, new ReorderingBulletinLayout(mContext, stickersReorderHint), ReorderingHintDrawable.DURATION * 2 + 250).show();
            }
        }
    } else if (actionModeShowed) {
        actionBar.hideActionMode();
        notifyStickersItemsChanged(UPDATE_REORDERABLE);
    }
}
 
Example #5
Source File: ThemeActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateMenuItem() {
    if (menuItem == null) {
        return;
    }
    Theme.ThemeInfo themeInfo = Theme.getCurrentTheme();
    Theme.ThemeAccent accent = themeInfo.getAccent(false);
    if (themeInfo.themeAccents != null && !themeInfo.themeAccents.isEmpty() && accent != null && accent.id >= 100) {
        menuItem.showSubItem(share_theme);
        menuItem.showSubItem(edit_theme);
    } else {
        menuItem.hideSubItem(share_theme);
        menuItem.hideSubItem(edit_theme);
    }
    int fontSize = AndroidUtilities.isTablet() ? 18 : 16;
    Theme.ThemeInfo currentTheme = Theme.getCurrentTheme();
    if (SharedConfig.fontSize != fontSize || SharedConfig.bubbleRadius != 10 || !currentTheme.firstAccentIsDefault || currentTheme.currentAccentId != Theme.DEFALT_THEME_ACCENT_ID) {
        menuItem.showSubItem(reset_settings);
    } else {
        menuItem.hideSubItem(reset_settings);
    }
}
 
Example #6
Source File: PaymentFormActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
    if (Build.VERSION.SDK_INT >= 23) {
        try {
            if ((currentStep == 2 || currentStep == 6) && !paymentForm.invoice.test) {
                getParentActivity().getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
            } else if (SharedConfig.passcodeHash.length() == 0 || SharedConfig.allowScreenCapture) {
                getParentActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_SECURE);
            }
        } catch (Throwable e) {
            FileLog.e(e);
        }
    }
}
 
Example #7
Source File: ProxyListActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();

    SharedConfig.loadProxyList();
    currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();

    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxyCheckDone);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didUpdateConnectionState);

    final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    useProxySettings = preferences.getBoolean("proxy_enabled", false) && !SharedConfig.proxyList.isEmpty();
    useProxyForCalls = preferences.getBoolean("proxy_enabled_calls", false);

    updateRows(true);

    return true;
}
 
Example #8
Source File: URLSpanMono.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void updateDrawState(TextPaint p) {
    p.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - 1));
    if (currentType == 2) {
        p.setColor(0xffffffff);
    } else if (currentType == 1) {
        p.setColor(Theme.getColor(Theme.key_chat_messageTextOut));
    } else {
        p.setColor(Theme.getColor(Theme.key_chat_messageTextIn));
    }
    if (style != null) {
        style.applyStyle(p);
    } else {
        p.setTypeface(Typeface.MONOSPACE);
        p.setUnderlineText(false);
    }
}
 
Example #9
Source File: PasscodeActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateDropDownTextView() {
    if (dropDown != null) {
        if (currentPasswordType == 0) {
            dropDown.setText(LocaleController.getString("PasscodePIN", R.string.PasscodePIN));
        } else if (currentPasswordType == 1) {
            dropDown.setText(LocaleController.getString("PasscodePassword", R.string.PasscodePassword));
        }
    }
    if (type == 1 && currentPasswordType == 0 || type == 2 && SharedConfig.passcodeType == 0) {
        InputFilter[] filterArray = new InputFilter[1];
        filterArray[0] = new InputFilter.LengthFilter(4);
        passwordEditText.setFilters(filterArray);
        passwordEditText.setInputType(InputType.TYPE_CLASS_PHONE);
        passwordEditText.setKeyListener(DigitsKeyListener.getInstance("1234567890"));
    } else if (type == 1 && currentPasswordType == 1 || type == 2 && SharedConfig.passcodeType == 1) {
        passwordEditText.setFilters(new InputFilter[0]);
        passwordEditText.setKeyListener(null);
        passwordEditText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
    }
    passwordEditText.setTransformationMethod(PasswordTransformationMethod.getInstance());
}
 
Example #10
Source File: ProxyListActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate()
{
    super.onFragmentCreate();

    SharedConfig.loadProxyList();
    currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();

    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxyCheckDone);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didUpdatedConnectionState);

    final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    useProxySettings = preferences.getBoolean("proxy_enabled", false) && !SharedConfig.proxyList.isEmpty();
    useProxyForCalls = preferences.getBoolean("proxy_enabled_calls", false);

    updateRows(true);

    return true;
}
 
Example #11
Source File: ThemeActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateMenuItem() {
    if (menuItem == null) {
        return;
    }
    Theme.ThemeInfo themeInfo = Theme.getCurrentTheme();
    Theme.ThemeAccent accent = themeInfo.getAccent(false);
    if (themeInfo.themeAccents != null && !themeInfo.themeAccents.isEmpty() && accent != null && accent.id >= 100) {
        menuItem.showSubItem(share_theme);
        menuItem.showSubItem(edit_theme);
    } else {
        menuItem.hideSubItem(share_theme);
        menuItem.hideSubItem(edit_theme);
    }
    int fontSize = AndroidUtilities.isTablet() ? 18 : 16;
    Theme.ThemeInfo currentTheme = Theme.getCurrentTheme();
    if (SharedConfig.fontSize != fontSize || SharedConfig.bubbleRadius != 10 || !currentTheme.firstAccentIsDefault || currentTheme.currentAccentId != Theme.DEFALT_THEME_ACCENT_ID) {
        menuItem.showSubItem(reset_settings);
    } else {
        menuItem.hideSubItem(reset_settings);
    }
}
 
Example #12
Source File: PasscodeView.java    From Telegram-FOSS 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) {
    View rootView = getRootView();
    int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
    getWindowVisibleDisplayFrame(rect);
    keyboardHeight = usableViewHeight - (rect.bottom - rect.top);

    if (SharedConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) {
        int t = 0;
        if (passwordFrameLayout.getTag() != null) {
            t = (Integer) passwordFrameLayout.getTag();
        }
        LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
        layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
        passwordFrameLayout.setLayoutParams(layoutParams);
    }

    super.onLayout(changed, left, top, right, bottom);
}
 
Example #13
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void onResume() {
    checkRetryTextView();
    if (retryTextView.getVisibility() != VISIBLE) {
        if (SharedConfig.passcodeType == 1) {
            if (passwordEditText != null) {
                passwordEditText.requestFocus();
                AndroidUtilities.showKeyboard(passwordEditText);
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (retryTextView.getVisibility() != VISIBLE && passwordEditText != null) {
                        passwordEditText.requestFocus();
                        AndroidUtilities.showKeyboard(passwordEditText);
                    }
                }
            }, 200);
        }
        checkFingerprint();
    }
}
 
Example #14
Source File: LogoutActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate() {
    super.onFragmentCreate();

    rowCount = 0;
    alternativeHeaderRow = rowCount++;
    if (UserConfig.getActivatedAccountsCount() < UserConfig.MAX_ACCOUNT_COUNT) {
        addAccountRow = rowCount++;
    } else {
        addAccountRow = -1;
    }
    if (SharedConfig.passcodeHash.length() <= 0) {
        passcodeRow = rowCount++;
    } else {
        passcodeRow = -1;
    }
    cacheRow = rowCount++;
    phoneRow = rowCount++;
    supportRow = rowCount++;
    alternativeSectionRow = rowCount++;
    logoutRow = rowCount++;
    logoutSectionRow = rowCount++;

    return true;
}
 
Example #15
Source File: ThemeActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private boolean setFontSize(int size) {
    if (size != SharedConfig.fontSize) {
        SharedConfig.fontSize = size;
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt("fons_size", SharedConfig.fontSize);
        editor.commit();
        Theme.chat_msgTextPaint.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize));

        RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(textSizeRow);
        if (holder != null && holder.itemView instanceof TextSizeCell) {
            TextSizeCell cell = (TextSizeCell) holder.itemView;
            ChatMessageCell[] cells = cell.messagesCell.getCells();
            for (int a = 0; a < cells.length; a++) {
                cells[a].getMessageObject().resetLayout();
                cells[a].requestLayout();
            }
        }
        updateMenuItem();
        return true;
    }
    return false;
}
 
Example #16
Source File: DialogsActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updatePasscodeButton()
{
    if (passcodeItem == null)
    {
        return;
    }
    if (SharedConfig.passcodeHash.length() != 0 && !searching)
    {
        passcodeItem.setVisibility(View.VISIBLE);
        if (SharedConfig.appLocked)
        {
            passcodeItem.setIcon(R.drawable.lock_close);
        }
        else
        {
            passcodeItem.setIcon(R.drawable.lock_open);
        }
    }
    else
    {
        passcodeItem.setVisibility(View.GONE);
    }
}
 
Example #17
Source File: DataSettingsActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onViewAttachedToWindow(RecyclerView.ViewHolder holder) {
    int viewType = holder.getItemViewType();
    if (viewType == 3) {
        TextCheckCell checkCell = (TextCheckCell) holder.itemView;
        int position = holder.getAdapterPosition();
        if (position == enableCacheStreamRow) {
            checkCell.setChecked(SharedConfig.saveStreamMedia);
        } else if (position == enableStreamRow) {
            checkCell.setChecked(SharedConfig.streamMedia);
        } else if (position == enableAllStreamRow) {
            checkCell.setChecked(SharedConfig.streamAllVideo);
        } else if (position == enableMkvRow) {
            checkCell.setChecked(SharedConfig.streamMkv);
        } else if (position == autoplayGifsRow) {
            checkCell.setChecked(SharedConfig.autoplayGifs);
        } else if (position == autoplayVideoRow) {
            checkCell.setChecked(SharedConfig.autoplayVideo);
        }
    }
}
 
Example #18
Source File: ProxyListActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean onFragmentCreate()
{
    super.onFragmentCreate();

    SharedConfig.loadProxyList();
    currentConnectionState = ConnectionsManager.getInstance(currentAccount).getConnectionState();

    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxySettingsChanged);
    NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.proxyCheckDone);
    NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.didUpdatedConnectionState);

    final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    useProxySettings = preferences.getBoolean("proxy_enabled", false) && !SharedConfig.proxyList.isEmpty();
    useProxyForCalls = preferences.getBoolean("proxy_enabled_calls", false);

    updateRows(true);

    return true;
}
 
Example #19
Source File: AudioPlayerAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateRepeatButton() {
    int mode = SharedConfig.repeatMode;
    if (mode == 0) {
        repeatButton.setImageResource(R.drawable.pl_repeat);
        repeatButton.setTag(Theme.key_player_button);
        repeatButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_player_button), PorterDuff.Mode.MULTIPLY));
    } else if (mode == 1) {
        repeatButton.setImageResource(R.drawable.pl_repeat);
        repeatButton.setTag(Theme.key_player_buttonActive);
        repeatButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_player_buttonActive), PorterDuff.Mode.MULTIPLY));
    } else if (mode == 2) {
        repeatButton.setImageResource(R.drawable.pl_repeat1);
        repeatButton.setTag(Theme.key_player_buttonActive);
        repeatButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_player_buttonActive), PorterDuff.Mode.MULTIPLY));
    }
}
 
Example #20
Source File: AudioPlayerAlert.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 1) {
        AudioPlayerCell cell = (AudioPlayerCell) holder.itemView;
        if (searchWas) {
            cell.setMessageObject(searchResult.get(position));
        } else if (searching) {
            if (SharedConfig.playOrderReversed) {
                cell.setMessageObject(playlist.get(position));
            } else {
                cell.setMessageObject(playlist.get(playlist.size() - position - 1));
            }
        } else if (position > 0) {
            if (SharedConfig.playOrderReversed) {
                cell.setMessageObject(playlist.get(position - 1));
            } else {
                cell.setMessageObject(playlist.get(playlist.size() - position));
            }
        }
    }
}
 
Example #21
Source File: PasscodeView.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void onResume() {
    checkRetryTextView();
    if (retryTextView.getVisibility() != VISIBLE) {
        if (SharedConfig.passcodeType == 1) {
            if (passwordEditText != null) {
                passwordEditText.requestFocus();
                AndroidUtilities.showKeyboard(passwordEditText);
            }
            AndroidUtilities.runOnUIThread(new Runnable() {
                @Override
                public void run() {
                    if (retryTextView.getVisibility() != VISIBLE && passwordEditText != null) {
                        passwordEditText.requestFocus();
                        AndroidUtilities.showKeyboard(passwordEditText);
                    }
                }
            }, 200);
        }
        checkFingerprint();
    }
}
 
Example #22
Source File: PasscodeView.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) {
    View rootView = getRootView();
    int usableViewHeight = rootView.getHeight() - AndroidUtilities.statusBarHeight - AndroidUtilities.getViewInset(rootView);
    getWindowVisibleDisplayFrame(rect);
    keyboardHeight = usableViewHeight - (rect.bottom - rect.top);

    if (SharedConfig.passcodeType == 1 && (AndroidUtilities.isTablet() || getContext().getResources().getConfiguration().orientation != Configuration.ORIENTATION_LANDSCAPE)) {
        int t = 0;
        if (passwordFrameLayout.getTag() != null) {
            t = (Integer) passwordFrameLayout.getTag();
        }
        LayoutParams layoutParams = (LayoutParams) passwordFrameLayout.getLayoutParams();
        layoutParams.topMargin = t + layoutParams.height - keyboardHeight / 2 - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
        passwordFrameLayout.setLayoutParams(layoutParams);
    }

    super.onLayout(changed, left, top, right, bottom);
}
 
Example #23
Source File: DrawerLayoutContainer.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (Build.VERSION.SDK_INT >= 21 && lastInsets != null) {
        WindowInsets insets = (WindowInsets) lastInsets;

        if (!SharedConfig.smoothKeyboard) {
            int bottomInset = insets.getSystemWindowInsetBottom();
            if (bottomInset > 0) {
                backgroundPaint.setColor(behindKeyboardColor);
                canvas.drawRect(0, getMeasuredHeight() - bottomInset, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }

        if (hasCutout) {
            backgroundPaint.setColor(0xff000000);
            int left = insets.getSystemWindowInsetLeft();
            if (left != 0) {
                canvas.drawRect(0, 0, left, getMeasuredHeight(), backgroundPaint);
            }
            int right = insets.getSystemWindowInsetRight();
            if (right != 0) {
                canvas.drawRect(right, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
            }
        }
    }
}
 
Example #24
Source File: ThemeActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private boolean setFontSize(int size) {
    if (size != SharedConfig.fontSize) {
        SharedConfig.fontSize = size;
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        SharedPreferences.Editor editor = preferences.edit();
        editor.putInt("fons_size", SharedConfig.fontSize);
        editor.commit();
        Theme.chat_msgTextPaint.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize));

        RecyclerView.ViewHolder holder = listView.findViewHolderForAdapterPosition(textSizeRow);
        if (holder != null && holder.itemView instanceof TextSizeCell) {
            TextSizeCell cell = (TextSizeCell) holder.itemView;
            ChatMessageCell[] cells = cell.messagesCell.getCells();
            for (int a = 0; a < cells.length; a++) {
                cells[a].getMessageObject().resetLayout();
                cells[a].requestLayout();
            }
        }
        updateMenuItem();
        return true;
    }
    return false;
}
 
Example #25
Source File: TextSelectionHelper.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onTextSelected(ChatMessageCell newView, ChatMessageCell oldView) {
    boolean idChanged = oldView == null || (oldView.getMessageObject() != null && oldView.getMessageObject().getId() != newView.getMessageObject().getId());
    selectedCellId = newView.getMessageObject().getId();
    enterProgress = 0;
    isDescription = maybeIsDescription;

    Animator oldAnimator = animatorSparseArray.get(selectedCellId);
    if (oldAnimator != null) {
        oldAnimator.removeAllListeners();
        oldAnimator.cancel();
    }

    ValueAnimator animator = ValueAnimator.ofFloat(0, 1f);
    animator.addUpdateListener(animation -> {
        enterProgress = (float) animation.getAnimatedValue();
        if (textSelectionOverlay != null) {
            textSelectionOverlay.invalidate();
        }
        if (selectedView != null && selectedView.getCurrentMessagesGroup() == null && idChanged) {
            selectedView.setSelectedBackgroundProgress(1f - enterProgress);
        }
    });
    animator.setDuration(250);
    animator.start();

    animatorSparseArray.put(selectedCellId, animator);

    if (!idChanged) {
        newView.setSelectedBackgroundProgress(0f);
    }

    SharedConfig.removeTextSelectionHint();
}
 
Example #26
Source File: ExternalActionActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void showPasscodeActivity() {
    if (passcodeView == null) {
        return;
    }
    SharedConfig.appLocked = true;
    if (SecretMediaViewer.hasInstance() && SecretMediaViewer.getInstance().isVisible()) {
        SecretMediaViewer.getInstance().closePhoto(false, false);
    } else if (PhotoViewer.hasInstance() && PhotoViewer.getInstance().isVisible()) {
        PhotoViewer.getInstance().closePhoto(false, true);
    } else if (ArticleViewer.hasInstance() && ArticleViewer.getInstance().isVisible()) {
        ArticleViewer.getInstance().close(false, true);
    }
    passcodeView.onShow();
    SharedConfig.isWaitingForPasscodeEnter = true;
    drawerLayoutContainer.setAllowOpenDrawer(false, false);
    passcodeView.setDelegate(() -> {
        SharedConfig.isWaitingForPasscodeEnter = false;
        if (passcodeSaveIntent != null) {
            handleIntent(passcodeSaveIntent, passcodeSaveIntentIsNew, passcodeSaveIntentIsRestore, true, passcodeSaveIntentAccount, passcodeSaveIntentState);
            passcodeSaveIntent = null;
        }
        drawerLayoutContainer.setAllowOpenDrawer(true, false);
        actionBarLayout.showLastFragment();
        if (AndroidUtilities.isTablet()) {
            layersActionBarLayout.showLastFragment();
        }
    });
}
 
Example #27
Source File: ChatAttachAlert.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public void checkCamera(boolean request) {
    if (baseFragment == null) {
        return;
    }
    boolean old = deviceHasGoodCamera;
    if (!SharedConfig.inappCamera) {
        deviceHasGoodCamera = false;
    } else {
        if (Build.VERSION.SDK_INT >= 23) {
            if (baseFragment.getParentActivity().checkSelfPermission(Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) {
                if (request) {
                    try {
                        baseFragment.getParentActivity().requestPermissions(new String[]{Manifest.permission.CAMERA}, 17);
                    } catch (Exception ignore) {

                    }
                }
                deviceHasGoodCamera = false;
            } else {
                if (request || SharedConfig.hasCameraCache) {
                    CameraController.getInstance().initCamera(null);
                }
                deviceHasGoodCamera = CameraController.getInstance().isCameraInitied();
            }
        } else {
            if (request || SharedConfig.hasCameraCache) {
                CameraController.getInstance().initCamera(null);
            }
            deviceHasGoodCamera = CameraController.getInstance().isCameraInitied();
        }
    }
    if (old != deviceHasGoodCamera && photoAttachAdapter != null) {
        photoAttachAdapter.notifyDataSetChanged();
    }
    if (isShowing() && deviceHasGoodCamera && baseFragment != null && backDrawable.getAlpha() != 0 && !revealAnimationInProgress && !cameraOpened) {
        showCamera();
    }
}
 
Example #28
Source File: URLSpanMono.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void updateDrawState(TextPaint ds) {
    ds.setTextSize(AndroidUtilities.dp(SharedConfig.fontSize - 1));
    ds.setTypeface(Typeface.MONOSPACE);
    ds.setUnderlineText(false);
    if (currentType == 2) {
        ds.setColor(0xffffffff);
    } else if (currentType == 1) {
        ds.setColor(Theme.getColor(Theme.key_chat_messageTextOut));
    } else {
        ds.setColor(Theme.getColor(Theme.key_chat_messageTextIn));
    }
}
 
Example #29
Source File: ProxyListActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
private void checkProxyList()
{
    for (int a = 0, count = SharedConfig.proxyList.size(); a < count; a++)
    {
        final SharedConfig.ProxyInfo proxyInfo = SharedConfig.proxyList.get(a);
        if (proxyInfo.checking || SystemClock.elapsedRealtime() - proxyInfo.availableCheckTime < 2 * 60 * 1000)
        {
            continue;
        }
        proxyInfo.checking = true;
        proxyInfo.proxyCheckPingId = ConnectionsManager.getInstance(currentAccount).checkProxy(proxyInfo.address, proxyInfo.port, proxyInfo.username, proxyInfo.password, proxyInfo.secret, time -> AndroidUtilities.runOnUIThread(() ->
        {
            proxyInfo.availableCheckTime = SystemClock.elapsedRealtime();
            proxyInfo.checking = false;
            if (time == -1)
            {
                proxyInfo.available = false;
                proxyInfo.ping = 0;
            }
            else
            {
                proxyInfo.ping = time;
                proxyInfo.available = true;
            }
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.proxyCheckDone, proxyInfo);
        }));
    }
}
 
Example #30
Source File: TextSelectionHelper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onTextSelected(ChatMessageCell newView, ChatMessageCell oldView) {
    boolean idChanged = oldView == null || (oldView.getMessageObject() != null && oldView.getMessageObject().getId() != newView.getMessageObject().getId());
    selectedCellId = newView.getMessageObject().getId();
    enterProgress = 0;
    isDescription = maybeIsDescription;

    Animator oldAnimator = animatorSparseArray.get(selectedCellId);
    if (oldAnimator != null) {
        oldAnimator.removeAllListeners();
        oldAnimator.cancel();
    }

    ValueAnimator animator = ValueAnimator.ofFloat(0, 1f);
    animator.addUpdateListener(animation -> {
        enterProgress = (float) animation.getAnimatedValue();
        if (textSelectionOverlay != null) {
            textSelectionOverlay.invalidate();
        }
        if (selectedView != null && selectedView.getCurrentMessagesGroup() == null && idChanged) {
            selectedView.setSelectedBackgroundProgress(1f - enterProgress);
        }
    });
    animator.setDuration(250);
    animator.start();

    animatorSparseArray.put(selectedCellId, animator);

    if (!idChanged) {
        newView.setSelectedBackgroundProgress(0f);
    }

    SharedConfig.removeTextSelectionHint();
}