Commit dbc5f830 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'feature/expanding_toolbar' into develop

parents 9a7822f5 e3c90c3d
......@@ -2,14 +2,14 @@ apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.xabber.androiddev"
minSdkVersion 14
targetSdkVersion 22
versionCode 136
versionName '0.10.36'
versionCode 144
versionName '0.10.44'
}
compileOptions {
......@@ -18,8 +18,13 @@ android {
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v13:22.0.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile project('otr4j')
}
......@@ -141,13 +141,13 @@
</activity>
<activity
android:label="@string/contact_editor"
android:name="com.xabber.android.ui.ContactEditor"
android:parentActivityName="com.xabber.android.ui.ContactList"
android:name="com.xabber.android.ui.GroupEditor"
android:parentActivityName="com.xabber.android.ui.ContactViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.ContactList" />
android:value="com.xabber.android.ui.ContactViewer" />
</activity>
<activity
android:label="@string/contact_add"
......@@ -219,13 +219,13 @@
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.preferences.ContactViewer"
android:parentActivityName="com.xabber.android.ui.ContactList"
android:name="com.xabber.android.ui.ContactViewer"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.ContactList" />
android:value="com.xabber.android.ui.ChatViewer" />
<intent-filter>
<action android:name="android.intent.action.VIEW" />
......@@ -235,6 +235,7 @@
<data android:host="com.android.contacts" />
</intent-filter>
</activity>
<activity
android:name="com.xabber.android.ui.FingerprintViewer"
android:label="@string/otr_verify_fingerprint"
......
......@@ -326,33 +326,40 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
ConnectionManager.getInstance().sendPacket(account, packet);
}
/**
* Requests to change contact's name and groups.
*
* @param account
* @param bareAddress
* @param name
* @param groups
* @throws NetworkException
*/
public void setNameAndGroup(String account, String bareAddress,
String name, Collection<String> groups) throws NetworkException {
public void setGroups(String account, String bareAddress, Collection<String> groups) throws NetworkException {
RosterContact contact = getRosterContact(account, bareAddress);
if (contact == null)
if (contact == null) {
throw new NetworkException(R.string.ENTRY_IS_NOT_FOUND);
if (contact.getRealName().equals(name)) {
HashSet<String> check = new HashSet<String>(contact.getGroupNames());
}
HashSet<String> check = new HashSet<>(contact.getGroupNames());
if (check.size() == groups.size()) {
check.removeAll(groups);
if (check.isEmpty())
return;
}
updateRosterContact(account, bareAddress, contact.getRealName(), groups);
}
public void setName(String account, String bareAddress, String name) throws NetworkException {
RosterContact contact = getRosterContact(account, bareAddress);
if (contact == null)
throw new NetworkException(R.string.ENTRY_IS_NOT_FOUND);
if (contact.getRealName().equals(name)) {
return;
}
updateRosterContact(account, bareAddress, name, contact.getGroupNames());
}
private void updateRosterContact(String account, String bareAddress, String name, Collection<String> groups) throws NetworkException {
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.SET);
RosterPacket.Item item = new RosterPacket.Item(bareAddress, name);
for (String group : groups)
for (String group : groups) {
item.addGroupName(group);
}
packet.addRosterItem(item);
ConnectionManager.getInstance().sendPacket(account, packet);
}
......
......@@ -27,13 +27,11 @@ import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.archive.MessageArchiveManager;
......@@ -41,8 +39,6 @@ import com.xabber.android.data.extension.attention.AttentionManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.RoomChat;
import com.xabber.android.data.extension.muc.RoomState;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.extension.otr.SecurityLevel;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager;
......@@ -58,7 +54,6 @@ import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.androiddev.R;
import java.util.Collection;
......@@ -222,24 +217,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
if (abstractChat instanceof RegularChat) {
menu.findItem(R.id.action_edit_contact).setVisible(true);
menu.findItem(R.id.action_view_contact).setVisible(true);
menu.findItem(R.id.action_close_chat).setVisible(true);
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
if (securityLevel == SecurityLevel.plain) {
menu.findItem(R.id.action_start_encryption).setVisible(true)
.setEnabled(SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled);
} else {
menu.findItem(R.id.action_restart_encryption).setVisible(true);
}
boolean isEncrypted = securityLevel != SecurityLevel.plain;
menu.findItem(R.id.action_stop_encryption).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_fingerprint).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_question).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_shared_secret).setEnabled(isEncrypted);
}
}
......@@ -314,8 +293,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
final String user = actionWithUser;
switch (item.getItemId()) {
case R.id.action_edit_contact:
startActivity(ContactEditor.createIntent(this, account, user));
case R.id.action_view_contact:
startActivity(ContactViewer.createIntent(this, account, user));
return true;
case R.id.action_chat_list:
......@@ -372,32 +351,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
startActivity(OccupantList.createIntent(this, account, user));
return true;
/* encryption */
case R.id.action_start_encryption:
startEncryption(account, user);
return true;
case R.id.action_restart_encryption:
restartEncryption(account, user);
return true;
case R.id.action_stop_encryption:
stopEncryption(account, user);
return true;
case R.id.action_verify_with_fingerprint:
startActivity(FingerprintViewer.createIntent(this, account, user));
return true;
case R.id.action_verify_with_question:
startActivity(QuestionViewer.createIntent(this, account, user, true, false, null));
return true;
case R.id.action_verify_with_shared_secret:
startActivity(QuestionViewer.createIntent(this, account, user, false, false, null));
return true;
default:
return super.onOptionsItemSelected(item);
}
......@@ -411,30 +364,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
}
}
private void stopEncryption(String account, String user) {
try {
OTRManager.getInstance().endSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void restartEncryption(String account, String user) {
try {
OTRManager.getInstance().refreshSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void startEncryption(String account, String user) {
try {
OTRManager.getInstance().startSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void callAttention(String account, String user) {
try {
AttentionManager.getInstance().sendAttention(account, user);
......@@ -656,21 +585,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
final AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
contactTitleActionBarInflater.update(abstractContact);
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
SettingsManager.SecurityOtrMode securityOtrMode = SettingsManager.securityOtrMode();
ImageView securityView = contactTitleActionBarInflater.getSecurityView();
if (securityLevel == SecurityLevel.plain
&& (securityOtrMode == SettingsManager.SecurityOtrMode.disabled
|| securityOtrMode == SettingsManager.SecurityOtrMode.manual)) {
securityView.setVisibility(View.GONE);
} else {
securityView.setVisibility(View.VISIBLE);
securityView.setImageLevel(securityLevel.getImageLevel());
}
}
private void updateRegisteredChats() {
......
......@@ -10,6 +10,7 @@ import android.text.TextWatcher;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
......@@ -18,18 +19,25 @@ import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.PopupMenu;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.cs.ChatStateManager;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.extension.otr.SecurityLevel;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.message.RegularChat;
import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.android.ui.adapter.ChatMessageAdapter;
import com.xabber.androiddev.R;
public class ChatViewerFragment extends Fragment implements AdapterView.OnItemClickListener {
public class ChatViewerFragment extends Fragment implements AdapterView.OnItemClickListener, PopupMenu.OnMenuItemClickListener {
public static final String ARGUMENT_ACCOUNT = "ARGUMENT_ACCOUNT";
public static final String ARGUMENT_USER = "ARGUMENT_USER";
......@@ -45,6 +53,7 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
boolean isInputEmpty = true;
private ImageButton sendButton;
private ImageButton securityButton;
public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment();
......@@ -74,6 +83,20 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
sendButton = (ImageButton) view.findViewById(R.id.button_send_message);
sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp);
AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
securityButton = (ImageButton) view.findViewById(R.id.button_security);
if (abstractChat instanceof RegularChat) {
securityButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
showSecurityMenu();
}
});
} else {
securityButton.setVisibility(View.GONE);
}
chatMessageAdapter = new ChatMessageAdapter(getActivity(), account, user);
listView = (ListView) view.findViewById(android.R.id.list);
......@@ -143,6 +166,32 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
}
private void showSecurityMenu() {
PopupMenu popup = new PopupMenu(getActivity(), securityButton);
popup.inflate(R.menu.security);
popup.setOnMenuItemClickListener(this);
Menu menu = popup.getMenu();
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
if (securityLevel == SecurityLevel.plain) {
menu.findItem(R.id.action_start_encryption).setVisible(true)
.setEnabled(SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled);
} else {
menu.findItem(R.id.action_restart_encryption).setVisible(true);
}
boolean isEncrypted = securityLevel != SecurityLevel.plain;
menu.findItem(R.id.action_stop_encryption).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_fingerprint).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_question).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_shared_secret).setEnabled(isEncrypted);
popup.show();
}
private void setSendButtonColor() {
boolean empty = inputView.getText().toString().isEmpty();
......@@ -274,6 +323,13 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
public void updateChat() {
chatMessageAdapter.onChange();
updateSecurityButton();
}
private void updateSecurityButton() {
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
securityButton.setImageLevel(securityLevel.getImageLevel());
}
public boolean isEqual(String account, String user) {
......@@ -314,4 +370,60 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
listView.showContextMenuForChild(view);
unregisterForContextMenu(listView);
}
@Override
public boolean onMenuItemClick(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_start_encryption:
startEncryption(account, user);
return true;
case R.id.action_restart_encryption:
restartEncryption(account, user);
return true;
case R.id.action_stop_encryption:
stopEncryption(account, user);
return true;
case R.id.action_verify_with_fingerprint:
startActivity(FingerprintViewer.createIntent(getActivity(), account, user));
return true;
case R.id.action_verify_with_question:
startActivity(QuestionViewer.createIntent(getActivity(), account, user, true, false, null));
return true;
case R.id.action_verify_with_shared_secret:
startActivity(QuestionViewer.createIntent(getActivity(), account, user, false, false, null));
return true;
default:
return false;
}
}
private void stopEncryption(String account, String user) {
try {
OTRManager.getInstance().endSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void restartEncryption(String account, String user) {
try {
OTRManager.getInstance().refreshSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void startEncryption(String account, String user) {
try {
OTRManager.getInstance().startSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
}
......@@ -14,187 +14,68 @@
*/
package com.xabber.android.ui;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.Toast;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class ContactAdd extends GroupListActivity implements
View.OnClickListener, OnItemSelectedListener {
private static final String SAVED_ACCOUNT = "com.xabber.android.ui.ContactAdd.SAVED_ACCOUNT";
private static final String SAVED_USER = "com.xabber.android.ui.ContactAdd.SAVED_USER";
private static final String SAVED_NAME = "com.xabber.android.ui.ContactAdd.SAVED_NAME";
public class ContactAdd extends ManagedActivity implements ContactAddFragment.Listener {
private String account;
private String user;
/**
* Views
*/
private Spinner accountView;
private EditText userView;
private EditText nameView;
ActionBarPainter actionBarPainter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
protected void onInflate(Bundle savedInstanceState) {
setContentView(R.layout.contact_add);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
getSupportActionBar().setTitle(null);
ListView listView = getListView();
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.contact_add_header, listView,
false);
listView.addHeaderView(view, null, false);
accountView = (Spinner) view.findViewById(R.id.contact_account);
accountView.setAdapter(new AccountChooseAdapter(this));
accountView.setOnItemSelectedListener(this);
userView = (EditText) view.findViewById(R.id.contact_user);
nameView = (EditText) view.findViewById(R.id.contact_name);
((Button) view.findViewById(R.id.ok)).setOnClickListener(this);
actionBarPainter = new ActionBarPainter(this);
String name;
Intent intent = getIntent();
if (savedInstanceState != null) {
account = savedInstanceState.getString(SAVED_ACCOUNT);
user = savedInstanceState.getString(SAVED_USER);
name = savedInstanceState.getString(SAVED_NAME);
} else {
account = getAccount(intent);
user = getUser(intent);
if (account == null || user == null)
name = null;
else {
name = RosterManager.getInstance().getName(account, user);
if (user.equals(name))
name = null;
}
}
if (account == null) {
Collection<String> accounts = AccountManager.getInstance()
.getAccounts();
if (accounts.size() == 1)
account = accounts.iterator().next();
}
if (account != null) {
for (int position = 0; position < accountView.getCount(); position++)
if (account.equals(accountView.getItemAtPosition(position))) {
accountView.setSelection(position);
break;
}
}
if (user != null)
userView.setText(user);
if (name != null)
nameView.setText(name);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SAVED_ACCOUNT,
(String) accountView.getSelectedItem());
outState.putString(SAVED_USER, userView.getText().toString());
outState.putString(SAVED_NAME, nameView.getText().toString());
if (savedInstanceState == null) {
getSupportFragmentManager()
.beginTransaction()
.add(R.id.container, ContactAddFragment.newInstance(getAccount(intent), getUser(intent)))
.commit();
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.ok:
String user = userView.getText().toString();
if ("".equals(user)) {
Toast.makeText(this, getString(R.string.EMPTY_USER_NAME),
Toast.LENGTH_LONG).show();
return;
}
String account = (String) accountView.getSelectedItem();
if (account == null) {
Toast.makeText(this, getString(R.string.EMPTY_ACCOUNT),
Toast.LENGTH_LONG).show();
return;
}
try {
RosterManager.getInstance().createContact(account, user,
nameView.getText().toString(), getSelected());
PresenceManager.getInstance()
.requestSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
finish();
return;
}
MessageManager.getInstance().openChat(account, user);
finish();
break;
default:
break;
}
}
@Override
Collection<String> getInitialGroups() {
String account = (String) accountView.getSelectedItem();
if (account == null)
return Collections.emptyList();
return RosterManager.getInstance().getGroups(account);
private void addContact() {
((ContactAddFragment)getSupportFragmentManager().findFragmentById(R.id.container)).addContact();
}
@Override
Collection<String> getInitialSelected() {
return Collections.emptyList();
}
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.add_contact, menu);
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
String account = (String) accountView.getSelectedItem();
if (account == null) {
onNothingSelected(parent);
} else {
HashSet<String> groups = new HashSet<String>(RosterManager
.getInstance().getGroups(account));
groups.addAll(getSelected());
setGroups(groups, getSelected());
}
return true;
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
setGroups(getSelected(), getSelected());
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_contact:
addContact();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
public static Intent createIntent(Context context) {
......@@ -205,10 +86,8 @@ public class ContactAdd extends GroupListActivity implements
return createIntent(context, account, null);
}
public static Intent createIntent(Context context, String account,
String user) {
return new EntityIntentBuilder(context, ContactAdd.class)
.setAccount(account).setUser(user).build();
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactAdd.class).setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
......@@ -219,4 +98,8 @@ public class ContactAdd extends GroupListActivity implements
return EntityIntentBuilder.getUser(intent);
}
@Override
public void onAccountSelected(String account) {
actionBarPainter.updateWithAccountName(account);
}
}
package com.xabber.android.ui;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
import com.xabber.androiddev.R;
import java.util.Collection;
public class ContactAddFragment extends GroupEditorFragment implements AdapterView.OnItemSelectedListener {
private static final String SAVED_NAME = "com.xabber.android.ui.ContactAdd.SAVED_NAME";
private static final String SAVED_ACCOUNT = "com.xabber.android.ui.ContactAdd.SAVED_ACCOUNT";
private static final String SAVED_USER = "com.xabber.android.ui.ContactAdd.SAVED_USER";
private Spinner accountView;
private EditText userView;
private EditText nameView;
Listener listenerActivity;
private String name;
private View accountSelectorPanel;
public static ContactAddFragment newInstance(String account, String user) {
ContactAddFragment fragment = new ContactAddFragment();
Bundle args = new Bundle();
args.putString(ARG_ACCOUNT, account);
args.putString(ARG_USER, user);
fragment.setArguments(args);
return fragment;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
listenerActivity = (Listener)activity;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.contact_add_fragment, container, false);
if (savedInstanceState != null) {
name = savedInstanceState.getString(SAVED_NAME);
setAccount(savedInstanceState.getString(SAVED_ACCOUNT));
setUser(savedInstanceState.getString(SAVED_USER));
} else {
if (getAccount() == null || getUser() == null) {
name = null;
} else {
name = RosterManager.getInstance().getName(getAccount(), getUser());
if (getUser().equals(name)) {
name = null;
}
}
}
if (getAccount() == null) {
Collection<String> accounts = AccountManager.getInstance().getAccounts();
if (accounts.size() == 1) {
setAccount(accounts.iterator().next());
}
}
accountSelectorPanel = view.findViewById(R.id.account_selector);
setUpAccountView((Spinner) view.findViewById(R.id.contact_account));
return view;
}
private void setUpAccountView(Spinner view) {
accountView = view;
accountView.setAdapter(new AccountChooseAdapter(getActivity()));
accountView.setOnItemSelectedListener(this);
if (getAccount() != null) {
for (int position = 0; position < accountView.getCount(); position++) {
if (getAccount().equals(accountView.getItemAtPosition(position))) {
accountView.setSelection(position);
break;
}
}
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getListView().setVisibility(View.GONE);
}
private void setUpListView() {
View headerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE))
.inflate(R.layout.contact_add_header, null, false);
getListView().addHeaderView(headerView);
accountSelectorPanel.setVisibility(View.GONE);
setUpAccountView((Spinner) headerView.findViewById(R.id.contact_account));
userView = (EditText) headerView.findViewById(R.id.contact_user);
nameView = (EditText) headerView.findViewById(R.id.contact_name);
if (getUser() != null) {
userView.setText(getUser());
}
if (name != null) {
nameView.setText(name);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SAVED_ACCOUNT, getAccount());
outState.putString(SAVED_USER, userView.getText().toString());
outState.putString(SAVED_NAME, nameView.getText().toString());
}
@Override
public void onDetach() {
super.onDetach();
listenerActivity = null;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedAccount = (String) accountView.getSelectedItem();
if (selectedAccount == null) {
onNothingSelected(parent);
setAccount(selectedAccount);
} else {
listenerActivity.onAccountSelected(selectedAccount);
if (!selectedAccount.equals(getAccount())) {
setAccount(selectedAccount);
setAccountGroups();
updateGroups();
}
if (getListView().getVisibility() == View.GONE) {
setUpListView();
getListView().setVisibility(View.VISIBLE);
}
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
public void addContact() {
if (getAccount() == null) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT),
Toast.LENGTH_LONG).show();
return;
}
String user = userView.getText().toString();
if ("".equals(user)) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_USER_NAME),
Toast.LENGTH_LONG).show();
return;
}
String account = (String) accountView.getSelectedItem();
if (account == null) {
Toast.makeText(getActivity(), getString(R.string.EMPTY_ACCOUNT),
Toast.LENGTH_LONG).show();
return;
}
try {
RosterManager.getInstance().createContact(account, user,
nameView.getText().toString(), getSelected());
PresenceManager.getInstance().requestSubscription(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
getActivity().finish();
return;
}
MessageManager.getInstance().openChat(account, user);
getActivity().finish();
}
public interface Listener {
void onAccountSelected(String account);
}
}
......@@ -12,26 +12,36 @@
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui.preferences;
package com.xabber.android.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.vcard.OnVCardListener;
import com.xabber.android.data.extension.vcard.VCardManager;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.dialog.ContactDeleteDialogFragment;
import com.xabber.android.ui.helper.ContactTitleExpandableToolbarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
......@@ -54,8 +64,8 @@ import java.util.Map;
public class ContactViewer extends ManagedActivity implements
OnVCardListener, OnContactChangedListener, OnAccountChangedListener {
private static final String SAVED_VCARD = "com.xabber.android.ui.preferences.ContactViewer.SAVED_VCARD";
private static final String SAVED_VCARD_ERROR = "com.xabber.android.ui.preferences.ContactViewer.SAVED_VCARD_ERROR";
private static final String SAVED_VCARD = "com.xabber.android.ui.ContactViewer.SAVED_VCARD";
private static final String SAVED_VCARD_ERROR = "com.xabber.android.ui.ContactViewer.SAVED_VCARD_ERROR";
private String account;
private String bareAddress;
......@@ -68,6 +78,8 @@ public class ContactViewer extends ManagedActivity implements
private static final Map<TelephoneType, Integer> TELEPHONE_TYPE_MAP = new HashMap<>();
private static final Map<EmailType, Integer> EMAIL_TYPE_MAP = new HashMap<>();
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
static {
ADDRESS_TYPE_MAP.put(AddressType.DOM, R.string.vcard_type_dom);
ADDRESS_TYPE_MAP.put(AddressType.HOME, R.string.vcard_type_home);
......@@ -184,22 +196,16 @@ public class ContactViewer extends ManagedActivity implements
LogManager.exception(this, e);
}
}
setTitle(getString(R.string.contact_viewer));
setContentView(R.layout.contact_viewer);
setSupportActionBar((Toolbar) findViewById(R.id.contact_viewer_toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ContactTitleActionBarInflater contactTitleActionBarInflater = new ContactTitleActionBarInflater(this);
contactTitleActionBarInflater.setUpActionBarView();
contactTitleActionBarInflater.update(RosterManager.getInstance().getBestContact(account, bareAddress));
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ContactViewerFragment()).commit();
.add(R.id.scrollable_container, new ContactViewerFragment()).commit();
}
contactTitleExpandableToolbarInflater = new ContactTitleExpandableToolbarInflater(this);
AbstractContact bestContact = RosterManager.getInstance().getBestContact(account, bareAddress);
contactTitleExpandableToolbarInflater.onCreate(bestContact);
}
@Override
......@@ -213,15 +219,78 @@ public class ContactViewer extends ManagedActivity implements
if (vCard == null && !vCardError)
VCardManager.getInstance().request(account, bareAddress, null);
contactTitleExpandableToolbarInflater.onResume();
ContactViewerFragment contactViewerFragment = getFragment();
contactViewerFragment.updateContact(account, bareAddress);
contactViewerFragment.updateVCard(vCard);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.contact_viewer, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_edit_alias:
editAlias();
return true;
case R.id.action_edit_groups:
startActivity(GroupEditor.createIntent(this, account, bareAddress));
return true;
case R.id.action_remove_contact:
ContactDeleteDialogFragment.newInstance(account, bareAddress)
.show(getFragmentManager(), "CONTACT_DELETE");
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void editAlias() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle(R.string.edit_alias);
final EditText input = new EditText(this);
input.setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
RosterContact rosterContact = RosterManager.getInstance().getRosterContact(account, bareAddress);
input.setText(rosterContact.getName());
builder.setView(input);
builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
RosterManager.getInstance().setName(account, bareAddress, input.getText().toString());
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
});
builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
builder.show();
}
private ContactViewerFragment getFragment() {
return (ContactViewerFragment) getFragmentManager()
.findFragmentById(R.id.preferences_activity_container);
.findFragmentById(R.id.scrollable_container);
}
@Override
......@@ -308,4 +377,10 @@ public class ContactViewer extends ManagedActivity implements
public static Map<EmailType, Integer> getEmailTypeMap() {
return EMAIL_TYPE_MAP;
}
public View getContactTitleView() {
return findViewById(R.id.expandable_contact_title);
}
}
package com.xabber.android.ui;
import android.app.Activity;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.util.Linkify;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.extension.capability.CapabilitiesManager;
import com.xabber.android.data.extension.capability.ClientInfo;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
import com.xabber.xmpp.vcard.Email;
import com.xabber.xmpp.vcard.EmailType;
import com.xabber.xmpp.vcard.NameProperty;
import com.xabber.xmpp.vcard.Organization;
import com.xabber.xmpp.vcard.Telephone;
import com.xabber.xmpp.vcard.TelephoneType;
import com.xabber.xmpp.vcard.VCard;
import com.xabber.xmpp.vcard.VCardProperty;
import java.util.ArrayList;
import java.util.List;
public class ContactViewerFragment extends Fragment {
private LinearLayout xmppItems;
private LinearLayout contactInfoItems;
String account;
String bareAddress;
private TextView contactNameView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
View view = inflater.inflate(R.layout.contact_viewer_fragment, container, false);
xmppItems = (LinearLayout) view.findViewById(R.id.xmpp_items);
contactInfoItems = (LinearLayout) view.findViewById(R.id.contact_info_items);
View contactTitleView = ((ContactViewer) getActivity()).getContactTitleView();
contactTitleView.findViewById(R.id.status_icon).setVisibility(View.GONE);
contactTitleView.findViewById(R.id.status_text).setVisibility(View.GONE);
contactNameView = (TextView) contactTitleView.findViewById(R.id.name);
return view;
}
/**
* @param source
* @param value
* @param splitter
* @return Concatenated source and value with splitter if necessary.
*/
private String addString(String source, String value, String splitter) {
if (value == null || "".equals(value))
return source;
if (source == null || "".equals(source))
return value;
return source + splitter + value;
}
public void updateContact(String account, String bareAddress) {
this.account = account;
this.bareAddress = bareAddress;
contactNameView.setText(RosterManager.getInstance().getBestContact(account, bareAddress).getName());
xmppItems.removeAllViews();
View jabberIdView = createItemView(xmppItems,
getString(R.string.contact_viewer_jid), bareAddress, R.drawable.ic_xmpp_24dp);
if (jabberIdView != null) {
xmppItems.addView(jabberIdView);
}
List<View> resourcesList = new ArrayList<>();
for (ResourceItem resourceItem
: PresenceManager.getInstance().getResourceItems(account, bareAddress)) {
String user = resourceItem.getUser(bareAddress);
ClientInfo clientInfo = CapabilitiesManager.getInstance().getClientInfo(account, user);
String client = "";
if (clientInfo == null) {
CapabilitiesManager.getInstance().request(account, user);
client = getString(R.string.please_wait);
} else if (clientInfo == CapabilitiesManager.INVALID_CLIENT_INFO) {
client = getString(R.string.unknown);
} else {
String name = clientInfo.getName();
if (name != null) {
client = name;
}
String type = clientInfo.getType();
if (type != null) {
if (client.isEmpty()) {
client = type;
} else {
client = client + "/" + type;
}
}
}
String priority = getString(R.string.account_priority) + ": " + resourceItem.getPriority();
String label = "";
if (!client.isEmpty()) {
label = getString(R.string.contact_viewer_client) + ": " + client + ", ";
}
label += priority;
String resource = getString(R.string.account_resource) + ": " + resourceItem.getVerbose();
String status = resourceItem.getStatusText().trim();
if (status.isEmpty()) {
status = getString(resourceItem.getStatusMode().getStringID());
}
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View resourceView = inflater.inflate(R.layout.contact_info_item, xmppItems, false);
((TextView)resourceView.findViewById(R.id.contact_info_item_secondary)).setText(label);
((TextView)resourceView.findViewById(R.id.contact_info_item_main)).setText(status);
((TextView)resourceView.findViewById(R.id.contact_info_item_secondary_second_line)).setText(resource);
resourceView.findViewById(R.id.contact_info_item_secondary_second_line).setVisibility(View.VISIBLE);
ImageView statusIcon = (ImageView) resourceView.findViewById(R.id.contact_info_right_icon);
statusIcon.setVisibility(View.VISIBLE);
statusIcon.setImageDrawable(getResources().getDrawable(R.drawable.ic_status));
statusIcon.setImageLevel(resourceItem.getStatusMode().getStatusLevel());
resourcesList.add(resourceView);
}
addItemGroup(resourcesList, xmppItems, R.drawable.ic_jabber_24dp);
}
public void updateVCard(VCard vCard) {
if (vCard == null) {
return;
}
contactInfoItems.removeAllViews();
addNameInfo(vCard);
List<View> birthDayList = new ArrayList<>();
addItem(birthDayList, contactInfoItems, getString(R.string.vcard_birth_date), vCard.getField(VCardProperty.BDAY));
addItemGroup(birthDayList, contactInfoItems, R.drawable.ic_birthday_24dp);
addOrganizationInfo(vCard);
List<View> webList = new ArrayList<>();
addItem(webList, contactInfoItems, getString(R.string.vcard_url), vCard.getField(VCardProperty.URL));
addItemGroup(webList, contactInfoItems, R.drawable.ic_web_24dp);
addAdditionalInfo(vCard);
addAddresses(vCard);
addPhones(vCard);
addEmails(vCard);
}
private void addEmails(VCard vCard) {
List<View> emailList = new ArrayList<>();
for (Email email : vCard.getEmails()) {
String types = null;
for (EmailType type : email.getTypes()) {
types = addString(types, getString(ContactViewer.getEmailTypeMap().get(type)), ", ");
}
addItem(emailList, contactInfoItems, types, email.getValue());
}
addItemGroup(emailList, contactInfoItems, R.drawable.ic_email_24dp);
}
private void addPhones(VCard vCard) {
List<View> phoneList = new ArrayList<>();
for (Telephone telephone : vCard.getTelephones()) {
String types = null;
for (TelephoneType type : telephone.getTypes()) {
types = addString(types, getString(ContactViewer.getTelephoneTypeMap().get(type)), ", ");
}
addItem(phoneList, contactInfoItems, types, telephone.getValue());
}
addItemGroup(phoneList, contactInfoItems, R.drawable.ic_phone_24dp);
}
private void addAddresses(VCard vCard) {
List<View> addressList = new ArrayList<>();
for (Address address : vCard.getAddresses()) {
String types = null;
for (AddressType type : address.getTypes()) {
types = addString(types, getString(ContactViewer.getAddressTypeMap().get(type)), ", ");
}
String value = null;
for (AddressProperty property : AddressProperty.values()) {
value = addString(value, address.getProperties().get(property), "\n");
}
addItem(addressList, contactInfoItems, types, value);
}
addItemGroup(addressList, contactInfoItems, R.drawable.ic_address_24dp);
}
private void addAdditionalInfo(VCard vCard) {
String categories = null;
for (String category : vCard.getCategories()) {
categories = addString(categories, category, "\n");
}
List<View> notesList = new ArrayList<>();
addItem(notesList, contactInfoItems, getString(R.string.vcard_categories), categories);
addItem(notesList, contactInfoItems, getString(R.string.vcard_note), vCard.getField(VCardProperty.NOTE));
addItem(notesList, contactInfoItems, getString(R.string.vcard_decsription), vCard.getField(VCardProperty.DESC));
addItemGroup(notesList, contactInfoItems, R.drawable.ic_notes_24dp);
}
private void addOrganizationInfo(VCard vCard) {
List<View> organizationList = new ArrayList<>();
addItem(organizationList, contactInfoItems, getString(R.string.vcard_title), vCard.getField(VCardProperty.TITLE));
addItem(organizationList, contactInfoItems, getString(R.string.vcard_role), vCard.getField(VCardProperty.ROLE));
List<Organization> organizations = vCard.getOrganizations();
String organization;
if (organizations.isEmpty()) {
organization = null;
} else {
organization = organizations.get(0).getName();
for (String unit : organizations.get(0).getUnits()) {
organization = addString(organization, unit, "\n");
}
}
addItem(organizationList, contactInfoItems, getString(R.string.vcard_organization), organization);
addItemGroup(organizationList, contactInfoItems, R.drawable.ic_job_title_24dp);
}
private void addNameInfo(VCard vCard) {
List<View> nameList = new ArrayList<>();
addItem(nameList, contactInfoItems, getString(R.string.vcard_nick_name), vCard.getField(VCardProperty.NICKNAME));
addItem(nameList, contactInfoItems, getString(R.string.vcard_formatted_name), vCard.getFormattedName());
addItem(nameList, contactInfoItems, getString(R.string.vcard_prefix_name), vCard.getField(NameProperty.PREFIX));
addItem(nameList, contactInfoItems, getString(R.string.vcard_given_name), vCard.getField(NameProperty.GIVEN));
addItem(nameList, contactInfoItems, getString(R.string.vcard_middle_name), vCard.getField(NameProperty.MIDDLE));
addItem(nameList, contactInfoItems, getString(R.string.vcard_family_name), vCard.getField(NameProperty.FAMILY));
addItem(nameList, contactInfoItems, getString(R.string.vcard_suffix_name), vCard.getField(NameProperty.SUFFIX));
addItemGroup(nameList, contactInfoItems, R.drawable.ic_contact_info_24dp);
}
private void addItemGroup(List<View> nameList, LinearLayout itemList, int groupIcon) {
if (nameList.isEmpty()) {
return;
}
addSeparator(itemList);
((ImageView) nameList.get(0).findViewById(R.id.contact_info_group_icon)).setImageResource(groupIcon);
for (View view : nameList) {
itemList.addView(view);
}
}
private void addItem(List<View> nameList, ViewGroup rootView, String label, String value) {
View itemView = createItemView(rootView, label, value, null);
if (itemView != null) {
Linkify.addLinks((TextView)itemView.findViewById(R.id.contact_info_item_main), Linkify.ALL);
nameList.add(itemView);
}
}
private void addSeparator(LinearLayout rootView) {
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
rootView.addView(inflater.inflate(R.layout.contact_info_separator, rootView, false));
}
private View createItemView(ViewGroup rootView, String label, String value, Integer iconResource) {
if (value == null || value.isEmpty() ) {
return null;
}
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View contactInfoItem = inflater.inflate(R.layout.contact_info_item, rootView, false);
if (label == null || label.trim().isEmpty()) {
contactInfoItem.findViewById(R.id.contact_info_item_secondary).setVisibility(View.GONE);
} else {
((TextView) contactInfoItem.findViewById(R.id.contact_info_item_secondary)).setText(label);
}
((TextView)contactInfoItem.findViewById(R.id.contact_info_item_main)).setText(value);
if (iconResource != null) {
((ImageView) contactInfoItem.findViewById(R.id.contact_info_group_icon)).setImageResource(iconResource);
}
return contactInfoItem;
}
}
......@@ -18,11 +18,8 @@ import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.widget.AdapterView;
import android.widget.EditText;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
......@@ -31,13 +28,13 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
public class ContactEditor extends GroupListActivity implements
OnContactChangedListener, AdapterView.OnItemClickListener,
public class GroupEditor extends ManagedActivity implements OnContactChangedListener,
OnAccountChangedListener {
private String account;
......@@ -45,38 +42,34 @@ public class ContactEditor extends GroupListActivity implements
ContactTitleActionBarInflater contactTitleActionBarInflater;
@Override
protected void onInflate(Bundle savedInstanceState) {
setContentView(R.layout.contact_editor);
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.group_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
contactTitleActionBarInflater = new ContactTitleActionBarInflater(this);
contactTitleActionBarInflater.setUpActionBarView();
Intent intent = getIntent();
account = ContactEditor.getAccount(intent);
user = ContactEditor.getUser(intent);
account = GroupEditor.getAccount(intent);
user = GroupEditor.getUser(intent);
if (AccountManager.getInstance().getAccount(account) == null || user == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish();
}
}
@Override
Collection<String> getInitialGroups() {
return RosterManager.getInstance().getGroups(account);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(R.id.container, GroupEditorFragment.newInstance(account, user)).commit();
}
@Override
Collection<String> getInitialSelected() {
return RosterManager.getInstance().getGroups(account, user);
}
@Override
protected void onResume() {
super.onResume();
((EditText) findViewById(R.id.contact_name)).setText(RosterManager.getInstance().getName(account, user));
Application.getInstance().addUIListener(OnAccountChangedListener.class, this);
Application.getInstance().addUIListener(OnContactChangedListener.class, this);
update();
......@@ -87,19 +80,13 @@ public class ContactEditor extends GroupListActivity implements
super.onPause();
Application.getInstance().removeUIListener(OnAccountChangedListener.class, this);
Application.getInstance().removeUIListener(OnContactChangedListener.class, this);
try {
String name = ((EditText) findViewById(R.id.contact_name)).getText().toString();
RosterManager.getInstance().setNameAndGroup(account, user, name, getSelected());
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void update() {
AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
contactTitleActionBarInflater.update(abstractContact);
contactTitleActionBarInflater.setName(getString(R.string.contact_editor_title, abstractContact.getName()));
contactTitleActionBarInflater.setStatusText(user);
contactTitleActionBarInflater.hideStatusIcon();
}
@Override
......@@ -121,7 +108,7 @@ public class ContactEditor extends GroupListActivity implements
}
public static Intent createIntent(Context context, String account, String user) {
Intent intent = new EntityIntentBuilder(context, ContactEditor.class)
Intent intent = new EntityIntentBuilder(context, GroupEditor.class)
.setAccount(account).setUser(user).build();
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
return intent;
......
package com.xabber.android.ui;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.GroupEditorAdapter;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
public class GroupEditorFragment extends ListFragment implements TextWatcher, View.OnClickListener {
protected static final String ARG_ACCOUNT = "com.xabber.android.ui.GroupEditorFragment.ARG_ACCOUNT";
protected static final String ARG_USER = "com.xabber.android.ui.GroupEditorFragment.ARG_USER";
private static final String SAVED_GROUPS = "com.xabber.android.ui.GroupEditorFragment.SAVED_GROUPS";
private static final String SAVED_SELECTED = "com.xabber.android.ui.GroupEditorFragment.SAVED_SELECTED";
private static final String SAVED_ADD_GROUP_NAME = "com.xabber.android.ui.GroupEditorFragment.SAVED_ADD_GROUP_NAME";
private String account;
private String user;
private GroupEditorAdapter groupEditorAdapter;
private Collection<String> groups;
private Collection<String> selected = new HashSet<>();
private EditText groupAddInput;
private CheckBox groupAddCheckBox;
private View footerView;
public static GroupEditorFragment newInstance(String account, String user) {
GroupEditorFragment fragment = new GroupEditorFragment();
Bundle args = new Bundle();
args.putString(ARG_ACCOUNT, account);
args.putString(ARG_USER, user);
fragment.setArguments(args);
return fragment;
}
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public GroupEditorFragment() {
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
account = getArguments().getString(ARG_ACCOUNT);
user = getArguments().getString(ARG_USER);
}
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setUpFooter();
groupEditorAdapter = new GroupEditorAdapter(getActivity(),
R.layout.group_list_item, new ArrayList<GroupEditorAdapter.Group>());
setListAdapter(groupEditorAdapter);
if (savedInstanceState != null) {
groups = savedInstanceState.getStringArrayList(SAVED_GROUPS);
selected = savedInstanceState.getStringArrayList(SAVED_SELECTED);
groupAddInput.setText(savedInstanceState.getString(SAVED_ADD_GROUP_NAME));
} else {
setAccountGroups();
if (user != null) {
selected = RosterManager.getInstance().getGroups(account, user);
}
}
}
protected void setAccountGroups() {
groups = RosterManager.getInstance().getGroups(account);
}
private void setUpFooter() {
footerView = ((LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.group_add_footer, null, false);
getListView().addFooterView(footerView);
groupAddInput = (EditText) footerView.findViewById(R.id.group_add_input);
groupAddInput.addTextChangedListener(this);
groupAddCheckBox = (CheckBox) footerView.findViewById(R.id.group_add_checkbox);
groupAddCheckBox.setVisibility(View.INVISIBLE);
groupAddCheckBox.setOnClickListener(this);
}
@Override
public void onResume() {
super.onResume();
updateGroups();
}
protected void updateGroups() {
ArrayList<String> list = new ArrayList<>(groups);
Collections.sort(list);
groupEditorAdapter.clear();
for (int position = 0; position < list.size(); position++) {
String groupName = list.get(position);
GroupEditorAdapter.Group group = new GroupEditorAdapter.Group(groupName, selected.contains(groupName));
groupEditorAdapter.add(group);
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
selected = getSelected();
outState.putStringArrayList(SAVED_GROUPS, getGroups());
outState.putStringArrayList(SAVED_SELECTED, new ArrayList<>(selected));
outState.putString(SAVED_ADD_GROUP_NAME, groupAddInput.getText().toString());
}
@Override
public void onPause() {
super.onPause();
selected = getSelected();
if (account != null && !"".equals(user)) {
try {
RosterManager.getInstance().setGroups(account, user, selected);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
}
@Override
public void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
CheckBox checkBox = (CheckBox) v.findViewById(R.id.group_item_selected_checkbox);
checkBox.toggle();
GroupEditorAdapter.Group group = groupEditorAdapter.getItem(position - getListView().getHeaderViewsCount());
group.setIsSelected(checkBox.isChecked());
}
protected ArrayList<String> getGroups() {
ArrayList<String> groups = new ArrayList<>();
for (int position = 0; position < groupEditorAdapter.getCount(); position++)
groups.add(groupEditorAdapter.getItem(position).getGroupName());
return groups;
}
public ArrayList<String> getSelected() {
ArrayList<String> selectedGroups = new ArrayList<>();
for (int position = 0; position < groupEditorAdapter.getCount(); position++) {
GroupEditorAdapter.Group item = groupEditorAdapter.getItem(position);
if (item.isSelected()) {
selectedGroups.add(item.getGroupName());
}
}
return selectedGroups;
}
@Override
public void afterTextChanged(Editable s) {
String groupName = groupAddInput.getText().toString().trim();
if (groupName.isEmpty() || getGroups().contains(groupName)) {
groupAddCheckBox.setVisibility(View.INVISIBLE);
} else {
groupAddCheckBox.setVisibility(View.VISIBLE);
}
}
@Override
public void onClick(View v) {
if (v.getId() == R.id.group_add_checkbox) {
String groupName = groupAddInput.getText().toString().trim();
groupEditorAdapter.add(new GroupEditorAdapter.Group(groupName, true));
groupAddInput.getText().clear();
groupAddInput.clearFocus();
hideKeyboard(getActivity());
groupAddCheckBox.setChecked(false);
}
}
public static void hideKeyboard(Activity activity) {
// Check if no view has focus:
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
protected String getAccount() {
return account;
}
protected String getUser() {
return user;
}
protected void setAccount(String account) {
this.account = account;
}
protected void setUser(String user) {
this.user = user;
}
protected View getFooterView() {
return footerView;
}
}
/**
* Copyright (c) 2013, Redsolution LTD. All rights reserved.
*
* This file is part of Xabber project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License, Version 3.
*
* Xabber is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License,
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
package com.xabber.android.ui;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import com.xabber.android.ui.dialog.GroupAddDialogFragment;
import com.xabber.android.ui.dialog.GroupAddDialogFragment.OnGroupAddConfirmed;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
/**
* Manage list of selected groups.
*
* @author alexander.ivanov
*/
public abstract class GroupListActivity extends ManagedListActivity implements
OnItemClickListener, OnGroupAddConfirmed {
private static final String SAVED_GROUPS = "com.xabber.android.ui.ContactList.SAVED_GROUPS";
private static final String SAVED_SELECTED = "com.xabber.android.ui.ContactList.SAVED_SELECTED";
private ArrayAdapter<String> arrayAdapter;
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
onInflate(savedInstanceState);
if (isFinishing())
return;
Collection<String> groups;
Collection<String> selected;
if (savedInstanceState != null) {
groups = savedInstanceState.getStringArrayList(SAVED_GROUPS);
selected = savedInstanceState.getStringArrayList(SAVED_SELECTED);
} else {
groups = getInitialGroups();
selected = getInitialSelected();
}
listView = getListView();
listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
listView.setOnItemClickListener(this);
arrayAdapter = new ArrayAdapter<>(this,
android.R.layout.simple_list_item_multiple_choice,
new ArrayList<String>());
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.add_item, listView, false);
((TextView) view.findViewById(android.R.id.message))
.setText(R.string.group_add);
listView.addFooterView(view, null, true);
setListAdapter(arrayAdapter);
setGroups(groups, selected);
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putStringArrayList(SAVED_GROUPS, getGroups());
outState.putStringArrayList(SAVED_SELECTED, getSelected());
}
/**
* Inflates layout.
*
* @param savedInstanceState
*/
protected abstract void onInflate(Bundle savedInstanceState);
/**
* @return List of initial allowed groups.
*/
abstract Collection<String> getInitialGroups();
/**
* @return List of initially selected groups.
*/
abstract Collection<String> getInitialSelected();
/**
* @return Actual groups from adapter.
*/
private ArrayList<String> getGroups() {
ArrayList<String> groups = new ArrayList<>();
for (int position = 0; position < arrayAdapter.getCount(); position++)
groups.add(arrayAdapter.getItem(position));
return groups;
}
/**
* @return Actual selected groups from adapter.
*/
public ArrayList<String> getSelected() {
ArrayList<String> groups = new ArrayList<>();
for (int position = 0; position < arrayAdapter.getCount(); position++)
if (listView.isItemChecked(position
+ listView.getHeaderViewsCount())) {
groups.add(arrayAdapter.getItem(position));
}
return groups;
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.create_new_group, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_create_new_group:
showGroupAddDialog();
return true;
}
return false;
}
private void showGroupAddDialog() {
GroupAddDialogFragment.newInstance(getGroups()).show(getFragmentManager(), "GROUP-ADD");
}
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
if (listView.getItemAtPosition(position) == null) // Footer
showGroupAddDialog();
}
/**
* Sets new list of groups and select specified groups.
*
* @param groups
* @param selected
*/
void setGroups(Collection<String> groups, Collection<String> selected) {
ArrayList<String> list = new ArrayList<>(groups);
Collections.sort(list);
arrayAdapter.clear();
for (int position = 0; position < list.size(); position++) {
String group = list.get(position);
arrayAdapter.add(group);
listView.setItemChecked(position + listView.getHeaderViewsCount(),
selected.contains(group));
}
}
@Override
public void onGroupAddConfirmed(String group) {
ArrayList<String> groups = getGroups();
groups.add(group);
ArrayList<String> selected = getSelected();
selected.add(group);
setGroups(groups, selected);
}
}
......@@ -14,18 +14,16 @@
*/
package com.xabber.android.ui;
import java.util.Collection;
import org.jivesoftware.smack.util.StringUtils;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Spinner;
......@@ -39,11 +37,15 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class MUCEditor extends ManagedActivity implements View.OnClickListener,
OnItemSelectedListener {
import org.jivesoftware.smack.util.StringUtils;
import java.util.Collection;
public class MUCEditor extends ManagedActivity implements OnItemSelectedListener {
private static final String SAVED_ACCOUNT = "com.xabber.android.ui.MUCEditor.SAVED_ACCOUNT";
private static final String SAVED_ROOM = "com.xabber.android.ui.MUCEditor.SAVED_ROOM";
......@@ -65,16 +67,21 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
private EditText nickView;
private EditText passwordView;
private ActionBarPainter actionBarPainter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
if (isFinishing()) {
return;
}
setContentView(R.layout.muc_editor);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_clear_white_24dp);
getSupportActionBar().setTitle(null);
accountView = (Spinner) findViewById(R.id.contact_account);
serverView = (EditText) findViewById(R.id.muc_server);
......@@ -82,7 +89,6 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
nickView = (EditText) findViewById(R.id.muc_nick);
passwordView = (EditText) findViewById(R.id.muc_password);
((Button) findViewById(R.id.ok)).setOnClickListener(this);
accountView.setAdapter(new AccountChooseAdapter(this));
accountView.setOnItemSelectedListener(this);
......@@ -105,30 +111,37 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
String password;
RoomInvite roomInvite = MUCManager.getInstance().getInvite(
account, room);
if (roomInvite != null)
if (roomInvite != null) {
password = roomInvite.getPassword();
else
password = MUCManager.getInstance().getPassword(account,
room);
} else {
password = MUCManager.getInstance().getPassword(account, room);
}
passwordView.setText(password);
}
}
if (account == null) {
Collection<String> accounts = AccountManager.getInstance()
.getAccounts();
if (accounts.size() == 1)
Collection<String> accounts = AccountManager.getInstance().getAccounts();
if (accounts.size() == 1) {
account = accounts.iterator().next();
}
}
actionBarPainter = new ActionBarPainter(this);
if (account != null) {
for (int position = 0; position < accountView.getCount(); position++)
actionBarPainter.updateWithAccountName(account);
for (int position = 0; position < accountView.getCount(); position++) {
if (account.equals(accountView.getItemAtPosition(position))) {
accountView.setSelection(position);
break;
}
}
if ("".equals(nickView.getText().toString()))
nickView.setText(getNickname(((String) accountView
.getSelectedItem())));
}
if ("".equals(nickView.getText().toString())) {
nickView.setText(getNickname(((String) accountView.getSelectedItem())));
}
}
@Override
......@@ -146,82 +159,92 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.ok:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
inflater.inflate(R.menu.add_conference, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.action_add_conference:
addConference();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void addConference() {
String account = (String) accountView.getSelectedItem();
if (account == null) {
Toast.makeText(this, getString(R.string.EMPTY_ACCOUNT),
Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.EMPTY_ACCOUNT), Toast.LENGTH_LONG).show();
return;
}
String server = serverView.getText().toString();
if ("".equals(server)) {
Toast.makeText(this, getString(R.string.EMPTY_SERVER_NAME),
Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.EMPTY_SERVER_NAME), Toast.LENGTH_LONG).show();
return;
}
String room = roomView.getText().toString();
if ("".equals(room)) {
Toast.makeText(this, getString(R.string.EMPTY_ROOM_NAME),
Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.EMPTY_ROOM_NAME), Toast.LENGTH_LONG).show();
return;
}
String nick = nickView.getText().toString();
if ("".equals(nick)) {
Toast.makeText(this, getString(R.string.EMPTY_NICK_NAME),
Toast.LENGTH_LONG).show();
Toast.makeText(this, getString(R.string.EMPTY_NICK_NAME), Toast.LENGTH_LONG).show();
return;
}
String password = passwordView.getText().toString();
boolean join = ((CheckBox) findViewById(R.id.muc_join)).isChecked();
room = room + "@" + server;
if (this.account != null && this.room != null)
if (this.account != null && this.room != null) {
if (!account.equals(this.account) || !room.equals(this.room)) {
MUCManager.getInstance()
.removeRoom(this.account, this.room);
MessageManager.getInstance().closeChat(this.account,
this.room);
NotificationManager.getInstance()
.removeMessageNotification(this.account, this.room);
}
MUCManager.getInstance().createRoom(account, room, nick, password,
join);
finish();
break;
default:
break;
MUCManager.getInstance().removeRoom(this.account, this.room);
MessageManager.getInstance().closeChat(this.account, this.room);
NotificationManager.getInstance().removeMessageNotification(this.account, this.room);
}
}
MUCManager.getInstance().createRoom(account, room, nick, password, join);
finish();
}
/**
* @param account
* @return Suggested nickname in the room.
*/
private String getNickname(String account) {
if (account == null)
if (account == null) {
return "";
}
String nickname = AccountManager.getInstance().getNickName(account);
String name = StringUtils.parseName(nickname);
if ("".equals(name))
if ("".equals(name)) {
return nickname;
else
} else {
return name;
}
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String current = nickView.getText().toString();
String previous;
if (selectedAccount == AdapterView.INVALID_POSITION)
if (selectedAccount == AdapterView.INVALID_POSITION) {
previous = "";
else
previous = getNickname((String) accountView.getAdapter().getItem(
selectedAccount));
if (current.equals(previous))
} else {
previous = getNickname((String) accountView.getAdapter().getItem(selectedAccount));
}
if (current.equals(previous)) {
nickView.setText(getNickname((String) accountView.getSelectedItem()));
}
selectedAccount = accountView.getSelectedItemPosition();
actionBarPainter.updateWithAccountName((String) accountView.getSelectedItem());
}
@Override
......@@ -235,8 +258,7 @@ public class MUCEditor extends ManagedActivity implements View.OnClickListener,
public static Intent createIntent(Context context, String account,
String room) {
return new EntityIntentBuilder(context, MUCEditor.class)
.setAccount(account).setUser(room).build();
return new EntityIntentBuilder(context, MUCEditor.class).setAccount(account).setUser(room).build();
}
private static String getAccount(Intent intent) {
......
......@@ -92,7 +92,7 @@ public class StatusEditor extends ManagedListActivity implements
setListAdapter(adapter);
statusTextView = (EditText) header.findViewById(R.id.status_text);
statusModeView = (Spinner) header.findViewById(R.id.status_mode);
statusModeView = (Spinner) header.findViewById(R.id.status_icon);
statusModeView.setAdapter(new StatusModeAdapter(this));
findViewById(R.id.ok).setOnClickListener(this);
......
......@@ -129,7 +129,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
* @return The data for the specified view.
*/
public String getItemForView(View view) {
if (view.getId() == R.id.status_mode) {
if (view.getId() == R.id.status_icon) {
view = (View) view.getParent();
}
for (int index = 0; index < linearLayout.getChildCount(); index++) {
......@@ -146,7 +146,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
final ImageView disabled;
public AccountViewHolder(View view) {
statusMode = (ImageView) view.findViewById(R.id.status_mode);
statusMode = (ImageView) view.findViewById(R.id.status_icon);
avatar = (ImageView) view.findViewById(R.id.avatar);
disabled = (ImageView) view.findViewById(R.id.disabled);
}
......
......@@ -61,7 +61,7 @@ public abstract class BaseContactInflater {
this.activity = activity;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.shadow);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.contact_shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
......
package com.xabber.android.ui.adapter;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.xabber.androiddev.R;
import java.util.List;
public class GroupEditorAdapter extends ArrayAdapter<GroupEditorAdapter.Group> {
private FragmentActivity activity;
private int layoutResourceId;
public GroupEditorAdapter(FragmentActivity activity, int layoutResourceId, List<GroupEditorAdapter.Group> objects) {
super(activity, layoutResourceId, objects);
this.activity = activity;
this.layoutResourceId = layoutResourceId;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
GroupHolder holder;
if (row == null) {
LayoutInflater inflater = activity.getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new GroupHolder();
holder.groupCheckbox = (CheckBox) row.findViewById(R.id.group_item_selected_checkbox);
holder.groupName = (TextView) row.findViewById(R.id.group_item_name);
row.setTag(holder);
} else {
holder = (GroupHolder)row.getTag();
}
Group group = getItem(position);
holder.groupName.setText(group.groupName);
holder.groupCheckbox.setChecked(group.isSelected);
return row;
}
static class GroupHolder {
TextView groupName;
CheckBox groupCheckbox;
}
public static class Group {
String groupName;
boolean isSelected;
public Group(String groupName, boolean isSelected) {
this.groupName = groupName;
this.isSelected = isSelected;
}
public String getGroupName() {
return groupName;
}
public boolean isSelected() {
return isSelected;
}
public void setIsSelected(boolean isSelected) {
this.isSelected = isSelected;
}
}
}
......@@ -92,7 +92,7 @@ public class OccupantListAdapter extends BaseAdapter implements
final TextView statusTextView = (TextView) view
.findViewById(R.id.status);
final ImageView statusModeView = (ImageView) view
.findViewById(R.id.status_mode);
.findViewById(R.id.status_icon);
if (MUCManager.getInstance().getNickname(account, room)
.equalsIgnoreCase(occupant.getNickname()))
avatarView.setImageDrawable(AvatarManager.getInstance()
......
......@@ -58,7 +58,7 @@ public class StatusContactInflater extends BaseContactInflater {
public ViewHolder(View view) {
super(view);
statusMode = (ImageView) view.findViewById(R.id.status_mode);
statusMode = (ImageView) view.findViewById(R.id.status_icon);
}
}
......
......@@ -7,6 +7,8 @@ import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.ContactViewer;
import com.xabber.androiddev.R;
public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
......@@ -44,6 +46,10 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
if (getActivity() instanceof ContactViewer) {
startActivity(ContactList.createIntent(getActivity()));
}
return true;
}
......
package com.xabber.android.ui.helper;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.view.Window;
import android.view.WindowManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.androiddev.R;
public class ActionBarPainter {
private int[] accountActionBarColors;
private int[] accountStatusBarColors;
private String[] accountColorNames;
private Window window;
private int defaultStatusBarColor;
private ColorDrawable defaultActionBarBackground;
private final ActionBarActivity activity;
public ActionBarPainter(ActionBarActivity activity) {
this.activity = activity;
accountActionBarColors = activity.getResources().getIntArray(R.array.account_action_bar);
accountStatusBarColors = activity.getResources().getIntArray(R.array.account_status_bar);
accountColorNames = activity.getResources().getStringArray(R.array.account_color_names);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window = this.activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
defaultStatusBarColor = window.getStatusBarColor();
}
TypedArray a = activity.getTheme().obtainStyledAttributes(R.style.Theme, new int[] {R.attr.colorPrimary});
int attributeResourceId = a.getResourceId(0, 0);
defaultActionBarBackground = new ColorDrawable(activity.getResources().getColor(attributeResourceId));
}
public void updateWithAccountName(String account) {
updateWithColorLevel(AccountManager.getInstance().getColorLevel(account));
}
public void updateWithColorLevel(int colorLevel) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(accountStatusBarColors[colorLevel]);
}
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(accountActionBarColors[colorLevel]));
}
public void restore() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(defaultStatusBarColor);
}
activity.getSupportActionBar().setBackgroundDrawable(defaultActionBarBackground);
}
public void updateWithColorName(String targetColorName) {
for (int i = 0; i < accountColorNames.length; i++) {
String accountColorName = accountColorNames[i];
if (accountColorName.equals(targetColorName)) {
updateWithColorLevel(i);
}
}
}
}
package com.xabber.android.ui.helper;
import android.content.res.TypedArray;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
......@@ -23,78 +16,47 @@ public class ContactTitleActionBarInflater {
private final ActionBarActivity activity;
private View actionBarView;
private int[] accountActionBarColors;
private int[] accountStatusBarColors;
private Window window;
private int defaultStatusBarColor;
private Animation shakeAnimation = null;
private ColorDrawable defaultActionBarBackground;
private ActionBarPainter actionBarPainter;
public ContactTitleActionBarInflater(ActionBarActivity activity) {
this.activity = activity;
}
public void setUpActionBarView() {
accountActionBarColors = activity.getResources().getIntArray(R.array.account_action_bar);
accountStatusBarColors = activity.getResources().getIntArray(R.array.account_status_bar);
actionBarPainter = new ActionBarPainter(activity);
ActionBar actionBar = activity.getSupportActionBar();
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBarView = LayoutInflater.from(activity).inflate(R.layout.contact_title, null);
actionBar.setCustomView(actionBarView, new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window = this.activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
defaultStatusBarColor = window.getStatusBarColor();
}
TypedArray a = activity.getTheme().obtainStyledAttributes(R.style.Theme, new int[] {R.attr.colorPrimary});
int attributeResourceId = a.getResourceId(0, 0);
defaultActionBarBackground = new ColorDrawable(activity.getResources().getColor(attributeResourceId));
}
public void update(AbstractContact abstractContact) {
actionBarPainter.updateWithAccountName(abstractContact.getAccount());
activity.getSupportActionBar().setDisplayShowCustomEnabled(true);
activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
actionBarView.setVisibility(View.VISIBLE);
ContactTitleInflater.updateTitle(actionBarView, activity, abstractContact);
int colorLevel = AccountManager.getInstance().getColorLevel(abstractContact.getAccount());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(accountStatusBarColors[colorLevel]);
}
activity.getSupportActionBar().setBackgroundDrawable(new ColorDrawable(accountActionBarColors[colorLevel]));
}
public void restoreDefaultTitleView(String title) {
actionBarPainter.restore();
activity.getSupportActionBar().setDisplayShowCustomEnabled(false);
activity.getSupportActionBar().setDisplayShowTitleEnabled(true);
actionBarView.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(defaultStatusBarColor);
}
activity.getSupportActionBar().setBackgroundDrawable(defaultActionBarBackground);
activity.setTitle(title);
}
public ImageView getSecurityView() {
return (ImageView)actionBarView.findViewById(R.id.security);
}
public void playIncomingAnimation() {
if (shakeAnimation == null) {
shakeAnimation = AnimationUtils.loadAnimation(activity, R.anim.shake);
......@@ -117,4 +79,8 @@ public class ContactTitleActionBarInflater {
public void setStatusText(String user) {
((TextView) actionBarView.findViewById(R.id.status_text)).setText(user);
}
public void hideStatusIcon() {
actionBarView.findViewById(R.id.status_icon).setVisibility(View.GONE);
}
}
package com.xabber.android.ui.helper;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.os.Build;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RelativeLayout;
import com.github.ksoichiro.android.observablescrollview.ObservableListView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
import static java.lang.Math.pow;
import static java.lang.Math.round;
import static java.lang.Math.sqrt;
public class ContactTitleExpandableToolbarInflater implements ObservableScrollViewCallbacks {
private final ActionBarActivity activity;
private View avatarView;
private View titleView;
private View contactNamePanel;
private int toolbarHeight;
private int paddingLeftMin;
private int paddingRight;
private int actionBarSize;
private int toolbarHeightDelta;
private int avatarLargeSize;
private int avatarNormalSize;
private int avatarRadius;
private int contactTitlePaddingBottomBig;
private int contactTitlePaddingBottomSmall;
public ContactTitleExpandableToolbarInflater(ActionBarActivity activity) {
this.activity = activity;
}
public void onCreate(AbstractContact abstractContact) {
activity.setContentView(R.layout.expandable_contact_title_activity);
activity.setSupportActionBar((Toolbar) activity.findViewById(R.id.toolbar_overlay));
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
avatarView = activity.findViewById(R.id.avatar);
contactNamePanel = activity.findViewById(R.id.contact_name_panel);
titleView = activity.findViewById(R.id.expandable_contact_title);
ContactTitleInflater.updateTitle(titleView, activity, abstractContact);
int[] accountStatusBarColors = activity.getResources().getIntArray(R.array.account_status_bar);
int colorLevel = AccountManager.getInstance().getColorLevel(abstractContact.getAccount());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.setStatusBarColor(accountStatusBarColors[colorLevel]);
}
}
public void onResume() {
Resources resources = activity.getResources();
paddingLeftMin = resources.getDimensionPixelSize(R.dimen.contact_title_padding_left);
paddingRight = resources.getDimensionPixelSize(R.dimen.contact_title_padding_right);
avatarLargeSize = resources.getDimensionPixelSize(R.dimen.avatar_large_size);
avatarNormalSize = resources.getDimensionPixelSize(R.dimen.avatar_normal_size);
avatarRadius = resources.getDimensionPixelSize(R.dimen.avatar_radius);
contactTitlePaddingBottomBig = resources.getDimensionPixelSize(R.dimen.contact_title_padding_bottom_big);
contactTitlePaddingBottomSmall = resources.getDimensionPixelSize(R.dimen.contact_title_padding_bottom_small);
toolbarHeight = resources.getDimensionPixelSize(R.dimen.toolbar_height);
actionBarSize = getActionBarSize();
toolbarHeightDelta = toolbarHeight - actionBarSize;
final ObservableScrollView scrollView = (ObservableScrollView) activity.findViewById(R.id.scroll);
scrollView.setScrollViewCallbacks(this);
ScrollUtils.addOnGlobalLayoutListener(activity.findViewById(R.id.expandable_contact_title), new Runnable() {
@Override
public void run() {
updateFlexibleSpaceText(scrollView.getCurrentScrollY());
}
});
}
protected int getActionBarSize() {
TypedValue typedValue = new TypedValue();
int[] textSizeAttr = new int[]{R.attr.actionBarSize};
int indexOfAttrTextSize = 0;
TypedArray a = activity.obtainStyledAttributes(typedValue.data, textSizeAttr);
int actionBarSize = a.getDimensionPixelSize(indexOfAttrTextSize, -1);
a.recycle();
return actionBarSize;
}
@Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) {
updateFlexibleSpaceText(scrollY);
}
@Override
public void onDownMotionEvent() {
}
@Override
public void onUpOrCancelMotionEvent(ScrollState scrollState) {
}
private void updateFlexibleSpaceText(final int scrollY) {
setLeftPadding(scrollY);
setTopPadding(scrollY);
setAvatarSize(scrollY);
setHeight(scrollY);
}
private void setTopPadding(int scrollY) {
int paddingDelta = contactTitlePaddingBottomBig - contactTitlePaddingBottomSmall;
int paddingBottom = contactTitlePaddingBottomBig - scrollY * paddingDelta / toolbarHeightDelta;
if (scrollY <= 0) {
paddingBottom = contactTitlePaddingBottomBig;
}
if (scrollY >= toolbarHeightDelta) {
paddingBottom = contactTitlePaddingBottomSmall;
}
contactNamePanel.setPadding(0, 0, 0, paddingBottom);
}
private void setAvatarSize(int scrollY) {
int newAvatarSize = avatarLargeSize - (scrollY / 2);
if (newAvatarSize < avatarNormalSize) {
newAvatarSize = avatarNormalSize;
}
if (avatarView.getWidth() != newAvatarSize) {
avatarView.getLayoutParams().width = newAvatarSize;
avatarView.getLayoutParams().height = newAvatarSize;
}
}
private void setHeight(int scrollY) {
int newHeight = toolbarHeight - scrollY;
if (newHeight < actionBarSize) {
newHeight = actionBarSize;
}
titleView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, newHeight));
}
private void setLeftPadding(int scrollY) {
int paddingLeft = (int) round(sqrt(pow(avatarRadius, 2) - pow(scrollY - avatarRadius, 2)));
if (scrollY < 0) {
paddingLeft = paddingLeftMin;
}
if (scrollY > avatarRadius) {
paddingLeft = avatarRadius;
}
if (paddingLeft < paddingLeftMin) {
paddingLeft = paddingLeftMin;
}
titleView.setPadding(paddingLeft, 0, paddingLeft, 0);
}
}
......@@ -62,7 +62,7 @@ public class ContactTitleInflater {
}
private static void setStatus(Activity activity, View titleView, AbstractContact abstractContact) {
final ImageView statusModeView = (ImageView) titleView.findViewById(R.id.status_mode);
final ImageView statusModeView = (ImageView) titleView.findViewById(R.id.status_icon);
int statusLevel = abstractContact.getStatusMode().getStatusLevel();
if (isContactOffline(statusLevel)) {
......
......@@ -33,9 +33,8 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.android.ui.ChatViewer;
import com.xabber.android.ui.ContactAdd;
import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.GroupEditor;
import com.xabber.android.ui.MUCEditor;
import com.xabber.android.ui.StatusEditor;
import com.xabber.android.ui.adapter.UpdatableAdapter;
......@@ -44,7 +43,7 @@ import com.xabber.android.ui.dialog.GroupDeleteDialogFragment;
import com.xabber.android.ui.dialog.GroupRenameDialogFragment;
import com.xabber.android.ui.dialog.MUCDeleteDialogFragment;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.preferences.ContactViewer;
import com.xabber.android.ui.ContactViewer;
import com.xabber.androiddev.R;
/**
......@@ -63,17 +62,6 @@ public class ContextMenuHelper {
final String account = abstractContact.getAccount();
final String user = abstractContact.getUser();
menu.setHeaderTitle(abstractContact.getName());
menu.add(R.string.chat_viewer).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MessageManager.getInstance().openChat(account, user);
activity.startActivity(ChatViewer.createIntent(
activity, account, user));
return true;
}
});
if (MUCManager.getInstance().hasRoom(account, user)) {
if (!MUCManager.getInstance().inUse(account, user))
menu.add(R.string.muc_edit).setIntent(
......@@ -121,10 +109,6 @@ public class ContextMenuHelper {
});
} else {
menu.add(R.string.contact_viewer).setIntent(
ContactViewer.createIntent(activity, account, user));
menu.add(R.string.contact_editor).setIntent(
ContactEditor.createIntent(activity, account, user));
menu.add(R.string.contact_delete).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
......@@ -185,7 +169,7 @@ public class ContextMenuHelper {
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
activity.startActivity(ContactEditor.createIntent(
activity.startActivity(GroupEditor.createIntent(
activity, account, user));
return true;
}
......@@ -290,7 +274,6 @@ public class ContextMenuHelper {
}
return true;
}
});
menu.add(R.string.contact_add).setIntent(
ContactAdd.createIntent(activity, account));
......
......@@ -28,6 +28,7 @@ import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.OAuthActivity;
import com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder;
import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
......@@ -46,6 +47,7 @@ public class AccountEditor extends ManagedActivity implements
private AccountItem accountItem;
private String token;
private ActionBarPainter actionBarPainter;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -76,6 +78,9 @@ public class AccountEditor extends ManagedActivity implements
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(AccountManager.getInstance().getVerboseName(account));
actionBarPainter = new ActionBarPainter(this);
actionBarPainter.updateWithAccountName(account);
}
@Override
......@@ -158,4 +163,9 @@ public class AccountEditor extends ManagedActivity implements
public void showOrbotDialog() {
showDialog(ORBOT_DIALOG_ID);
}
@Override
public void onColorChange(String colorName) {
actionBarPainter.updateWithColorName(colorName);
}
}
......@@ -92,6 +92,11 @@ public class AccountEditorFragment extends BaseSettingsFragment
}
}
}
if (getString(R.string.account_color_key).equals(key)) {
mListener.onColorChange((String)newValue);
}
return true;
}
......@@ -210,10 +215,11 @@ public class AccountEditorFragment extends BaseSettingsFragment
}
public interface AccountEditorFragmentInteractionListener {
public String getAccount();
public AccountItem getAccountItem();
public String getToken();
public void onOAuthClick();
public void showOrbotDialog();
String getAccount();
AccountItem getAccountItem();
String getToken();
void onOAuthClick();
void showOrbotDialog();
void onColorChange(String colorName);
}
}
......@@ -23,6 +23,7 @@ import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
......@@ -51,6 +52,9 @@ public class ChatEditor extends ManagedActivity
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
ActionBarPainter actionBarPainter = new ActionBarPainter(this);
actionBarPainter.updateWithAccountName(account);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ChatEditorFragment()).commit();
......
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import com.xabber.android.data.extension.capability.CapabilitiesManager;
import com.xabber.android.data.extension.capability.ClientInfo;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.android.ui.widget.StatusPreference;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
import com.xabber.xmpp.vcard.Email;
import com.xabber.xmpp.vcard.EmailType;
import com.xabber.xmpp.vcard.NameProperty;
import com.xabber.xmpp.vcard.Organization;
import com.xabber.xmpp.vcard.Telephone;
import com.xabber.xmpp.vcard.TelephoneType;
import com.xabber.xmpp.vcard.VCard;
import com.xabber.xmpp.vcard.VCardProperty;
import java.util.ArrayList;
import java.util.List;
public class ContactViewerFragment extends android.preference.PreferenceFragment {
private List<PreferenceCategory> addresses;
private List<PreferenceCategory> telephones;
private List<PreferenceCategory> emails;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addresses = new ArrayList<>();
telephones = new ArrayList<>();
emails = new ArrayList<>();
addPreferencesFromResource(R.xml.contact_viewer);
PreferenceSummaryHelper.updateSummary(getPreferenceScreen());
}
/**
* Sets value for the preference by its id.
*
* @param resourceId
* @param value
*/
private void setValue(int resourceId, String value) {
if (value == null)
value = "";
findPreference(getString(resourceId)).setSummary(value);
}
/**
* @param source
* @param value
* @param splitter
* @return Concatenated source and value with splitter if necessary.
*/
private String addString(String source, String value, String splitter) {
if (value == null || "".equals(value))
return source;
if (source == null || "".equals(source))
return value;
return source + splitter + value;
}
public void updateContact(String account, String bareAddress) {
setValue(R.string.contact_viewer_jid, bareAddress);
RosterContact rosterContact = RosterManager.getInstance()
.getRosterContact(account, bareAddress);
setValue(R.string.contact_viewer_name, rosterContact == null ? null
: rosterContact.getRealName());
PreferenceCategory preferenceCategory = (PreferenceCategory) findPreference(getString(R.string.contact_viewer_resources));
preferenceCategory.removeAll();
if (rosterContact != null && rosterContact.isConnected())
for (ResourceItem resourceItem : PresenceManager.getInstance()
.getResourceItems(account, bareAddress)) {
StatusPreference preference = new StatusPreference(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setStatusMode(resourceItem.getStatusMode());
String user = resourceItem.getUser(bareAddress);
ClientInfo clientInfo = CapabilitiesManager.getInstance()
.getClientInfo(account, user);
String client;
if (clientInfo == null) {
CapabilitiesManager.getInstance().request(account, user);
client = getString(R.string.please_wait);
} else if (clientInfo == CapabilitiesManager.INVALID_CLIENT_INFO) {
client = getString(R.string.unknown);
} else {
String name = clientInfo.getName();
if (name == null)
name = getString(R.string.unknown);
String type = clientInfo.getType();
if (type == null)
type = getString(R.string.unknown);
client = getString(R.string.contact_viewer_client_info,
name, type);
}
preference.setTitle(getString(
R.string.contact_viewer_resource_summary,
resourceItem.getVerbose(), resourceItem.getPriority(),
client));
preference.setSummary(resourceItem.getStatusText());
preferenceCategory.addPreference(preference);
}
}
public void updateVCard(VCard vCard) {
if (vCard == null)
return;
setValue(R.string.vcard_nick_name,
vCard.getField(VCardProperty.NICKNAME));
setValue(R.string.vcard_formatted_name, vCard.getFormattedName());
setValue(R.string.vcard_prefix_name,
vCard.getField(NameProperty.PREFIX));
setValue(R.string.vcard_given_name, vCard.getField(NameProperty.GIVEN));
setValue(R.string.vcard_middle_name,
vCard.getField(NameProperty.MIDDLE));
setValue(R.string.vcard_family_name,
vCard.getField(NameProperty.FAMILY));
setValue(R.string.vcard_suffix_name,
vCard.getField(NameProperty.SUFFIX));
setValue(R.string.vcard_birth_date, vCard.getField(VCardProperty.BDAY));
setValue(R.string.vcard_title, vCard.getField(VCardProperty.TITLE));
setValue(R.string.vcard_role, vCard.getField(VCardProperty.ROLE));
List<Organization> organizations = vCard.getOrganizations();
String organization;
if (organizations.isEmpty())
organization = null;
else {
organization = organizations.get(0).getName();
for (String unit : organizations.get(0).getUnits())
organization = addString(organization, unit, "\n");
}
setValue(R.string.vcard_organization, organization);
setValue(R.string.vcard_url, vCard.getField(VCardProperty.URL));
String categories = null;
for (String category : vCard.getCategories())
categories = addString(categories, category, "\n");
setValue(R.string.vcard_categories, categories);
setValue(R.string.vcard_note, vCard.getField(VCardProperty.NOTE));
setValue(R.string.vcard_decsription, vCard.getField(VCardProperty.DESC));
PreferenceScreen screen = getPreferenceScreen();
for (PreferenceCategory category : addresses)
screen.removePreference(category);
for (PreferenceCategory category : telephones)
screen.removePreference(category);
for (PreferenceCategory category : emails)
screen.removePreference(category);
for (Address address : vCard.getAddresses()) {
String types = null;
for (AddressType type : address.getTypes())
types = addString(types, getString(ContactViewer.getAddressTypeMap().get(type)),
", ");
String value = null;
for (AddressProperty property : AddressProperty.values())
value = addString(value, address.getProperties().get(property),
"\n");
PreferenceScreen addressScreen = createTypedCategory(
R.string.vcard_address, types, value);
for (AddressProperty property : AddressProperty.values())
addPreferenceScreen(addressScreen,
ContactViewer.getAddressPropertyMap().get(property), address
.getProperties().get(property));
}
for (Telephone telephone : vCard.getTelephones()) {
String types = null;
for (TelephoneType type : telephone.getTypes())
types = addString(types,
getString(ContactViewer.getTelephoneTypeMap().get(type)), ", ");
createTypedCategory(R.string.vcard_telephone, types,
telephone.getValue());
}
for (Email email : vCard.getEmails()) {
String types = null;
for (EmailType type : email.getTypes())
types = addString(types, getString(ContactViewer.getEmailTypeMap().get(type)),
", ");
createTypedCategory(R.string.vcard_email, types, email.getValue());
}
}
private PreferenceScreen createTypedCategory(int title, String types,
String value) {
PreferenceCategory preferenceCategory = new PreferenceCategory(getActivity());
preferenceCategory.setTitle(title);
getPreferenceScreen().addPreference(preferenceCategory);
addPreferenceScreen(preferenceCategory, R.string.vcard_type, types);
return addPreferenceScreen(preferenceCategory, title, value);
}
private PreferenceScreen addPreferenceScreen(PreferenceGroup container,
int title, String summary) {
PreferenceScreen preference = getPreferenceManager().createPreferenceScreen(getActivity());
preference.setLayoutResource(R.layout.info_preference);
preference.setTitle(title);
preference.setSummary(summary == null ? "" : summary);
container.addPreference(preference);
return preference;
}
}
......@@ -58,7 +58,7 @@ public class StatusPreference extends Preference {
@Override
protected void onBindView(View view) {
super.onBindView(view);
((ImageView) view.findViewById(R.id.status_mode))
((ImageView) view.findViewById(R.id.status_icon))
.setImageLevel(statusMode.getStatusLevel());
}
......
......@@ -16,7 +16,7 @@ package com.xabber.xmpp.vcard;
public class Email extends AbstractTypedDataWithValue<EmailType> {
public static final String ELEMENT_NAME = "TEL";
public static final String ELEMENT_NAME = "EMAIL";
public static final String USERID_NAME = "USERID";
public Email() {
......
<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/ic_security_plain_24dp" android:minLevel="0" android:maxLevel="0" />
<item android:drawable="@drawable/ic_security_encrypted_24dp" android:minLevel="1" android:maxLevel="1" />
<item android:drawable="@drawable/ic_security_verified_24dp" android:minLevel="2" android:maxLevel="2" />
<item android:drawable="@drawable/ic_security_finished_24dp" android:minLevel="3" android:maxLevel="3" />
</level-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="-2dp" android:left="-2dp" android:right="-2dp">
<shape android:shape="rectangle">
<solid android:color="@color/primary_material_dark"/>
</shape>
</item>
</layer-list>
\ No newline at end of file
......@@ -22,7 +22,7 @@
<ImageView
android:id="@+id/color"
android:layout_width="4dp"
android:layout_height="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_marginRight="2dp"
android:layout_marginEnd="2dp"
android:layout_marginLeft="2dp"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:text="@string/contact_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.xabber.android.ui.widget.NoDefaultSpinner
android:id="@+id/contact_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="@string/choose_account" />
</LinearLayout>
\ No newline at end of file
......@@ -27,7 +27,7 @@
android:src="@drawable/ic_avatar_1"
/>
<ImageView
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_status_account"
......
......@@ -2,8 +2,8 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:id="@+id/avatar_account"
>
......
......@@ -24,7 +24,7 @@
android:id="@+id/color"
android:layout_width="4dp"
android:layout_height="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_marginLeft="2dp"
android:layout_marginStart="2dp"
......@@ -37,8 +37,8 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_toRightOf="@id/color"
android:src="@drawable/ic_avatar_1"
/>
......@@ -88,7 +88,7 @@
android:textColor="?android:attr/textColorSecondary"
/>
<ImageView
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:layout_width="@dimen/status_icon_width"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
......@@ -100,7 +100,7 @@
android:id="@+id/shadow"
android:layout_width="match_parent"
android:layout_height="@dimen/contact_list_item_height"
android:background="@drawable/shadow"
android:background="@drawable/contact_shadow"
android:visibility="gone"
/>
</RelativeLayout>
......@@ -34,8 +34,8 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_toRightOf="@id/color"
android:src="@drawable/ic_avatar_1"
/>
......
......@@ -44,6 +44,17 @@
android:elevation="8dp"
>
<ImageButton
android:id="@+id/button_security"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="8dp"
android:src="@drawable/ic_security_grey_24dp"
android:background="@null"
android:contentDescription="@string/otr_encryption"
android:layout_gravity="bottom"
/>
<EditText
android:id="@+id/chat_input"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
......@@ -51,7 +62,7 @@
android:hint="@string/chat_input_hint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="5"
android:maxLines="4"
android:scrollbars="vertical"
android:fadingEdge="vertical"
android:focusable="true"
......@@ -67,7 +78,9 @@
android:padding="8dp"
android:src="@drawable/ic_button_send"
android:background="@null"
android:contentDescription="@string/chat_send" />
android:contentDescription="@string/chat_send"
android:layout_gravity="bottom"
/>
</LinearLayout>
</RelativeLayout>
......@@ -12,20 +12,24 @@
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/toolbar_default" />
<include layout="@layout/toolbar_default"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_alignParentTop="true"
android:id="@+id/toolbar_default"
/>
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/list"
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="4dip" />
</LinearLayout>
\ No newline at end of file
android:layout_below="@+id/toolbar_default"
>
</FrameLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -3,23 +3,22 @@
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/contact_viewer_toolbar"
android:layout_height="100dp"
<FrameLayout
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="@color/background_material_dark"
android:elevation="8dp"
/>
android:layout_height="wrap_content"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:paddingTop="16dp"
android:id="@+id/account_selector"
>
<include layout="@layout/account_select_spinner"/>
</FrameLayout>
<RelativeLayout
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/preferences_activity_container"
/>
android:drawSelectorOnTop="false" >
</ListView>
</LinearLayout>
\ No newline at end of file
......@@ -16,21 +16,13 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingRight="4dip"
android:layout_height="wrap_content"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:paddingTop="16dp"
>
<TextView
android:text="@string/contact_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<com.xabber.android.ui.widget.NoDefaultSpinner
android:id="@+id/contact_account"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:prompt="@string/choose_account"
/>
<include layout="@layout/account_select_spinner" />
<TextView
android:text="@string/contact_user"
......@@ -60,21 +52,8 @@
android:singleLine="true"
/>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_horizontal|bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:text="@string/contact_add"
android:id="@+id/ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<TextView
android:id="@+id/select_groups_text_view"
android:text="@string/contact_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="72dp"
>
<ImageView
android:id="@+id/contact_info_group_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="32dp"
android:layout_marginTop="24dp"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:layout_marginRight="16dp"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
android:text="(650) 555-1234"
android:id="@+id/contact_info_item_main"
android:textIsSelectable="true"
android:textSize="@dimen/abc_text_size_medium_material" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:singleLine="true"
android:text="Mobile"
android:id="@+id/contact_info_item_secondary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorSecondary"
android:singleLine="true"
android:text="Mobile"
android:visibility="gone"
android:id="@+id/contact_info_item_secondary_second_line" />
</LinearLayout>
<ImageView
android:id="@+id/contact_info_right_icon"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical"
android:visibility="gone"
android:layout_marginRight="16dp"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="72dp"
android:layout_marginStart="72dp"
android:background="@color/grey_400"
android:layout_marginTop="16dp"
android:layout_marginBottom="16dp"
xmlns:android="http://schemas.android.com/apk/res/android" />
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
android:orientation="horizontal"
android:background="@color/green_500"
android:gravity="center_vertical"
>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="48dip"
android:layout_height="48dip"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:src="@drawable/ic_avatar_1"
android:layout_gravity="bottom"
/>
<LinearLayout
android:id="@+id/name_holder"
android:layout_width="0dp"
android:layout_height="48dip"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:layout_weight="1"
android:gravity="center_vertical"
>
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:textColor="@color/primary_text_default_material_dark"
android:text="Lorem Ipsum"
android:layout_marginLeft="6dp"
android:layout_marginTop="3dp"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/security"
android:src="@drawable/ic_security"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:padding="3dp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:singleLine="true"
android:textColor="@color/grey_200"
android:text="Lorem ipsum dolor sit amet"
android:layout_marginBottom="4dp"
android:layout_marginLeft="6dp"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:src="@drawable/ic_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<com.github.ksoichiro.android.observablescrollview.ObservableScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingTop="@dimen/toolbar_height"
android:paddingBottom="8dp"
>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/xmpp_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/contact_info_items"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
/>
</LinearLayout>
</com.github.ksoichiro.android.observablescrollview.ObservableScrollView>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="beforeDescendants"
android:focusableInTouchMode="true" >
<FrameLayout
android:id="@+id/scrollable_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<include layout="@layout/expandable_fake_toolbar" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_overlay"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:elevation="8dp"
/>
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/expandable_contact_title"
android:layout_width="match_parent"
android:layout_height="@dimen/toolbar_height"
android:background="@color/green_500"
android:elevation="8dp"
tools:showIn="@layout/expandable_contact_title_activity">
<LinearLayout
android:id="@+id/contact_name_panel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/actionBarSize"
android:orientation="horizontal"
android:layout_gravity="bottom"
android:paddingBottom="10dp">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_large_size"
android:layout_height="@dimen/avatar_large_size"
android:src="@drawable/ic_avatar_1"
android:layout_gravity="center_vertical" />
<LinearLayout
android:id="@+id/name_holder"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:gravity="center_vertical">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:textColor="@color/primary_text_default_material_dark"
android:text="Lorem Ipsum"
android:layout_marginLeft="6dp"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/status_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:singleLine="true"
android:textColor="@color/grey_200"
android:text="Lorem ipsum dolor sit amet"
android:layout_marginTop="3dp"
android:layout_marginLeft="6dp" />
</LinearLayout>
<ImageView
android:id="@+id/status_icon"
android:src="@drawable/ic_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical" />
</LinearLayout>
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/input_holder"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="12dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/group_add_input"
android:layout_weight="1"
android:hint="@string/add_new_group"
android:textColorHint="@color/grey_400"
android:singleLine="true" />
<CheckBox
android:id="@+id/group_add_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
\ No newline at end of file
......@@ -12,46 +12,21 @@
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<include layout="@layout/toolbar_default"/>
android:layout_height="match_parent">
<TextView
android:text="@string/contact_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:paddingBottom="4dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
<include layout="@layout/toolbar_default"
android:id="@+id/toolbar_default"
/>
<EditText
android:id="@+id/contact_name"
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
android:layout_height="match_parent"
android:layout_below="@+id/toolbar_default"
>
<TextView
android:text="@string/contact_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:paddingBottom="2dip"
android:paddingLeft="2dip"
android:paddingRight="2dip"
/>
</FrameLayout>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="6dip"
/>
</LinearLayout>
\ No newline at end of file
</RelativeLayout>
\ No newline at end of file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/input_holder"
android:layout_width="match_parent"
android:layout_height="40dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView
android:id="@+id/group_item_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Medium Text"
android:layout_weight="1"
android:singleLine="true"
/>
<CheckBox
android:id="@+id/group_item_selected_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:focusable="false"
android:clickable="false"
/>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Layout for a Preference in a PreferenceActivity. The
Preference is able to place a specific widget for its particular
type in the "widget_frame" layout. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical"
android:paddingRight="?android:attr/scrollbarSize">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_marginRight="6dip"
android:layout_marginTop="6dip"
android:layout_marginBottom="6dip"
android:layout_weight="1">
<TextView android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@android:id/title"
android:layout_alignLeft="@android:id/title"
android:textAppearance="?android:attr/textAppearanceLarge"
/>
</RelativeLayout>
<!-- Preference should place its actual preference widget here. -->
<LinearLayout android:id="@+android:id/widget_frame"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical" />
</LinearLayout>
......@@ -12,21 +12,23 @@
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<ScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/toolbar_default"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
>
<include layout="@layout/toolbar_default"/>
<TextView
android:text="@string/contact_account"
android:layout_width="wrap_content"
......@@ -99,23 +101,5 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<LinearLayout
android:orientation="horizontal"
android:gravity="center_horizontal|bottom"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<Button
android:text="@string/muc_save"
android:id="@+id/ok"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
......@@ -26,8 +26,8 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/avatar"
android:layout_width="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size"
android:layout_width="@dimen/avatar_size_toolbar"
android:layout_height="@dimen/avatar_size_toolbar"
android:src="@drawable/ic_avatar_1"
/>
......@@ -35,7 +35,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/affilation"
android:layout_width="2dip"
android:layout_height="@dimen/avatar_size"
android:layout_height="@dimen/avatar_size_toolbar"
android:layout_marginLeft="2dip"
android:scaleType="fitXY"
android:src="@drawable/ic_affilation"
......@@ -72,7 +72,7 @@
android:textColor="?android:attr/textColorSecondary"
/>
<ImageView
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:layout_width="@dimen/status_icon_width"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
......
......@@ -14,7 +14,7 @@
-->
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
......
......@@ -18,7 +18,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/status_mode"
android:id="@+id/status_icon"
android:prompt="@string/status_editor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
......
......@@ -2,13 +2,13 @@
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/toolbar_default"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:background="@color/background_material_dark"
android:background="?attr/colorPrimary"
android:elevation="8dp"
tools:showIn="@layout/contact_list" />
/>
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_create_new_group"
android:title="@string/group_add"
app:showAsAction="ifRoom"
android:icon="@drawable/ic_group_add_white_24dp"
android:orderInCategory="100"
<item android:id="@+id/action_add_conference"
android:title="@string/muc_add"
app:showAsAction="always"
/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_add_contact"
android:title="@string/contact_add"
app:showAsAction="always"
/>
</menu>
\ No newline at end of file
......@@ -17,12 +17,11 @@
android:visible="false"
/>
<item android:id="@+id/action_edit_contact"
android:title="@string/contact_editor"
<item android:id="@+id/action_view_contact"
android:title="@string/contact_viewer"
app:showAsAction="never"
android:orderInCategory="100"
android:visible="false"
android:icon="@drawable/ic_create_white_24dp"
/>
<item android:id="@+id/action_chat_list"
......@@ -92,53 +91,6 @@
android:orderInCategory="180"
/>
<item android:id="@+id/action_otr_encryption"
android:title="@string/otr_encryption"
app:showAsAction="never"
android:orderInCategory="190">
<menu>
<item android:id="@+id/action_start_encryption"
android:title="@string/otr_start"
app:showAsAction="never"
android:orderInCategory="100"
android:visible="false"
/>
<item android:id="@+id/action_restart_encryption"
android:title="@string/otr_refresh"
app:showAsAction="never"
android:orderInCategory="105"
android:visible="false"
/>
<item android:id="@+id/action_stop_encryption"
android:title="@string/otr_end"
app:showAsAction="never"
android:orderInCategory="110"
/>
<item android:id="@+id/action_verify_with_fingerprint"
android:title="@string/otr_verify_fingerprint"
app:showAsAction="never"
android:orderInCategory="120"
/>
<item android:id="@+id/action_verify_with_question"
android:title="@string/otr_verify_question"
app:showAsAction="never"
android:orderInCategory="130"
/>
<item android:id="@+id/action_verify_with_shared_secret"
android:title="@string/otr_verify_secret"
app:showAsAction="never"
android:orderInCategory="140"
/>
</menu>
</item>
<item android:id="@+id/action_list_of_occupants"
android:title="@string/occupant_list"
app:showAsAction="never"
......
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_edit_alias"
android:title="@string/edit_alias"
app:showAsAction="never"
android:orderInCategory="90"
/>
<item android:id="@+id/action_edit_groups"
android:title="@string/edit_contact_groups"
app:showAsAction="never"
android:orderInCategory="100"
/>
<item android:id="@+id/action_remove_contact"
android:title="@string/remove_contact"
app:showAsAction="never"
android:orderInCategory="110"
/>
</menu>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/action_start_encryption"
android:title="@string/otr_start"
android:orderInCategory="100"
android:visible="false"
/>
<item android:id="@+id/action_restart_encryption"
android:title="@string/otr_refresh"
android:orderInCategory="105"
android:visible="false"
/>
<item android:id="@+id/action_stop_encryption"
android:title="@string/otr_end"
android:orderInCategory="110"
/>
<item android:id="@+id/action_verify_with_fingerprint"
android:title="@string/otr_verify_fingerprint"
android:orderInCategory="120"
/>
<item android:id="@+id/action_verify_with_question"
android:title="@string/otr_verify_question"
android:orderInCategory="130"
/>
<item android:id="@+id/action_verify_with_shared_secret"
android:title="@string/otr_verify_secret"
android:orderInCategory="140"
/>
</menu>
\ No newline at end of file
......@@ -40,4 +40,6 @@
<string name="choose_account">Выберите учетную запись</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_editor_error.png -->
<string name="EMPTY_ACCOUNT">Пожалуйста, выберите учетную запись</string>
<string name="add_new_group">Добавить новую группу…</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_contact_context_menu.png -->
<string name="contact_viewer">Просмотр информации</string>
<string name="contact_viewer">Информация о контакте</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_for">Просмотр информации о %s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
......@@ -14,6 +14,7 @@
<string name="contact_viewer_resources">Ресурсы</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_resource_summary">Ресурс: %1$s\nПриоритет: %2$d\nКлиент: %3$s</string>
<string name="contact_viewer_client">Клиент</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_client_info">%1$s, тип: %2$s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_personal.png -->
......@@ -114,4 +115,8 @@
<string name="please_wait">Пожалуйста, подождите...</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="unknown">Не известно</string>
<string name="edit_alias">Редактировать псевдоним</string>
<string name="edit_contact_groups">Редактировать группы</string>
<string name="remove_contact">Удалить контакт</string>
</resources>
\ No newline at end of file
......@@ -27,7 +27,7 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/conference_editor_error.png -->
<string name="ALREADY_JOINED">Уже подключена</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/conference_editor.png -->
<string name="muc_add">Присоединиться к конференции</string>
<string name="muc_add">Добавить конференцию</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_conference_context_menu.png -->
<string name="muc_delete">Удалить конференцию</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_conference_confirm.png -->
......
......@@ -28,4 +28,8 @@
<string name="auto">Автоматически</string>
<string name="save">Сохранить</string>
<string name="ok">Ok</string>
<string name="cancel">Отмена</string>
</resources>
\ No newline at end of file
......@@ -14,11 +14,11 @@
-->
<resources>
<array name="default_avatars_icons">
<item>@drawable/ic_avatar_1</item>
<item>@drawable/ic_avatar_2</item>
<item>@drawable/ic_avatar_5</item>
<item>@drawable/ic_avatar_3</item>
<item>@drawable/ic_avatar_4</item>
<item>@drawable/ic_avatar_1_72dp</item>
<item>@drawable/ic_avatar_2_72dp</item>
<item>@drawable/ic_avatar_5_72dp</item>
<item>@drawable/ic_avatar_3_72dp</item>
<item>@drawable/ic_avatar_4_72dp</item>
</array>
<array name="default_avatars_colors">
......@@ -33,6 +33,6 @@
</array>
<array name="muc_avatars">
<item>@drawable/ic_avatar_muc</item>
<item>@drawable/ic_avatar_muc_72dp</item>
</array>
</resources>
\ No newline at end of file
......@@ -40,4 +40,6 @@
<string name="choose_account">Choose an account</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_editor_error.png -->
<string name="EMPTY_ACCOUNT">Please select an account</string>
<string name="add_new_group">Add new group…</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_contact_context_menu.png -->
<string name="contact_viewer">View information</string>
<string name="contact_viewer">Contact info</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_for">View information about %s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
......@@ -14,6 +14,7 @@
<string name="contact_viewer_resources">Resources</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_resource_summary">Resource: %1$s\nPriority: %2$d\nClient: %3$s</string>
<string name="contact_viewer_client">Client</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="contact_viewer_client_info">%1$s, type: %2$s</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_personal.png -->
......@@ -114,4 +115,10 @@
<string name="please_wait">Please wait...</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_viewer_xmpp.png -->
<string name="unknown">Unknown</string>
<string name="edit_alias">Edit alias</string>
<string name="edit_contact_groups">Edit groups</string>
<string name="remove_contact">Remove contact</string>
</resources>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="toolbar_height">138dp</dimen>
<dimen name="contact_title_padding_left">10dp</dimen>
<dimen name="contact_title_padding_right">10dp</dimen>
<dimen name="contact_title_padding_bottom_small">2dp</dimen>
<dimen name="contact_title_padding_bottom_big">10dp</dimen>
<dimen name="avatar_large_size">72dp</dimen>
<dimen name="avatar_normal_size">48dp</dimen>
<dimen name="avatar_radius">56dp</dimen>
</resources>
\ No newline at end of file
......@@ -27,7 +27,7 @@
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/conference_editor_error.png -->
<string name="ALREADY_JOINED">Already joined</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/conference_editor.png -->
<string name="muc_add">Join conference</string>
<string name="muc_add">Add conference</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_conference_context_menu.png -->
<string name="muc_delete">Remove conference</string>
<!-- http://dl.dropbox.com/u/1029995/com.xabber.android/contact_list_conference_confirm.png -->
......
......@@ -102,7 +102,8 @@
</style>
<dimen name="status_icon_width">24dip</dimen>
<dimen name="avatar_size">48dip</dimen>
<dimen name="avatar_size">72dip</dimen>
<dimen name="avatar_size_toolbar">48dip</dimen>
<dimen name="title_height">44dip</dimen>
......
......@@ -18,5 +18,10 @@
<item name="expanderAccountColor">?android:attr/textColorPrimaryInverse</item>
<item name="expanderIndicator">@drawable/expander_indicator_dark</item>
<item name="windowActionBar">false</item>
<!--for text selection toolbar to be above usual toolbar -->
<item name="windowActionModeOverlay">true</item>
<!--for text selection toolbar color -->
<item name="actionModeBackground">@drawable/myapp_action_mode_background</item>
</style>
</resources>
\ No newline at end of file
......@@ -28,4 +28,7 @@
<string name="auto">Automatically</string>
<string name="save">Save</string>
<string name="ok">Ok</string>
<string name="cancel">Cancel</string>
</resources>
\ No newline at end of file
......@@ -21,12 +21,10 @@
<PreferenceScreen
android:title="@string/contact_viewer_jid"
android:key="@string/contact_viewer_jid"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/contact_viewer_name"
android:key="@string/contact_viewer_name"
android:layout="@layout/info_preference"
/>
</PreferenceCategory>
<PreferenceCategory
......@@ -39,43 +37,35 @@
<PreferenceScreen
android:title="@string/vcard_nick_name"
android:key="@string/vcard_nick_name"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_formatted_name"
android:key="@string/vcard_formatted_name"
android:layout="@layout/info_preference"
>
<PreferenceScreen
android:title="@string/vcard_prefix_name"
android:key="@string/vcard_prefix_name"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_given_name"
android:key="@string/vcard_given_name"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_middle_name"
android:key="@string/vcard_middle_name"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_family_name"
android:key="@string/vcard_family_name"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_suffix_name"
android:key="@string/vcard_suffix_name"
android:layout="@layout/info_preference"
/>
</PreferenceScreen>
<PreferenceScreen
android:title="@string/vcard_birth_date"
android:key="@string/vcard_birth_date"
android:layout="@layout/info_preference"
/>
</PreferenceCategory>
<PreferenceCategory
......@@ -84,17 +74,14 @@
<PreferenceScreen
android:title="@string/vcard_title"
android:key="@string/vcard_title"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_role"
android:key="@string/vcard_role"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_organization"
android:key="@string/vcard_organization"
android:layout="@layout/info_preference"
/>
</PreferenceCategory>
<PreferenceCategory
......@@ -103,22 +90,18 @@
<PreferenceScreen
android:title="@string/vcard_url"
android:key="@string/vcard_url"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_categories"
android:key="@string/vcard_categories"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_decsription"
android:key="@string/vcard_decsription"
android:layout="@layout/info_preference"
/>
<PreferenceScreen
android:title="@string/vcard_note"
android:key="@string/vcard_note"
android:layout="@layout/info_preference"
/>
</PreferenceCategory>
</PreferenceScreen>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment