2014-12-01 18:56:31 +01:00
|
|
|
|
/*
|
2019-01-23 18:03:33 +01:00
|
|
|
|
* This is the source code of Telegram for Android v. 5.x.x.
|
2014-12-01 18:56:31 +01:00
|
|
|
|
* It is licensed under GNU GPL v. 2 or later.
|
|
|
|
|
* You should have received a copy of the license in this archive (see LICENSE).
|
|
|
|
|
*
|
2019-01-23 18:03:33 +01:00
|
|
|
|
* Copyright Nikolai Kudashov, 2013-2018.
|
2014-12-01 18:56:31 +01:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
import android.Manifest;
|
2016-06-24 12:27:15 +02:00
|
|
|
|
import android.animation.Animator;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
import android.animation.AnimatorListenerAdapter;
|
2016-06-24 12:27:15 +02:00
|
|
|
|
import android.animation.AnimatorSet;
|
|
|
|
|
import android.animation.ObjectAnimator;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
import android.annotation.SuppressLint;
|
2019-09-10 12:56:11 +02:00
|
|
|
|
import android.app.Activity;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
import android.app.Dialog;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import android.content.Context;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
|
import android.content.pm.PackageInfo;
|
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
|
import android.graphics.Canvas;
|
|
|
|
|
import android.graphics.Paint;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
|
import android.graphics.PorterDuffColorFilter;
|
|
|
|
|
import android.graphics.Rect;
|
|
|
|
|
import android.graphics.drawable.Drawable;
|
2021-04-14 03:44:46 +02:00
|
|
|
|
import android.net.Uri;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
import android.os.Build;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import android.os.Bundle;
|
2019-05-14 14:08:05 +02:00
|
|
|
|
import android.telephony.PhoneNumberUtils;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
|
import android.text.Editable;
|
|
|
|
|
import android.text.InputFilter;
|
|
|
|
|
import android.text.InputType;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.TextWatcher;
|
|
|
|
|
import android.util.TypedValue;
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
import android.view.KeyEvent;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.view.animation.AccelerateDecelerateInterpolator;
|
|
|
|
|
import android.view.inputmethod.EditorInfo;
|
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
|
import android.widget.FrameLayout;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
import android.widget.ImageView;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import android.widget.LinearLayout;
|
|
|
|
|
import android.widget.ScrollView;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2015-09-24 22:52:02 +02:00
|
|
|
|
import org.telegram.messenger.AndroidUtilities;
|
2019-09-10 12:56:11 +02:00
|
|
|
|
import org.telegram.messenger.BuildVars;
|
2015-09-24 22:52:02 +02:00
|
|
|
|
import org.telegram.messenger.LocaleController;
|
|
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
|
import org.telegram.messenger.MessagesStorage;
|
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import org.telegram.messenger.ApplicationLoader;
|
|
|
|
|
import org.telegram.messenger.FileLog;
|
|
|
|
|
import org.telegram.messenger.R;
|
2015-09-24 22:52:02 +02:00
|
|
|
|
import org.telegram.tgnet.ConnectionsManager;
|
|
|
|
|
import org.telegram.tgnet.TLRPC;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import org.telegram.messenger.UserConfig;
|
|
|
|
|
import org.telegram.ui.ActionBar.ActionBar;
|
|
|
|
|
import org.telegram.ui.ActionBar.ActionBarMenu;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
import org.telegram.ui.ActionBar.AlertDialog;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import org.telegram.ui.ActionBar.BaseFragment;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
import org.telegram.ui.ActionBar.Theme;
|
|
|
|
|
import org.telegram.ui.ActionBar.ThemeDescription;
|
|
|
|
|
import org.telegram.ui.Components.AlertsCreator;
|
2017-12-08 18:35:59 +01:00
|
|
|
|
import org.telegram.ui.Components.EditTextBoldCursor;
|
2015-11-26 22:04:02 +01:00
|
|
|
|
import org.telegram.ui.Components.HintEditText;
|
2015-05-03 13:48:36 +02:00
|
|
|
|
import org.telegram.ui.Components.LayoutHelper;
|
2021-02-23 12:53:38 +01:00
|
|
|
|
import org.telegram.ui.Components.RLottieDrawable;
|
|
|
|
|
import org.telegram.ui.Components.RLottieImageView;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
import org.telegram.ui.Components.SlideView;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Collections;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
import java.util.Timer;
|
|
|
|
|
import java.util.TimerTask;
|
|
|
|
|
|
|
|
|
|
public class ChangePhoneActivity extends BaseFragment {
|
|
|
|
|
|
|
|
|
|
private int currentViewNum = 0;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private SlideView[] views = new SlideView[5];
|
2017-03-31 01:58:05 +02:00
|
|
|
|
private AlertDialog progressDialog;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private Dialog permissionsDialog;
|
|
|
|
|
private ArrayList<String> permissionsItems = new ArrayList<>();
|
|
|
|
|
private boolean checkPermissions = true;
|
|
|
|
|
private View doneButton;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
private int scrollHeight;
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private final static int done_button = 1;
|
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
private class ProgressView extends View {
|
|
|
|
|
|
|
|
|
|
private Paint paint = new Paint();
|
|
|
|
|
private Paint paint2 = new Paint();
|
|
|
|
|
private float progress;
|
|
|
|
|
|
|
|
|
|
public ProgressView(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
paint.setColor(Theme.getColor(Theme.key_login_progressInner));
|
|
|
|
|
paint2.setColor(Theme.getColor(Theme.key_login_progressOuter));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setProgress(float value) {
|
|
|
|
|
progress = value;
|
|
|
|
|
invalidate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDraw(Canvas canvas) {
|
|
|
|
|
int start = (int) (getMeasuredWidth() * progress);
|
|
|
|
|
canvas.drawRect(0, 0, start, getMeasuredHeight(), paint2);
|
|
|
|
|
canvas.drawRect(start, 0, getMeasuredWidth(), getMeasuredHeight(), paint);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
|
super.onFragmentDestroy();
|
2016-03-16 13:26:32 +01:00
|
|
|
|
for (int a = 0; a < views.length; a++) {
|
|
|
|
|
if (views[a] != null) {
|
|
|
|
|
views[a].onDestroyActivity();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (progressDialog != null) {
|
|
|
|
|
try {
|
|
|
|
|
progressDialog.dismiss();
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
progressDialog = null;
|
|
|
|
|
}
|
2015-09-24 22:52:02 +02:00
|
|
|
|
AndroidUtilities.removeAdjustResize(getParentActivity(), classGuid);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-07-22 20:56:37 +02:00
|
|
|
|
public View createView(Context context) {
|
2015-04-09 20:00:14 +02:00
|
|
|
|
actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
|
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
|
|
|
|
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
|
if (id == done_button) {
|
|
|
|
|
views[currentViewNum].onNextPressed();
|
|
|
|
|
} else if (id == -1) {
|
|
|
|
|
finishFragment();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ActionBarMenu menu = actionBar.createMenu();
|
2020-12-24 06:36:01 +01:00
|
|
|
|
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56), LocaleController.getString("Done", R.string.Done));
|
2015-04-09 20:00:14 +02:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
ScrollView scrollView = new ScrollView(context) {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) {
|
|
|
|
|
if (currentViewNum == 1 || currentViewNum == 2 || currentViewNum == 4) {
|
|
|
|
|
rectangle.bottom += AndroidUtilities.dp(40);
|
|
|
|
|
}
|
|
|
|
|
return super.requestChildRectangleOnScreen(child, rectangle, immediate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
|
scrollHeight = MeasureSpec.getSize(heightMeasureSpec) - AndroidUtilities.dp(30);
|
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
|
}
|
|
|
|
|
};
|
2015-04-09 20:00:14 +02:00
|
|
|
|
scrollView.setFillViewport(true);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
fragmentView = scrollView;
|
2015-04-09 20:00:14 +02:00
|
|
|
|
|
|
|
|
|
FrameLayout frameLayout = new FrameLayout(context);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
scrollView.addView(frameLayout, LayoutHelper.createScroll(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT));
|
2015-04-09 20:00:14 +02:00
|
|
|
|
|
|
|
|
|
views[0] = new PhoneView(context);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
views[1] = new LoginActivitySmsView(context, 1);
|
|
|
|
|
views[2] = new LoginActivitySmsView(context, 2);
|
|
|
|
|
views[3] = new LoginActivitySmsView(context, 3);
|
|
|
|
|
views[4] = new LoginActivitySmsView(context, 4);
|
|
|
|
|
|
|
|
|
|
for (int a = 0; a < views.length; a++) {
|
|
|
|
|
views[a].setVisibility(a == 0 ? View.VISIBLE : View.GONE);
|
|
|
|
|
frameLayout.addView(views[a], LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, a == 0 ? LayoutHelper.WRAP_CONTENT : LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, AndroidUtilities.isTablet() ? 26 : 18, 30, AndroidUtilities.isTablet() ? 26 : 18, 0));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2015-04-09 20:00:14 +02:00
|
|
|
|
|
|
|
|
|
actionBar.setTitle(views[0].getHeaderName());
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
return fragmentView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onResume() {
|
|
|
|
|
super.onResume();
|
2015-09-24 22:52:02 +02:00
|
|
|
|
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onRequestPermissionsResultFragment(int requestCode, String[] permissions, int[] grantResults) {
|
|
|
|
|
if (requestCode == 6) {
|
|
|
|
|
checkPermissions = false;
|
|
|
|
|
if (currentViewNum == 0) {
|
|
|
|
|
views[currentViewNum].onNextPressed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDialogDismiss(Dialog dialog) {
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && dialog == permissionsDialog && !permissionsItems.isEmpty()) {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
getParentActivity().requestPermissions(permissionsItems.toArray(new String[0]), 6);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public boolean onBackPressed() {
|
|
|
|
|
if (currentViewNum == 0) {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
for (int a = 0; a < views.length; a++) {
|
|
|
|
|
if (views[a] != null) {
|
|
|
|
|
views[a].onDestroyActivity();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (views[currentViewNum].onBackPressed(false)) {
|
|
|
|
|
setPage(0, true, null, true);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2015-10-29 18:10:07 +01:00
|
|
|
|
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
|
|
|
|
if (isOpen) {
|
|
|
|
|
views[currentViewNum].onShow();
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void needShowProgress() {
|
|
|
|
|
if (getParentActivity() == null || getParentActivity().isFinishing() || progressDialog != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
progressDialog = new AlertDialog(getParentActivity(), 3);
|
|
|
|
|
progressDialog.setCanCacnel(false);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
progressDialog.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void needHideProgress() {
|
|
|
|
|
if (progressDialog == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
progressDialog.dismiss();
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
progressDialog = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPage(int page, boolean animated, Bundle params, boolean back) {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (page == 3) {
|
|
|
|
|
doneButton.setVisibility(View.GONE);
|
|
|
|
|
} else {
|
|
|
|
|
if (page == 0) {
|
|
|
|
|
checkPermissions = true;
|
|
|
|
|
}
|
|
|
|
|
doneButton.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
2016-06-24 12:27:15 +02:00
|
|
|
|
final SlideView outView = views[currentViewNum];
|
|
|
|
|
final SlideView newView = views[page];
|
|
|
|
|
currentViewNum = page;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
newView.setParams(params, false);
|
2016-06-24 12:27:15 +02:00
|
|
|
|
actionBar.setTitle(newView.getHeaderName());
|
|
|
|
|
newView.onShow();
|
|
|
|
|
newView.setX(back ? -AndroidUtilities.displaySize.x : AndroidUtilities.displaySize.x);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
|
AnimatorSet animatorSet = new AnimatorSet();
|
|
|
|
|
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
|
|
|
|
|
animatorSet.setDuration(300);
|
|
|
|
|
animatorSet.playTogether(
|
|
|
|
|
ObjectAnimator.ofFloat(outView, "translationX", back ? AndroidUtilities.displaySize.x : -AndroidUtilities.displaySize.x),
|
|
|
|
|
ObjectAnimator.ofFloat(newView, "translationX", 0));
|
2017-03-31 01:58:05 +02:00
|
|
|
|
animatorSet.addListener(new AnimatorListenerAdapter() {
|
2016-06-24 12:27:15 +02:00
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationStart(Animator animation) {
|
|
|
|
|
newView.setVisibility(View.VISIBLE);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2016-06-24 12:27:15 +02:00
|
|
|
|
@Override
|
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
|
outView.setVisibility(View.GONE);
|
|
|
|
|
outView.setX(0);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
animatorSet.start();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private void fillNextCodeParams(Bundle params, TLRPC.TL_auth_sentCode res) {
|
|
|
|
|
params.putString("phoneHash", res.phone_code_hash);
|
|
|
|
|
if (res.next_type instanceof TLRPC.TL_auth_codeTypeCall) {
|
|
|
|
|
params.putInt("nextType", 4);
|
|
|
|
|
} else if (res.next_type instanceof TLRPC.TL_auth_codeTypeFlashCall) {
|
|
|
|
|
params.putInt("nextType", 3);
|
|
|
|
|
} else if (res.next_type instanceof TLRPC.TL_auth_codeTypeSms) {
|
|
|
|
|
params.putInt("nextType", 2);
|
|
|
|
|
}
|
|
|
|
|
if (res.type instanceof TLRPC.TL_auth_sentCodeTypeApp) {
|
|
|
|
|
params.putInt("type", 1);
|
|
|
|
|
params.putInt("length", res.type.length);
|
|
|
|
|
setPage(1, true, params, false);
|
|
|
|
|
} else {
|
|
|
|
|
if (res.timeout == 0) {
|
|
|
|
|
res.timeout = 60;
|
|
|
|
|
}
|
|
|
|
|
params.putInt("timeout", res.timeout * 1000);
|
|
|
|
|
if (res.type instanceof TLRPC.TL_auth_sentCodeTypeCall) {
|
|
|
|
|
params.putInt("type", 4);
|
|
|
|
|
params.putInt("length", res.type.length);
|
|
|
|
|
setPage(4, true, params, false);
|
|
|
|
|
} else if (res.type instanceof TLRPC.TL_auth_sentCodeTypeFlashCall) {
|
|
|
|
|
params.putInt("type", 3);
|
|
|
|
|
params.putString("pattern", res.type.pattern);
|
|
|
|
|
setPage(3, true, params, false);
|
|
|
|
|
} else if (res.type instanceof TLRPC.TL_auth_sentCodeTypeSms) {
|
|
|
|
|
params.putInt("type", 2);
|
|
|
|
|
params.putInt("length", res.type.length);
|
|
|
|
|
setPage(2, true, params, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
public class PhoneView extends SlideView implements AdapterView.OnItemSelectedListener {
|
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
|
private EditTextBoldCursor codeField;
|
2015-11-26 22:04:02 +01:00
|
|
|
|
private HintEditText phoneField;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private TextView countryButton;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
private View view;
|
|
|
|
|
private TextView textView;
|
|
|
|
|
private TextView textView2;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
private int countryState = 0;
|
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
|
private ArrayList<String> countriesArray = new ArrayList<>();
|
|
|
|
|
private HashMap<String, String> countriesMap = new HashMap<>();
|
|
|
|
|
private HashMap<String, String> codesMap = new HashMap<>();
|
2015-11-26 22:04:02 +01:00
|
|
|
|
private HashMap<String, String> phoneFormatMap = new HashMap<>();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
private boolean ignoreSelection = false;
|
|
|
|
|
private boolean ignoreOnTextChange = false;
|
|
|
|
|
private boolean ignoreOnPhoneChange = false;
|
|
|
|
|
private boolean nextPressed = false;
|
|
|
|
|
|
|
|
|
|
public PhoneView(Context context) {
|
|
|
|
|
super(context);
|
|
|
|
|
|
|
|
|
|
setOrientation(VERTICAL);
|
|
|
|
|
|
|
|
|
|
countryButton = new TextView(context);
|
|
|
|
|
countryButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
countryButton.setPadding(AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4), AndroidUtilities.dp(4));
|
2017-03-31 01:58:05 +02:00
|
|
|
|
countryButton.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryButton.setMaxLines(1);
|
|
|
|
|
countryButton.setSingleLine(true);
|
|
|
|
|
countryButton.setEllipsize(TextUtils.TruncateAt.END);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
countryButton.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_HORIZONTAL);
|
2019-12-31 14:08:08 +01:00
|
|
|
|
countryButton.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 7));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
addView(countryButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 36, 0, 0, 0, 14));
|
2019-01-23 18:03:33 +01:00
|
|
|
|
countryButton.setOnClickListener(view -> {
|
|
|
|
|
CountrySelectActivity fragment = new CountrySelectActivity(true);
|
|
|
|
|
fragment.setCountrySelectActivityDelegate((name, shortName) -> {
|
|
|
|
|
selectCountry(name);
|
|
|
|
|
AndroidUtilities.runOnUIThread(() -> AndroidUtilities.showKeyboard(phoneField), 300);
|
|
|
|
|
phoneField.requestFocus();
|
|
|
|
|
phoneField.setSelection(phoneField.length());
|
|
|
|
|
});
|
|
|
|
|
presentFragment(fragment);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
});
|
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
view = new View(context);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
view.setPadding(AndroidUtilities.dp(12), 0, AndroidUtilities.dp(12), 0);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayLine));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
addView(view, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 1, 4, -17.5f, 4, 0));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
LinearLayout linearLayout = new LinearLayout(context);
|
|
|
|
|
linearLayout.setOrientation(HORIZONTAL);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
addView(linearLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 20, 0, 0));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
textView = new TextView(context);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
textView.setText("+");
|
2017-03-31 01:58:05 +02:00
|
|
|
|
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
linearLayout.addView(textView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
|
codeField = new EditTextBoldCursor(context);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
codeField.setInputType(InputType.TYPE_CLASS_PHONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
codeField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
2017-12-08 18:35:59 +01:00
|
|
|
|
codeField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
codeField.setCursorSize(AndroidUtilities.dp(20));
|
|
|
|
|
codeField.setCursorWidth(1.5f);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
codeField.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
codeField.setPadding(AndroidUtilities.dp(10), 0, 0, 0);
|
|
|
|
|
codeField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
|
codeField.setMaxLines(1);
|
|
|
|
|
codeField.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
|
|
|
|
codeField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
|
|
|
|
InputFilter[] inputFilters = new InputFilter[1];
|
2015-11-26 22:04:02 +01:00
|
|
|
|
inputFilters[0] = new InputFilter.LengthFilter(5);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
codeField.setFilters(inputFilters);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
linearLayout.addView(codeField, LayoutHelper.createLinear(55, 36, -9, 0, 16, 0));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
codeField.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable editable) {
|
|
|
|
|
if (ignoreOnTextChange) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ignoreOnTextChange = true;
|
|
|
|
|
String text = PhoneFormat.stripExceptNumbers(codeField.getText().toString());
|
|
|
|
|
codeField.setText(text);
|
|
|
|
|
if (text.length() == 0) {
|
|
|
|
|
countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField.setHintText(null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 1;
|
|
|
|
|
} else {
|
2015-11-26 22:04:02 +01:00
|
|
|
|
String country;
|
|
|
|
|
boolean ok = false;
|
|
|
|
|
String textToSet = null;
|
|
|
|
|
if (text.length() > 4) {
|
|
|
|
|
ignoreOnTextChange = true;
|
|
|
|
|
for (int a = 4; a >= 1; a--) {
|
|
|
|
|
String sub = text.substring(0, a);
|
|
|
|
|
country = codesMap.get(sub);
|
|
|
|
|
if (country != null) {
|
|
|
|
|
ok = true;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
textToSet = text.substring(a) + phoneField.getText().toString();
|
2015-11-26 22:04:02 +01:00
|
|
|
|
codeField.setText(text = sub);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!ok) {
|
|
|
|
|
ignoreOnTextChange = true;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
textToSet = text.substring(1) + phoneField.getText().toString();
|
2015-11-26 22:04:02 +01:00
|
|
|
|
codeField.setText(text = text.substring(0, 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
country = codesMap.get(text);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (country != null) {
|
|
|
|
|
int index = countriesArray.indexOf(country);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
ignoreSelection = true;
|
|
|
|
|
countryButton.setText(countriesArray.get(index));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
String hint = phoneFormatMap.get(text);
|
|
|
|
|
phoneField.setHintText(hint != null ? hint.replace('X', '–') : null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 0;
|
|
|
|
|
} else {
|
|
|
|
|
countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField.setHintText(null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 2;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
countryButton.setText(LocaleController.getString("WrongCountry", R.string.WrongCountry));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField.setHintText(null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 2;
|
|
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
|
if (!ok) {
|
|
|
|
|
codeField.setSelection(codeField.getText().length());
|
|
|
|
|
}
|
|
|
|
|
if (textToSet != null) {
|
|
|
|
|
phoneField.requestFocus();
|
|
|
|
|
phoneField.setText(textToSet);
|
|
|
|
|
phoneField.setSelection(phoneField.length());
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
ignoreOnTextChange = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
|
codeField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
|
|
|
|
if (i == EditorInfo.IME_ACTION_NEXT) {
|
|
|
|
|
phoneField.requestFocus();
|
|
|
|
|
phoneField.setSelection(phoneField.length());
|
|
|
|
|
return true;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
return false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
});
|
|
|
|
|
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField = new HintEditText(context);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
phoneField.setInputType(InputType.TYPE_CLASS_PHONE);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
phoneField.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
phoneField.setHintTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteHintText));
|
|
|
|
|
phoneField.setBackgroundDrawable(Theme.createEditTextDrawable(context, false));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
phoneField.setPadding(0, 0, 0, 0);
|
2017-12-08 18:35:59 +01:00
|
|
|
|
phoneField.setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
phoneField.setCursorSize(AndroidUtilities.dp(20));
|
|
|
|
|
phoneField.setCursorWidth(1.5f);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
phoneField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
|
phoneField.setMaxLines(1);
|
|
|
|
|
phoneField.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
|
|
|
|
phoneField.setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
linearLayout.addView(phoneField, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 36));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
phoneField.addTextChangedListener(new TextWatcher() {
|
2015-11-26 22:04:02 +01:00
|
|
|
|
|
|
|
|
|
private int characterAction = -1;
|
|
|
|
|
private int actionPosition;
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
2015-11-26 22:04:02 +01:00
|
|
|
|
if (count == 0 && after == 1) {
|
|
|
|
|
characterAction = 1;
|
|
|
|
|
} else if (count == 1 && after == 0) {
|
|
|
|
|
if (s.charAt(start) == ' ' && start > 0) {
|
|
|
|
|
characterAction = 3;
|
|
|
|
|
actionPosition = start - 1;
|
|
|
|
|
} else {
|
|
|
|
|
characterAction = 2;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
|
} else {
|
|
|
|
|
characterAction = -1;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
if (ignoreOnPhoneChange) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-11-26 22:04:02 +01:00
|
|
|
|
int start = phoneField.getSelectionStart();
|
|
|
|
|
String phoneChars = "0123456789";
|
|
|
|
|
String str = phoneField.getText().toString();
|
|
|
|
|
if (characterAction == 3) {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
str = str.substring(0, actionPosition) + str.substring(actionPosition + 1);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
start--;
|
|
|
|
|
}
|
|
|
|
|
StringBuilder builder = new StringBuilder(str.length());
|
|
|
|
|
for (int a = 0; a < str.length(); a++) {
|
|
|
|
|
String ch = str.substring(a, a + 1);
|
|
|
|
|
if (phoneChars.contains(ch)) {
|
|
|
|
|
builder.append(ch);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ignoreOnPhoneChange = true;
|
|
|
|
|
String hint = phoneField.getHintText();
|
|
|
|
|
if (hint != null) {
|
|
|
|
|
for (int a = 0; a < builder.length(); a++) {
|
|
|
|
|
if (a < hint.length()) {
|
|
|
|
|
if (hint.charAt(a) == ' ') {
|
|
|
|
|
builder.insert(a, ' ');
|
|
|
|
|
a++;
|
|
|
|
|
if (start == a && characterAction != 2 && characterAction != 3) {
|
|
|
|
|
start++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
builder.insert(a, ' ');
|
|
|
|
|
if (start == a + 1 && characterAction != 2 && characterAction != 3) {
|
|
|
|
|
start++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
phoneField.setText(builder);
|
|
|
|
|
if (start >= 0) {
|
|
|
|
|
phoneField.setSelection(start <= phoneField.length() ? start : phoneField.length());
|
|
|
|
|
}
|
|
|
|
|
phoneField.onTextChange();
|
|
|
|
|
ignoreOnPhoneChange = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
|
phoneField.setOnEditorActionListener((textView, i, keyEvent) -> {
|
|
|
|
|
if (i == EditorInfo.IME_ACTION_NEXT) {
|
|
|
|
|
onNextPressed();
|
|
|
|
|
return true;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
phoneField.setOnKeyListener((v, keyCode, event) -> {
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DEL && phoneField.length() == 0) {
|
|
|
|
|
codeField.requestFocus();
|
|
|
|
|
codeField.setSelection(codeField.length());
|
|
|
|
|
codeField.dispatchKeyEvent(event);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
});
|
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
textView2 = new TextView(context);
|
|
|
|
|
textView2.setText(LocaleController.getString("ChangePhoneHelp", R.string.ChangePhoneHelp));
|
|
|
|
|
textView2.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
|
textView2.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
|
|
|
|
textView2.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
|
|
|
|
addView(textView2, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 28, 0, 10));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2015-02-26 02:32:51 +01:00
|
|
|
|
HashMap<String, String> languageMap = new HashMap<>();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
try {
|
|
|
|
|
BufferedReader reader = new BufferedReader(new InputStreamReader(getResources().getAssets().open("countries.txt")));
|
|
|
|
|
String line;
|
|
|
|
|
while ((line = reader.readLine()) != null) {
|
|
|
|
|
String[] args = line.split(";");
|
|
|
|
|
countriesArray.add(0, args[2]);
|
|
|
|
|
countriesMap.put(args[2], args[0]);
|
|
|
|
|
codesMap.put(args[0], args[2]);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
if (args.length > 3) {
|
|
|
|
|
phoneFormatMap.put(args[0], args[3]);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
languageMap.put(args[1], args[2]);
|
|
|
|
|
}
|
2015-02-27 20:57:58 +01:00
|
|
|
|
reader.close();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
Collections.sort(countriesArray, String::compareTo);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
String country = null;
|
|
|
|
|
|
|
|
|
|
try {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
TelephonyManager telephonyManager = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (telephonyManager != null) {
|
|
|
|
|
country = telephonyManager.getSimCountryIso().toUpperCase();
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (country != null) {
|
|
|
|
|
String countryName = languageMap.get(country);
|
|
|
|
|
if (countryName != null) {
|
|
|
|
|
int index = countriesArray.indexOf(countryName);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
codeField.setText(countriesMap.get(countryName));
|
|
|
|
|
countryState = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (codeField.length() == 0) {
|
|
|
|
|
countryButton.setText(LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField.setHintText(null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (codeField.length() != 0) {
|
|
|
|
|
AndroidUtilities.showKeyboard(phoneField);
|
|
|
|
|
phoneField.requestFocus();
|
2015-11-26 22:04:02 +01:00
|
|
|
|
phoneField.setSelection(phoneField.length());
|
2014-12-01 18:56:31 +01:00
|
|
|
|
} else {
|
|
|
|
|
AndroidUtilities.showKeyboard(codeField);
|
|
|
|
|
codeField.requestFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void selectCountry(String name) {
|
|
|
|
|
int index = countriesArray.indexOf(name);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
ignoreOnTextChange = true;
|
2015-11-26 22:04:02 +01:00
|
|
|
|
String code = countriesMap.get(name);
|
|
|
|
|
codeField.setText(code);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryButton.setText(name);
|
2015-11-26 22:04:02 +01:00
|
|
|
|
String hint = phoneFormatMap.get(code);
|
|
|
|
|
phoneField.setHintText(hint != null ? hint.replace('X', '–') : null);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
countryState = 0;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
ignoreOnTextChange = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
|
|
if (ignoreSelection) {
|
|
|
|
|
ignoreSelection = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ignoreOnTextChange = true;
|
|
|
|
|
String str = countriesArray.get(i);
|
|
|
|
|
codeField.setText(countriesMap.get(str));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
ignoreOnTextChange = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onCancelPressed() {
|
|
|
|
|
nextPressed = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onNothingSelected(AdapterView<?> adapterView) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onNextPressed() {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (getParentActivity() == null || nextPressed) {
|
2014-12-01 18:56:31 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
TelephonyManager tm = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService(Context.TELEPHONY_SERVICE);
|
|
|
|
|
boolean simcardAvailable = tm.getSimState() != TelephonyManager.SIM_STATE_ABSENT && tm.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE;
|
|
|
|
|
boolean allowCall = true;
|
|
|
|
|
if (Build.VERSION.SDK_INT >= 23 && simcardAvailable) {
|
|
|
|
|
allowCall = getParentActivity().checkSelfPermission(Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_GRANTED;
|
|
|
|
|
if (checkPermissions) {
|
|
|
|
|
permissionsItems.clear();
|
|
|
|
|
if (!allowCall) {
|
|
|
|
|
permissionsItems.add(Manifest.permission.READ_PHONE_STATE);
|
|
|
|
|
}
|
|
|
|
|
if (!permissionsItems.isEmpty()) {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (preferences.getBoolean("firstlogin", true) || getParentActivity().shouldShowRequestPermissionRationale(Manifest.permission.READ_PHONE_STATE)) {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
preferences.edit().putBoolean("firstlogin", 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);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
builder.setMessage(LocaleController.getString("AllowReadCall", R.string.AllowReadCall));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
permissionsDialog = showDialog(builder.create());
|
|
|
|
|
} else {
|
2019-08-22 01:53:26 +02:00
|
|
|
|
getParentActivity().requestPermissions(permissionsItems.toArray(new String[0]), 6);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (countryState == 1) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
AlertsCreator.showSimpleAlert(ChangePhoneActivity.this, LocaleController.getString("ChooseCountry", R.string.ChooseCountry));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (codeField.length() == 0) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
AlertsCreator.showSimpleAlert(ChangePhoneActivity.this, LocaleController.getString("InvalidPhoneNumber", R.string.InvalidPhoneNumber));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
final TLRPC.TL_account_sendChangePhoneCode req = new TLRPC.TL_account_sendChangePhoneCode();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
String phone = PhoneFormat.stripExceptNumbers("" + codeField.getText() + phoneField.getText());
|
|
|
|
|
req.phone_number = phone;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
req.settings = new TLRPC.TL_codeSettings();
|
|
|
|
|
req.settings.allow_flashcall = simcardAvailable && allowCall;
|
2019-08-22 01:53:26 +02:00
|
|
|
|
req.settings.allow_app_hash = ApplicationLoader.hasPlayServices;
|
2019-09-10 12:56:11 +02:00
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
|
|
|
|
if (req.settings.allow_app_hash) {
|
|
|
|
|
preferences.edit().putString("sms_hash", BuildVars.SMS_HASH).commit();
|
|
|
|
|
} else {
|
|
|
|
|
preferences.edit().remove("sms_hash").commit();
|
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (req.settings.allow_flashcall) {
|
2016-10-11 13:57:01 +02:00
|
|
|
|
try {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
@SuppressLint("HardwareIds") String number = tm.getLine1Number();
|
|
|
|
|
if (!TextUtils.isEmpty(number)) {
|
2019-05-14 14:08:05 +02:00
|
|
|
|
req.settings.current_number = PhoneNumberUtils.compare(phone, number);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (!req.settings.current_number) {
|
|
|
|
|
req.settings.allow_flashcall = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
req.settings.current_number = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
}
|
2016-10-11 13:57:01 +02:00
|
|
|
|
} catch (Exception e) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
req.settings.allow_flashcall = false;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2016-10-11 13:57:01 +02:00
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
final Bundle params = new Bundle();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
params.putString("phone", "+" + codeField.getText() + " " + phoneField.getText());
|
2016-03-16 13:26:32 +01:00
|
|
|
|
try {
|
|
|
|
|
params.putString("ephone", "+" + PhoneFormat.stripExceptNumbers(codeField.getText().toString()) + " " + PhoneFormat.stripExceptNumbers(phoneField.getText().toString()));
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
params.putString("ephone", "+" + phone);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
params.putString("phoneFormated", phone);
|
|
|
|
|
nextPressed = true;
|
|
|
|
|
needShowProgress();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
nextPressed = false;
|
|
|
|
|
if (error == null) {
|
|
|
|
|
fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
|
|
|
|
|
} else {
|
|
|
|
|
AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req, params.getString("phone"));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
needHideProgress();
|
|
|
|
|
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onShow() {
|
|
|
|
|
super.onShow();
|
|
|
|
|
if (phoneField != null) {
|
2015-11-26 22:04:02 +01:00
|
|
|
|
if (codeField.length() != 0) {
|
|
|
|
|
AndroidUtilities.showKeyboard(phoneField);
|
|
|
|
|
phoneField.requestFocus();
|
|
|
|
|
phoneField.setSelection(phoneField.length());
|
|
|
|
|
} else {
|
|
|
|
|
AndroidUtilities.showKeyboard(codeField);
|
|
|
|
|
codeField.requestFocus();
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String getHeaderName() {
|
|
|
|
|
return LocaleController.getString("ChangePhoneNewNumber", R.string.ChangePhoneNewNumber);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LoginActivitySmsView extends SlideView implements NotificationCenter.NotificationCenterDelegate {
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private String phone;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private String phoneHash;
|
|
|
|
|
private String requestPhone;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private String emailPhone;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
private LinearLayout codeFieldContainer;
|
|
|
|
|
private EditTextBoldCursor[] codeField;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private TextView confirmTextView;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
private TextView titleTextView;
|
|
|
|
|
private ImageView blackImageView;
|
2021-02-23 12:53:38 +01:00
|
|
|
|
private RLottieImageView blueImageView;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private TextView timeText;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private TextView problemText;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private Bundle currentParams;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private ProgressView progressView;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
|
RLottieDrawable hintDrawable;
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private Timer timeTimer;
|
|
|
|
|
private Timer codeTimer;
|
|
|
|
|
private final Object timerSync = new Object();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
private int time = 60000;
|
|
|
|
|
private int codeTime = 15000;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private double lastCurrentTime;
|
|
|
|
|
private double lastCodeTime;
|
2015-11-26 22:04:02 +01:00
|
|
|
|
private boolean ignoreOnTextChange;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private boolean waitingForEvent;
|
|
|
|
|
private boolean nextPressed;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
private String lastError = "";
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private int currentType;
|
|
|
|
|
private int nextType;
|
|
|
|
|
private String pattern = "*";
|
|
|
|
|
private int length;
|
|
|
|
|
private int timeout;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
public LoginActivitySmsView(Context context, final int type) {
|
2014-12-01 18:56:31 +01:00
|
|
|
|
super(context);
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
currentType = type;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
setOrientation(VERTICAL);
|
|
|
|
|
|
|
|
|
|
confirmTextView = new TextView(context);
|
2017-03-31 01:58:05 +02:00
|
|
|
|
confirmTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
confirmTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
|
confirmTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
titleTextView = new TextView(context);
|
|
|
|
|
titleTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
|
|
|
|
titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
|
titleTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
|
|
|
|
titleTextView.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
|
|
|
|
titleTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 3) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
confirmTextView.setGravity(Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
FrameLayout frameLayout = new FrameLayout(context);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
|
|
|
|
ImageView imageView = new ImageView(context);
|
|
|
|
|
imageView.setImageResource(R.drawable.phone_activate);
|
|
|
|
|
if (LocaleController.isRTL) {
|
|
|
|
|
frameLayout.addView(imageView, LayoutHelper.createFrame(64, 76, Gravity.LEFT | Gravity.CENTER_VERTICAL, 2, 2, 0, 0));
|
|
|
|
|
frameLayout.addView(confirmTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 64 + 18, 0, 0, 0));
|
|
|
|
|
} else {
|
|
|
|
|
frameLayout.addView(confirmTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT, 0, 0, 64 + 18, 0));
|
|
|
|
|
frameLayout.addView(imageView, LayoutHelper.createFrame(64, 76, Gravity.RIGHT | Gravity.CENTER_VERTICAL, 0, 2, 0, 2));
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
confirmTextView.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
FrameLayout frameLayout = new FrameLayout(context);
|
|
|
|
|
addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (currentType == 1) {
|
|
|
|
|
blackImageView = new ImageView(context);
|
|
|
|
|
blackImageView.setImageResource(R.drawable.sms_devices);
|
|
|
|
|
blackImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
frameLayout.addView(blackImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
|
blueImageView = new RLottieImageView(context);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
blueImageView.setImageResource(R.drawable.sms_bubble);
|
|
|
|
|
blueImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_actionBackground), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
titleTextView.setText(LocaleController.getString("SentAppCodeTitle", R.string.SentAppCodeTitle));
|
|
|
|
|
} else {
|
2021-02-23 12:53:38 +01:00
|
|
|
|
blueImageView = new RLottieImageView(context);
|
|
|
|
|
hintDrawable = new RLottieDrawable(R.raw.sms_incoming_info, "" + R.raw.sms_incoming_info, AndroidUtilities.dp(64), AndroidUtilities.dp(64), true, null);
|
|
|
|
|
hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
|
|
|
|
hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
|
|
|
|
blueImageView.setAnimation(hintDrawable);
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
frameLayout.addView(blueImageView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, 0));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
titleTextView.setText(LocaleController.getString("SentSmsCodeTitle", R.string.SentSmsCodeTitle));
|
2015-11-26 22:04:02 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, 18, 0, 0));
|
|
|
|
|
addView(confirmTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, 17, 0, 0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
codeFieldContainer = new LinearLayout(context);
|
|
|
|
|
codeFieldContainer.setOrientation(HORIZONTAL);
|
|
|
|
|
addView(codeFieldContainer, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, 36, Gravity.CENTER_HORIZONTAL));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 3) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
codeFieldContainer.setVisibility(GONE);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
timeText = new TextView(context) {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.AT_MOST));
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-03-31 01:58:05 +02:00
|
|
|
|
timeText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText6));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
timeText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 3) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
timeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
|
|
|
|
addView(timeText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
progressView = new ProgressView(context);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
timeText.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
addView(progressView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 3, 0, 12, 0, 0));
|
2019-01-23 18:03:33 +01:00
|
|
|
|
} else {
|
|
|
|
|
timeText.setPadding(0, AndroidUtilities.dp(2), 0, AndroidUtilities.dp(10));
|
|
|
|
|
timeText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
|
|
|
|
timeText.setGravity(Gravity.TOP | Gravity.CENTER_HORIZONTAL);
|
|
|
|
|
addView(timeText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
problemText = new TextView(context) {
|
|
|
|
|
@Override
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
|
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(100), MeasureSpec.AT_MOST));
|
|
|
|
|
}
|
|
|
|
|
};
|
2017-03-31 01:58:05 +02:00
|
|
|
|
problemText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
problemText.setLineSpacing(AndroidUtilities.dp(2), 1.0f);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
problemText.setPadding(0, AndroidUtilities.dp(2), 0, AndroidUtilities.dp(10));
|
|
|
|
|
problemText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
|
|
|
|
|
problemText.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
|
|
|
|
if (currentType == 1) {
|
|
|
|
|
problemText.setText(LocaleController.getString("DidNotGetTheCodeSms", R.string.DidNotGetTheCodeSms));
|
|
|
|
|
} else {
|
|
|
|
|
problemText.setText(LocaleController.getString("DidNotGetTheCode", R.string.DidNotGetTheCode));
|
|
|
|
|
}
|
|
|
|
|
addView(problemText, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL | Gravity.TOP));
|
|
|
|
|
problemText.setOnClickListener(v -> {
|
|
|
|
|
if (nextPressed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
boolean email = nextType == 4 && currentType == 2 || nextType == 0;
|
|
|
|
|
if (!email) {
|
|
|
|
|
resendCode();
|
|
|
|
|
} else {
|
|
|
|
|
try {
|
|
|
|
|
PackageInfo pInfo = ApplicationLoader.applicationContext.getPackageManager().getPackageInfo(ApplicationLoader.applicationContext.getPackageName(), 0);
|
|
|
|
|
String version = String.format(Locale.US, "%s (%d)", pInfo.versionName, pInfo.versionCode);
|
|
|
|
|
|
2021-04-14 03:44:46 +02:00
|
|
|
|
Intent mailer = new Intent(Intent.ACTION_SENDTO);
|
|
|
|
|
mailer.setData(Uri.parse("mailto:"));
|
2019-01-23 18:03:33 +01:00
|
|
|
|
mailer.putExtra(Intent.EXTRA_EMAIL, new String[]{"sms@stel.com"});
|
|
|
|
|
mailer.putExtra(Intent.EXTRA_SUBJECT, "Android registration/login issue " + version + " " + emailPhone);
|
|
|
|
|
mailer.putExtra(Intent.EXTRA_TEXT, "Phone: " + requestPhone + "\nApp version: " + version + "\nOS version: SDK " + Build.VERSION.SDK_INT + "\nDevice Name: " + Build.MANUFACTURER + Build.MODEL + "\nLocale: " + Locale.getDefault() + "\nError: " + lastError);
|
|
|
|
|
getContext().startActivity(Intent.createChooser(mailer, "Send email..."));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
AlertsCreator.showSimpleAlert(ChangePhoneActivity.this, LocaleController.getString("NoMailInstalled", R.string.NoMailInstalled));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-01-23 18:03:33 +01:00
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
@Override
|
|
|
|
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
|
|
|
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
|
|
|
|
if (currentType != 3 && blueImageView != null) {
|
|
|
|
|
int innerHeight = blueImageView.getMeasuredHeight() + titleTextView.getMeasuredHeight() + confirmTextView.getMeasuredHeight() + AndroidUtilities.dp(18 + 17);
|
|
|
|
|
int requiredHeight = AndroidUtilities.dp(80);
|
|
|
|
|
int maxHeight = AndroidUtilities.dp(291);
|
|
|
|
|
if (scrollHeight - innerHeight < requiredHeight) {
|
|
|
|
|
setMeasuredDimension(getMeasuredWidth(), innerHeight + requiredHeight);
|
|
|
|
|
} else if (scrollHeight > maxHeight) {
|
|
|
|
|
setMeasuredDimension(getMeasuredWidth(), maxHeight);
|
|
|
|
|
} else {
|
|
|
|
|
setMeasuredDimension(getMeasuredWidth(), scrollHeight);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
@Override
|
|
|
|
|
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
|
|
|
|
super.onLayout(changed, l, t, r, b);
|
|
|
|
|
if (currentType != 3 && blueImageView != null) {
|
|
|
|
|
int bottom = confirmTextView.getBottom();
|
|
|
|
|
int height = getMeasuredHeight() - bottom;
|
|
|
|
|
|
|
|
|
|
int h;
|
|
|
|
|
if (problemText.getVisibility() == VISIBLE) {
|
|
|
|
|
h = problemText.getMeasuredHeight();
|
|
|
|
|
t = bottom + height - h;
|
|
|
|
|
problemText.layout(problemText.getLeft(), t, problemText.getRight(), t + h);
|
|
|
|
|
} else if (timeText.getVisibility() == VISIBLE) {
|
|
|
|
|
h = timeText.getMeasuredHeight();
|
|
|
|
|
t = bottom + height - h;
|
|
|
|
|
timeText.layout(timeText.getLeft(), t, timeText.getRight(), t + h);
|
|
|
|
|
} else {
|
|
|
|
|
t = bottom + height;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
|
|
|
|
|
height = t - bottom;
|
|
|
|
|
h = codeFieldContainer.getMeasuredHeight();
|
|
|
|
|
t = (height - h) / 2 + bottom;
|
|
|
|
|
codeFieldContainer.layout(codeFieldContainer.getLeft(), t, codeFieldContainer.getRight(), t + h);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
private void resendCode() {
|
|
|
|
|
final Bundle params = new Bundle();
|
|
|
|
|
params.putString("phone", phone);
|
|
|
|
|
params.putString("ephone", emailPhone);
|
|
|
|
|
params.putString("phoneFormated", requestPhone);
|
|
|
|
|
|
|
|
|
|
nextPressed = true;
|
|
|
|
|
needShowProgress();
|
|
|
|
|
|
2017-03-31 01:58:05 +02:00
|
|
|
|
final TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
|
2016-03-16 13:26:32 +01:00
|
|
|
|
req.phone_number = requestPhone;
|
|
|
|
|
req.phone_code_hash = phoneHash;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
nextPressed = false;
|
|
|
|
|
if (error == null) {
|
|
|
|
|
fillNextCodeParams(params, (TLRPC.TL_auth_sentCode) response);
|
|
|
|
|
} else {
|
|
|
|
|
AlertDialog dialog = (AlertDialog) AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
|
|
|
|
|
if (dialog != null && error.text.contains("PHONE_CODE_EXPIRED")) {
|
|
|
|
|
dialog.setPositiveButtonListener((dialog1, which) -> {
|
|
|
|
|
onBackPressed(true);
|
|
|
|
|
finishFragment();
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
needHideProgress();
|
|
|
|
|
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public String getHeaderName() {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (currentType == 1) {
|
|
|
|
|
return phone;
|
|
|
|
|
} else {
|
|
|
|
|
return LocaleController.getString("YourCode", R.string.YourCode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean needBackButton() {
|
|
|
|
|
return true;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-08 18:35:59 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onCancelPressed() {
|
|
|
|
|
nextPressed = false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
2017-03-31 01:58:05 +02:00
|
|
|
|
public void setParams(Bundle params, boolean restore) {
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (params == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
waitingForEvent = true;
|
|
|
|
|
if (currentType == 2) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(true);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveSmsCode);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(true);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didReceiveCall);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
currentParams = params;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
phone = params.getString("phone");
|
|
|
|
|
emailPhone = params.getString("ephone");
|
2014-12-01 18:56:31 +01:00
|
|
|
|
requestPhone = params.getString("phoneFormated");
|
|
|
|
|
phoneHash = params.getString("phoneHash");
|
2016-03-16 13:26:32 +01:00
|
|
|
|
timeout = time = params.getInt("timeout");
|
|
|
|
|
nextType = params.getInt("nextType");
|
|
|
|
|
pattern = params.getString("pattern");
|
|
|
|
|
length = params.getInt("length");
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (length == 0) {
|
|
|
|
|
length = 5;
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (codeField == null || codeField.length != length) {
|
|
|
|
|
codeField = new EditTextBoldCursor[length];
|
|
|
|
|
for (int a = 0; a < length; a++) {
|
|
|
|
|
final int num = a;
|
|
|
|
|
codeField[a] = new EditTextBoldCursor(getContext());
|
|
|
|
|
codeField[a].setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
codeField[a].setCursorColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
codeField[a].setCursorSize(AndroidUtilities.dp(20));
|
|
|
|
|
codeField[a].setCursorWidth(1.5f);
|
|
|
|
|
|
|
|
|
|
Drawable pressedDrawable = getResources().getDrawable(R.drawable.search_dark_activated).mutate();
|
|
|
|
|
pressedDrawable.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated), PorterDuff.Mode.MULTIPLY));
|
|
|
|
|
|
|
|
|
|
codeField[a].setBackgroundDrawable(pressedDrawable);
|
|
|
|
|
codeField[a].setImeOptions(EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
|
|
|
|
codeField[a].setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
|
|
|
|
codeField[a].setMaxLines(1);
|
|
|
|
|
codeField[a].setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
|
|
|
|
codeField[a].setPadding(0, 0, 0, 0);
|
|
|
|
|
codeField[a].setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
|
|
|
|
|
if (currentType == 3) {
|
|
|
|
|
codeField[a].setEnabled(false);
|
|
|
|
|
codeField[a].setInputType(InputType.TYPE_NULL);
|
|
|
|
|
codeField[a].setVisibility(GONE);
|
|
|
|
|
} else {
|
|
|
|
|
codeField[a].setInputType(InputType.TYPE_CLASS_PHONE);
|
|
|
|
|
}
|
|
|
|
|
codeFieldContainer.addView(codeField[a], LayoutHelper.createLinear(34, 36, Gravity.CENTER_HORIZONTAL, 0, 0, a != length - 1 ? 7 : 0, 0));
|
|
|
|
|
codeField[a].addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
|
|
if (ignoreOnTextChange) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
int len = s.length();
|
|
|
|
|
if (len >= 1) {
|
|
|
|
|
if (len > 1) {
|
|
|
|
|
String text = s.toString();
|
|
|
|
|
ignoreOnTextChange = true;
|
|
|
|
|
for (int a = 0; a < Math.min(length - num, len); a++) {
|
|
|
|
|
if (a == 0) {
|
|
|
|
|
s.replace(0, len, text.substring(a, a + 1));
|
|
|
|
|
} else {
|
|
|
|
|
codeField[num + a].setText(text.substring(a, a + 1));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ignoreOnTextChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (num != length - 1) {
|
|
|
|
|
codeField[num + 1].setSelection(codeField[num + 1].length());
|
|
|
|
|
codeField[num + 1].requestFocus();
|
|
|
|
|
}
|
|
|
|
|
if ((num == length - 1 || num == length - 2 && len >= 2) && getCode().length() == length) {
|
|
|
|
|
onNextPressed();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
codeField[a].setOnKeyListener((v, keyCode, event) -> {
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_DEL && codeField[num].length() == 0 && num > 0) {
|
|
|
|
|
codeField[num - 1].setSelection(codeField[num - 1].length());
|
|
|
|
|
codeField[num - 1].requestFocus();
|
|
|
|
|
codeField[num - 1].dispatchKeyEvent(event);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
codeField[a].setOnEditorActionListener((textView, i, keyEvent) -> {
|
|
|
|
|
if (i == EditorInfo.IME_ACTION_NEXT) {
|
|
|
|
|
onNextPressed();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
for (int a = 0; a < codeField.length; a++) {
|
|
|
|
|
codeField[a].setText("");
|
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (progressView != null) {
|
|
|
|
|
progressView.setVisibility(nextType != 0 ? VISIBLE : GONE);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
if (phone == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String number = PhoneFormat.getInstance().format(phone);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
CharSequence str = "";
|
|
|
|
|
if (currentType == 1) {
|
|
|
|
|
str = AndroidUtilities.replaceTags(LocaleController.getString("SentAppCode", R.string.SentAppCode));
|
|
|
|
|
} else if (currentType == 2) {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
str = AndroidUtilities.replaceTags(LocaleController.formatString("SentSmsCode", R.string.SentSmsCode, LocaleController.addNbsp(number)));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 3) {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallCode", R.string.SentCallCode, LocaleController.addNbsp(number)));
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 4) {
|
2018-07-30 04:07:02 +02:00
|
|
|
|
str = AndroidUtilities.replaceTags(LocaleController.formatString("SentCallOnly", R.string.SentCallOnly, LocaleController.addNbsp(number)));
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
confirmTextView.setText(str);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType != 3) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
AndroidUtilities.showKeyboard(codeField[0]);
|
|
|
|
|
codeField[0].requestFocus();
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
AndroidUtilities.hideKeyboard(codeField[0]);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
|
|
|
|
|
destroyTimer();
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
|
2016-03-16 13:26:32 +01:00
|
|
|
|
lastCurrentTime = System.currentTimeMillis();
|
|
|
|
|
if (currentType == 1) {
|
|
|
|
|
problemText.setVisibility(VISIBLE);
|
|
|
|
|
timeText.setVisibility(GONE);
|
|
|
|
|
} else if (currentType == 3 && (nextType == 4 || nextType == 2)) {
|
|
|
|
|
problemText.setVisibility(GONE);
|
|
|
|
|
timeText.setVisibility(VISIBLE);
|
|
|
|
|
if (nextType == 4) {
|
|
|
|
|
timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 1, 0));
|
|
|
|
|
} else if (nextType == 2) {
|
|
|
|
|
timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 1, 0));
|
|
|
|
|
}
|
|
|
|
|
createTimer();
|
2016-04-22 15:49:00 +02:00
|
|
|
|
} else if (currentType == 2 && (nextType == 4 || nextType == 3)) {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
timeText.setText(LocaleController.formatString("CallText", R.string.CallText, 2, 0));
|
|
|
|
|
problemText.setVisibility(time < 1000 ? VISIBLE : GONE);
|
2019-01-23 18:03:33 +01:00
|
|
|
|
timeText.setVisibility(time < 1000 ? GONE : VISIBLE);
|
|
|
|
|
createTimer();
|
|
|
|
|
} else if (currentType == 4 && nextType == 2) {
|
|
|
|
|
timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, 2, 0));
|
|
|
|
|
problemText.setVisibility(time < 1000 ? VISIBLE : GONE);
|
|
|
|
|
timeText.setVisibility(time < 1000 ? GONE : VISIBLE);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
createTimer();
|
|
|
|
|
} else {
|
|
|
|
|
timeText.setVisibility(GONE);
|
|
|
|
|
problemText.setVisibility(GONE);
|
|
|
|
|
createCodeTimer();
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createCodeTimer() {
|
|
|
|
|
if (codeTimer != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
codeTime = 15000;
|
|
|
|
|
codeTimer = new Timer();
|
|
|
|
|
lastCodeTime = System.currentTimeMillis();
|
|
|
|
|
codeTimer.schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
double currentTime = System.currentTimeMillis();
|
|
|
|
|
double diff = currentTime - lastCodeTime;
|
|
|
|
|
lastCodeTime = currentTime;
|
|
|
|
|
codeTime -= diff;
|
|
|
|
|
if (codeTime <= 1000) {
|
|
|
|
|
problemText.setVisibility(VISIBLE);
|
|
|
|
|
timeText.setVisibility(GONE);
|
|
|
|
|
destroyCodeTimer();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, 0, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void destroyCodeTimer() {
|
|
|
|
|
try {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
synchronized (timerSync) {
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (codeTimer != null) {
|
|
|
|
|
codeTimer.cancel();
|
|
|
|
|
codeTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void createTimer() {
|
|
|
|
|
if (timeTimer != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
timeTimer = new Timer();
|
|
|
|
|
timeTimer.schedule(new TimerTask() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (timeTimer == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-12-31 14:08:08 +01:00
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
final double currentTime = System.currentTimeMillis();
|
|
|
|
|
double diff = currentTime - lastCurrentTime;
|
|
|
|
|
time -= diff;
|
|
|
|
|
lastCurrentTime = currentTime;
|
|
|
|
|
if (time >= 1000) {
|
|
|
|
|
int minutes = time / 1000 / 60;
|
|
|
|
|
int seconds = time / 1000 - minutes * 60;
|
|
|
|
|
if (nextType == 4 || nextType == 3) {
|
|
|
|
|
timeText.setText(LocaleController.formatString("CallText", R.string.CallText, minutes, seconds));
|
|
|
|
|
} else if (nextType == 2) {
|
|
|
|
|
timeText.setText(LocaleController.formatString("SmsText", R.string.SmsText, minutes, seconds));
|
|
|
|
|
}
|
|
|
|
|
if (progressView != null) {
|
|
|
|
|
progressView.setProgress(1.0f - (float) time / (float) timeout);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (progressView != null) {
|
|
|
|
|
progressView.setProgress(1.0f);
|
|
|
|
|
}
|
|
|
|
|
destroyTimer();
|
|
|
|
|
if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(false);
|
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
|
|
|
|
|
waitingForEvent = false;
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
resendCode();
|
|
|
|
|
} else if (currentType == 2 || currentType == 4) {
|
|
|
|
|
if (nextType == 4 || nextType == 2) {
|
|
|
|
|
if (nextType == 4) {
|
|
|
|
|
timeText.setText(LocaleController.getString("Calling", R.string.Calling));
|
|
|
|
|
} else {
|
|
|
|
|
timeText.setText(LocaleController.getString("SendingSms", R.string.SendingSms));
|
|
|
|
|
}
|
|
|
|
|
createCodeTimer();
|
|
|
|
|
TLRPC.TL_auth_resendCode req = new TLRPC.TL_auth_resendCode();
|
|
|
|
|
req.phone_number = requestPhone;
|
|
|
|
|
req.phone_code_hash = phoneHash;
|
|
|
|
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
|
|
|
|
if (error != null && error.text != null) {
|
|
|
|
|
AndroidUtilities.runOnUIThread(() -> lastError = error.text);
|
|
|
|
|
}
|
|
|
|
|
}, ConnectionsManager.RequestFlagFailOnServerErrors);
|
|
|
|
|
} else if (nextType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(false);
|
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
waitingForEvent = false;
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
resendCode();
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}, 0, 1000);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void destroyTimer() {
|
|
|
|
|
try {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
synchronized (timerSync) {
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (timeTimer != null) {
|
|
|
|
|
timeTimer.cancel();
|
|
|
|
|
timeTimer = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
FileLog.e(e);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
private String getCode() {
|
|
|
|
|
if (codeField == null) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
StringBuilder codeBuilder = new StringBuilder();
|
|
|
|
|
for (int a = 0; a < codeField.length; a++) {
|
|
|
|
|
codeBuilder.append(PhoneFormat.stripExceptNumbers(codeField[a].getText().toString()));
|
|
|
|
|
}
|
|
|
|
|
return codeBuilder.toString();
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
@Override
|
|
|
|
|
public void onNextPressed() {
|
|
|
|
|
if (nextPressed) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
String code = getCode();
|
|
|
|
|
if (TextUtils.isEmpty(code)) {
|
|
|
|
|
AndroidUtilities.shakeView(codeFieldContainer, 2, 0);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
nextPressed = true;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 2) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
waitingForEvent = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
final TLRPC.TL_account_changePhone req = new TLRPC.TL_account_changePhone();
|
|
|
|
|
req.phone_number = requestPhone;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
req.phone_code = code;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
req.phone_code_hash = phoneHash;
|
|
|
|
|
destroyTimer();
|
|
|
|
|
needShowProgress();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
needHideProgress();
|
|
|
|
|
nextPressed = false;
|
|
|
|
|
if (error == null) {
|
|
|
|
|
TLRPC.User user = (TLRPC.User) response;
|
|
|
|
|
destroyTimer();
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
UserConfig.getInstance(currentAccount).setCurrentUser(user);
|
|
|
|
|
UserConfig.getInstance(currentAccount).saveConfig(true);
|
|
|
|
|
ArrayList<TLRPC.User> users = new ArrayList<>();
|
|
|
|
|
users.add(user);
|
|
|
|
|
MessagesStorage.getInstance(currentAccount).putUsersAndChats(users, null, true, true);
|
|
|
|
|
MessagesController.getInstance(currentAccount).putUser(user, false);
|
|
|
|
|
finishFragment();
|
|
|
|
|
NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
|
|
|
|
|
} else {
|
|
|
|
|
lastError = error.text;
|
|
|
|
|
if (currentType == 3 && (nextType == 4 || nextType == 2) || currentType == 2 && (nextType == 4 || nextType == 3) || currentType == 4 && nextType == 2) {
|
|
|
|
|
createTimer();
|
|
|
|
|
}
|
|
|
|
|
if (currentType == 2) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(true);
|
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveSmsCode);
|
|
|
|
|
} else if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(true);
|
|
|
|
|
NotificationCenter.getGlobalInstance().addObserver(LoginActivitySmsView.this, NotificationCenter.didReceiveCall);
|
|
|
|
|
}
|
|
|
|
|
waitingForEvent = true;
|
|
|
|
|
if (currentType != 3) {
|
|
|
|
|
AlertsCreator.processError(currentAccount, error, ChangePhoneActivity.this, req);
|
|
|
|
|
}
|
|
|
|
|
if (error.text.contains("PHONE_CODE_EMPTY") || error.text.contains("PHONE_CODE_INVALID")) {
|
|
|
|
|
for (int a = 0; a < codeField.length; a++) {
|
|
|
|
|
codeField[a].setText("");
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
codeField[0].requestFocus();
|
|
|
|
|
} else if (error.text.contains("PHONE_CODE_EXPIRED")) {
|
|
|
|
|
onBackPressed(true);
|
|
|
|
|
setPage(0, true, null, true);
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2019-01-23 18:03:33 +01:00
|
|
|
|
public boolean onBackPressed(boolean force) {
|
|
|
|
|
if (!force) {
|
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
|
builder.setMessage(LocaleController.getString("StopVerification", R.string.StopVerification));
|
|
|
|
|
builder.setPositiveButton(LocaleController.getString("Continue", R.string.Continue), null);
|
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Stop", R.string.Stop), (dialogInterface, i) -> {
|
|
|
|
|
onBackPressed(true);
|
|
|
|
|
setPage(0, true, null, true);
|
|
|
|
|
});
|
|
|
|
|
showDialog(builder.create());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
TLRPC.TL_auth_cancelCode req = new TLRPC.TL_auth_cancelCode();
|
|
|
|
|
req.phone_number = requestPhone;
|
|
|
|
|
req.phone_code_hash = phoneHash;
|
|
|
|
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
|
|
|
|
|
|
|
|
|
}, ConnectionsManager.RequestFlagFailOnServerErrors | ConnectionsManager.RequestFlagWithoutLogin);
|
|
|
|
|
|
2014-12-01 18:56:31 +01:00
|
|
|
|
destroyTimer();
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
currentParams = null;
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 2) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
waitingForEvent = false;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
return true;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroyActivity() {
|
|
|
|
|
super.onDestroyActivity();
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (currentType == 2) {
|
|
|
|
|
AndroidUtilities.setWaitingForSms(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveSmsCode);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
} else if (currentType == 3) {
|
|
|
|
|
AndroidUtilities.setWaitingForCall(false);
|
2018-07-30 04:07:02 +02:00
|
|
|
|
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didReceiveCall);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
}
|
|
|
|
|
waitingForEvent = false;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
destroyTimer();
|
|
|
|
|
destroyCodeTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onShow() {
|
|
|
|
|
super.onShow();
|
2019-01-23 18:03:33 +01:00
|
|
|
|
if (currentType == 3) {
|
|
|
|
|
return;
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
2021-02-23 12:53:38 +01:00
|
|
|
|
if (hintDrawable != null) {
|
|
|
|
|
hintDrawable.setCurrentFrame(0);
|
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
AndroidUtilities.runOnUIThread(() -> {
|
|
|
|
|
if (codeField != null) {
|
|
|
|
|
for (int a = codeField.length - 1; a >= 0; a--) {
|
|
|
|
|
if (a == 0 || codeField[a].length() != 0) {
|
|
|
|
|
codeField[a].requestFocus();
|
|
|
|
|
codeField[a].setSelection(codeField[a].length());
|
|
|
|
|
AndroidUtilities.showKeyboard(codeField[a]);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-23 12:53:38 +01:00
|
|
|
|
if (hintDrawable != null) {
|
|
|
|
|
hintDrawable.start();
|
|
|
|
|
}
|
2019-01-23 18:03:33 +01:00
|
|
|
|
}, 100);
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2018-07-30 04:07:02 +02:00
|
|
|
|
public void didReceivedNotification(int id, int account, Object... args) {
|
2016-03-16 13:26:32 +01:00
|
|
|
|
if (!waitingForEvent || codeField == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
if (id == NotificationCenter.didReceiveSmsCode) {
|
2019-01-23 18:03:33 +01:00
|
|
|
|
codeField[0].setText("" + args[0]);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
onNextPressed();
|
|
|
|
|
} else if (id == NotificationCenter.didReceiveCall) {
|
|
|
|
|
String num = "" + args[0];
|
2017-03-31 01:58:05 +02:00
|
|
|
|
if (!AndroidUtilities.checkPhonePattern(pattern, num)) {
|
|
|
|
|
return;
|
2015-05-21 23:27:27 +02:00
|
|
|
|
}
|
2016-03-16 13:26:32 +01:00
|
|
|
|
ignoreOnTextChange = true;
|
2019-01-23 18:03:33 +01:00
|
|
|
|
codeField[0].setText(num);
|
2016-03-16 13:26:32 +01:00
|
|
|
|
ignoreOnTextChange = false;
|
|
|
|
|
onNextPressed();
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-31 01:58:05 +02:00
|
|
|
|
|
|
|
|
|
@Override
|
2020-04-24 11:21:58 +02:00
|
|
|
|
public ArrayList<ThemeDescription> getThemeDescriptions() {
|
2017-03-31 01:58:05 +02:00
|
|
|
|
PhoneView phoneView = (PhoneView) views[0];
|
|
|
|
|
LoginActivitySmsView smsView1 = (LoginActivitySmsView) views[1];
|
|
|
|
|
LoginActivitySmsView smsView2 = (LoginActivitySmsView) views[2];
|
|
|
|
|
LoginActivitySmsView smsView3 = (LoginActivitySmsView) views[3];
|
|
|
|
|
LoginActivitySmsView smsView4 = (LoginActivitySmsView) views[4];
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
ArrayList<ThemeDescription> arrayList = new ArrayList<>();
|
|
|
|
|
|
2021-02-23 12:53:38 +01:00
|
|
|
|
ThemeDescription.ThemeDescriptionDelegate descriptionDelegate = () -> {
|
|
|
|
|
for (int i = 0; i < views.length; i++) {
|
|
|
|
|
if (views[i] instanceof LoginActivity.LoginActivitySmsView) {
|
|
|
|
|
LoginActivity.LoginActivitySmsView smsView = (LoginActivity.LoginActivitySmsView) views[i];
|
|
|
|
|
if (smsView.hintDrawable != null) {
|
|
|
|
|
smsView.hintDrawable.setLayerColor("Bubble.**", Theme.getColor(Theme.key_chats_actionBackground));
|
|
|
|
|
smsView.hintDrawable.setLayerColor("Phone.**", Theme.getColor(Theme.key_chats_actionBackground));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2019-01-23 18:03:33 +01:00
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhite));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_actionBarDefault));
|
|
|
|
|
arrayList.add(new ThemeDescription(fragmentView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
|
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_ITEMSCOLOR, null, null, null, null, Theme.key_actionBarDefaultIcon));
|
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_TITLECOLOR, null, null, null, null, Theme.key_actionBarDefaultTitle));
|
|
|
|
|
arrayList.add(new ThemeDescription(actionBar, ThemeDescription.FLAG_AB_SELECTORCOLOR, null, null, null, null, Theme.key_actionBarDefaultSelector));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.countryButton, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
2019-12-31 14:08:08 +01:00
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.countryButton, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_listSelector));
|
2019-01-23 18:03:33 +01:00
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.view, ThemeDescription.FLAG_BACKGROUND, null, null, null, null, Theme.key_windowBackgroundWhiteGrayLine));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.textView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.codeField, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.codeField, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.codeField, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.phoneField, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.phoneField, ThemeDescription.FLAG_HINTTEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteHintText));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.phoneField, ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputField));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.phoneField, ThemeDescription.FLAG_BACKGROUNDFILTER | ThemeDescription.FLAG_DRAWABLESELECTEDSTATE, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
arrayList.add(new ThemeDescription(phoneView.textView2, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.confirmTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
if (smsView1.codeField != null) {
|
|
|
|
|
for (int a = 0; a < smsView1.codeField.length; a++) {
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.codeField[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.codeField[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.timeText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.problemText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressInner));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView1.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.confirmTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
if (smsView2.codeField != null) {
|
|
|
|
|
for (int a = 0; a < smsView2.codeField.length; a++) {
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.codeField[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.codeField[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.timeText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.problemText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressInner));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView2.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.confirmTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
if (smsView3.codeField != null) {
|
|
|
|
|
for (int a = 0; a < smsView3.codeField.length; a++) {
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.codeField[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.codeField[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.timeText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.problemText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressInner));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView3.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
|
|
|
|
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.confirmTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.titleTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
if (smsView4.codeField != null) {
|
|
|
|
|
for (int a = 0; a < smsView4.codeField.length; a++) {
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.codeField[a], ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.codeField[a], ThemeDescription.FLAG_BACKGROUNDFILTER, null, null, null, null, Theme.key_windowBackgroundWhiteInputFieldActivated));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.timeText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText6));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.problemText, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlueText4));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressInner));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.progressView, 0, new Class[]{ProgressView.class}, new String[]{"paint"}, null, null, null, Theme.key_login_progressOuter));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.blackImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteBlackText));
|
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.blueImageView, ThemeDescription.FLAG_IMAGECOLOR, null, null, null, null, Theme.key_chats_actionBackground));
|
2021-02-23 12:53:38 +01:00
|
|
|
|
arrayList.add(new ThemeDescription(smsView4.blueImageView, 0, null, null, null, descriptionDelegate, Theme.key_chats_actionBackground));
|
2019-01-23 18:03:33 +01:00
|
|
|
|
|
2020-04-24 11:21:58 +02:00
|
|
|
|
return arrayList;
|
2017-03-31 01:58:05 +02:00
|
|
|
|
}
|
2014-12-01 18:56:31 +01:00
|
|
|
|
}
|