Java Code Examples for org.telegram.messenger.SharedConfig#saveConfig()
The following examples show how to use
org.telegram.messenger.SharedConfig#saveConfig() .
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: ImageUpdater.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void processBitmap(Bitmap bitmap) { if (bitmap == null) { return; } if (encryptedDocument) { bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 2048, 2048, 89, false, 320, 320); if (delegate != null) { TLRPC.TL_secureFile secureFile = new TLRPC.TL_secureFile(); secureFile.dc_id = (int) bigPhoto.location.volume_id; secureFile.id = bigPhoto.location.local_id; secureFile.date = (int) (System.currentTimeMillis() / 1000); delegate.didUploadedPhoto(null, null, null, secureFile); } SharedConfig.saveConfig(); } else { smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false); bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320); bitmap.recycle(); if (bigPhoto != null && smallPhoto != null) { if (returnOnly) { if (delegate != null) { delegate.didUploadedPhoto(null, smallPhoto, bigPhoto, null); } } else { UserConfig.getInstance(currentAccount).saveConfig(false); uploadingImage = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE) + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg"; NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidUpload); NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidFailUpload); FileLoader.getInstance(currentAccount).uploadFile(uploadingImage, false, true, ConnectionsManager.FileTypePhoto); } } } }
Example 2
Source File: PasscodeView.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void checkRetryTextView() { long currentTime = SystemClock.elapsedRealtime(); if (currentTime > SharedConfig.lastUptimeMillis) { SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis); if (SharedConfig.passcodeRetryInMs < 0) { SharedConfig.passcodeRetryInMs = 0; } } SharedConfig.lastUptimeMillis = currentTime; SharedConfig.saveConfig(); if (SharedConfig.passcodeRetryInMs > 0) { int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0)); if (value != lastValue) { retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value))); lastValue = value; } if (retryTextView.getVisibility() != VISIBLE) { retryTextView.setVisibility(VISIBLE); passwordFrameLayout.setVisibility(INVISIBLE); if (numbersFrameLayout.getVisibility() == VISIBLE) { numbersFrameLayout.setVisibility(INVISIBLE); } AndroidUtilities.hideKeyboard(passwordEditText); AndroidUtilities.cancelRunOnUIThread(checkRunnable); AndroidUtilities.runOnUIThread(checkRunnable, 100); } } else { AndroidUtilities.cancelRunOnUIThread(checkRunnable); if (passwordFrameLayout.getVisibility() != VISIBLE) { retryTextView.setVisibility(INVISIBLE); passwordFrameLayout.setVisibility(VISIBLE); if (SharedConfig.passcodeType == 0) { numbersFrameLayout.setVisibility(VISIBLE); } else if (SharedConfig.passcodeType == 1) { AndroidUtilities.showKeyboard(passwordEditText); } } } }
Example 3
Source File: ExternalActionActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void onPasscodeResume() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (AndroidUtilities.needShowPasscode(true)) { showPasscodeActivity(); } if (SharedConfig.lastPauseTime != 0) { SharedConfig.lastPauseTime = 0; SharedConfig.saveConfig(); } }
Example 4
Source File: ExternalActionActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void onPasscodePause() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (SharedConfig.passcodeHash.length() != 0) { SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000); lockRunnable = new Runnable() { @Override public void run() { if (lockRunnable == this) { if (AndroidUtilities.needShowPasscode(true)) { if (BuildVars.LOGS_ENABLED) { FileLog.d("lock app"); } showPasscodeActivity(); } else { if (BuildVars.LOGS_ENABLED) { FileLog.d("didn't pass lock check"); } } lockRunnable = null; } } }; if (SharedConfig.appLocked) { AndroidUtilities.runOnUIThread(lockRunnable, 1000); } else if (SharedConfig.autoLockIn != 0) { AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000); } } else { SharedConfig.lastPauseTime = 0; } SharedConfig.saveConfig(); }
Example 5
Source File: PasscodeView.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void checkRetryTextView() { long currentTime = SystemClock.elapsedRealtime(); if (currentTime > SharedConfig.lastUptimeMillis) { SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis); if (SharedConfig.passcodeRetryInMs < 0) { SharedConfig.passcodeRetryInMs = 0; } } SharedConfig.lastUptimeMillis = currentTime; SharedConfig.saveConfig(); if (SharedConfig.passcodeRetryInMs > 0) { int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0)); if (value != lastValue) { retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value))); lastValue = value; } if (retryTextView.getVisibility() != VISIBLE) { retryTextView.setVisibility(VISIBLE); passwordFrameLayout.setVisibility(INVISIBLE); if (numbersFrameLayout.getVisibility() == VISIBLE) { numbersFrameLayout.setVisibility(INVISIBLE); } AndroidUtilities.hideKeyboard(passwordEditText); AndroidUtilities.cancelRunOnUIThread(checkRunnable); AndroidUtilities.runOnUIThread(checkRunnable, 100); } } else { AndroidUtilities.cancelRunOnUIThread(checkRunnable); if (passwordFrameLayout.getVisibility() != VISIBLE) { retryTextView.setVisibility(INVISIBLE); passwordFrameLayout.setVisibility(VISIBLE); if (SharedConfig.passcodeType == 0) { numbersFrameLayout.setVisibility(VISIBLE); } else if (SharedConfig.passcodeType == 1) { AndroidUtilities.showKeyboard(passwordEditText); } } } }
Example 6
Source File: ExternalActionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void onPasscodeResume() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (AndroidUtilities.needShowPasscode(true)) { showPasscodeActivity(); } if (SharedConfig.lastPauseTime != 0) { SharedConfig.lastPauseTime = 0; SharedConfig.saveConfig(); } }
Example 7
Source File: ExternalActionActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void onPasscodePause() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (SharedConfig.passcodeHash.length() != 0) { SharedConfig.lastPauseTime = (int) (SystemClock.elapsedRealtime() / 1000); lockRunnable = new Runnable() { @Override public void run() { if (lockRunnable == this) { if (AndroidUtilities.needShowPasscode(true)) { if (BuildVars.LOGS_ENABLED) { FileLog.d("lock app"); } showPasscodeActivity(); } else { if (BuildVars.LOGS_ENABLED) { FileLog.d("didn't pass lock check"); } } lockRunnable = null; } } }; if (SharedConfig.appLocked) { AndroidUtilities.runOnUIThread(lockRunnable, 1000); } else if (SharedConfig.autoLockIn != 0) { AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000); } } else { SharedConfig.lastPauseTime = 0; } SharedConfig.saveConfig(); }
Example 8
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void onPasscodePause() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (SharedConfig.passcodeHash.length() != 0) { SharedConfig.lastPauseTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime(); lockRunnable = new Runnable() { @Override public void run() { if (lockRunnable == this) { if (AndroidUtilities.needShowPasscode(true)) { if (BuildVars.LOGS_ENABLED) { FileLog.d("lock app"); } showPasscodeActivity(); } else { if (BuildVars.LOGS_ENABLED) { FileLog.d("didn't pass lock check"); } } lockRunnable = null; } } }; if (SharedConfig.appLocked) { AndroidUtilities.runOnUIThread(lockRunnable, 1000); } else if (SharedConfig.autoLockIn != 0) { AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000); } } else { SharedConfig.lastPauseTime = 0; } SharedConfig.saveConfig(); }
Example 9
Source File: PasscodeView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void checkRetryTextView() { long currentTime = SystemClock.elapsedRealtime(); if (currentTime > SharedConfig.lastUptimeMillis) { SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis); if (SharedConfig.passcodeRetryInMs < 0) { SharedConfig.passcodeRetryInMs = 0; } } SharedConfig.lastUptimeMillis = currentTime; SharedConfig.saveConfig(); if (SharedConfig.passcodeRetryInMs > 0) { int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0)); if (value != lastValue) { retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value))); lastValue = value; } if (retryTextView.getVisibility() != VISIBLE) { retryTextView.setVisibility(VISIBLE); passwordFrameLayout.setVisibility(INVISIBLE); if (numbersFrameLayout.getVisibility() == VISIBLE) { numbersFrameLayout.setVisibility(INVISIBLE); } AndroidUtilities.hideKeyboard(passwordEditText); AndroidUtilities.cancelRunOnUIThread(checkRunnable); AndroidUtilities.runOnUIThread(checkRunnable, 100); } } else { AndroidUtilities.cancelRunOnUIThread(checkRunnable); if (passwordFrameLayout.getVisibility() != VISIBLE) { retryTextView.setVisibility(INVISIBLE); passwordFrameLayout.setVisibility(VISIBLE); if (SharedConfig.passcodeType == 0) { numbersFrameLayout.setVisibility(VISIBLE); } else if (SharedConfig.passcodeType == 1) { AndroidUtilities.showKeyboard(passwordEditText); } } } }
Example 10
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void onPasscodeResume() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (AndroidUtilities.needShowPasscode(true)) { showPasscodeActivity(); } if (SharedConfig.lastPauseTime != 0) { SharedConfig.lastPauseTime = 0; SharedConfig.saveConfig(); } }
Example 11
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void onPasscodePause() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (SharedConfig.passcodeHash.length() != 0) { SharedConfig.lastPauseTime = ConnectionsManager.getInstance(UserConfig.selectedAccount).getCurrentTime(); lockRunnable = new Runnable() { @Override public void run() { if (lockRunnable == this) { if (AndroidUtilities.needShowPasscode(true)) { if (BuildVars.LOGS_ENABLED) { FileLog.d("lock app"); } showPasscodeActivity(); } else { if (BuildVars.LOGS_ENABLED) { FileLog.d("didn't pass lock check"); } } lockRunnable = null; } } }; if (SharedConfig.appLocked) { AndroidUtilities.runOnUIThread(lockRunnable, 1000); } else if (SharedConfig.autoLockIn != 0) { AndroidUtilities.runOnUIThread(lockRunnable, (long) SharedConfig.autoLockIn * 1000 + 1000); } } else { SharedConfig.lastPauseTime = 0; } SharedConfig.saveConfig(); }
Example 12
Source File: ImageUpdater.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void processBitmap(Bitmap bitmap) { if (bitmap == null) { return; } if (encryptedDocument) { bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 2048, 2048, 89, false, 320, 320); if (delegate != null) { TLRPC.TL_secureFile secureFile = new TLRPC.TL_secureFile(); secureFile.dc_id = (int) bigPhoto.location.volume_id; secureFile.id = bigPhoto.location.local_id; secureFile.date = (int) (System.currentTimeMillis() / 1000); delegate.didUploadedPhoto(null, null, null, secureFile); } SharedConfig.saveConfig(); } else { smallPhoto = ImageLoader.scaleAndSaveImage(bitmap, 100, 100, 80, false); bigPhoto = ImageLoader.scaleAndSaveImage(bitmap, 800, 800, 80, false, 320, 320); bitmap.recycle(); if (bigPhoto != null && smallPhoto != null) { if (returnOnly) { if (delegate != null) { delegate.didUploadedPhoto(null, smallPhoto, bigPhoto, null); } } else { UserConfig.getInstance(currentAccount).saveConfig(false); uploadingImage = FileLoader.getDirectory(FileLoader.MEDIA_DIR_CACHE) + "/" + bigPhoto.location.volume_id + "_" + bigPhoto.location.local_id + ".jpg"; NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidUpload); NotificationCenter.getInstance(currentAccount).addObserver(ImageUpdater.this, NotificationCenter.FileDidFailUpload); FileLoader.getInstance(currentAccount).uploadFile(uploadingImage, false, true, ConnectionsManager.FileTypePhoto); } } } }
Example 13
Source File: PasscodeView.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void checkRetryTextView() { long currentTime = SystemClock.elapsedRealtime(); if (currentTime > SharedConfig.lastUptimeMillis) { SharedConfig.passcodeRetryInMs -= (currentTime - SharedConfig.lastUptimeMillis); if (SharedConfig.passcodeRetryInMs < 0) { SharedConfig.passcodeRetryInMs = 0; } } SharedConfig.lastUptimeMillis = currentTime; SharedConfig.saveConfig(); if (SharedConfig.passcodeRetryInMs > 0) { int value = Math.max(1, (int) Math.ceil(SharedConfig.passcodeRetryInMs / 1000.0)); if (value != lastValue) { retryTextView.setText(LocaleController.formatString("TooManyTries", R.string.TooManyTries, LocaleController.formatPluralString("Seconds", value))); lastValue = value; } if (retryTextView.getVisibility() != VISIBLE) { retryTextView.setVisibility(VISIBLE); passwordFrameLayout.setVisibility(INVISIBLE); if (numbersFrameLayout.getVisibility() == VISIBLE) { numbersFrameLayout.setVisibility(INVISIBLE); } AndroidUtilities.hideKeyboard(passwordEditText); AndroidUtilities.cancelRunOnUIThread(checkRunnable); AndroidUtilities.runOnUIThread(checkRunnable, 100); } } else { AndroidUtilities.cancelRunOnUIThread(checkRunnable); if (passwordFrameLayout.getVisibility() != VISIBLE) { retryTextView.setVisibility(INVISIBLE); passwordFrameLayout.setVisibility(VISIBLE); if (SharedConfig.passcodeType == 0) { numbersFrameLayout.setVisibility(VISIBLE); } else if (SharedConfig.passcodeType == 1) { AndroidUtilities.showKeyboard(passwordEditText); } } } }
Example 14
Source File: ExternalActionActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void onPasscodeResume() { if (lockRunnable != null) { AndroidUtilities.cancelRunOnUIThread(lockRunnable); lockRunnable = null; } if (AndroidUtilities.needShowPasscode(true)) { showPasscodeActivity(); } if (SharedConfig.lastPauseTime != 0) { SharedConfig.lastPauseTime = 0; SharedConfig.saveConfig(); } }
Example 15
Source File: PasscodeView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void processDone(boolean fingerprint) { if (!fingerprint) { if (SharedConfig.passcodeRetryInMs > 0) { return; } String password = ""; if (SharedConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (SharedConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); } if (password.length() == 0) { onPasscodeError(); return; } if (!SharedConfig.checkPasscode(password)) { SharedConfig.increaseBadPasscodeTries(); if (SharedConfig.passcodeRetryInMs > 0) { checkRetryTextView(); } passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } SharedConfig.badPasscodeTries = 0; passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether( ObjectAnimator.ofFloat(this, "translationY", AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, "alpha", AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); SharedConfig.appLocked = false; SharedConfig.saveConfig(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }
Example 16
Source File: PasscodeView.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void processDone(boolean fingerprint) { if (!fingerprint) { if (SharedConfig.passcodeRetryInMs > 0) { return; } String password = ""; if (SharedConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (SharedConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); } if (password.length() == 0) { onPasscodeError(); return; } if (!SharedConfig.checkPasscode(password)) { SharedConfig.increaseBadPasscodeTries(); if (SharedConfig.passcodeRetryInMs > 0) { checkRetryTextView(); } passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } SharedConfig.badPasscodeTries = 0; passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether( ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, View.ALPHA, AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); SharedConfig.appLocked = false; SharedConfig.saveConfig(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }
Example 17
Source File: PasscodeView.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void processDone(boolean fingerprint) { if (!fingerprint) { if (SharedConfig.passcodeRetryInMs > 0) { return; } String password = ""; if (SharedConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (SharedConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); } if (password.length() == 0) { onPasscodeError(); return; } if (!SharedConfig.checkPasscode(password)) { SharedConfig.increaseBadPasscodeTries(); if (SharedConfig.passcodeRetryInMs > 0) { checkRetryTextView(); } passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } SharedConfig.badPasscodeTries = 0; passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether( ObjectAnimator.ofFloat(this, "translationY", AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, "alpha", AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); SharedConfig.appLocked = false; SharedConfig.saveConfig(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }
Example 18
Source File: PasscodeView.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void processDone(boolean fingerprint) { if (!fingerprint) { if (SharedConfig.passcodeRetryInMs > 0) { return; } String password = ""; if (SharedConfig.passcodeType == 0) { password = passwordEditText2.getString(); } else if (SharedConfig.passcodeType == 1) { password = passwordEditText.getText().toString(); } if (password.length() == 0) { onPasscodeError(); return; } if (!SharedConfig.checkPasscode(password)) { SharedConfig.increaseBadPasscodeTries(); if (SharedConfig.passcodeRetryInMs > 0) { checkRetryTextView(); } passwordEditText.setText(""); passwordEditText2.eraseAllCharacters(true); onPasscodeError(); return; } } SharedConfig.badPasscodeTries = 0; passwordEditText.clearFocus(); AndroidUtilities.hideKeyboard(passwordEditText); AnimatorSet AnimatorSet = new AnimatorSet(); AnimatorSet.setDuration(200); AnimatorSet.playTogether( ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, AndroidUtilities.dp(20)), ObjectAnimator.ofFloat(this, View.ALPHA, AndroidUtilities.dp(0.0f))); AnimatorSet.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { setVisibility(View.GONE); } }); AnimatorSet.start(); SharedConfig.appLocked = false; SharedConfig.saveConfig(); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didSetPasscode); setOnTouchListener(null); if (delegate != null) { delegate.didAcceptedPassword(); } }