mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Add activity to create or edit users.
This commit is contained in:
@@ -1328,17 +1328,8 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
addToContactsButton.setMaxLines(1);
|
||||
addToContactsButton.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0);
|
||||
addToContactsButton.setGravity(Gravity.CENTER);
|
||||
addToContactsButton.setText(LocaleController.getString("AddContactChat", R.string.AddContactChat));
|
||||
addToContactsButton.setText("foo bar");
|
||||
reportSpamView.addView(addToContactsButton, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0.5f, Gravity.LEFT | Gravity.TOP, 0, 0, 0, AndroidUtilities.dp(1)));
|
||||
addToContactsButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", currentUser.id);
|
||||
args.putBoolean("addContact", true);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
}
|
||||
});
|
||||
|
||||
reportSpamContainer = new FrameLayout(context);
|
||||
reportSpamView.addView(reportSpamContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 0, AndroidUtilities.dp(1)));
|
||||
@@ -5680,40 +5671,6 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
|
||||
chatActivityEnterView.addRecentGif(searchImage);
|
||||
break;
|
||||
}
|
||||
case 12: {
|
||||
// was: edit messages
|
||||
break;
|
||||
}
|
||||
case 13: {
|
||||
// was: pinning
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
// was: unpinning
|
||||
break;
|
||||
}
|
||||
case 15: {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", selectedObject.messageOwner.media.user_id);
|
||||
args.putString("phone", selectedObject.messageOwner.media.phone_number);
|
||||
args.putBoolean("addContact", true);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
break;
|
||||
}
|
||||
case 16: {
|
||||
AndroidUtilities.addToClipboard(selectedObject.messageOwner.media.phone_number);
|
||||
break;
|
||||
}
|
||||
case 17: {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + selectedObject.messageOwner.media.phone_number));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
getParentActivity().startActivityForResult(intent, 500);
|
||||
} catch (Exception e) {
|
||||
FileLog.e("tmessages", e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
selectedObject = null;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
/*
|
||||
* This part of the Delta Chat fronted is based on Telegram which is covered by the following note:
|
||||
*
|
||||
* This is the source code of Telegram for Android v. 3.x.x.
|
||||
* It is licensed under GNU GPL v. 2 or later.
|
||||
* You should have received a copy of the license in this archive (see LICENSE).
|
||||
@@ -8,28 +10,25 @@
|
||||
|
||||
package org.telegram.ui;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
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.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.widget.EditText;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ContactsController;
|
||||
import org.telegram.messenger.LocaleController;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
import org.telegram.tgnet.TLRPC;
|
||||
import org.telegram.messenger.MessagesController;
|
||||
import org.telegram.messenger.NotificationCenter;
|
||||
@@ -37,271 +36,282 @@ import org.telegram.messenger.R;
|
||||
import org.telegram.ui.ActionBar.ActionBar;
|
||||
import org.telegram.ui.ActionBar.ActionBarMenu;
|
||||
import org.telegram.ui.Components.AvatarDrawable;
|
||||
import org.telegram.ui.Components.AvatarUpdater;
|
||||
import org.telegram.ui.Components.BackupImageView;
|
||||
import org.telegram.ui.ActionBar.BaseFragment;
|
||||
import org.telegram.ui.Components.LayoutHelper;
|
||||
|
||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
|
||||
|
||||
private View doneButton;
|
||||
private EditText firstNameField;
|
||||
private EditText lastNameField;
|
||||
public class ContactAddActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, AvatarUpdater.AvatarUpdaterDelegate {
|
||||
|
||||
private int do_what = 0;
|
||||
public final static int CREATE_CONTACT = 1;
|
||||
public final static int EDIT_NAME = 2;
|
||||
|
||||
private EditText nameTextView;
|
||||
private EditText emailTextView;
|
||||
private TLRPC.FileLocation avatar;
|
||||
private TLRPC.InputFile uploadedAvatar;
|
||||
private BackupImageView avatarImage;
|
||||
private TextView nameTextView;
|
||||
private TextView onlineTextView;
|
||||
|
||||
private AvatarDrawable avatarDrawable;
|
||||
private boolean createAfterUpload;
|
||||
private AvatarUpdater avatarUpdater = new AvatarUpdater();
|
||||
private String nameToSet = null;
|
||||
private int user_id;
|
||||
private boolean addContact;
|
||||
private String phone = null;
|
||||
|
||||
private final static int done_button = 1;
|
||||
|
||||
public ContactAddActivity(Bundle args) {
|
||||
super(args);
|
||||
avatarDrawable = new AvatarDrawable();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public boolean onFragmentCreate() {
|
||||
NotificationCenter.getInstance().addObserver(this, NotificationCenter.updateInterfaces);
|
||||
avatarUpdater.parentFragment = this;
|
||||
avatarUpdater.delegate = this;
|
||||
do_what = getArguments().getInt("do_what", 0);
|
||||
user_id = getArguments().getInt("user_id", 0);
|
||||
phone = getArguments().getString("phone");
|
||||
addContact = getArguments().getBoolean("addContact", false);
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
return user != null && super.onFragmentCreate();
|
||||
return super.onFragmentCreate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentDestroy() {
|
||||
super.onFragmentDestroy();
|
||||
NotificationCenter.getInstance().removeObserver(this, NotificationCenter.updateInterfaces);
|
||||
|
||||
avatarUpdater.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View createView(Context context) {
|
||||
actionBar.setBackButtonImage(R.drawable.ic_ab_back);
|
||||
actionBar.setAllowOverlayTitle(true);
|
||||
if (addContact) {
|
||||
if (do_what==CREATE_CONTACT) {
|
||||
actionBar.setTitle(LocaleController.getString("NewContactTitle", R.string.NewContactTitle));
|
||||
} else {
|
||||
actionBar.setTitle(LocaleController.getString("EditName", R.string.EditName));
|
||||
}
|
||||
|
||||
actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
|
||||
@Override
|
||||
public void onItemClick(int id) {
|
||||
if (id == -1) {
|
||||
finishFragment();
|
||||
} else if (id == done_button) {
|
||||
if (firstNameField.getText().length() != 0) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
user.first_name = firstNameField.getText().toString();
|
||||
user.last_name = lastNameField.getText().toString();
|
||||
ContactsController.getInstance().addContact(user);
|
||||
finishFragment();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
||||
preferences.edit().putInt("spam3_" + user_id, 1).commit();
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||
if (do_what==CREATE_CONTACT) {
|
||||
String name = nameTextView.getText().toString();
|
||||
String addr = emailTextView.getText().toString();
|
||||
//MrMailbox.MrMailboxCreateContact(MrMailbox.hMailbox, name, addr);
|
||||
}
|
||||
else if(do_what == EDIT_NAME) {
|
||||
}
|
||||
finishFragment();
|
||||
NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, MessagesController.UPDATE_MASK_NAME);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ActionBarMenu menu = actionBar.createMenu();
|
||||
doneButton = menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
menu.addItemWithWidth(done_button, R.drawable.ic_done, AndroidUtilities.dp(56));
|
||||
|
||||
fragmentView = new ScrollView(context);
|
||||
|
||||
LinearLayout linearLayout = new LinearLayout(context);
|
||||
fragmentView = new LinearLayout(context);
|
||||
LinearLayout linearLayout = (LinearLayout) fragmentView;
|
||||
linearLayout.setOrientation(LinearLayout.VERTICAL);
|
||||
((ScrollView) fragmentView).addView(linearLayout);
|
||||
ScrollView.LayoutParams layoutParams2 = (ScrollView.LayoutParams) linearLayout.getLayoutParams();
|
||||
layoutParams2.width = ScrollView.LayoutParams.MATCH_PARENT;
|
||||
layoutParams2.height = ScrollView.LayoutParams.WRAP_CONTENT;
|
||||
linearLayout.setLayoutParams(layoutParams2);
|
||||
linearLayout.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
FrameLayout frameLayout = new FrameLayout(context);
|
||||
linearLayout.addView(frameLayout);
|
||||
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) frameLayout.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
|
||||
frameLayout.setLayoutParams(layoutParams);
|
||||
|
||||
avatarImage = new BackupImageView(context);
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(30));
|
||||
avatarImage.setRoundRadius(AndroidUtilities.dp(32));
|
||||
avatarDrawable.setInfoByName(null);
|
||||
avatarImage.setImageDrawable(avatarDrawable);
|
||||
frameLayout.addView(avatarImage);
|
||||
FrameLayout.LayoutParams layoutParams3 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
||||
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
|
||||
layoutParams3.width = AndroidUtilities.dp(60);
|
||||
layoutParams3.height = AndroidUtilities.dp(60);
|
||||
avatarImage.setLayoutParams(layoutParams3);
|
||||
FrameLayout.LayoutParams layoutParams1 = (FrameLayout.LayoutParams) avatarImage.getLayoutParams();
|
||||
layoutParams1.width = AndroidUtilities.dp(64);
|
||||
layoutParams1.height = AndroidUtilities.dp(64);
|
||||
layoutParams1.topMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.bottomMargin = AndroidUtilities.dp(12);
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? 0 : AndroidUtilities.dp(16);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : 0;
|
||||
layoutParams1.gravity = Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
avatarImage.setLayoutParams(layoutParams1);
|
||||
{
|
||||
avatarDrawable.setDrawPhoto(true);
|
||||
avatarImage.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (getParentActivity() == null) {
|
||||
return;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
||||
|
||||
nameTextView = new TextView(context);
|
||||
CharSequence[] items;
|
||||
|
||||
if (avatar != null) {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley), LocaleController.getString("DeletePhoto", R.string.DeletePhoto)};
|
||||
} else {
|
||||
items = new CharSequence[]{LocaleController.getString("FromCamera", R.string.FromCamera), LocaleController.getString("FromGalley", R.string.FromGalley)};
|
||||
}
|
||||
|
||||
builder.setItems(items, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialogInterface, int i) {
|
||||
if (i == 0) {
|
||||
avatarUpdater.openCamera();
|
||||
} else if (i == 1) {
|
||||
avatarUpdater.openGallery();
|
||||
} else if (i == 2) {
|
||||
avatar = null;
|
||||
uploadedAvatar = null;
|
||||
avatarImage.setImage(avatar, "50_50", avatarDrawable);
|
||||
}
|
||||
}
|
||||
});
|
||||
showDialog(builder.create());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
nameTextView = new EditText(context);
|
||||
nameTextView.setHint(LocaleController.getString("Name", R.string.Name));
|
||||
if (nameToSet != null) {
|
||||
nameTextView.setText(nameToSet);
|
||||
nameToSet = null;
|
||||
}
|
||||
nameTextView.setMaxLines(4);
|
||||
nameTextView.setGravity(Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
nameTextView.setHintTextColor(0xff979797);
|
||||
nameTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
nameTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
||||
nameTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
|
||||
InputFilter[] inputFilters = new InputFilter[1];
|
||||
inputFilters[0] = new InputFilter.LengthFilter(100);
|
||||
nameTextView.setFilters(inputFilters);
|
||||
AndroidUtilities.clearCursorDrawable(nameTextView);
|
||||
nameTextView.setTextColor(0xff212121);
|
||||
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
|
||||
nameTextView.setLines(1);
|
||||
nameTextView.setMaxLines(1);
|
||||
nameTextView.setSingleLine(true);
|
||||
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
|
||||
frameLayout.addView(nameTextView);
|
||||
layoutParams3 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
layoutParams3.width = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams3.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
|
||||
layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
|
||||
layoutParams3.topMargin = AndroidUtilities.dp(3);
|
||||
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
|
||||
nameTextView.setLayoutParams(layoutParams3);
|
||||
layoutParams1 = (FrameLayout.LayoutParams) nameTextView.getLayoutParams();
|
||||
layoutParams1.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams1.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams1.leftMargin = LocaleController.isRTL ? AndroidUtilities.dp(16) : AndroidUtilities.dp(96);
|
||||
layoutParams1.rightMargin = LocaleController.isRTL ? AndroidUtilities.dp(96) : AndroidUtilities.dp(16);
|
||||
layoutParams1.gravity = Gravity.CENTER_VERTICAL;
|
||||
nameTextView.setLayoutParams(layoutParams1);
|
||||
{
|
||||
nameTextView.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
onlineTextView = new TextView(context);
|
||||
onlineTextView.setTextColor(0xff999999);
|
||||
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
|
||||
onlineTextView.setLines(1);
|
||||
onlineTextView.setMaxLines(1);
|
||||
onlineTextView.setSingleLine(true);
|
||||
onlineTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
|
||||
frameLayout.addView(onlineTextView);
|
||||
layoutParams3 = (FrameLayout.LayoutParams) onlineTextView.getLayoutParams();
|
||||
layoutParams3.width = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams3.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams3.leftMargin = AndroidUtilities.dp(LocaleController.isRTL ? 0 : 80);
|
||||
layoutParams3.rightMargin = AndroidUtilities.dp(LocaleController.isRTL ? 80 : 0);
|
||||
layoutParams3.topMargin = AndroidUtilities.dp(32);
|
||||
layoutParams3.gravity = (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP;
|
||||
onlineTextView.setLayoutParams(layoutParams3);
|
||||
|
||||
firstNameField = new EditText(context);
|
||||
firstNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
firstNameField.setHintTextColor(0xff979797);
|
||||
firstNameField.setTextColor(0xff212121);
|
||||
firstNameField.setMaxLines(1);
|
||||
firstNameField.setLines(1);
|
||||
firstNameField.setSingleLine(true);
|
||||
firstNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
firstNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
firstNameField.setImeOptions(EditorInfo.IME_ACTION_NEXT);
|
||||
firstNameField.setHint(LocaleController.getString("FirstName", R.string.FirstName));
|
||||
AndroidUtilities.clearCursorDrawable(firstNameField);
|
||||
linearLayout.addView(firstNameField);
|
||||
layoutParams = (LinearLayout.LayoutParams) firstNameField.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.height = AndroidUtilities.dp(36);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
firstNameField.setLayoutParams(layoutParams);
|
||||
firstNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_NEXT) {
|
||||
lastNameField.requestFocus();
|
||||
lastNameField.setSelection(lastNameField.length());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
lastNameField = new EditText(context);
|
||||
lastNameField.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
|
||||
lastNameField.setHintTextColor(0xff979797);
|
||||
lastNameField.setTextColor(0xff212121);
|
||||
lastNameField.setMaxLines(1);
|
||||
lastNameField.setLines(1);
|
||||
lastNameField.setSingleLine(true);
|
||||
lastNameField.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
lastNameField.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT);
|
||||
lastNameField.setImeOptions(EditorInfo.IME_ACTION_DONE);
|
||||
lastNameField.setHint(LocaleController.getString("LastName", R.string.LastName));
|
||||
AndroidUtilities.clearCursorDrawable(lastNameField);
|
||||
linearLayout.addView(lastNameField);
|
||||
layoutParams = (LinearLayout.LayoutParams) lastNameField.getLayoutParams();
|
||||
layoutParams.topMargin = AndroidUtilities.dp(16);
|
||||
layoutParams.height = AndroidUtilities.dp(36);
|
||||
layoutParams.leftMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.rightMargin = AndroidUtilities.dp(24);
|
||||
layoutParams.width = LayoutHelper.MATCH_PARENT;
|
||||
lastNameField.setLayoutParams(layoutParams);
|
||||
lastNameField.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
||||
@Override
|
||||
public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
|
||||
if (i == EditorInfo.IME_ACTION_DONE) {
|
||||
doneButton.performClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user != null) {
|
||||
if (user.phone == null) {
|
||||
if (phone != null) {
|
||||
user.phone = "";//PhoneFormat.stripExceptNumbers(phone);
|
||||
}
|
||||
}
|
||||
firstNameField.setText(user.first_name);
|
||||
firstNameField.setSelection(firstNameField.length());
|
||||
lastNameField.setText(user.last_name);
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
avatarDrawable.setInfoByName(nameTextView.length() > 0 ? nameTextView.getText().toString() : null);
|
||||
avatarImage.invalidate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if( do_what==CREATE_CONTACT ) {
|
||||
emailTextView = new EditText(context);
|
||||
emailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
|
||||
emailTextView.setHintTextColor(0xff979797);
|
||||
emailTextView.setTextColor(0xff212121);
|
||||
emailTextView.setMaxLines(4);
|
||||
emailTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
|
||||
emailTextView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
|
||||
emailTextView.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
|
||||
emailTextView.setPadding(0, 0, 0, AndroidUtilities.dp(8));
|
||||
emailTextView.setHint(LocaleController.getString("EmailAddress", R.string.EmailAddress));
|
||||
AndroidUtilities.clearCursorDrawable(emailTextView);
|
||||
linearLayout.addView(emailTextView);
|
||||
LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) emailTextView.getLayoutParams();
|
||||
layoutParams2.width = LayoutHelper.MATCH_PARENT;
|
||||
layoutParams2.height = LayoutHelper.WRAP_CONTENT;
|
||||
layoutParams2.topMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.leftMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.rightMargin = AndroidUtilities.dp(16);
|
||||
layoutParams2.gravity = Gravity.CENTER_VERTICAL;
|
||||
emailTextView.setLayoutParams(layoutParams2);
|
||||
}
|
||||
|
||||
return fragmentView;
|
||||
}
|
||||
|
||||
private void updateAvatarLayout() {
|
||||
if (nameTextView == null) {
|
||||
return;
|
||||
}
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
nameTextView.setText(""/*PhoneFormat.getInstance().format("+" + user.phone)*/);
|
||||
onlineTextView.setText(LocaleController.formatUserStatus(user));
|
||||
|
||||
TLRPC.FileLocation photo = null;
|
||||
if (user.photo != null) {
|
||||
photo = user.photo.photo_small;
|
||||
}
|
||||
avatarImage.setImage(photo, "50_50", new AvatarDrawable(user));
|
||||
@Override
|
||||
public void didUploadedPhoto(final TLRPC.InputFile file, final TLRPC.PhotoSize small, final TLRPC.PhotoSize big) {
|
||||
}
|
||||
|
||||
public void didReceivedNotification(int id, Object... args) {
|
||||
if (id == NotificationCenter.updateInterfaces) {
|
||||
int mask = (Integer) args[0];
|
||||
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
|
||||
updateAvatarLayout();
|
||||
@Override
|
||||
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
||||
avatarUpdater.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null && avatarUpdater.currentPicturePath != null) {
|
||||
args.putString("path", avatarUpdater.currentPicturePath);
|
||||
}
|
||||
if (nameTextView != null) {
|
||||
String text = nameTextView.getText().toString();
|
||||
if (text != null && text.length() != 0) {
|
||||
args.putString("nameTextView", text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
updateAvatarLayout();
|
||||
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE);
|
||||
boolean animations = preferences.getBoolean("view_animations", true);
|
||||
if (!animations) {
|
||||
firstNameField.requestFocus();
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
public void restoreSelfArgs(Bundle args) {
|
||||
if (avatarUpdater != null) {
|
||||
avatarUpdater.currentPicturePath = args.getString("path");
|
||||
}
|
||||
String text = args.getString("nameTextView");
|
||||
if (text != null) {
|
||||
if (nameTextView != null) {
|
||||
nameTextView.setText(text);
|
||||
} else {
|
||||
nameToSet = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
|
||||
if (isOpen) {
|
||||
firstNameField.requestFocus();
|
||||
AndroidUtilities.showKeyboard(firstNameField);
|
||||
nameTextView.requestFocus();
|
||||
AndroidUtilities.showKeyboard(nameTextView);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void didReceivedNotification(int id, final Object... args) {
|
||||
if (id == NotificationCenter.updateInterfaces) {
|
||||
int mask = (Integer)args[0];
|
||||
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0 || (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
|
||||
updateVisibleRows(mask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateVisibleRows(int mask) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.telegram.messenger.AndroidUtilities;
|
||||
import org.telegram.messenger.ApplicationLoader;
|
||||
@@ -171,7 +170,9 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
|
||||
}
|
||||
else if( id == id_add_contact )
|
||||
{
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_LONG).show();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactAddActivity.CREATE_CONTACT);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
}
|
||||
else if( id == id_done_button )
|
||||
{
|
||||
|
||||
@@ -121,7 +121,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
|
||||
private TLRPC.Chat currentChat;
|
||||
|
||||
private final static int add_contact = 1;
|
||||
private final static int block_contact = 2;
|
||||
private final static int delete_contact = 5;
|
||||
private final static int invite_to_group = 9;
|
||||
@@ -289,13 +288,6 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
||||
showDialog(builder.create());
|
||||
}
|
||||
|
||||
} else if (id == add_contact) {
|
||||
TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("user_id", user.id);
|
||||
args.putBoolean("addContact", true);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
} else if (id == delete_contact) {
|
||||
final TLRPC.User user = MessagesController.getInstance().getUser(user_id);
|
||||
if (user == null || getParentActivity() == null) {
|
||||
@@ -416,7 +408,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
|
||||
presentFragment(new ProfileNotificationsActivity(args));
|
||||
}
|
||||
else if(position==changeNameRow) {
|
||||
Toast.makeText(getParentActivity(), LocaleController.getString("NotYetImplemented", R.string.NotYetImplemented), Toast.LENGTH_LONG).show();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("do_what", ContactAddActivity.EDIT_NAME);
|
||||
args.putInt("user_id", user_id);
|
||||
presentFragment(new ContactAddActivity(args));
|
||||
}
|
||||
else if(position==startChatRow) {
|
||||
int belonging_chat_id = MrMailbox.MrMailboxGetChatIdByContactId(MrMailbox.hMailbox, user_id);
|
||||
|
||||
@@ -521,7 +521,7 @@
|
||||
<string name="ShareYouLocationUnableManually">Selbst wählen</string>
|
||||
<string name="ShareYouLocationInline">Dieser Bot möchte bei jeder Anfrage deinen Standort wissen. Das kann für standortabhängig aufbereitete Informationen benutzt werden.</string>
|
||||
<string name="AreYouSureBlockContact">Diesen Benutzer wirklich blockieren?</string>
|
||||
<string name="AreYouSureDeleteContact">Diesen Kontakt wirklich löschen?</string>
|
||||
<string name="AreYouSureDeleteContact">Diesen Benutzer wirklich löschen?</string>
|
||||
<string name="AreYouSureRegistration">Bist du dir sicher, dass du die Registrierung abbrechen willst?</string>
|
||||
<string name="AreYouSureDeleteMessages">%1$s löschen? Die Nachrichten werden auch auf dem Server gelöscht.</string>
|
||||
<string name="SendMessagesToGroup">Nachricht an %1$s senden?</string>
|
||||
@@ -716,4 +716,6 @@
|
||||
<string name="DefaultStatusText">Mit meinem Delta Chat Messenger gesendet</string>
|
||||
<string name="SubjectPrefix">Sofortnachricht</string>
|
||||
<string name="SeachUser">Benutzer suchen</string>
|
||||
<string name="Name">Name</string>
|
||||
<string name="EmailAddress">E-Mail-Adresse</string>
|
||||
</resources>
|
||||
|
||||
@@ -520,8 +520,8 @@
|
||||
<string name="ShareYouLocationUnable">App was unable to determine your current location</string>
|
||||
<string name="ShareYouLocationUnableManually">Choose manually</string>
|
||||
<string name="ShareYouLocationInline">This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.</string>
|
||||
<string name="AreYouSureBlockContact">Are you sure you want to block this contact?</string>
|
||||
<string name="AreYouSureDeleteContact">Are you sure you want to delete this contact?</string>
|
||||
<string name="AreYouSureBlockContact">Are you sure you want to block this user?</string>
|
||||
<string name="AreYouSureDeleteContact">Are you sure you want to delete this user?</string>
|
||||
<string name="AreYouSureRegistration">Are you sure you want to cancel registration?</string>
|
||||
<string name="AreYouSureDeleteMessages">Delete %1$s? The messages will also be deleted from the server.</string>
|
||||
<string name="SendMessagesToGroup">Send messages to %1$s?</string>
|
||||
@@ -717,4 +717,6 @@
|
||||
<string name="DefaultStatusText">Sent with my Delta Chat Messenger</string>
|
||||
<string name="SubjectPrefix">Instant message</string>
|
||||
<string name="SeachUser">Search user</string>
|
||||
<string name="Name" >Name</string>
|
||||
<string name="EmailAddress">E-mail address</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user