Java Code Examples for org.telegram.messenger.MessagesController#getGlobalMainSettings()

The following examples show how to use org.telegram.messenger.MessagesController#getGlobalMainSettings() . 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: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    Theme.ThemeInfo themeInfo = Theme.getActiveTheme();
    Theme.OverrideWallpaperInfo overrideWallpaper = themeInfo.overrideWallpaper;
    if (overrideWallpaper != null) {
        selectedBackgroundSlug = overrideWallpaper.slug;
        selectedColor = overrideWallpaper.color;
        selectedGradientColor = overrideWallpaper.gradientColor;
        selectedGradientRotation = overrideWallpaper.rotation;
        selectedIntensity = overrideWallpaper.intensity;
        selectedBackgroundMotion = overrideWallpaper.isMotion;
        selectedBackgroundBlurred = overrideWallpaper.isBlurred;
    } else {
        selectedBackgroundSlug = Theme.hasWallpaperFromTheme() ? Theme.THEME_BACKGROUND_SLUG :  Theme.DEFAULT_BACKGROUND_SLUG;
        selectedColor = 0;
        selectedGradientColor = 0;
        selectedGradientRotation = 45;
        selectedIntensity = 1.0f;
        selectedBackgroundMotion = false;
        selectedBackgroundBlurred = false;
    }
    fillWallpapersWithCustom();
    fixLayout();
}
 
Example 2
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 3
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 4
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 5
Source File: ProxyListActivity.java    From Telegram-FOSS 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 6
Source File: DialogsAdapter.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public DialogsAdapter(Context context, int type, int folder, boolean onlySelect, ArrayList<Long> selected) {
    mContext = context;
    dialogsType = type;
    folderId = folder;
    isOnlySelect = onlySelect;
    hasHints = folder == 0 && type == 0 && !onlySelect;
    selectedDialogs = selected;
    if (folderId == 1) {
        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        showArchiveHint = preferences.getBoolean("archivehint", true);
        preferences.edit().putBoolean("archivehint", false).commit();
        if (showArchiveHint) {
            archiveHintCell = new ArchiveHintCell(context);
        }
    }
}
 
Example 7
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 8
Source File: GroupStickersActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (listAdapter != null) {
        listAdapter.notifyDataSetChanged();
    }
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        usernameTextView.requestFocus();
        AndroidUtilities.showKeyboard(usernameTextView);
    }
}
 
Example 9
Source File: ReportOtherActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        firstNameField.requestFocus();
        AndroidUtilities.showKeyboard(firstNameField);
    }
}
 
Example 10
Source File: GroupStickersActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    if (listAdapter != null) {
        listAdapter.notifyDataSetChanged();
    }
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        usernameTextView.requestFocus();
        AndroidUtilities.showKeyboard(usernameTextView);
    }
}
 
Example 11
Source File: IntroActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void onDestroy()
{
    super.onDestroy();
    destroyed = true;
    NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.suggestedLangpack);
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    preferences.edit().putLong("intro_crashed_time", 0).apply();
}
 
Example 12
Source File: PrivacyControlActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void processDone() {
    if (getParentActivity() == null) {
        return;
    }

    if (currentType != 0 && rulesType == PRIVACY_RULES_TYPE_LASTSEEN) {
        final SharedPreferences preferences = MessagesController.getGlobalMainSettings();
        boolean showed = preferences.getBoolean("privacyAlertShowed", false);
        if (!showed) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
            if (rulesType == PRIVACY_RULES_TYPE_INVITE) {
                builder.setMessage(LocaleController.getString("WhoCanAddMeInfo", R.string.WhoCanAddMeInfo));
            } else {
                builder.setMessage(LocaleController.getString("CustomHelp", R.string.CustomHelp));
            }
            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialogInterface, i) -> {
                applyCurrentPrivacySettings();
                preferences.edit().putBoolean("privacyAlertShowed", true).commit();
            });
            builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
            showDialog(builder.create());
            return;
        }
    }
    applyCurrentPrivacySettings();
}
 
Example 13
Source File: ChangeNameActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume()
{
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations)
    {
        firstNameField.requestFocus();
        AndroidUtilities.showKeyboard(firstNameField);
    }
}
 
Example 14
Source File: ChangeUsernameActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        firstNameField.requestFocus();
        AndroidUtilities.showKeyboard(firstNameField);
    }
}
 
Example 15
Source File: ChangeUsernameActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        firstNameField.requestFocus();
        AndroidUtilities.showKeyboard(firstNameField);
    }
}
 
Example 16
Source File: ChangeNameActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onResume() {
    super.onResume();
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    boolean animations = preferences.getBoolean("view_animations", true);
    if (!animations) {
        firstNameField.requestFocus();
        AndroidUtilities.showKeyboard(firstNameField);
    }
}
 
Example 17
Source File: ConnectionsManager.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void switchBackend()
{
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    preferences.edit().remove("language_showed2").apply();
    native_switchBackend(currentAccount);
}
 
