List of usage examples for android.widget TextView setLinkTextColor
public final void setLinkTextColor(ColorStateList colors)
From source file:com.ubuntuone.android.files.fragment.SignUpFragment.java
private void setupViews(View content) { fullnameEditText = (EditTextPlus) content.findViewById(R.id.sso_fullname); emailErrorTextView = (TextViewPlus) content.findViewById(R.id.email_error); emailEditText = (EditTextPlus) content.findViewById(R.id.sso_username); passwordErrorTextView = (TextViewPlus) content.findViewById(R.id.password_error); passwordEditText = (EditTextPlus) content.findViewById(R.id.sso_password); passwordVisibleCheckBox = (CheckBoxPlus) content.findViewById(R.id.password_toggle); passwordVisibleCheckBox.setOnClickListener(this); captchaErrorTextView = (TextViewPlus) content.findViewById(R.id.captcha_error); signupButton = (Button) content.findViewById(R.id.sso_signup); signupButton.setOnClickListener(onButtonClickedListener); final TextView footer = (TextView) content.findViewById(R.id.signup_footer_tos); footer.setText(Html.fromHtml(getString(R.string.signup_footer_tos))); footer.setLinkTextColor(getResources().getColor(R.color.web_url)); footer.setMovementMethod(LinkMovementMethod.getInstance()); setupCaptchaImageView(content);/* w w w. j ava2s .c o m*/ }
From source file:com.orange.essentials.otb.ui.OtbTermsFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { mView = inflater.inflate(R.layout.otb_terms, container, false); LinearLayout llayout = (LinearLayout) mView.findViewById(R.id.otb_terms_layout); TextView headerTv = (TextView) llayout.findViewById(R.id.otb_header_tv_text); headerTv.setText(R.string.otb_home_terms_content); List<Term> terms = TrustBadgeManager.INSTANCE.getTerms(); for (Term term : terms) { View layoutToAdd = null;//from w w w . j a va2 s .c o m if (term.getTermType() == TermType.VIDEO && Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) { layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_video, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_video_title); final AutoResizingFrameLayout anchorView = (AutoResizingFrameLayout) layoutToAdd .findViewById(R.id.videoSurfaceContainer); if (mVideoViews == null) { mVideoViews = new ArrayList<>(); } mVideoViews.add(anchorView); SurfaceView videoSurface = (SurfaceView) layoutToAdd.findViewById(R.id.videoSurface); titleTv.setText(term.getTitleId()); SurfaceHolder videoHolder = videoSurface.getHolder(); MediaPlayer player = new MediaPlayer(); if (mPlayers == null) { mPlayers = new ArrayList<>(); } mPlayers.add(player); final VideoControllerView controller = new VideoControllerView(getContext()); VideoCallback videoCallback = new VideoCallback(player, controller, anchorView); videoHolder.addCallback(videoCallback); anchorView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { controller.show(); return false; } }); try { player.setAudioStreamType(AudioManager.STREAM_MUSIC); player.setDataSource(getContext(), Uri.parse(getString(term.getContentId()))); player.setOnPreparedListener(videoCallback); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } else if (term.getTermType() == TermType.TEXT) {//TermType.TEXT layoutToAdd = View.inflate(getActivity(), R.layout.otb_terms_text, null); TextView titleTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_title); TextView contentTv = (TextView) layoutToAdd.findViewById(R.id.otb_term_text_content); titleTv.setText(term.getTitleId()); contentTv.setText(Html.fromHtml(getString(term.getContentId()))); contentTv.setMovementMethod(LinkMovementMethod.getInstance()); contentTv.setLinkTextColor(getResources().getColor(R.color.colorAccent)); } if (null != layoutToAdd) { llayout.addView(layoutToAdd); } if (terms.indexOf(term) != terms.size() - 1) { View.inflate(getActivity(), R.layout.otb_separator, llayout); } } return mView; }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
private void setUpInterface() { timerView = commentsBar.findViewById(R.id.timer_container); commentButton = commentsBar.findViewById(R.id.commentButton); commentField = (EditText) commentsBar.findViewById(R.id.commentField); final boolean showTimerShortcut = preferences.getBoolean(R.string.p_show_timer_shortcut, false); if (showTimerShortcut) { commentField.setOnFocusChangeListener(new OnFocusChangeListener() { @Override//from ww w . j av a2s . c om public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { timerView.setVisibility(View.GONE); commentButton.setVisibility(View.VISIBLE); } else { timerView.setVisibility(View.VISIBLE); commentButton.setVisibility(View.GONE); } } }); } commentField.setHorizontallyScrolling(false); commentField.setMaxLines(Integer.MAX_VALUE); commentField.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { AndroidUtilities.hideSoftInputForViews(activity, commentField); return true; } return false; } }); commentField.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { commentField.setCursorVisible(true); } }); commentField.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable s) { commentButton.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.VISIBLE : View.GONE); if (showTimerShortcut) { timerView.setVisibility( (s.length() > 0 || pendingCommentPicture != null) ? View.GONE : View.VISIBLE); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // } }); commentField.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView view, int actionId, KeyEvent event) { if (commentField.getText().length() > 0) { if (actionId == EditorInfo.IME_ACTION_DONE || actionId == EditorInfo.IME_NULL) { // commentField.setCursorVisible(false); addComment(); } } return false; } }); commentButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { addComment(); } }); final ClearImageCallback clearImage = new ClearImageCallback() { @Override public void clearImage() { pendingCommentPicture = null; pictureButton.setImageResource(cameraButton); } }; pictureButton = (ImageButton) commentsBar.findViewById(R.id.picture); pictureButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (pendingCommentPicture != null) { actFmCameraModule.showPictureLauncher(clearImage); } else { actFmCameraModule.showPictureLauncher(null); } respondToPicture = true; } }); if (!TextUtils.isEmpty(task.getNotes())) { TextView notes = new TextView(getContext()); notes.setLinkTextColor(Color.rgb(100, 160, 255)); notes.setTextSize(18); notes.setText(task.getNotes()); notes.setPadding(5, 10, 5, 10); Linkify.addLinks(notes, Linkify.ALL); } if (activity != null) { String uri = activity.getIntent().getStringExtra(TaskEditFragment.TOKEN_PICTURE_IN_PROGRESS); if (uri != null) { pendingCommentPicture = Uri.parse(uri); setPictureButtonToPendingPicture(); } } }
From source file:org.telegram.ui.IdenticonActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("EncryptionKey", R.string.EncryptionKey)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override//from w w w . ja v a 2 s .c om public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); fragmentView = new LinearLayout(context); LinearLayout linearLayout = (LinearLayout) fragmentView; linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setWeightSum(100); linearLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.card_background)); fragmentView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); FrameLayout frameLayout = new FrameLayout(context); frameLayout.setPadding(AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20), AndroidUtilities.dp(20)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); ImageView identiconView = new ImageView(context); identiconView.setScaleType(ImageView.ScaleType.FIT_XY); frameLayout.addView(identiconView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); frameLayout = new FrameLayout(context); frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.background)); frameLayout.setPadding(AndroidUtilities.dp(10), 0, AndroidUtilities.dp(10), AndroidUtilities.dp(10)); linearLayout.addView(frameLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 50.0f)); TextView textView = new TextView(context); textView.setTextColor(ContextCompat.getColor(context, R.color.secondary_text)); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setLinksClickable(true); textView.setClickable(true); textView.setMovementMethod(new LinkMovementMethodMy()); //textView.setAutoLinkMask(Linkify.WEB_URLS); textView.setLinkTextColor(Theme.MSG_LINK_TEXT_COLOR); textView.setGravity(Gravity.CENTER); frameLayout.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat(chat_id); if (encryptedChat != null) { IdenticonDrawable drawable = new IdenticonDrawable(); identiconView.setImageDrawable(drawable); drawable.setEncryptedChat(encryptedChat); TLRPC.User user = MessagesController.getInstance().getUser(encryptedChat.user_id); SpannableStringBuilder hash = new SpannableStringBuilder(); if (encryptedChat.key_hash.length > 16) { String hex = Utilities.bytesToHex(encryptedChat.key_hash); for (int a = 0; a < 32; a++) { if (a != 0) { if (a % 8 == 0) { hash.append('\n'); } else if (a % 4 == 0) { hash.append(' '); } } hash.append(hex.substring(a * 2, a * 2 + 2)); hash.append(' '); } hash.append("\n\n"); } hash.append(AndroidUtilities.replaceTags(LocaleController.formatString("EncryptionKeyDescription", R.string.EncryptionKeyDescription, user.first_name, user.first_name))); final String url = "telegram.org"; int index = hash.toString().indexOf(url); if (index != -1) { hash.setSpan( new URLSpanReplacement( LocaleController.getString("EncryptionKeyLink", R.string.EncryptionKeyLink)), index, index + url.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } textView.setText(hash); } return fragmentView; }
From source file:br.com.carlosrafaelgn.fplay.ActivityBrowserRadio.java
@Override public void onClick(View view) { if (view == btnGoBack) { if (isAtFavorites) { isAtFavorites = false;/*from w w w . ja v a 2 s . c om*/ doSearch(); } else { finish(0, view, true); } } else if (view == btnFavorite) { isAtFavorites = true; radioStationList.cancel(); radioStationList.fetchFavorites(getApplication()); updateButtons(); } else if (view == btnSearch) { final Context ctx = getHostActivity(); final LinearLayout l = (LinearLayout) UI.createDialogView(ctx, null); LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); chkGenre = new RadioButton(ctx); chkGenre.setText(R.string.genre); chkGenre.setChecked(Player.lastRadioSearchWasByGenre); chkGenre.setOnClickListener(this); chkGenre.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; btnGenre = new Spinner(ctx); btnGenre.setContentDescription(ctx.getText(R.string.genre)); btnGenre.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad << 1; chkTerm = new RadioButton(ctx); chkTerm.setText(R.string.search_term); chkTerm.setChecked(!Player.lastRadioSearchWasByGenre); chkTerm.setOnClickListener(this); chkTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); chkTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; txtTerm = new EditText(ctx); txtTerm.setContentDescription(ctx.getText(R.string.search_term)); txtTerm.setText(Player.radioSearchTerm == null ? "" : Player.radioSearchTerm); txtTerm.setOnClickListener(this); txtTerm.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._DLGsp); txtTerm.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES); txtTerm.setSingleLine(); txtTerm.setLayoutParams(p); p = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT); p.topMargin = UI._DLGsppad; p.bottomMargin = UI._DLGsppad; final TextView lbl = new TextView(ctx); lbl.setAutoLinkMask(0); lbl.setLinksClickable(true); //http://developer.android.com/design/style/color.html lbl.setLinkTextColor(new BgColorStateList(UI.isAndroidThemeLight() ? 0xff0099cc : 0xff33b5e5)); lbl.setTextSize(TypedValue.COMPLEX_UNIT_PX, UI._14sp); lbl.setGravity(Gravity.CENTER_HORIZONTAL); lbl.setText(SafeURLSpan.parseSafeHtml(getText(R.string.by_dir_xiph_org))); lbl.setMovementMethod(LinkMovementMethod.getInstance()); lbl.setLayoutParams(p); l.addView(chkGenre); l.addView(btnGenre); l.addView(chkTerm); l.addView(txtTerm); l.addView(lbl); btnGenre.setAdapter(this); btnGenre.setSelection(getValidGenre(Player.radioLastGenre)); defaultTextColors = txtTerm.getTextColors(); UI.prepareDialogAndShow((new AlertDialog.Builder(ctx)).setTitle(getText(R.string.search)).setView(l) .setPositiveButton(R.string.search, this).setNegativeButton(R.string.cancel, this) .setOnCancelListener(this).create()); } else if (view == btnGoBackToPlayer) { finish(-1, view, false); } else if (view == btnAdd) { addPlaySelectedItem(false); } else if (view == btnPlay) { addPlaySelectedItem(true); } else if (view == chkGenre || view == btnGenre) { chkGenre.setChecked(true); chkTerm.setChecked(false); } else if (view == chkTerm || view == txtTerm) { chkGenre.setChecked(false); chkTerm.setChecked(true); } else if (view == list) { if (!isAtFavorites && !loading && (radioStationList == null || radioStationList.getCount() == 0)) onClick(btnFavorite); } }
From source file:net.kourlas.voipms_sms.adapters.ConversationRecyclerViewAdapter.java
@Override public void onBindViewHolder(MessageViewHolder messageViewHolder, int i) { Message message = messages.get(i);/*from w ww .j a v a 2s . c o m*/ int viewType = getItemViewType(i); if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_RIGHT_PRIMARY) { QuickContactBadge contactBadge = messageViewHolder.getContactBadge(); if (viewType == ITEM_LEFT_PRIMARY) { contactBadge.assignContactFromPhone(message.getContact(), true); } else { contactBadge.assignContactFromPhone(message.getDid(), true); } String photoUri; if (viewType == ITEM_LEFT_PRIMARY) { photoUri = Utils.getContactPhotoUri(applicationContext, message.getContact()); } else { photoUri = Utils.getContactPhotoUri(applicationContext, ContactsContract.Profile.CONTENT_URI); if (photoUri == null) { photoUri = Utils.getContactPhotoUri(applicationContext, message.getDid()); } } if (photoUri != null) { contactBadge.setImageURI(Uri.parse(photoUri)); } else { contactBadge.setImageToDefault(); } } View smsContainer = messageViewHolder.getSmsContainer(); TextView messageText = messageViewHolder.getMessageText(); SpannableStringBuilder messageTextBuilder = new SpannableStringBuilder(); messageTextBuilder.append(message.getText()); if (!filterConstraint.equals("")) { int index = message.getText().toLowerCase().indexOf(filterConstraint.toLowerCase()); if (index != -1) { messageTextBuilder.setSpan( new BackgroundColorSpan(ContextCompat.getColor(applicationContext, R.color.highlight)), index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE); messageTextBuilder.setSpan( new ForegroundColorSpan(ContextCompat.getColor(applicationContext, R.color.dark_gray)), index, index + filterConstraint.length(), SpannableString.SPAN_INCLUSIVE_EXCLUSIVE); } } messageText.setText(messageTextBuilder); TextView dateText = messageViewHolder.getDateText(); if (!message.isDelivered()) { if (!message.isDeliveryInProgress()) { SpannableStringBuilder dateTextBuilder = new SpannableStringBuilder(); if (isItemChecked(i)) { dateTextBuilder .append(applicationContext.getString(R.string.conversation_message_not_sent_selected)); } else { dateTextBuilder.append(applicationContext.getString(R.string.conversation_message_not_sent)); } dateTextBuilder.setSpan( new ForegroundColorSpan( isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white) : ContextCompat.getColor(applicationContext, android.R.color.holo_red_dark)), 0, dateTextBuilder.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE); dateText.setText(dateTextBuilder); dateText.setVisibility(View.VISIBLE); } else { dateText.setText(applicationContext.getString(R.string.conversation_message_sending)); dateText.setVisibility(View.VISIBLE); } } else if (i == messages.size() - 1 || ((viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY) && getItemViewType(i + 1) != ITEM_LEFT_SECONDARY) || ((viewType == ITEM_RIGHT_PRIMARY || viewType == ITEM_RIGHT_SECONDARY) && getItemViewType(i + 1) != ITEM_RIGHT_SECONDARY)) { dateText.setText(Utils.getFormattedDate(applicationContext, message.getDate(), false)); dateText.setVisibility(View.VISIBLE); } else { dateText.setVisibility(View.GONE); } if (viewType == ITEM_LEFT_PRIMARY || viewType == ITEM_LEFT_SECONDARY) { smsContainer.setBackgroundResource(isItemChecked(i) ? android.R.color.holo_blue_dark : R.color.primary); } else { smsContainer.setBackgroundResource( isItemChecked(i) ? android.R.color.holo_blue_dark : android.R.color.white); messageText.setTextColor( isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white) : ContextCompat.getColor(applicationContext, R.color.dark_gray)); messageText.setLinkTextColor( isItemChecked(i) ? ContextCompat.getColor(applicationContext, android.R.color.white) : ContextCompat.getColor(applicationContext, R.color.dark_gray)); dateText.setTextColor( isItemChecked(i) ? ContextCompat.getColor(applicationContext, R.color.message_translucent_white) : ContextCompat.getColor(applicationContext, R.color.message_translucent_dark_grey)); } }
From source file:org.telegram.ui.PassportActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { private boolean onIdentityDone(Runnable finishRunnable, ErrorRunnable errorRunnable) { if (!uploadingDocuments.isEmpty() || checkFieldsForError()) { return false; }/*from w w w . java 2 s . co m*/ if (allowNonLatinName) { allowNonLatinName = false; boolean error = false; for (int a = 0; a < nonLatinNames.length; a++) { if (nonLatinNames[a]) { inputFields[a].setErrorText(LocaleController.getString("PassportUseLatinOnly", R.string.PassportUseLatinOnly)); if (!error) { error = true; String firstName = nonLatinNames[0] ? getTranslitString( inputExtraFields[FIELD_NATIVE_NAME].getText().toString()) : inputFields[FIELD_NAME].getText().toString(); String middleName = nonLatinNames[1] ? getTranslitString( inputExtraFields[FIELD_NATIVE_MIDNAME].getText().toString()) : inputFields[FIELD_MIDNAME].getText().toString(); String lastName = nonLatinNames[2] ? getTranslitString( inputExtraFields[FIELD_NATIVE_SURNAME].getText().toString()) : inputFields[FIELD_SURNAME].getText().toString(); if (!TextUtils.isEmpty(firstName) && !TextUtils.isEmpty(middleName) && !TextUtils.isEmpty(lastName)) { int num = a; AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setMessage(LocaleController.formatString("PassportNameCheckAlert", R.string.PassportNameCheckAlert, firstName, middleName, lastName)); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setPositiveButton(LocaleController.getString("Done", R.string.Done), (dialogInterface, i) -> { inputFields[FIELD_NAME].setText(firstName); inputFields[FIELD_MIDNAME].setText(middleName); inputFields[FIELD_SURNAME].setText(lastName); showEditDoneProgress(true, true); onIdentityDone(finishRunnable, errorRunnable); }); builder.setNegativeButton(LocaleController.getString("Edit", R.string.Edit), (dialogInterface, i) -> onFieldError(inputFields[num])); showDialog(builder.create()); } else { onFieldError(inputFields[a]); } } } } if (error) { return false; } } if (isHasNotAnyChanges()) { finishFragment(); return false; } JSONObject json = null; JSONObject documentsJson = null; try { if (!documentOnly) { HashMap<String, String> valuesToSave = new HashMap<>(currentValues); if (currentType.native_names) { if (nativeInfoCell.getVisibility() == View.VISIBLE) { valuesToSave.put("first_name_native", inputExtraFields[FIELD_NATIVE_NAME].getText().toString()); valuesToSave.put("middle_name_native", inputExtraFields[FIELD_NATIVE_MIDNAME].getText().toString()); valuesToSave.put("last_name_native", inputExtraFields[FIELD_NATIVE_SURNAME].getText().toString()); } else { valuesToSave.put("first_name_native", inputFields[FIELD_NATIVE_NAME].getText().toString()); valuesToSave.put("middle_name_native", inputFields[FIELD_NATIVE_MIDNAME].getText().toString()); valuesToSave.put("last_name_native", inputFields[FIELD_NATIVE_SURNAME].getText().toString()); } } valuesToSave.put("first_name", inputFields[FIELD_NAME].getText().toString()); valuesToSave.put("middle_name", inputFields[FIELD_MIDNAME].getText().toString()); valuesToSave.put("last_name", inputFields[FIELD_SURNAME].getText().toString()); valuesToSave.put("birth_date", inputFields[FIELD_BIRTHDAY].getText().toString()); valuesToSave.put("gender", currentGender); valuesToSave.put("country_code", currentCitizeship); valuesToSave.put("residence_country_code", currentResidence); json = new JSONObject(); ArrayList<String> keys = new ArrayList<>(valuesToSave.keySet()); Collections.sort(keys, (key1, key2) -> { int val1 = getFieldCost(key1); int val2 = getFieldCost(key2); if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } return 0; }); for (int a = 0, size = keys.size(); a < size; a++) { String key = keys.get(a); json.put(key, valuesToSave.get(key)); } } if (currentDocumentsType != null) { HashMap<String, String> valuesToSave = new HashMap<>(currentDocumentValues); valuesToSave.put("document_no", inputFields[FIELD_CARDNUMBER].getText().toString()); if (currentExpireDate[0] != 0) { valuesToSave.put("expiry_date", String.format(Locale.US, "%02d.%02d.%d", currentExpireDate[2], currentExpireDate[1], currentExpireDate[0])); } else { valuesToSave.put("expiry_date", ""); } documentsJson = new JSONObject(); ArrayList<String> keys = new ArrayList<>(valuesToSave.keySet()); Collections.sort(keys, (key1, key2) -> { int val1 = getFieldCost(key1); int val2 = getFieldCost(key2); if (val1 < val2) { return -1; } else if (val1 > val2) { return 1; } return 0; }); for (int a = 0, size = keys.size(); a < size; a++) { String key = keys.get(a); documentsJson.put(key, valuesToSave.get(key)); } } } catch (Exception ignore) { } if (fieldsErrors != null) { fieldsErrors.clear(); } if (documentsErrors != null) { documentsErrors.clear(); } delegate.saveValue(currentType, null, json != null ? json.toString() : null, currentDocumentsType, documentsJson != null ? documentsJson.toString() : null, null, selfieDocument, translationDocuments, frontDocument, reverseLayout != null && reverseLayout.getVisibility() == View.VISIBLE ? reverseDocument : null, finishRunnable, errorRunnable); return true; } @Override public void onItemClick(int id) { if (id == -1) { if (checkDiscard()) { return; } if (currentActivityType == TYPE_REQUEST || currentActivityType == TYPE_PASSWORD) { callCallback(false); } finishFragment(); } else if (id == info_item) { if (getParentActivity() == null) { return; } final TextView message = new TextView(getParentActivity()); String str2 = LocaleController.getString("PassportInfo2", R.string.PassportInfo2); SpannableStringBuilder spanned = new SpannableStringBuilder(str2); int index1 = str2.indexOf('*'); int index2 = str2.lastIndexOf('*'); if (index1 != -1 && index2 != -1) { spanned.replace(index2, index2 + 1, ""); spanned.replace(index1, index1 + 1, ""); spanned.setSpan(new URLSpanNoUnderline( LocaleController.getString("PassportInfoUrl", R.string.PassportInfoUrl)) { @Override public void onClick(View widget) { dismissCurrentDialig(); super.onClick(widget); } }, index1, index2 - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } message.setText(spanned); message.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); message.setLinkTextColor(Theme.getColor(Theme.key_dialogTextLink)); message.setHighlightColor(Theme.getColor(Theme.key_dialogLinkSelection)); message.setPadding(AndroidUtilities.dp(23), 0, AndroidUtilities.dp(23), 0); message.setMovementMethod(new AndroidUtilities.LinkMovementMethodMy()); message.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setView(message); builder.setTitle(LocaleController.getString("PassportInfoTitle", R.string.PassportInfoTitle)); builder.setNegativeButton(LocaleController.getString("Close", R.string.Close), null); showDialog(builder.create()); } else if (id == done_button) { if (currentActivityType == TYPE_PASSWORD) { onPasswordDone(false); return; } if (currentActivityType == TYPE_PHONE_VERIFICATION) { views[currentViewNum].onNextPressed(); } else { final Runnable finishRunnable = () -> finishFragment(); final ErrorRunnable errorRunnable = new ErrorRunnable() { @Override public void onError(String error, String text) { if ("PHONE_VERIFICATION_NEEDED".equals(error)) { startPhoneVerification(true, text, finishRunnable, this, delegate); } else { showEditDoneProgress(true, false); } } }; if (currentActivityType == TYPE_EMAIL) { String value; if (useCurrentValue) { value = currentEmail; } else { if (checkFieldsForError()) { return; } value = inputFields[FIELD_EMAIL].getText().toString(); } delegate.saveValue(currentType, value, null, null, null, null, null, null, null, null, finishRunnable, errorRunnable); } else if (currentActivityType == TYPE_PHONE) { String value; if (useCurrentValue) { value = UserConfig.getInstance(currentAccount).getCurrentUser().phone; } else { if (checkFieldsForError()) { return; } value = inputFields[FIELD_PHONECODE].getText().toString() + inputFields[FIELD_PHONE].getText().toString(); } delegate.saveValue(currentType, value, null, null, null, null, null, null, null, null, finishRunnable, errorRunnable); } else if (currentActivityType == TYPE_ADDRESS) { if (!uploadingDocuments.isEmpty() || checkFieldsForError()) { return; } if (isHasNotAnyChanges()) { finishFragment(); return; } JSONObject json = null; try { if (!documentOnly) { json = new JSONObject(); json.put("street_line1", inputFields[FIELD_STREET1].getText().toString()); json.put("street_line2", inputFields[FIELD_STREET2].getText().toString()); json.put("post_code", inputFields[FIELD_POSTCODE].getText().toString()); json.put("city", inputFields[FIELD_CITY].getText().toString()); json.put("state", inputFields[FIELD_STATE].getText().toString()); json.put("country_code", currentCitizeship); } } catch (Exception ignore) { } if (fieldsErrors != null) { fieldsErrors.clear(); } if (documentsErrors != null) { documentsErrors.clear(); } delegate.saveValue(currentType, null, json != null ? json.toString() : null, currentDocumentsType, null, documents, selfieDocument, translationDocuments, null, null, finishRunnable, errorRunnable); } else if (currentActivityType == TYPE_IDENTITY) { if (!onIdentityDone(finishRunnable, errorRunnable)) { return; } } else if (currentActivityType == TYPE_EMAIL_VERIFICATION) { final TLRPC.TL_account_verifyEmail req = new TLRPC.TL_account_verifyEmail(); req.email = currentValues.get("email"); req.code = inputFields[FIELD_EMAIL].getText().toString(); int reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { if (error == null) { delegate.saveValue(currentType, currentValues.get("email"), null, null, null, null, null, null, null, null, finishRunnable, errorRunnable); } else { AlertsCreator.processError(currentAccount, error, PassportActivity.this, req); errorRunnable.onError(null, null); } })); ConnectionsManager.getInstance(currentAccount).bindRequestToGuid(reqId, classGuid); } showEditDoneProgress(true, true); } } } }); if (currentActivityType == TYPE_PHONE_VERIFICATION) { fragmentView = scrollView = new ScrollView(context) { @Override protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { return false; } @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); } }; scrollView.setFillViewport(true); AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_actionBarDefault)); } else { fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; fragmentView.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray)); scrollView = new ScrollView(context) { @Override protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) { return false; } @Override public boolean requestChildRectangleOnScreen(View child, Rect rectangle, boolean immediate) { rectangle.offset(child.getLeft() - child.getScrollX(), child.getTop() - child.getScrollY()); rectangle.top += AndroidUtilities.dp(20); rectangle.bottom += AndroidUtilities.dp(50); return super.requestChildRectangleOnScreen(child, rectangle, immediate); } }; scrollView.setFillViewport(true); AndroidUtilities.setScrollViewEdgeEffectColor(scrollView, Theme.getColor(Theme.key_actionBarDefault)); frameLayout.addView(scrollView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 0, 0, currentActivityType == TYPE_REQUEST ? 48 : 0)); linearLayout2 = new LinearLayout(context); linearLayout2.setOrientation(LinearLayout.VERTICAL); scrollView.addView(linearLayout2, new ScrollView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); } if (currentActivityType != TYPE_REQUEST && currentActivityType != TYPE_MANAGE) { ActionBarMenu menu = actionBar.createMenu(); doneItem = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56)); progressView = new ContextProgressView(context, 1); progressView.setAlpha(0.0f); progressView.setScaleX(0.1f); progressView.setScaleY(0.1f); progressView.setVisibility(View.INVISIBLE); doneItem.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); if (currentActivityType == TYPE_IDENTITY || currentActivityType == TYPE_ADDRESS) { if (chatAttachAlert != null) { try { if (chatAttachAlert.isShowing()) { chatAttachAlert.dismiss(); } } catch (Exception ignore) { } chatAttachAlert.onDestroy(); chatAttachAlert = null; } } } if (currentActivityType == TYPE_PASSWORD) { createPasswordInterface(context); } else if (currentActivityType == TYPE_REQUEST) { createRequestInterface(context); } else if (currentActivityType == TYPE_IDENTITY) { createIdentityInterface(context); fillInitialValues(); } else if (currentActivityType == TYPE_ADDRESS) { createAddressInterface(context); fillInitialValues(); } else if (currentActivityType == TYPE_PHONE) { createPhoneInterface(context); } else if (currentActivityType == TYPE_EMAIL) { createEmailInterface(context); } else if (currentActivityType == TYPE_EMAIL_VERIFICATION) { createEmailVerificationInterface(context); } else if (currentActivityType == TYPE_PHONE_VERIFICATION) { createPhoneVerificationInterface(context); } else if (currentActivityType == TYPE_MANAGE) { createManageInterface(context); } return fragmentView; }