2013-10-25 15:19:00 +00:00
|
|
|
/*
|
2013-12-20 19:25:49 +00:00
|
|
|
* This is the source code of Telegram for Android v. 1.3.2.
|
2013-10-25 15:19:00 +00: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).
|
|
|
|
*
|
|
|
|
* Copyright Nikolai Kudashov, 2013.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.telegram.ui;
|
|
|
|
|
|
|
|
import android.app.Activity;
|
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.DialogInterface;
|
|
|
|
import android.content.Intent;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import android.graphics.Typeface;
|
|
|
|
import android.media.Ringtone;
|
|
|
|
import android.media.RingtoneManager;
|
|
|
|
import android.net.Uri;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.provider.Settings;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import android.widget.AdapterView;
|
|
|
|
import android.widget.BaseAdapter;
|
|
|
|
import android.widget.ImageButton;
|
|
|
|
import android.widget.ListView;
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
import org.telegram.PhoneFormat.PhoneFormat;
|
2014-03-22 22:31:55 +00:00
|
|
|
import org.telegram.messenger.LocaleController;
|
2014-02-28 22:28:25 +00:00
|
|
|
import org.telegram.messenger.TLObject;
|
|
|
|
import org.telegram.messenger.TLRPC;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.ConnectionsManager;
|
2014-02-04 18:36:55 +00:00
|
|
|
import org.telegram.messenger.ContactsController;
|
2013-12-20 19:25:49 +00:00
|
|
|
import org.telegram.messenger.FileLog;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.messenger.MessagesController;
|
|
|
|
import org.telegram.messenger.MessagesStorage;
|
|
|
|
import org.telegram.messenger.NotificationCenter;
|
|
|
|
import org.telegram.messenger.R;
|
|
|
|
import org.telegram.messenger.RPCRequest;
|
|
|
|
import org.telegram.messenger.Utilities;
|
2014-06-10 23:05:54 +00:00
|
|
|
import org.telegram.objects.MessageObject;
|
2014-06-03 23:31:48 +00:00
|
|
|
import org.telegram.ui.Views.ActionBar.ActionBarLayer;
|
|
|
|
import org.telegram.ui.Views.ActionBar.ActionBarMenu;
|
|
|
|
import org.telegram.ui.Views.ActionBar.ActionBarMenuItem;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.ui.Views.BackupImageView;
|
2014-06-03 23:31:48 +00:00
|
|
|
import org.telegram.ui.Views.ActionBar.BaseFragment;
|
2013-10-25 15:19:00 +00:00
|
|
|
import org.telegram.ui.Views.IdenticonView;
|
|
|
|
|
2014-02-04 18:36:55 +00:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2014-06-10 23:05:54 +00:00
|
|
|
public class UserProfileActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate, MessagesActivity.MessagesActivityDelegate, PhotoViewer.PhotoViewerProvider {
|
2013-10-25 15:19:00 +00:00
|
|
|
private ListView listView;
|
|
|
|
private ListAdapter listAdapter;
|
|
|
|
private int user_id;
|
|
|
|
private String selectedPhone;
|
|
|
|
private int totalMediaCount = -1;
|
|
|
|
private boolean creatingChat = false;
|
|
|
|
private long dialog_id;
|
|
|
|
private TLRPC.EncryptedChat currentEncryptedChat;
|
|
|
|
|
2014-04-02 17:36:57 +00:00
|
|
|
private final static int add_contact = 1;
|
|
|
|
private final static int block_contact = 2;
|
|
|
|
private final static int share_contact = 3;
|
|
|
|
private final static int edit_contact = 4;
|
|
|
|
private final static int delete_contact = 5;
|
|
|
|
|
2014-05-16 23:05:49 +00:00
|
|
|
private int avatarRow;
|
|
|
|
private int phoneSectionRow;
|
|
|
|
private int phoneRow;
|
|
|
|
private int settingsSectionRow;
|
|
|
|
private int settingsTimerRow;
|
|
|
|
private int settingsKeyRow;
|
|
|
|
private int settingsNotificationsRow;
|
|
|
|
private int settingsVibrateRow;
|
|
|
|
private int settingsSoundRow;
|
|
|
|
private int sharedMediaSectionRow;
|
|
|
|
private int sharedMediaRow;
|
|
|
|
private int rowCount = 0;
|
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
public UserProfileActivity(Bundle args) {
|
|
|
|
super(args);
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
|
|
|
public boolean onFragmentCreate() {
|
2014-03-22 22:31:55 +00:00
|
|
|
NotificationCenter.getInstance().addObserver(this, MessagesController.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, MessagesController.contactsDidLoaded);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, MessagesController.mediaCountDidLoaded);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatCreated);
|
|
|
|
NotificationCenter.getInstance().addObserver(this, MessagesController.encryptedChatUpdated);
|
2014-06-03 23:31:48 +00:00
|
|
|
user_id = arguments.getInt("user_id", 0);
|
|
|
|
dialog_id = arguments.getLong("dialog_id", 0);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (dialog_id != 0) {
|
2014-03-22 22:31:55 +00:00
|
|
|
currentEncryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
updateRowsIds();
|
2014-06-03 23:31:48 +00:00
|
|
|
return MessagesController.getInstance().users.get(user_id) != null && super.onFragmentCreate();
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFragmentDestroy() {
|
|
|
|
super.onFragmentDestroy();
|
2014-03-22 22:31:55 +00:00
|
|
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.updateInterfaces);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.contactsDidLoaded);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.mediaCountDidLoaded);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.encryptedChatCreated);
|
|
|
|
NotificationCenter.getInstance().removeObserver(this, MessagesController.encryptedChatUpdated);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
2014-05-16 23:05:49 +00:00
|
|
|
private void updateRowsIds() {
|
|
|
|
rowCount = 0;
|
|
|
|
avatarRow = rowCount++;
|
|
|
|
phoneSectionRow = rowCount++;
|
|
|
|
phoneRow = rowCount++;
|
|
|
|
settingsSectionRow = rowCount++;
|
|
|
|
if (currentEncryptedChat instanceof TLRPC.TL_encryptedChat) {
|
|
|
|
settingsTimerRow = rowCount++;
|
|
|
|
settingsKeyRow = rowCount++;
|
|
|
|
} else {
|
|
|
|
settingsTimerRow = -1;
|
|
|
|
settingsKeyRow = -1;
|
|
|
|
}
|
|
|
|
settingsNotificationsRow = rowCount++;
|
|
|
|
settingsVibrateRow = rowCount++;
|
|
|
|
settingsSoundRow = rowCount++;
|
|
|
|
sharedMediaSectionRow = rowCount++;
|
|
|
|
sharedMediaRow = rowCount++;
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
2014-06-03 23:31:48 +00:00
|
|
|
public View createView(LayoutInflater inflater, ViewGroup container) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (fragmentView == null) {
|
2014-06-03 23:31:48 +00:00
|
|
|
actionBarLayer.setDisplayHomeAsUpEnabled(true);
|
|
|
|
if (dialog_id != 0) {
|
|
|
|
actionBarLayer.setTitle(LocaleController.getString("SecretTitle", R.string.SecretTitle));
|
|
|
|
actionBarLayer.setTitleIcon(R.drawable.ic_lock_white, Utilities.dp(4));
|
|
|
|
} else {
|
|
|
|
actionBarLayer.setTitle(LocaleController.getString("ContactInfo", R.string.ContactInfo));
|
|
|
|
}
|
|
|
|
actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() {
|
|
|
|
@Override
|
|
|
|
public void onItemClick(int id) {
|
|
|
|
if (id == -1) {
|
|
|
|
finishFragment();
|
|
|
|
} else if (id == block_contact) {
|
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TLRPC.TL_contacts_block req = new TLRPC.TL_contacts_block();
|
|
|
|
req.id = MessagesController.getInputUser(user);
|
|
|
|
TLRPC.TL_contactBlocked blocked = new TLRPC.TL_contactBlocked();
|
|
|
|
blocked.user_id = user_id;
|
|
|
|
blocked.date = (int)(System.currentTimeMillis() / 1000);
|
|
|
|
ConnectionsManager.getInstance().performRpc(req, new RPCRequest.RPCRequestDelegate() {
|
|
|
|
@Override
|
|
|
|
public void run(TLObject response, TLRPC.TL_error error) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}, null, true, RPCRequest.RPCRequestClassGeneric);
|
|
|
|
} else if (id == add_contact) {
|
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", user.id);
|
|
|
|
presentFragment(new ContactAddActivity(args));
|
|
|
|
} else if (id == share_contact) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("onlySelect", true);
|
|
|
|
args.putBoolean("serverOnly", true);
|
|
|
|
MessagesActivity fragment = new MessagesActivity(args);
|
|
|
|
fragment.setDelegate(UserProfileActivity.this);
|
|
|
|
presentFragment(fragment);
|
|
|
|
} else if (id == edit_contact) {
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", user_id);
|
|
|
|
presentFragment(new ContactAddActivity(args));
|
|
|
|
} else if (id == delete_contact) {
|
|
|
|
final TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
ArrayList<TLRPC.User> arrayList = new ArrayList<TLRPC.User>();
|
|
|
|
arrayList.add(user);
|
|
|
|
ContactsController.getInstance().deleteContact(arrayList);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2014-06-03 23:31:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
createActionBarMenu();
|
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
fragmentView = inflater.inflate(R.layout.user_profile_layout, container, false);
|
2014-06-03 23:31:48 +00:00
|
|
|
listAdapter = new ListAdapter(getParentActivity());
|
2013-12-20 19:25:49 +00:00
|
|
|
|
2014-03-22 22:31:55 +00:00
|
|
|
TextView textView = (TextView)fragmentView.findViewById(R.id.start_secret_button_text);
|
|
|
|
textView.setText(LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat));
|
|
|
|
|
2013-12-20 19:25:49 +00:00
|
|
|
View startSecretButton = fragmentView.findViewById(R.id.start_secret_button);
|
|
|
|
startSecretButton.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2014-06-04 19:27:43 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
|
|
|
builder.setMessage(LocaleController.getString("AreYouSure", R.string.AreYouSure));
|
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
creatingChat = true;
|
|
|
|
MessagesController.getInstance().startSecretChat(getParentActivity(), MessagesController.getInstance().users.get(user_id));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2013-12-20 19:25:49 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
startSecretButton.setVisibility(View.VISIBLE);
|
|
|
|
} else {
|
|
|
|
startSecretButton.setVisibility(View.GONE);
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
|
|
|
|
listView = (ListView)fragmentView.findViewById(R.id.listView);
|
|
|
|
listView.setAdapter(listAdapter);
|
|
|
|
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
@Override
|
2014-05-16 23:05:49 +00:00
|
|
|
public void onItemClick(AdapterView<?> adapterView, View view, final int i, long l) {
|
|
|
|
if (i == settingsVibrateRow || i == settingsNotificationsRow) {
|
2014-06-03 23:31:48 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-05-16 23:05:49 +00:00
|
|
|
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
|
|
|
|
builder.setItems(new CharSequence[] {
|
|
|
|
LocaleController.getString("Default", R.string.Default),
|
|
|
|
LocaleController.getString("Enabled", R.string.Enabled),
|
|
|
|
LocaleController.getString("Disabled", R.string.Disabled)
|
|
|
|
}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
if (i == settingsVibrateRow) {
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
editor.putInt("vibrate_" + user_id, which);
|
|
|
|
} else {
|
|
|
|
editor.putInt("vibrate_" + dialog_id, which);
|
|
|
|
}
|
|
|
|
} else if (i == settingsNotificationsRow) {
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
editor.putInt("notify2_" + user_id, which);
|
|
|
|
} else {
|
|
|
|
editor.putInt("notify2_" + dialog_id, which);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsSoundRow) {
|
2013-12-20 19:25:49 +00:00
|
|
|
try {
|
|
|
|
Intent tmpIntent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
|
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
|
2014-03-22 22:31:55 +00:00
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
|
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_DEFAULT_URI, RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
|
2014-06-03 23:31:48 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-12-20 19:25:49 +00:00
|
|
|
Uri currentSound = null;
|
|
|
|
|
|
|
|
String defaultPath = null;
|
|
|
|
Uri defaultUri = Settings.System.DEFAULT_NOTIFICATION_URI;
|
|
|
|
if (defaultUri != null) {
|
|
|
|
defaultPath = defaultUri.getPath();
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2013-12-20 19:25:49 +00:00
|
|
|
String path = preferences.getString("sound_path_" + user_id, defaultPath);
|
|
|
|
if (path != null && !path.equals("NoSound")) {
|
|
|
|
if (path.equals(defaultPath)) {
|
|
|
|
currentSound = defaultUri;
|
|
|
|
} else {
|
|
|
|
currentSound = Uri.parse(path);
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 19:25:49 +00:00
|
|
|
tmpIntent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, currentSound);
|
2014-06-03 23:31:48 +00:00
|
|
|
getParentActivity().startActivityForResult(tmpIntent, 12);
|
2013-12-20 19:25:49 +00:00
|
|
|
} catch (Exception e) {
|
|
|
|
FileLog.e("tmessages", e);
|
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == sharedMediaRow) {
|
2014-06-03 23:31:48 +00:00
|
|
|
Bundle args = new Bundle();
|
2013-10-25 15:19:00 +00:00
|
|
|
if (dialog_id != 0) {
|
2014-06-03 23:31:48 +00:00
|
|
|
args.putLong("dialog_id", dialog_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
args.putLong("dialog_id", user_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-06-03 23:31:48 +00:00
|
|
|
presentFragment(new MediaActivity(args));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsKeyRow) {
|
2014-06-03 23:31:48 +00:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("chat_id", (int)(dialog_id >> 32));
|
|
|
|
presentFragment(new IdenticonActivity(args));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsTimerRow) {
|
2014-06-03 23:31:48 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2014-03-22 22:31:55 +00:00
|
|
|
builder.setTitle(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
2013-10-25 15:19:00 +00:00
|
|
|
builder.setItems(new CharSequence[]{
|
2014-03-22 22:31:55 +00:00
|
|
|
LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever),
|
|
|
|
LocaleController.getString("ShortMessageLifetime2s", R.string.ShortMessageLifetime2s),
|
|
|
|
LocaleController.getString("ShortMessageLifetime5s", R.string.ShortMessageLifetime5s),
|
|
|
|
LocaleController.getString("ShortMessageLifetime1m", R.string.ShortMessageLifetime1m),
|
|
|
|
LocaleController.getString("ShortMessageLifetime1h", R.string.ShortMessageLifetime1h),
|
|
|
|
LocaleController.getString("ShortMessageLifetime1d", R.string.ShortMessageLifetime1d),
|
|
|
|
LocaleController.getString("ShortMessageLifetime1w", R.string.ShortMessageLifetime1w)
|
2013-10-25 15:19:00 +00:00
|
|
|
|
|
|
|
}, new DialogInterface.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
int oldValue = currentEncryptedChat.ttl;
|
|
|
|
if (which == 0) {
|
|
|
|
currentEncryptedChat.ttl = 0;
|
|
|
|
} else if (which == 1) {
|
|
|
|
currentEncryptedChat.ttl = 2;
|
|
|
|
} else if (which == 2) {
|
|
|
|
currentEncryptedChat.ttl = 5;
|
|
|
|
} else if (which == 3) {
|
|
|
|
currentEncryptedChat.ttl = 60;
|
|
|
|
} else if (which == 4) {
|
|
|
|
currentEncryptedChat.ttl = 60 * 60;
|
|
|
|
} else if (which == 5) {
|
|
|
|
currentEncryptedChat.ttl = 60 * 60 * 24;
|
|
|
|
} else if (which == 6) {
|
|
|
|
currentEncryptedChat.ttl = 60 * 60 * 24 * 7;
|
|
|
|
}
|
|
|
|
if (oldValue != currentEncryptedChat.ttl) {
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
2014-03-22 22:31:55 +00:00
|
|
|
MessagesController.getInstance().sendTTLMessage(currentEncryptedChat);
|
|
|
|
MessagesStorage.getInstance().updateEncryptedChat(currentEncryptedChat);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-03-22 22:31:55 +00:00
|
|
|
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (dialog_id != 0) {
|
2014-03-22 22:31:55 +00:00
|
|
|
MessagesController.getInstance().getMediaCount(dialog_id, classGuid, true);
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
2014-03-22 22:31:55 +00:00
|
|
|
MessagesController.getInstance().getMediaCount(user_id, classGuid, true);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ViewGroup parent = (ViewGroup)fragmentView.getParent();
|
|
|
|
if (parent != null) {
|
|
|
|
parent.removeView(fragmentView);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return fragmentView;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-03-26 20:16:28 +00:00
|
|
|
public void onActivityResultFragment(int requestCode, int resultCode, Intent data) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
2013-12-20 19:25:49 +00:00
|
|
|
if (data == null) {
|
|
|
|
return;
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
Uri ringtone = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
|
|
|
|
String name = null;
|
|
|
|
if (ringtone != null) {
|
2013-12-20 19:25:49 +00:00
|
|
|
Ringtone rng = RingtoneManager.getRingtone(ApplicationLoader.applicationContext, ringtone);
|
2013-12-22 23:47:35 +00:00
|
|
|
if (rng != null) {
|
2014-03-22 22:31:55 +00:00
|
|
|
if(ringtone.equals(Settings.System.DEFAULT_NOTIFICATION_URI)) {
|
|
|
|
name = LocaleController.getString("Default", R.string.Default);
|
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
name = rng.getTitle(getParentActivity());
|
2014-03-22 22:31:55 +00:00
|
|
|
}
|
2013-12-22 23:47:35 +00:00
|
|
|
rng.stop();
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
2013-12-20 19:25:49 +00:00
|
|
|
SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
2013-10-25 15:19:00 +00:00
|
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
|
|
|
2014-03-26 20:16:28 +00:00
|
|
|
if (requestCode == 12) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (name != null && ringtone != null) {
|
|
|
|
editor.putString("sound_" + user_id, name);
|
|
|
|
editor.putString("sound_path_" + user_id, ringtone.toString());
|
|
|
|
} else {
|
|
|
|
editor.putString("sound_" + user_id, "NoSound");
|
|
|
|
editor.putString("sound_path_" + user_id, "NoSound");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
editor.commit();
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void didReceivedNotification(int id, Object... args) {
|
|
|
|
if (id == MessagesController.updateInterfaces) {
|
2014-02-04 18:36:55 +00:00
|
|
|
int mask = (Integer)args[0];
|
|
|
|
if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0 || (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (id == MessagesController.contactsDidLoaded) {
|
2014-06-03 23:31:48 +00:00
|
|
|
createActionBarMenu();
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (id == MessagesController.mediaCountDidLoaded) {
|
|
|
|
long uid = (Long)args[0];
|
|
|
|
if (uid > 0 && user_id == uid && dialog_id == 0 || dialog_id != 0 && dialog_id == uid) {
|
|
|
|
totalMediaCount = (Integer)args[1];
|
|
|
|
if (listView != null) {
|
|
|
|
listView.invalidateViews();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (id == MessagesController.encryptedChatCreated) {
|
|
|
|
if (creatingChat) {
|
2014-03-22 22:31:55 +00:00
|
|
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
2013-10-25 15:19:00 +00:00
|
|
|
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat)args[0];
|
2014-06-03 23:31:48 +00:00
|
|
|
Bundle args2 = new Bundle();
|
|
|
|
args2.putInt("enc_id", encryptedChat.id);
|
|
|
|
presentFragment(new ChatActivity(args2), true);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (id == MessagesController.encryptedChatUpdated) {
|
|
|
|
TLRPC.EncryptedChat chat = (TLRPC.EncryptedChat)args[0];
|
|
|
|
if (currentEncryptedChat != null && chat.id == currentEncryptedChat.id) {
|
|
|
|
currentEncryptedChat = chat;
|
2014-05-16 23:05:49 +00:00
|
|
|
updateRowsIds();
|
2013-10-25 15:19:00 +00:00
|
|
|
if (listAdapter != null) {
|
|
|
|
listAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onResume() {
|
2014-06-04 16:00:42 +00:00
|
|
|
super.onResume();
|
2014-06-03 23:31:48 +00:00
|
|
|
if (listAdapter != null) {
|
2013-10-25 15:19:00 +00:00
|
|
|
listAdapter.notifyDataSetChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-10 23:05:54 +00:00
|
|
|
@Override
|
|
|
|
public PhotoViewer.PlaceProviderObject getPlaceForPhoto(MessageObject messageObject, TLRPC.FileLocation fileLocation) {
|
|
|
|
if (fileLocation == null) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
|
|
if (user != null && user.photo != null && user.photo.photo_big != null) {
|
|
|
|
TLRPC.FileLocation photoBig = user.photo.photo_big;
|
|
|
|
if (photoBig.local_id == fileLocation.local_id && photoBig.volume_id == fileLocation.volume_id && photoBig.dc_id == fileLocation.dc_id) {
|
|
|
|
int count = listView.getChildCount();
|
|
|
|
for (int a = 0; a < count; a++) {
|
|
|
|
View view = listView.getChildAt(a);
|
|
|
|
BackupImageView avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
|
|
|
if (avatarImage != null) {
|
|
|
|
int coords[] = new int[2];
|
|
|
|
avatarImage.getLocationInWindow(coords);
|
|
|
|
PhotoViewer.PlaceProviderObject object = new PhotoViewer.PlaceProviderObject();
|
|
|
|
object.viewX = coords[0];
|
|
|
|
object.viewY = coords[1] - Utilities.statusBarHeight;
|
|
|
|
object.parentView = listView;
|
|
|
|
object.imageReceiver = avatarImage.imageReceiver;
|
|
|
|
object.user_id = user_id;
|
|
|
|
object.thumb = object.imageReceiver.getBitmap();
|
|
|
|
object.size = -1;
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-06-11 00:22:42 +00:00
|
|
|
@Override
|
|
|
|
public void willHidePhotoViewer() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
private void createActionBarMenu() {
|
|
|
|
ActionBarMenu menu = actionBarLayer.createMenu();
|
|
|
|
menu.clearItems();
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-03-22 22:31:55 +00:00
|
|
|
if (ContactsController.getInstance().contactsDict.get(user_id) == null) {
|
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
2014-02-04 18:36:55 +00:00
|
|
|
if (user == null) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-03 23:31:48 +00:00
|
|
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (user.phone != null && user.phone.length() != 0) {
|
2014-06-03 23:31:48 +00:00
|
|
|
item.addSubItem(add_contact, LocaleController.getString("AddContact", R.string.AddContact), 0);
|
|
|
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other);
|
|
|
|
item.addSubItem(share_contact, LocaleController.getString("ShareContact", R.string.ShareContact), 0);
|
|
|
|
item.addSubItem(block_contact, LocaleController.getString("BlockContact", R.string.BlockContact), 0);
|
|
|
|
item.addSubItem(edit_contact, LocaleController.getString("EditContact", R.string.EditContact), 0);
|
|
|
|
item.addSubItem(delete_contact, LocaleController.getString("DeleteContact", R.string.DeleteContact), 0);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void didSelectDialog(MessagesActivity messageFragment, long dialog_id) {
|
|
|
|
if (dialog_id != 0) {
|
2014-06-03 23:31:48 +00:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putBoolean("scrollToTopOnResume", true);
|
|
|
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
2013-10-25 15:19:00 +00:00
|
|
|
int lower_part = (int)dialog_id;
|
|
|
|
if (lower_part != 0) {
|
|
|
|
if (lower_part > 0) {
|
2014-06-03 23:31:48 +00:00
|
|
|
args.putInt("user_id", lower_part);
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (lower_part < 0) {
|
2014-06-03 23:31:48 +00:00
|
|
|
args.putInt("chat_id", -lower_part);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
args.putInt("enc_id", (int)(dialog_id >> 32));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-06-03 23:31:48 +00:00
|
|
|
presentFragment(new ChatActivity(args), true);
|
|
|
|
messageFragment.removeSelfFromStack();
|
|
|
|
removeSelfFromStack();
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
|
|
|
MessagesController.getInstance().sendMessage(user, dialog_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class ListAdapter extends BaseAdapter {
|
|
|
|
private Context mContext;
|
|
|
|
|
|
|
|
public ListAdapter(Context context) {
|
|
|
|
mContext = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean areAllItemsEnabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEnabled(int i) {
|
2014-05-16 23:05:49 +00:00
|
|
|
return i == phoneRow || i == settingsTimerRow || i == settingsKeyRow || i == settingsNotificationsRow || i == sharedMediaRow || i == settingsSoundRow || i == settingsVibrateRow;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCount() {
|
2014-05-16 23:05:49 +00:00
|
|
|
return rowCount;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getItem(int i) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public long getItemId(int i) {
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean hasStableIds() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View getView(int i, View view, ViewGroup viewGroup) {
|
|
|
|
int type = getItemViewType(i);
|
|
|
|
if (type == 0) {
|
|
|
|
BackupImageView avatarImage;
|
|
|
|
TextView onlineText;
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.user_profile_avatar_layout, viewGroup, false);
|
|
|
|
|
|
|
|
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
|
|
|
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
2014-06-03 23:31:48 +00:00
|
|
|
avatarImage.processDetach = false;
|
2013-10-25 15:19:00 +00:00
|
|
|
avatarImage.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (user.photo != null && user.photo.photo_big != null) {
|
2014-06-10 23:05:54 +00:00
|
|
|
PhotoViewer.getInstance().openPhoto(user.photo.photo_big, UserProfileActivity.this);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
avatarImage = (BackupImageView)view.findViewById(R.id.settings_avatar_image);
|
|
|
|
onlineText = (TextView)view.findViewById(R.id.settings_online);
|
|
|
|
}
|
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_name);
|
2013-12-20 19:25:49 +00:00
|
|
|
Typeface typeface = Utilities.getTypeface("fonts/rmedium.ttf");
|
|
|
|
textView.setTypeface(typeface);
|
2013-10-25 15:19:00 +00:00
|
|
|
|
|
|
|
textView.setText(Utilities.formatName(user.first_name, user.last_name));
|
2014-05-16 23:05:49 +00:00
|
|
|
onlineText.setText(LocaleController.formatUserStatus(user));
|
2013-10-25 15:19:00 +00:00
|
|
|
|
|
|
|
TLRPC.FileLocation photo = null;
|
2014-06-10 23:05:54 +00:00
|
|
|
TLRPC.FileLocation photoBig = null;
|
2013-10-25 15:19:00 +00:00
|
|
|
if (user.photo != null) {
|
|
|
|
photo = user.photo.photo_small;
|
2014-06-10 23:05:54 +00:00
|
|
|
photoBig = user.photo.photo_big;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
avatarImage.setImage(photo, "50_50", Utilities.getUserAvatarForId(user.id));
|
2014-06-10 23:05:54 +00:00
|
|
|
avatarImage.imageReceiver.setVisible(!PhotoViewer.getInstance().isShowingImage(photoBig), false);
|
2013-10-25 15:19:00 +00:00
|
|
|
return view;
|
|
|
|
} else if (type == 1) {
|
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.settings_section_layout, viewGroup, false);
|
|
|
|
}
|
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_section_text);
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == phoneSectionRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(LocaleController.getString("PHONE", R.string.PHONE));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsSectionRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(LocaleController.getString("SETTINGS", R.string.SETTINGS));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == sharedMediaSectionRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(LocaleController.getString("SHAREDMEDIA", R.string.SHAREDMEDIA));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (type == 2) {
|
2014-03-22 22:31:55 +00:00
|
|
|
final TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.user_profile_phone_layout, viewGroup, false);
|
|
|
|
view.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
|
|
|
if (user.phone == null || user.phone.length() == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selectedPhone = user.phone;
|
|
|
|
|
2014-06-03 23:31:48 +00:00
|
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
|
2013-10-25 15:19:00 +00:00
|
|
|
|
2014-03-22 22:31:55 +00:00
|
|
|
builder.setItems(new CharSequence[] {LocaleController.getString("Copy", R.string.Copy), LocaleController.getString("Call", R.string.Call)}, new DialogInterface.OnClickListener() {
|
2013-10-25 15:19:00 +00:00
|
|
|
@Override
|
|
|
|
public void onClick(DialogInterface dialogInterface, int i) {
|
|
|
|
if (i == 1) {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:+" + selectedPhone));
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
2014-06-03 23:31:48 +00:00
|
|
|
getParentActivity().startActivity(intent);
|
2013-10-25 15:19:00 +00:00
|
|
|
} catch (Exception e) {
|
2013-12-20 19:25:49 +00:00
|
|
|
FileLog.e("tmessages", e);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (i == 0) {
|
|
|
|
int sdk = android.os.Build.VERSION.SDK_INT;
|
|
|
|
if(sdk < android.os.Build.VERSION_CODES.HONEYCOMB) {
|
2014-06-03 23:31:48 +00:00
|
|
|
android.text.ClipboardManager clipboard = (android.text.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
2013-10-25 15:19:00 +00:00
|
|
|
clipboard.setText(selectedPhone);
|
|
|
|
} else {
|
2014-06-03 23:31:48 +00:00
|
|
|
android.content.ClipboardManager clipboard = (android.content.ClipboardManager)ApplicationLoader.applicationContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
2013-10-25 15:19:00 +00:00
|
|
|
android.content.ClipData clip = android.content.ClipData.newPlainText("label", selectedPhone);
|
|
|
|
clipboard.setPrimaryClip(clip);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2014-06-06 23:35:21 +00:00
|
|
|
showAlertDialog(builder);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
ImageButton button = (ImageButton)view.findViewById(R.id.settings_edit_name);
|
|
|
|
button.setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.User user = MessagesController.getInstance().users.get(user_id);
|
2013-10-25 15:19:00 +00:00
|
|
|
if (user == null || user instanceof TLRPC.TL_userEmpty) {
|
|
|
|
return;
|
|
|
|
}
|
2014-03-22 22:31:55 +00:00
|
|
|
NotificationCenter.getInstance().postNotificationName(MessagesController.closeChats);
|
2014-06-03 23:31:48 +00:00
|
|
|
Bundle args = new Bundle();
|
|
|
|
args.putInt("user_id", user_id);
|
|
|
|
presentFragment(new ChatActivity(args), true);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
|
|
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
|
|
|
View divider = view.findViewById(R.id.settings_row_divider);
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == phoneRow) {
|
2013-10-25 15:19:00 +00:00
|
|
|
if (user.phone != null && user.phone.length() != 0) {
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(PhoneFormat.getInstance().format("+" + user.phone));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
|
|
|
textView.setText("Unknown");
|
|
|
|
}
|
2013-12-20 19:25:49 +00:00
|
|
|
divider.setVisibility(View.INVISIBLE);
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("PhoneMobile", R.string.PhoneMobile));
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
} else if (type == 3) {
|
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.user_profile_leftright_row_layout, viewGroup, false);
|
|
|
|
}
|
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
|
|
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
2013-12-20 19:25:49 +00:00
|
|
|
|
2013-10-25 15:19:00 +00:00
|
|
|
View divider = view.findViewById(R.id.settings_row_divider);
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == sharedMediaRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(LocaleController.getString("SharedMedia", R.string.SharedMedia));
|
2013-10-25 15:19:00 +00:00
|
|
|
if (totalMediaCount == -1) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("Loading", R.string.Loading));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
|
|
|
detailTextView.setText(String.format("%d", totalMediaCount));
|
|
|
|
}
|
|
|
|
divider.setVisibility(View.INVISIBLE);
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsTimerRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
|
|
|
textView.setText(LocaleController.getString("MessageLifetime", R.string.MessageLifetime));
|
2013-10-25 15:19:00 +00:00
|
|
|
divider.setVisibility(View.VISIBLE);
|
|
|
|
if (encryptedChat.ttl == 0) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 2) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime2s", R.string.ShortMessageLifetime2s));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 5) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime5s", R.string.ShortMessageLifetime5s));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 60) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime1m", R.string.ShortMessageLifetime1m));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 60 * 60) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime1h", R.string.ShortMessageLifetime1h));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 60 * 60 * 24) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime1d", R.string.ShortMessageLifetime1d));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else if (encryptedChat.ttl == 60 * 60 * 24 * 7) {
|
2014-03-22 22:31:55 +00:00
|
|
|
detailTextView.setText(LocaleController.getString("ShortMessageLifetime1w", R.string.ShortMessageLifetime1w));
|
2013-10-25 15:19:00 +00:00
|
|
|
} else {
|
|
|
|
detailTextView.setText(String.format("%d", encryptedChat.ttl));
|
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (i == settingsVibrateRow) {
|
|
|
|
textView.setText(LocaleController.getString("Vibrate", R.string.Vibrate));
|
|
|
|
divider.setVisibility(View.VISIBLE);
|
|
|
|
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
|
|
|
|
String key;
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
key = "vibrate_" + user_id;
|
|
|
|
} else {
|
|
|
|
key = "vibrate_" + dialog_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
int value = preferences.getInt(key, 0);
|
|
|
|
if (value == 0) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
|
|
|
} else if (value == 1) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
|
|
|
} else if (value == 2) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
|
|
|
}
|
|
|
|
} else if (i == settingsNotificationsRow) {
|
|
|
|
textView.setText(LocaleController.getString("Notifications", R.string.Notifications));
|
|
|
|
divider.setVisibility(View.VISIBLE);
|
|
|
|
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
String key;
|
|
|
|
if (dialog_id == 0) {
|
|
|
|
key = "notify2_" + user_id;
|
|
|
|
} else {
|
|
|
|
key = "notify2_" + dialog_id;
|
|
|
|
}
|
|
|
|
int value = preferences.getInt(key, 0);
|
|
|
|
if (value == 0) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Default", R.string.Default));
|
|
|
|
} else if (value == 1) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Enabled", R.string.Enabled));
|
|
|
|
} else if (value == 2) {
|
|
|
|
detailTextView.setText(LocaleController.getString("Disabled", R.string.Disabled));
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (type == 4) {
|
2013-12-20 19:25:49 +00:00
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.user_profile_identicon_layout, viewGroup, false);
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
2013-12-20 19:25:49 +00:00
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
|
|
View divider = view.findViewById(R.id.settings_row_divider);
|
|
|
|
divider.setVisibility(View.VISIBLE);
|
|
|
|
IdenticonView identiconView = (IdenticonView)view.findViewById(R.id.identicon_view);
|
2014-03-22 22:31:55 +00:00
|
|
|
TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().encryptedChats.get((int)(dialog_id >> 32));
|
2013-12-20 19:25:49 +00:00
|
|
|
identiconView.setBytes(encryptedChat.auth_key);
|
2014-03-22 22:31:55 +00:00
|
|
|
textView.setText(LocaleController.getString("EncryptionKey", R.string.EncryptionKey));
|
2014-05-16 23:05:49 +00:00
|
|
|
} else if (type == 5) {
|
2014-03-22 22:31:55 +00:00
|
|
|
if (view == null) {
|
|
|
|
LayoutInflater li = (LayoutInflater)mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
|
view = li.inflate(R.layout.settings_row_detail_layout, viewGroup, false);
|
|
|
|
}
|
|
|
|
TextView textView = (TextView)view.findViewById(R.id.settings_row_text);
|
|
|
|
TextView detailTextView = (TextView)view.findViewById(R.id.settings_row_text_detail);
|
|
|
|
|
|
|
|
View divider = view.findViewById(R.id.settings_row_divider);
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == settingsSoundRow) {
|
2014-03-22 22:31:55 +00:00
|
|
|
SharedPreferences preferences = mContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE);
|
|
|
|
String name = preferences.getString("sound_" + user_id, LocaleController.getString("Default", R.string.Default));
|
|
|
|
if (name.equals("NoSound")) {
|
|
|
|
detailTextView.setText(LocaleController.getString("NoSound", R.string.NoSound));
|
|
|
|
} else {
|
|
|
|
detailTextView.setText(name);
|
|
|
|
}
|
|
|
|
textView.setText(LocaleController.getString("Sound", R.string.Sound));
|
|
|
|
divider.setVisibility(View.INVISIBLE);
|
|
|
|
}
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return view;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getItemViewType(int i) {
|
2014-05-16 23:05:49 +00:00
|
|
|
if (i == avatarRow) {
|
|
|
|
return 0;
|
|
|
|
} else if (i == phoneSectionRow || i == settingsSectionRow || i == sharedMediaSectionRow) {
|
|
|
|
return 1;
|
|
|
|
} else if (i == phoneRow) {
|
|
|
|
return 2;
|
|
|
|
} else if (i == sharedMediaRow || i == settingsTimerRow || i == settingsNotificationsRow || i == settingsVibrateRow) {
|
|
|
|
return 3;
|
|
|
|
} else if (i == settingsKeyRow) {
|
|
|
|
return 4;
|
|
|
|
} else if (i == settingsSoundRow) {
|
|
|
|
return 5;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getViewTypeCount() {
|
2014-05-16 23:05:49 +00:00
|
|
|
return 6;
|
2013-10-25 15:19:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|