Example 18
Source File: AlertsCreator.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public static Dialog createFreeSpaceDialog(final LaunchActivity parentActivity)
{
    final int selected[] = new int[1];

    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    int keepMedia = preferences.getInt("keep_media", 2);
    if (keepMedia == 2)
    {
        selected[0] = 3;
    }
    else if (keepMedia == 0)
    {
        selected[0] = 1;
    }
    else if (keepMedia == 1)
    {
        selected[0] = 2;
    }
    else if (keepMedia == 3)
    {
        selected[0] = 0;
    }

    String[] descriptions = new String[]{
            LocaleController.formatPluralString("Days", 3),
            LocaleController.formatPluralString("Weeks", 1),
            LocaleController.formatPluralString("Months", 1),
            LocaleController.getString("LowDiskSpaceNeverRemove", R.string.LowDiskSpaceNeverRemove)
    };

    final LinearLayout linearLayout = new LinearLayout(parentActivity);
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    TextView titleTextView = new TextView(parentActivity);
    titleTextView.setText(LocaleController.getString("LowDiskSpaceTitle2", R.string.LowDiskSpaceTitle2));
    titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
    titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
    titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
    linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8));

    for (int a = 0; a < descriptions.length; a++)
    {
        RadioColorCell cell = new RadioColorCell(parentActivity);
        cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
        cell.setTag(a);
        cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
        cell.setTextAndValue(descriptions[a], selected[0] == a);
        linearLayout.addView(cell);
        cell.setOnClickListener(v ->
        {
            int num = (Integer) v.getTag();
            if (num == 0)
            {
                selected[0] = 3;
            }
            else if (num == 1)
            {
                selected[0] = 0;
            }
            else if (num == 2)
            {
                selected[0] = 1;
            }
            else if (num == 3)
            {
                selected[0] = 2;
            }
            int count = linearLayout.getChildCount();
            for (int a1 = 0; a1 < count; a1++)
            {
                View child = linearLayout.getChildAt(a1);
                if (child instanceof RadioColorCell)
                {
                    ((RadioColorCell) child).setChecked(child == v, true);
                }
            }
        });
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity);
    builder.setTitle(LocaleController.getString("LowDiskSpaceTitle", R.string.LowDiskSpaceTitle));
    builder.setMessage(LocaleController.getString("LowDiskSpaceMessage", R.string.LowDiskSpaceMessage));
    builder.setView(linearLayout);
    builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> MessagesController.getGlobalMainSettings().edit().putInt("keep_media", selected[0]).commit());
    builder.setNeutralButton(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), (dialog, which) -> parentActivity.presentFragment(new CacheControlActivity()));
    return builder.create();
}
 
Example 19
Source File: LoginActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void fillNumber()
{
    try
    {
        TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
        if (tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT && tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE)
        {
            boolean allowCall = true;
            boolean allowSms = true;
            if (Build.VERSION.SDK_INT >= 23)
            {
                allowCall = getParentActivity().checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
                allowSms = getParentActivity().checkSelfPermission(Manifest.permission.RECEIVE_SMS) == PackageManager.PERMISSION_GRANTED;
                if (checkShowPermissions && !allowCall && !allowSms)
                {
                    permissionsShowItems.clear();
                    if (!allowCall)
                    {
                        permissionsShowItems.add(Manifest.permission.READ_PHONE_STATE);
                    }
                    if (!allowSms)
                    {
                        permissionsShowItems.add(Manifest.permission.RECEIVE_SMS);
                        if (Build.VERSION.SDK_INT >= 23)
                        {
                            permissionsShowItems.add(Manifest.permission.READ_SMS);
                        }
                    }
                    if (!permissionsShowItems.isEmpty())
                    {
                        SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                        if (preferences.getBoolean("firstloginshow", true) || getParentActivity().shouldShowRequestPermissionRationale(Manifest.permission.READ_PHONE_STATE) || getParentActivity().shouldShowRequestPermissionRationale(Manifest.permission.RECEIVE_SMS))
                        {
                            preferences.edit().putBoolean("firstloginshow", false).commit();
                            AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
                            builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
                            builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
                            builder.setMessage(LocaleController.getString("AllowFillNumber", R.string.AllowFillNumber));
                            permissionsShowDialog = showDialog(builder.create());
                        }
                        else
                        {
                            getParentActivity().requestPermissions(permissionsShowItems.toArray(new String[permissionsShowItems.size()]), 7);
                        }
                    }
                    return;
                }
            }
            if (!newAccount && (allowCall || allowSms))
            {
                String number = PhoneFormat.stripExceptNumbers(tm.getLine1Number());
                String textToSet = null;
                boolean ok = false;
                if (!TextUtils.isEmpty(number))
                {
                    if (number.length() > 4)
                    {
                        for (int a = 4; a >= 1; a--)
                        {
                            String sub = number.substring(0, a);
                            String country = codesMap.get(sub);
                            if (country != null)
                            {
                                ok = true;
                                textToSet = number.substring(a, number.length());
                                codeField.setText(sub);
                                break;
                            }
                        }
                        if (!ok)
                        {
                            textToSet = number.substring(1, number.length());
                            codeField.setText(number.substring(0, 1));
                        }
                    }
                    if (textToSet != null)
                    {
                        phoneField.requestFocus();
                        phoneField.setText(textToSet);
                        phoneField.setSelection(phoneField.length());
                    }
                }
            }
        }
    }
    catch (Exception e)
    {
        FileLog.e(e);
    }
}
 
Example 20
Source File: ConnectionsManager.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void switchBackend() {
    SharedPreferences preferences = MessagesController.getGlobalMainSettings();
    preferences.edit().remove("language_showed2").commit();
    native_switchBackend(currentAccount);
}