Commit 2f4a2121 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'feature/new_contact_list_design' into develop

parents 0140402c 286a9398
...@@ -8,8 +8,8 @@ android { ...@@ -8,8 +8,8 @@ android {
applicationId "com.xabber.androiddev" applicationId "com.xabber.androiddev"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 22 targetSdkVersion 22
versionCode 145 versionCode 161
versionName '0.10.45' versionName '0.10.61'
} }
compileOptions { compileOptions {
...@@ -26,5 +26,7 @@ dependencies { ...@@ -26,5 +26,7 @@ dependencies {
compile 'com.android.support:appcompat-v7:22.0.0' compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:support-v13:22.0.0' compile 'com.android.support:support-v13:22.0.0'
compile 'com.github.ksoichiro:android-observablescrollview:1.5.0' compile 'com.github.ksoichiro:android-observablescrollview:1.5.0'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'com.melnykov:floatingactionbutton:1.2.0'
compile project('otr4j') compile project('otr4j')
} }
...@@ -236,6 +236,17 @@ ...@@ -236,6 +236,17 @@
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.ContactEditor"
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.ChatViewer" />
</activity>
<activity <activity
android:name="com.xabber.android.ui.FingerprintViewer" android:name="com.xabber.android.ui.FingerprintViewer"
android:label="@string/otr_verify_fingerprint" android:label="@string/otr_verify_fingerprint"
...@@ -260,7 +271,13 @@ ...@@ -260,7 +271,13 @@
<activity <activity
android:name="com.xabber.android.ui.ContactSubscription" android:name="com.xabber.android.ui.ContactSubscription"
/> android:parentActivityName="com.xabber.android.ui.ContactList"
>
<!-- 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" />
</activity>
<activity <activity
android:name="com.xabber.android.ui.MUCInvite" android:name="com.xabber.android.ui.MUCInvite"
/> />
...@@ -314,15 +331,6 @@ ...@@ -314,15 +331,6 @@
android:excludeFromRecents="true" android:excludeFromRecents="true"
/> />
<activity
android:name="com.xabber.android.ui.preferences.ThemeSettings"
android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor">
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.xabber.android.ui.preferences.PreferenceEditor" />
</activity>
<activity <activity
android:name="com.xabber.android.ui.preferences.ContactListSettings" android:name="com.xabber.android.ui.preferences.ContactListSettings"
android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor"> android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor">
......
...@@ -14,11 +14,6 @@ ...@@ -14,11 +14,6 @@
*/ */
package com.xabber.android.data; package com.xabber.android.data;
import java.util.Collections;
import java.util.Comparator;
import java.util.Map;
import java.util.regex.Pattern;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor; import android.content.SharedPreferences.Editor;
...@@ -39,9 +34,10 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -39,9 +34,10 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.service.XabberService; import com.xabber.android.service.XabberService;
import com.xabber.android.ui.adapter.ComparatorByName; import com.xabber.android.ui.adapter.ComparatorByName;
import com.xabber.android.ui.adapter.ComparatorByStatus; import com.xabber.android.ui.adapter.ComparatorByStatus;
import com.xabber.android.utils.Emoticons;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import java.util.Comparator;
/** /**
* Manage operations with common settings. * Manage operations with common settings.
* *
...@@ -611,20 +607,6 @@ public class SettingsManager implements OnInitializedListener, ...@@ -611,20 +607,6 @@ public class SettingsManager implements OnInitializedListener,
throw new IllegalStateException(); throw new IllegalStateException();
} }
public static Map<Pattern, Integer> interfaceSmiles() {
String value = getString(R.string.interface_smiles_key,
R.string.interface_smiles_default);
if (Application.getInstance()
.getString(R.string.interface_smiles_none_value).equals(value))
return Collections.unmodifiableMap(Emoticons.NONE_EMOTICONS);
else if (Application.getInstance()
.getString(R.string.interface_smiles_android_value)
.equals(value))
return Collections.unmodifiableMap(Emoticons.ANDROID_EMOTICONS);
else
throw new IllegalStateException();
}
public static boolean securityCheckCertificate() { public static boolean securityCheckCertificate() {
return getBoolean(R.string.security_check_certificate_key, return getBoolean(R.string.security_check_certificate_key,
R.bool.security_check_certificate_default); R.bool.security_check_certificate_default);
......
package com.xabber.android.data;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
import com.xabber.xmpp.vcard.EmailType;
import com.xabber.xmpp.vcard.TelephoneType;
import java.util.HashMap;
import java.util.Map;
/**
* Created by grigory.fedorov on 13.04.15.
*/
public class VcardMaps {
private static final Map<AddressType, Integer> ADDRESS_TYPE_MAP = new HashMap<>();
private static final Map<AddressProperty, Integer> ADDRESS_PROPERTY_MAP = new HashMap<>();
private static final Map<TelephoneType, Integer> TELEPHONE_TYPE_MAP = new HashMap<>();
private static final Map<EmailType, Integer> EMAIL_TYPE_MAP = new HashMap<>();
static {
ADDRESS_TYPE_MAP.put(AddressType.DOM, R.string.vcard_type_dom);
ADDRESS_TYPE_MAP.put(AddressType.HOME, R.string.vcard_type_home);
ADDRESS_TYPE_MAP.put(AddressType.INTL, R.string.vcard_type_intl);
ADDRESS_TYPE_MAP.put(AddressType.PARCEL, R.string.vcard_type_parcel);
ADDRESS_TYPE_MAP.put(AddressType.POSTAL, R.string.vcard_type_postal);
ADDRESS_TYPE_MAP.put(AddressType.PREF, R.string.vcard_type_pref);
ADDRESS_TYPE_MAP.put(AddressType.WORK, R.string.vcard_type_work);
if (ADDRESS_TYPE_MAP.size() != AddressType.values().length)
throw new IllegalStateException();
ADDRESS_PROPERTY_MAP.put(AddressProperty.CTRY,
R.string.vcard_address_ctry);
ADDRESS_PROPERTY_MAP.put(AddressProperty.EXTADR,
R.string.vcard_address_extadr);
ADDRESS_PROPERTY_MAP.put(AddressProperty.LOCALITY,
R.string.vcard_address_locality);
ADDRESS_PROPERTY_MAP.put(AddressProperty.PCODE,
R.string.vcard_address_pcode);
ADDRESS_PROPERTY_MAP.put(AddressProperty.POBOX,
R.string.vcard_address_pobox);
ADDRESS_PROPERTY_MAP.put(AddressProperty.REGION,
R.string.vcard_address_region);
ADDRESS_PROPERTY_MAP.put(AddressProperty.STREET,
R.string.vcard_address_street);
if (ADDRESS_PROPERTY_MAP.size() != AddressProperty.values().length)
throw new IllegalStateException();
TELEPHONE_TYPE_MAP.put(TelephoneType.BBS, R.string.vcard_type_bbs);
TELEPHONE_TYPE_MAP.put(TelephoneType.CELL, R.string.vcard_type_cell);
TELEPHONE_TYPE_MAP.put(TelephoneType.FAX, R.string.vcard_type_fax);
TELEPHONE_TYPE_MAP.put(TelephoneType.HOME, R.string.vcard_type_home);
TELEPHONE_TYPE_MAP.put(TelephoneType.ISDN, R.string.vcard_type_isdn);
TELEPHONE_TYPE_MAP.put(TelephoneType.MODEM, R.string.vcard_type_modem);
TELEPHONE_TYPE_MAP.put(TelephoneType.MSG, R.string.vcard_type_msg);
TELEPHONE_TYPE_MAP.put(TelephoneType.PAGER, R.string.vcard_type_pager);
TELEPHONE_TYPE_MAP.put(TelephoneType.PCS, R.string.vcard_type_pcs);
TELEPHONE_TYPE_MAP.put(TelephoneType.PREF, R.string.vcard_type_pref);
TELEPHONE_TYPE_MAP.put(TelephoneType.VIDEO, R.string.vcard_type_video);
TELEPHONE_TYPE_MAP.put(TelephoneType.VOICE, R.string.vcard_type_voice);
TELEPHONE_TYPE_MAP.put(TelephoneType.WORK, R.string.vcard_type_work);
if (TELEPHONE_TYPE_MAP.size() != TelephoneType.values().length)
throw new IllegalStateException();
EMAIL_TYPE_MAP.put(EmailType.HOME, R.string.vcard_type_home);
EMAIL_TYPE_MAP.put(EmailType.INTERNET, R.string.vcard_type_internet);
EMAIL_TYPE_MAP.put(EmailType.PREF, R.string.vcard_type_pref);
EMAIL_TYPE_MAP.put(EmailType.WORK, R.string.vcard_type_work);
EMAIL_TYPE_MAP.put(EmailType.X400, R.string.vcard_type_x400);
if (EMAIL_TYPE_MAP.size() != EmailType.values().length)
throw new IllegalStateException();
}
public static Map<AddressType, Integer> getAddressTypeMap() {
return ADDRESS_TYPE_MAP;
}
public static Map<AddressProperty, Integer> getAddressPropertyMap() {
return ADDRESS_PROPERTY_MAP;
}
public static Map<TelephoneType, Integer> getTelephoneTypeMap() {
return TELEPHONE_TYPE_MAP;
}
public static Map<EmailType, Integer> getEmailTypeMap() {
return EMAIL_TYPE_MAP;
}
}
...@@ -404,7 +404,14 @@ public class AccountManager implements OnLoadListener, OnWipeListener { ...@@ -404,7 +404,14 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
resource = "android" + StringUtils.randomString(8); resource = "android" + StringUtils.randomString(8);
} }
accountItem = addAccount(accountType.getProtocol(), true, host, port, serverName, userName,
boolean useCustomHost = false;
if (accountType.getProtocol() == AccountProtocol.gtalk) {
useCustomHost = true;
}
accountItem = addAccount(accountType.getProtocol(), useCustomHost, host, port, serverName, userName,
storePassword, password, resource, getNextColorIndex(), 0, StatusMode.available, storePassword, password, resource, getNextColorIndex(), 0, StatusMode.available,
SettingsManager.statusText(), true, true, tlsRequired ? TLSMode.required : TLSMode.enabled, SettingsManager.statusText(), true, true, tlsRequired ? TLSMode.required : TLSMode.enabled,
false, useOrbot ? ProxyType.orbot : ProxyType.none, "localhost", 8080, false, useOrbot ? ProxyType.orbot : ProxyType.none, "localhost", 8080,
...@@ -850,7 +857,10 @@ public class AccountManager implements OnLoadListener, OnWipeListener { ...@@ -850,7 +857,10 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
* @param statusText * @param statusText
*/ */
public void setStatus(String account, StatusMode statusMode, String statusText) { public void setStatus(String account, StatusMode statusMode, String statusText) {
addSavedStatus(statusMode, statusText); if (statusText != null && !statusText.trim().isEmpty()) {
addSavedStatus(statusMode, statusText);
}
AccountItem accountItem = getAccount(account); AccountItem accountItem = getAccount(account);
setStatus(accountItem, statusMode, statusText); setStatus(accountItem, statusMode, statusText);
try { try {
......
...@@ -118,8 +118,6 @@ class StatusTable extends AbstractTable { ...@@ -118,8 +118,6 @@ class StatusTable extends AbstractTable {
} }
void write(StatusMode statusMode, String statusText) { void write(StatusMode statusMode, String statusText) {
if (statusText == null)
statusText = "";
synchronized (writeLock) { synchronized (writeLock) {
if (writeStatement == null) { if (writeStatement == null) {
SQLiteDatabase db = databaseManager.getWritableDatabase(); SQLiteDatabase db = databaseManager.getWritableDatabase();
......
...@@ -28,6 +28,7 @@ import com.xabber.android.data.OnLoadListener; ...@@ -28,6 +28,7 @@ import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.OnLowMemoryListener; import com.xabber.android.data.OnLowMemoryListener;
import com.xabber.android.data.SettingsManager; import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountItem; import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OAuthManager; import com.xabber.android.data.account.OAuthManager;
import com.xabber.android.data.connection.ConnectionItem; import com.xabber.android.data.connection.ConnectionItem;
import com.xabber.android.data.connection.OnPacketListener; import com.xabber.android.data.connection.OnPacketListener;
...@@ -108,6 +109,8 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -108,6 +109,8 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
Application.getInstance().addManager(instance); Application.getInstance().addManager(instance);
} }
private final int[] accountColors;
public static AvatarManager getInstance() { public static AvatarManager getInstance() {
return instance; return instance;
} }
...@@ -116,6 +119,9 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -116,6 +119,9 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
this.application = Application.getInstance(); this.application = Application.getInstance();
userAvatarSet = new BaseAvatarSet(application, R.array.default_avatars_icons, R.array.default_avatars_colors); userAvatarSet = new BaseAvatarSet(application, R.array.default_avatars_icons, R.array.default_avatars_colors);
roomAvatarSet = new BaseAvatarSet(application, R.array.muc_avatars, R.array.default_avatars_colors); roomAvatarSet = new BaseAvatarSet(application, R.array.muc_avatars, R.array.default_avatars_colors);
accountColors = application.getResources().getIntArray(R.array.account_action_bar);
hashes = new HashMap<>(); hashes = new HashMap<>();
bitmaps = new HashMap<>(); bitmaps = new HashMap<>();
contactListDrawables = new HashMap<>(); contactListDrawables = new HashMap<>();
...@@ -269,7 +275,10 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac ...@@ -269,7 +275,10 @@ public class AvatarManager implements OnLoadListener, OnLowMemoryListener, OnPac
if (value != null) { if (value != null) {
return new BitmapDrawable(application.getResources(), value); return new BitmapDrawable(application.getResources(), value);
} else { } else {
return application.getResources().getDrawable(R.drawable.ic_avatar_1); Drawable[] layers = new Drawable[2];
layers[0] = new ColorDrawable(accountColors[AccountManager.getInstance().getColorLevel(account)]);
layers[1] = application.getResources().getDrawable(R.drawable.ic_avatar_1);
return new LayerDrawable(layers);
} }
} }
......
...@@ -18,9 +18,9 @@ import java.util.Date; ...@@ -18,9 +18,9 @@ import java.util.Date;
import android.text.Spannable; import android.text.Spannable;
import android.text.Html; import android.text.Html;
import android.text.SpannableString;
import android.text.util.Linkify; import android.text.util.Linkify;
import com.xabber.android.utils.Emoticons;
import com.xabber.xmpp.uri.XMPPUri; import com.xabber.xmpp.uri.XMPPUri;
/** /**
...@@ -151,7 +151,7 @@ public class MessageItem implements Comparable<MessageItem> { ...@@ -151,7 +151,7 @@ public class MessageItem implements Comparable<MessageItem> {
public Spannable getSpannable() { public Spannable getSpannable() {
if (spannable == null) { if (spannable == null) {
spannable = Emoticons.newSpannable(Html.fromHtml(text)); spannable = new SpannableString(Html.fromHtml(text));
Linkify.addLinks(this.spannable, Linkify.ALL); Linkify.addLinks(this.spannable, Linkify.ALL);
XMPPUri.addLinks(this.spannable); XMPPUri.addLinks(this.spannable);
} }
......
...@@ -362,10 +362,10 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan ...@@ -362,10 +362,10 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
if (connected > 0) { if (connected > 0) {
persistentNotificationBuilder.setColor(COLOR_MATERIAL_RED_500); persistentNotificationBuilder.setColor(COLOR_MATERIAL_RED_500);
persistentNotificationBuilder.setSmallIcon(R.drawable.ic_stat_light_bulb_big); persistentNotificationBuilder.setSmallIcon(R.drawable.ic_stat_online);
} else { } else {
persistentNotificationBuilder.setColor(NotificationCompat.COLOR_DEFAULT); persistentNotificationBuilder.setColor(NotificationCompat.COLOR_DEFAULT);
persistentNotificationBuilder.setSmallIcon(R.drawable.ic_stat_light_bulb_big_off); persistentNotificationBuilder.setSmallIcon(R.drawable.ic_stat_offline);
} }
persistentNotificationBuilder.setContentText(getConnectionState(waiting, connecting, connected, accountList.size())); persistentNotificationBuilder.setContentText(getConnectionState(waiting, connecting, connected, accountList.size()));
......
...@@ -22,9 +22,9 @@ package com.xabber.android.data.roster; ...@@ -22,9 +22,9 @@ package com.xabber.android.data.roster;
public enum ShowOfflineMode { public enum ShowOfflineMode {
/** /**
* Never show offline contacts. * Always show offline contacts.
*/ */
never, always,
/** /**
* Show offline contacts according to global settings. * Show offline contacts according to global settings.
...@@ -32,8 +32,7 @@ public enum ShowOfflineMode { ...@@ -32,8 +32,7 @@ public enum ShowOfflineMode {
normal, normal,
/** /**
* Always show offline contacts. * Never show offline contacts.
*/ */
always; never
} }
\ No newline at end of file
...@@ -23,8 +23,7 @@ import com.xabber.android.data.notification.EntityNotificationItem; ...@@ -23,8 +23,7 @@ import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.ui.ContactSubscription; import com.xabber.android.ui.ContactSubscription;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class SubscriptionRequest extends BaseEntity implements public class SubscriptionRequest extends BaseEntity implements EntityNotificationItem {
EntityNotificationItem {
public SubscriptionRequest(String account, String user) { public SubscriptionRequest(String account, String user) {
super(account, user); super(account, user);
...@@ -32,8 +31,7 @@ public class SubscriptionRequest extends BaseEntity implements ...@@ -32,8 +31,7 @@ public class SubscriptionRequest extends BaseEntity implements
@Override @Override
public Intent getIntent() { public Intent getIntent() {
return ContactSubscription.createIntent(Application.getInstance(), return ContactSubscription.createIntent(Application.getInstance(), account, user);
account, user);
} }
@Override @Override
...@@ -48,11 +46,8 @@ public class SubscriptionRequest extends BaseEntity implements ...@@ -48,11 +46,8 @@ public class SubscriptionRequest extends BaseEntity implements
} }
public String getConfirmation() { public String getConfirmation() {
String accountName = AccountManager.getInstance().getVerboseName( String accountName = AccountManager.getInstance().getVerboseName(account);
account); return Application.getInstance().getString(R.string.contact_subscribe_confirm, accountName);
String userName = RosterManager.getInstance().getName(account, user);
return Application.getInstance().getString(
R.string.contact_subscribe_confirm, userName, accountName);
} }
} }
package com.xabber.android.ui;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
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.account.AccountType;
import com.xabber.android.ui.adapter.AccountTypeAdapter;
import com.xabber.android.ui.dialog.OrbotInstallerDialogBuilder;
import com.xabber.android.ui.helper.OrbotHelper;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.androiddev.R;
public class AccountAddFragment extends Fragment implements View.OnClickListener, AdapterView.OnItemSelectedListener {
private CheckBox storePasswordView;
private CheckBox useOrbotView;
private CheckBox createAccountCheckBox;
private Spinner accountTypeView;
private LinearLayout passwordConfirmView;
private EditText userView;
private EditText passwordView;
private EditText passwordConfirmEditText;
private static final String SAVED_ACCOUNT_TYPE = "com.xabber.android.ui.AccountAdd.ACCOUNT_TYPE";
private View authPanel;
private TextView accountHelpView;
public static AccountAddFragment newInstance() {
return new AccountAddFragment();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.account_add_fragment, container, false);
accountTypeView = (Spinner) view.findViewById(R.id.account_type);
accountTypeView.setAdapter(new AccountTypeAdapter(getActivity()));
accountTypeView.setOnItemSelectedListener(this);
String accountType;
if (savedInstanceState == null) {
accountType = null;
} else {
accountType = savedInstanceState.getString(SAVED_ACCOUNT_TYPE);
}
accountTypeView.setSelection(0);
for (int position = 0; position < accountTypeView.getCount(); position++) {
if (((AccountType) accountTypeView.getItemAtPosition(position)).getName().equals(accountType)){
accountTypeView.setSelection(position);
break;
}
}
storePasswordView = (CheckBox) view.findViewById(R.id.store_password);
useOrbotView = (CheckBox) view.findViewById(R.id.use_orbot);
createAccountCheckBox = (CheckBox) view.findViewById(R.id.register_account);
createAccountCheckBox.setOnClickListener(this);
authPanel = view.findViewById(R.id.auth_panel);
userView = (EditText) view.findViewById(R.id.account_user_name);
accountHelpView = (TextView) view.findViewById(R.id.account_help);
passwordView = (EditText) view.findViewById(R.id.account_password);
passwordConfirmEditText = (EditText) view.findViewById(R.id.confirm_password);
passwordConfirmView = (LinearLayout) view.findViewById(R.id.confirm_password_layout);
return view;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SAVED_ACCOUNT_TYPE, ((AccountType) accountTypeView.getSelectedItem()).getName());
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.register_account:
if(createAccountCheckBox.isChecked()) {
passwordConfirmView.setVisibility(View.VISIBLE);
} else {
passwordConfirmView.setVisibility(View.GONE);
}
default:
break;
}
}
public void addAccount() {
if (useOrbotView.isChecked() && !OrbotHelper.isOrbotInstalled()) {
OrbotInstallerDialogBuilder.show(getActivity());
return;
}
if (createAccountCheckBox.isChecked() &&
!passwordView.getText().toString().contentEquals(passwordConfirmEditText.getText().toString())) {
Toast.makeText(getActivity(), getString(R.string.CONFIRM_PASSWORD), Toast.LENGTH_LONG).show();
return;
}
AccountType accountType = (AccountType) accountTypeView.getSelectedItem();
String account;
try {
account = AccountManager.getInstance().addAccount(
userView.getText().toString(),
passwordView.getText().toString(), accountType,
false,
storePasswordView.isChecked(),
useOrbotView.isChecked(),
createAccountCheckBox.isChecked());
} catch (NetworkException e) {
Application.getInstance().onError(e);
return;
}
getActivity().setResult(Activity.RESULT_OK, AccountAdd.createAuthenticatorResult(account));
startActivity(AccountEditor.createIntent(getActivity(), account));
getActivity().finish();
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
AccountType accountType = (AccountType) accountTypeView.getSelectedItem();
authPanel.setVisibility(View.VISIBLE);
accountHelpView.setText(accountType.getHelp());
userView.setHint(accountType.getHint());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
accountTypeView.setSelection(0);
}
}
...@@ -294,7 +294,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -294,7 +294,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.action_view_contact: case R.id.action_view_contact:
startActivity(ContactViewer.createIntent(this, account, user)); showContactInfo();
return true; return true;
case R.id.action_chat_list: case R.id.action_chat_list:
...@@ -424,8 +424,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -424,8 +424,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return ACTION_ATTENTION.equals(intent.getAction()); return ACTION_ATTENTION.equals(intent.getAction());
} }
public static Intent createIntent(Context context, String account, public static Intent createIntent(Context context, String account, String user) {
String user) {
return new EntityIntentBuilder(context, ChatViewer.class).setAccount(account).setUser(user).build(); return new EntityIntentBuilder(context, ChatViewer.class).setAccount(account).setUser(user).build();
} }
...@@ -433,8 +432,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -433,8 +432,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return new EntityIntentBuilder(context, ChatViewer.class).build(); return new EntityIntentBuilder(context, ChatViewer.class).build();
} }
public static Intent createClearTopIntent(Context context, String account, public static Intent createClearTopIntent(Context context, String account, String user) {
String user) {
Intent intent = createIntent(context, account, user); Intent intent = createIntent(context, account, user);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
return intent; return intent;
...@@ -452,24 +450,21 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -452,24 +450,21 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
* of messages. Else only one message can be send. * of messages. Else only one message can be send.
* @return * @return
*/ */
public static Intent createSendIntent(Context context, String account, public static Intent createSendIntent(Context context, String account, String user, String text) {
String user, String text) {
Intent intent = ChatViewer.createIntent(context, account, user); Intent intent = ChatViewer.createIntent(context, account, user);
intent.setAction(Intent.ACTION_SEND); intent.setAction(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_TEXT, text); intent.putExtra(Intent.EXTRA_TEXT, text);
return intent; return intent;
} }
public static Intent createAttentionRequestIntent(Context context, public static Intent createAttentionRequestIntent(Context context, String account, String user) {
String account, String user) {
Intent intent = ChatViewer.createClearTopIntent(context, account, user); Intent intent = ChatViewer.createClearTopIntent(context, account, user);
intent.setAction(ACTION_ATTENTION); intent.setAction(ACTION_ATTENTION);
return intent; return intent;
} }
@Override @Override
public void onChatChanged(final String account, final String user, public void onChatChanged(final String account, final String user, final boolean incoming) {
final boolean incoming) {
String currentAccount = null; String currentAccount = null;
String currentUser = null; String currentUser = null;
...@@ -716,7 +711,15 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -716,7 +711,15 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (v.getId() == R.id.avatar) { if (v.getId() == R.id.avatar) {
showContactInfo();
}
}
private void showContactInfo() {
if (MUCManager.getInstance().hasRoom(actionWithAccount, actionWithUser)) {
startActivity(ContactViewer.createIntent(this, actionWithAccount, actionWithUser)); startActivity(ContactViewer.createIntent(this, actionWithAccount, actionWithUser));
} else {
startActivity(ContactEditor.createIntent(this, actionWithAccount, actionWithUser));
} }
} }
} }
...@@ -80,6 +80,8 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl ...@@ -80,6 +80,8 @@ public class ChatViewerFragment extends Fragment implements AdapterView.OnItemCl
View view = inflater.inflate(R.layout.chat_viewer_item, container, false); View view = inflater.inflate(R.layout.chat_viewer_item, container, false);
view.getBackground().setAlpha(40);
sendButton = (ImageButton) view.findViewById(R.id.button_send_message); sendButton = (ImageButton) view.findViewById(R.id.button_send_message);
sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp); sendButton.setImageResource(R.drawable.ic_button_send_inactive_24dp);
......
package com.xabber.android.ui;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.text.InputType;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.dialog.ContactDeleteDialogFragment;
import com.xabber.androiddev.R;
public class ContactEditor extends ContactViewer {
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().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, getAccount(), getBareAddress()));
return true;
case R.id.action_remove_contact:
ContactDeleteDialogFragment.newInstance(getAccount(), getBareAddress())
.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(getAccount(), getBareAddress());
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(getAccount(), getBareAddress(), 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();
}
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactEditor.class)
.setAccount(account).setUser(user).build();
}
}
...@@ -26,16 +26,13 @@ import android.os.Bundle; ...@@ -26,16 +26,13 @@ import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.view.MenuItemCompat; import android.support.v4.view.MenuItemCompat;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.view.ContextMenu; import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo; import android.view.ContextMenu.ContextMenuInfo;
import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import android.widget.SearchView; import android.widget.SearchView;
import android.widget.Toast; import android.widget.Toast;
...@@ -57,7 +54,6 @@ import com.xabber.android.data.roster.AbstractContact; ...@@ -57,7 +54,6 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterContact; import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ContactListFragment.OnContactClickListener; import com.xabber.android.ui.ContactListFragment.OnContactClickListener;
import com.xabber.android.ui.adapter.AccountToggleAdapter;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment; import com.xabber.android.ui.dialog.AccountChooseDialogFragment;
import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener; import com.xabber.android.ui.dialog.AccountChooseDialogFragment.OnChoosedListener;
import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment; import com.xabber.android.ui.dialog.ContactIntegrationDialogFragment;
...@@ -93,11 +89,6 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -93,11 +89,6 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
private static final String CONTACT_LIST_TAG = "CONTACT_LIST"; private static final String CONTACT_LIST_TAG = "CONTACT_LIST";
/**
* Adapter for account list.
*/
private AccountToggleAdapter accountToggleAdapter;
/** /**
* Current action. * Current action.
*/ */
...@@ -109,7 +100,6 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -109,7 +100,6 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
private String sendText; private String sendText;
private SearchView searchView; private SearchView searchView;
private View actionBarView;
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
...@@ -126,25 +116,13 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -126,25 +116,13 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
} }
setContentView(R.layout.contact_list); setContentView(R.layout.contact_list);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default)); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_default);
toolbar.setLogo(R.drawable.ic_xabber_logo);
toolbar.setOnClickListener(this);
setSupportActionBar(toolbar);
setTitle(getString(R.string.production_title)); setTitle(getString(R.string.production_title));
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
actionBarView = LayoutInflater.from(this).inflate(R.layout.contact_list_action_bar, null);
actionBarView.setOnClickListener(this);
actionBar.setCustomView(actionBarView, new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
accountToggleAdapter = new AccountToggleAdapter(this, this,
(LinearLayout) actionBarView.findViewById(R.id.account_list));
if (savedInstanceState != null) { if (savedInstanceState != null) {
sendText = savedInstanceState.getString(SAVED_SEND_TEXT); sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
action = savedInstanceState.getString(SAVED_ACTION); action = savedInstanceState.getString(SAVED_ACTION);
...@@ -455,25 +433,9 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -455,25 +433,9 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
@Override @Override
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case android.R.id.title: case R.id.toolbar_default:
getContactListFragment().scrollUp(); getContactListFragment().scrollUp();
break; break;
default:
String account = accountToggleAdapter.getItemForView(view);
if (account == null) { // Check for tap on account in the title
break;
}
if (!SettingsManager.contactsShowAccounts()) {
if (AccountManager.getInstance().getAccounts().size() < 2) {
getContactListFragment().scrollUp();
} else {
getContactListFragment().setSelectedAccount(account);
rebuildAccountToggle();
}
} else {
getContactListFragment().scrollTo(account);
}
break;
} }
} }
...@@ -537,7 +499,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -537,7 +499,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
@Override @Override
public void onAccountsChanged(Collection<String> accounts) { public void onAccountsChanged(Collection<String> accounts) {
accountToggleAdapter.onChange(); ((ContactListFragment)getSupportFragmentManager().findFragmentById(R.id.container)).onAccountsChanged();
} }
@Override @Override
...@@ -546,14 +508,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -546,14 +508,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
} }
private void rebuildAccountToggle() { private void rebuildAccountToggle() {
accountToggleAdapter.rebuild(); ((ContactListFragment)getSupportFragmentManager().findFragmentById(R.id.container)).rebuild();
if (SettingsManager.contactsShowPanel() && accountToggleAdapter.getCount() > 0) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
actionBarView.setVisibility(View.VISIBLE);
} else {
actionBarView.setVisibility(View.GONE);
getSupportActionBar().setDisplayShowTitleEnabled(true);
}
} }
public static Intent createPersistentIntent(Context context) { public static Intent createPersistentIntent(Context context) {
......
...@@ -17,17 +17,26 @@ package com.xabber.android.ui; ...@@ -17,17 +17,26 @@ package com.xabber.android.ui;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.data.Application; import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException; import com.xabber.android.data.NetworkException;
import com.xabber.android.data.intent.EntityIntentBuilder; import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.PresenceManager; import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.data.roster.SubscriptionRequest; import com.xabber.android.data.roster.SubscriptionRequest;
import com.xabber.android.ui.helper.ManagedDialog; import com.xabber.android.ui.helper.ActionBarPainter;
import com.xabber.android.ui.helper.SingleActivity;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
public class ContactSubscription extends ManagedDialog { import org.w3c.dom.Text;
public class ContactSubscription extends SingleActivity implements View.OnClickListener {
private String account; private String account;
private String user; private String user;
...@@ -40,21 +49,63 @@ public class ContactSubscription extends ManagedDialog { ...@@ -40,21 +49,63 @@ public class ContactSubscription extends ManagedDialog {
Intent intent = getIntent(); Intent intent = getIntent();
account = getAccount(intent); account = getAccount(intent);
user = getUser(intent); user = getUser(intent);
subscriptionRequest = PresenceManager.getInstance() subscriptionRequest = PresenceManager.getInstance().getSubscriptionRequest(account, user);
.getSubscriptionRequest(account, user);
if (subscriptionRequest == null) { if (subscriptionRequest == null) {
Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND); Application.getInstance().onError(R.string.ENTRY_IS_NOT_FOUND);
finish(); finish();
return; return;
} }
setDialogMessage(subscriptionRequest.getConfirmation());
setDialogTitle(R.string.subscription_request_message); setContentView(R.layout.contact_subscription);
findViewById(android.R.id.button3).setVisibility(View.GONE); Toolbar toolbar = (Toolbar) findViewById(R.id.top_toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(getString(R.string.subscription_request_message));
ActionBarPainter actionBarPainter = new ActionBarPainter(this);
actionBarPainter.updateWithAccountName(account);
View fakeToolbar = findViewById(R.id.fake_toolbar);
fakeToolbar.setBackgroundColor(actionBarPainter.getAccountColor(account));
toolbar.setBackgroundResource(android.R.color.transparent);
AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
((ImageView)fakeToolbar.findViewById(R.id.avatar)).setImageDrawable(abstractContact.getAvatar());
((TextView)fakeToolbar.findViewById(R.id.dialog_message)).setText(subscriptionRequest.getConfirmation());
Button acceptButton = (Button) findViewById(R.id.accept_button);
acceptButton.setTextColor(actionBarPainter.getAccountColor(account));
acceptButton.setOnClickListener(this);
findViewById(R.id.decline_button).setOnClickListener(this);
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.scrollable_container, ContactVcardViewerFragment.newInstance(account, user)).commit();
}
} }
@Override @Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.accept_button:
onAccept();
break;
case R.id.decline_button:
onDecline();
break;
}
}
public void onAccept() { public void onAccept() {
super.onAccept();
try { try {
PresenceManager.getInstance().acceptSubscription( PresenceManager.getInstance().acceptSubscription(
subscriptionRequest.getAccount(), subscriptionRequest.getAccount(),
...@@ -66,9 +117,7 @@ public class ContactSubscription extends ManagedDialog { ...@@ -66,9 +117,7 @@ public class ContactSubscription extends ManagedDialog {
finish(); finish();
} }
@Override
public void onDecline() { public void onDecline() {
super.onDecline();
try { try {
PresenceManager.getInstance().discardSubscription( PresenceManager.getInstance().discardSubscription(
subscriptionRequest.getAccount(), subscriptionRequest.getAccount(),
......
/**
* 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.adapter; package com.xabber.android.ui.adapter;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.ColorDrawable; import android.content.res.Resources;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import com.melnykov.fab.FloatingActionButton;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode; import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.extension.avatar.AvatarManager; import com.xabber.android.data.extension.avatar.AvatarManager;
...@@ -30,19 +15,17 @@ import com.xabber.androiddev.R; ...@@ -30,19 +15,17 @@ import com.xabber.androiddev.R;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
/** import de.hdodenhof.circleimageview.CircleImageView;
* Adapter for the list of accounts in the title of contact list.
*
* @author alexander.ivanov public class AccountActionButtonsAdapter implements UpdatableAdapter {
*/
public class AccountToggleAdapter implements UpdatableAdapter {
private final Activity activity; private final Activity activity;
/** /**
* Listener for click on elements. * Listener for click on elements.
*/ */
private final OnClickListener onClickListener; private final View.OnClickListener onClickListener;
/** /**
* Layout to be populated. * Layout to be populated.
...@@ -54,14 +37,22 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -54,14 +37,22 @@ public class AccountToggleAdapter implements UpdatableAdapter {
*/ */
private final ArrayList<String> accounts; private final ArrayList<String> accounts;
private int[] accountActionBarColors; private int[] accountActionBarColors;
private int[] accountStatusBarColors;
private int[] accountBackgroundColors;
public AccountToggleAdapter(Activity activity, public AccountActionButtonsAdapter(Activity activity,
OnClickListener onClickListener, LinearLayout linearLayout) { View.OnClickListener onClickListener, LinearLayout linearLayout) {
super(); super();
this.activity = activity; this.activity = activity;
this.onClickListener = onClickListener; this.onClickListener = onClickListener;
this.linearLayout = linearLayout; this.linearLayout = linearLayout;
accounts = new ArrayList<>(); accounts = new ArrayList<>();
Resources resources = activity.getResources();
accountActionBarColors = resources.getIntArray(R.array.account_action_bar);
accountStatusBarColors = resources.getIntArray(R.array.account_status_bar);
accountBackgroundColors = resources.getIntArray(R.array.account_background);
} }
/** /**
...@@ -72,21 +63,18 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -72,21 +63,18 @@ public class AccountToggleAdapter implements UpdatableAdapter {
public void rebuild() { public void rebuild() {
accounts.clear(); accounts.clear();
accounts.addAll(AccountManager.getInstance().getAccounts()); accounts.addAll(AccountManager.getInstance().getAccounts());
Collections.sort(accounts); Collections.sort(accounts);
final int size = accounts.size(); final int size = accounts.size();
accountActionBarColors = activity.getResources().getIntArray(R.array.account_action_bar);
final LayoutInflater inflater = (LayoutInflater) activity final LayoutInflater inflater = (LayoutInflater) activity
.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); .getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
while (linearLayout.getChildCount() < size) { while (linearLayout.getChildCount() < size) {
final View view = inflater.inflate(R.layout.account_toggler_item, linearLayout, false); View view = inflater.inflate(R.layout.account_action_button, linearLayout, false);
view.setOnClickListener(onClickListener);
linearLayout.addView(view); linearLayout.addView(view);
final AccountViewHolder accountViewHolder = new AccountViewHolder(view);
view.setTag(accountViewHolder);
activity.registerForContextMenu(accountViewHolder.statusMode);
accountViewHolder.statusMode.setOnClickListener(onClickListener);
} }
while (linearLayout.getChildCount() > size) { while (linearLayout.getChildCount() > size) {
linearLayout.removeViewAt(size); linearLayout.removeViewAt(size);
} }
...@@ -95,21 +83,43 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -95,21 +83,43 @@ public class AccountToggleAdapter implements UpdatableAdapter {
@Override @Override
public void onChange() { public void onChange() {
String selected = AccountManager.getInstance().getSelectedAccount();
for (int index = 0; index < accounts.size(); index++) { for (int index = 0; index < accounts.size(); index++) {
final View view = linearLayout.getChildAt(index); View view = linearLayout.getChildAt(index);
final AccountViewHolder accountViewHolder = (AccountViewHolder) view.getTag();
final CircleImageView circleImageView = (CircleImageView) view.findViewById(R.id.account_avatar);
final String account = accounts.get(index); final String account = accounts.get(index);
StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode(); circleImageView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
FloatingActionButton backgroundActionButton = (FloatingActionButton) view.findViewById(R.id.fab);
int colorLevel = AccountManager.getInstance().getColorLevel(account); int colorLevel = AccountManager.getInstance().getColorLevel(account);
view.setBackgroundDrawable(new ColorDrawable(accountActionBarColors[colorLevel])); backgroundActionButton.setColorNormal(accountActionBarColors[colorLevel]);
if (selected == null || account.equals(selected)) { backgroundActionButton.setColorPressed(accountStatusBarColors[colorLevel]);
accountViewHolder.disabled.setVisibility(View.GONE); backgroundActionButton.setColorRipple(accountBackgroundColors[colorLevel]);
String selectedAccount = AccountManager.getInstance().getSelectedAccount();
int shadowVisibility;
if (selectedAccount == null) {
shadowVisibility = View.GONE;
} else { } else {
accountViewHolder.disabled.setVisibility(View.VISIBLE); shadowVisibility = View.VISIBLE;
if (selectedAccount.equalsIgnoreCase(account)) {
shadowVisibility = View.GONE;
}
} }
accountViewHolder.statusMode.setImageLevel(statusMode.ordinal());
accountViewHolder.avatar.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); view.findViewById(R.id.account_unselected_shadow).setVisibility(shadowVisibility);
StatusMode statusMode = AccountManager.getInstance().getAccount(account).getDisplayStatusMode();
int offlineShadowVisibility;
if (statusMode == StatusMode.connection || statusMode == StatusMode.unavailable) {
offlineShadowVisibility = View.VISIBLE;
} else {
offlineShadowVisibility = View.GONE;
}
view.findViewById(R.id.account_offline_shadow).setVisibility(offlineShadowVisibility);
} }
} }
...@@ -121,17 +131,7 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -121,17 +131,7 @@ public class AccountToggleAdapter implements UpdatableAdapter {
return accounts.get(position); return accounts.get(position);
} }
/**
* Get the data item associated with the specified view.
*
* @param view direct child of linear layout or status_mode view in direct
* child.
* @return The data for the specified view.
*/
public String getItemForView(View view) { public String getItemForView(View view) {
if (view.getId() == R.id.status_icon) {
view = (View) view.getParent();
}
for (int index = 0; index < linearLayout.getChildCount(); index++) { for (int index = 0; index < linearLayout.getChildCount(); index++) {
if (view == linearLayout.getChildAt(index)) { if (view == linearLayout.getChildAt(index)) {
return accounts.get(index); return accounts.get(index);
...@@ -139,17 +139,4 @@ public class AccountToggleAdapter implements UpdatableAdapter { ...@@ -139,17 +139,4 @@ public class AccountToggleAdapter implements UpdatableAdapter {
} }
return null; return null;
} }
private static class AccountViewHolder {
final ImageView statusMode;
final ImageView avatar;
final ImageView disabled;
public AccountViewHolder(View view) {
statusMode = (ImageView) view.findViewById(R.id.status_icon);
avatar = (ImageView) view.findViewById(R.id.avatar);
disabled = (ImageView) view.findViewById(R.id.disabled);
}
}
} }
...@@ -43,8 +43,7 @@ public class AccountChooseAdapter extends BaseAdapter { ...@@ -43,8 +43,7 @@ public class AccountChooseAdapter extends BaseAdapter {
public AccountChooseAdapter(Activity activity) { public AccountChooseAdapter(Activity activity) {
super(); super();
this.activity = activity; this.activity = activity;
accounts = new ArrayList<String>(AccountManager.getInstance() accounts = new ArrayList<>(AccountManager.getInstance().getAccounts());
.getAccounts());
Collections.sort(accounts); Collections.sort(accounts);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar); accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
...@@ -78,7 +77,6 @@ public class AccountChooseAdapter extends BaseAdapter { ...@@ -78,7 +77,6 @@ public class AccountChooseAdapter extends BaseAdapter {
final String account = (String) getItem(position); final String account = (String) getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)]; int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.avatar_background)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar)) ((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); .setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
...@@ -89,24 +87,7 @@ public class AccountChooseAdapter extends BaseAdapter { ...@@ -89,24 +87,7 @@ public class AccountChooseAdapter extends BaseAdapter {
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
final View view; return getView(position, convertView, parent);
final AccountManager accountManager = AccountManager.getInstance();
if (convertView == null) {
view = activity.getLayoutInflater().inflate(
R.layout.account_choose_dropdown, parent, false);
} else {
view = convertView;
}
final String account = (String) getItem(position);
int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.avatar_background)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
((TextView) view.findViewById(R.id.name)).setText(accountManager
.getVerboseName(account));
return view;
} }
} }
...@@ -31,7 +31,7 @@ public class AccountConfiguration extends GroupConfiguration { ...@@ -31,7 +31,7 @@ public class AccountConfiguration extends GroupConfiguration {
public AccountConfiguration(String account, String user, public AccountConfiguration(String account, String user,
GroupStateProvider groupStateProvider) { GroupStateProvider groupStateProvider) {
super(account, user, groupStateProvider); super(account, user, groupStateProvider);
groups = new TreeMap<String, GroupConfiguration>(); groups = new TreeMap<>();
} }
/** /**
......
...@@ -61,7 +61,6 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> { ...@@ -61,7 +61,6 @@ public class AccountListAdapter extends BaseListEditorAdapter<String> {
int accountColor = accountColors[accountManager.getColorLevel(account)]; int accountColor = accountColors[accountManager.getColorLevel(account)];
((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor)); ((ImageView) view.findViewById(R.id.color)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar_background)).setImageDrawable(new ColorDrawable(accountColor));
((ImageView) view.findViewById(R.id.avatar)) ((ImageView) view.findViewById(R.id.avatar))
.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); .setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account));
......
...@@ -62,32 +62,19 @@ public class AccountTypeAdapter extends BaseAdapter { ...@@ -62,32 +62,19 @@ public class AccountTypeAdapter extends BaseAdapter {
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
final View view; final View view;
if (convertView == null) { if (convertView == null) {
view = activity.getLayoutInflater().inflate( view = activity.getLayoutInflater().inflate(R.layout.account_type_item, parent, false);
R.layout.account_type_item, parent, false);
} else { } else {
view = convertView; view = convertView;
} }
final AccountType type = (AccountType) getItem(position); final AccountType type = (AccountType) getItem(position);
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(type ((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(type.getIcon());
.getIcon());
((TextView) view.findViewById(R.id.name)).setText(type.getName()); ((TextView) view.findViewById(R.id.name)).setText(type.getName());
return view; return view;
} }
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
final View view; return getView(position, convertView, parent);
if (convertView == null) {
view = activity.getLayoutInflater().inflate(
R.layout.account_type_dropdown, parent, false);
} else {
view = convertView;
}
final AccountType type = (AccountType) getItem(position);
((ImageView) view.findViewById(R.id.avatar)).setImageDrawable(type
.getIcon());
((TextView) view.findViewById(R.id.name)).setText(type.getName());
return view;
} }
} }
\ No newline at end of file
/**
* 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.adapter;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.roster.AbstractContact;
import java.util.ArrayList;
import java.util.Locale;
/**
* Base adapter for the list of contacts.
*
* @author alexander.ivanov
*/
public abstract class BaseContactAdapter<Inflater extends BaseContactInflater>
extends BaseAdapter implements UpdatableAdapter, Filterable {
final Activity activity;
final Locale locale;
/**
* List of entities.
*/
final ArrayList<BaseEntity> baseEntities;
/**
* Used view inflater.
*/
final Inflater inflater;
/**
* Contact filter.
*/
ContactFilter contactFilter;
/**
* Filter string. Can be <code>null</code> if filter is disabled.
*/
String filterString;
public BaseContactAdapter(Activity activity, Inflater inflater) {
this.activity = activity;
this.locale = Locale.getDefault();
this.baseEntities = new ArrayList<>();
this.inflater = inflater;
inflater.setAdapter(this);
contactFilter = null;
filterString = null;
}
@Override
public void onChange() {
notifyDataSetChanged();
}
@Override
public int getCount() {
return baseEntities.size();
}
@Override
public Object getItem(int position) {
return baseEntities.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
final View view;
if (convertView == null) {
view = inflater.createView(position, parent);
view.setTag(inflater.createViewHolder(position, view));
} else {
view = convertView;
}
inflater.getView(view, (AbstractContact) getItem(position));
return view;
}
@Override
public Filter getFilter() {
if (contactFilter == null) {
contactFilter = new ContactFilter();
}
return contactFilter;
}
private class ContactFilter extends Filter {
@Override
protected FilterResults performFiltering(CharSequence constraint) {
return null;
}
@Override
protected void publishResults(CharSequence constraint,
FilterResults results) {
if (constraint == null || constraint.length() == 0) {
filterString = null;
} else {
filterString = constraint.toString().toLowerCase(locale);
}
onChange();
}
}
}
/**
* 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.adapter;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
/**
* Provides views and fills them with data for {@link BaseContactAdapter}.
*
* @author alexander.ivanov
*/
public abstract class BaseContactInflater {
final Activity activity;
final LayoutInflater layoutInflater;
/**
* Repeated shadow for drawable.
*/
final BitmapDrawable shadowDrawable;
/**
* Managed adapter.
*/
BaseAdapter adapter;
private final int[] accountColors;
public BaseContactInflater(Activity activity) {
this.activity = activity;
layoutInflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Bitmap bitmap = BitmapFactory.decodeResource(activity.getResources(), R.drawable.contact_shadow);
shadowDrawable = new BitmapDrawable(activity.getResources(), bitmap);
shadowDrawable.setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);
accountColors = activity.getResources().getIntArray(R.array.account_action_bar);
}
/**
* Sets managed adapter.
*
* @param adapter
*/
void setAdapter(BaseAdapter adapter) {
this.adapter = adapter;
}
/**
* Creates new view for specified position.
*
* @param position
* @param parent
* @return
*/
abstract View createView(int position, ViewGroup parent);
/**
* Creates new instance of ViewHolder.
*
* @param position
* @param view
* @return
*/
abstract ViewHolder createViewHolder(int position, View view);
/**
* Returns status text.
*
* @param abstractContact
* @return
*/
String getStatusText(AbstractContact abstractContact) {
return abstractContact.getStatusText();
}
/**
* Fills view for {@link BaseContactAdapter}.
*
* @param view view to be inflated.
* @param abstractContact contact to be shown.
*/
public void getView(View view, AbstractContact abstractContact) {
final ViewHolder viewHolder = (ViewHolder) view.getTag();
if (abstractContact.isConnected()) {
viewHolder.shadow.setVisibility(View.GONE);
} else {
viewHolder.shadow.setVisibility(View.VISIBLE);
}
int colorLevel = abstractContact.getColorLevel();
viewHolder.color.setImageDrawable(new ColorDrawable(accountColors[colorLevel]));
if (SettingsManager.contactsShowAvatars()) {
viewHolder.avatar.setVisibility(View.VISIBLE);
viewHolder.avatar.setImageDrawable(abstractContact.getAvatarForContactList());
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.avatar);
} else {
viewHolder.avatar.setVisibility(View.GONE);
((RelativeLayout.LayoutParams) viewHolder.panel.getLayoutParams())
.addRule(RelativeLayout.RIGHT_OF, R.id.color);
}
viewHolder.name.setText(abstractContact.getName());
final String statusText = getStatusText(abstractContact);
if ("".equals(statusText)) {
viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize(R.dimen.contact_name_height_hide_status);
viewHolder.name.setGravity(Gravity.CENTER_VERTICAL);
viewHolder.status.setVisibility(View.GONE);
} else {
viewHolder.name.getLayoutParams().height = activity.getResources()
.getDimensionPixelSize(R.dimen.contact_name_height_show_status);
viewHolder.name.setGravity(Gravity.BOTTOM);
viewHolder.status.setText(statusText);
viewHolder.status.setVisibility(View.VISIBLE);
}
viewHolder.shadow.setBackgroundDrawable(shadowDrawable);
}
/**
* Holder for views in contact item.
*/
static class ViewHolder {
final ImageView color;
final ImageView avatar;
final RelativeLayout panel;
final TextView name;
final TextView status;
final ImageView shadow;
public ViewHolder(View view) {
color = (ImageView) view.findViewById(R.id.color);
avatar = (ImageView) view.findViewById(R.id.avatar);
panel = (RelativeLayout) view.findViewById(R.id.panel);
name = (TextView) view.findViewById(R.id.name);
status = (TextView) view.findViewById(R.id.status);
shadow = (ImageView) view.findViewById(R.id.shadow);
}
}
}
/**
* 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.adapter;
import android.app.Activity;
import android.content.res.TypedArray;
import android.view.View;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
/**
* Inflate view with contact's last message or status text as well as active
* chat badge.
*
* @author alexander.ivanov
*/
public class ChatContactInflater extends ClientContactInflater {
/**
* Name's normal color.
*/
private final int textColorPrimary;
/**
* Status's normal color.
*/
private final int textColorSecondary;
public ChatContactInflater(Activity activity) {
super(activity);
TypedArray typedArray;
typedArray = activity.getTheme().obtainStyledAttributes(
new int[]{android.R.attr.textColorPrimary,
android.R.attr.textColorSecondary,});
textColorPrimary = typedArray.getColor(0, 0);
textColorSecondary = typedArray.getColor(1, 0);
typedArray.recycle();
}
@Override
ViewHolder createViewHolder(int position, View view) {
return new ViewHolder(view);
}
@Override
String getStatusText(AbstractContact abstractContact) {
if (MessageManager.getInstance().hasActiveChat(
abstractContact.getAccount(), abstractContact.getUser()))
return MessageManager.getInstance().getLastText(
abstractContact.getAccount(), abstractContact.getUser());
else
return super.getStatusText(abstractContact);
}
@Override
public void getView(View view, AbstractContact abstractContact) {
super.getView(view, abstractContact);
final ViewHolder contactViewHolder = (ViewHolder) view.getTag();
if (MessageManager.getInstance().hasActiveChat(
abstractContact.getAccount(), abstractContact.getUser())) {
contactViewHolder.panel
.setBackgroundResource(R.drawable.active_chat);
contactViewHolder.name.setTextColor(activity.getResources()
.getColor(android.R.color.primary_text_light));
contactViewHolder.status.setTextColor(activity.getResources()
.getColor(android.R.color.secondary_text_light));
} else {
contactViewHolder.panel.setBackgroundDrawable(null);
contactViewHolder.name.setTextColor(textColorPrimary);
contactViewHolder.status.setTextColor(textColorSecondary);
}
}
static class ViewHolder extends ClientContactInflater.ViewHolder {
final View panel;
public ViewHolder(View view) {
super(view);
panel = view.findViewById(R.id.panel);
}
}
}
...@@ -37,7 +37,6 @@ import com.xabber.android.data.message.MessageItem; ...@@ -37,7 +37,6 @@ import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager; import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterManager; import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.utils.Emoticons;
import com.xabber.android.utils.StringUtils; import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -171,14 +170,10 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter ...@@ -171,14 +170,10 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
ChatAction action = messageItem.getAction(); ChatAction action = messageItem.getAction();
Spannable text = Emoticons.newSpannable(
action.getText(activity, messageItem.getResource(), messageItem.getSpannable().toString()));
Emoticons.getSmiledText(activity.getApplication(), text);
String time = StringUtils.getSmartTimeText(activity, messageItem.getTimestamp()); String time = StringUtils.getSmartTimeText(activity, messageItem.getTimestamp());
((TextView)view.findViewById(R.id.action_message_text)).setText(time + ": " + text); ((TextView)view.findViewById(R.id.action_message_text)).setText(time + ": "
+ action.getText(activity, messageItem.getResource(), messageItem.getSpannable().toString()));
return view; return view;
} }
...@@ -229,7 +224,6 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter ...@@ -229,7 +224,6 @@ public class ChatMessageAdapter extends BaseAdapter implements UpdatableAdapter
} }
Spannable text = messageItem.getSpannable(); Spannable text = messageItem.getSpannable();
Emoticons.getSmiledText(activity.getApplication(), text);
if (messageItem.getTag() == null) { if (messageItem.getTag() == null) {
builder.append(text); builder.append(text);
} else { } else {
......
/**
* 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.adapter;
import android.app.Activity;
import android.view.View;
import android.widget.ImageView;
import com.xabber.android.data.extension.capability.ClientSoftware;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
/**
* Inflate view with contact's client software.
*
* @author alexander.ivanov
*/
public class ClientContactInflater extends StatusContactInflater {
public ClientContactInflater(Activity activity) {
super(activity);
}
@Override
ViewHolder createViewHolder(int position, View view) {
return new ClientContactInflater.ViewHolder(view);
}
@Override
public void getView(View view, AbstractContact abstractContact) {
super.getView(view, abstractContact);
ViewHolder viewHolder = (ViewHolder) view.getTag();
ClientSoftware clientSoftware = abstractContact.getClientSoftware();
if (clientSoftware == ClientSoftware.unknown)
viewHolder.clientSoftware.setVisibility(View.INVISIBLE);
else {
viewHolder.clientSoftware.setVisibility(View.VISIBLE);
viewHolder.clientSoftware.setImageLevel(clientSoftware.ordinal());
}
}
static class ViewHolder extends StatusContactInflater.ViewHolder {
final ImageView clientSoftware;
public ViewHolder(View view) {
super(view);
clientSoftware = (ImageView) view
.findViewById(R.id.client_software);
}
}
}
...@@ -63,7 +63,7 @@ public class GroupConfiguration extends BaseEntity { ...@@ -63,7 +63,7 @@ public class GroupConfiguration extends BaseEntity {
public GroupConfiguration(String account, String group, public GroupConfiguration(String account, String group,
GroupStateProvider groupStateProvider) { GroupStateProvider groupStateProvider) {
super(account, group); super(account, group);
abstractContacts = new ArrayList<AbstractContact>(); abstractContacts = new ArrayList<>();
expanded = groupStateProvider.isExpanded(account, group); expanded = groupStateProvider.isExpanded(account, group);
showOfflineMode = groupStateProvider.getShowOfflineMode(account, group); showOfflineMode = groupStateProvider.getShowOfflineMode(account, group);
empty = true; empty = true;
...@@ -105,8 +105,9 @@ public class GroupConfiguration extends BaseEntity { ...@@ -105,8 +105,9 @@ public class GroupConfiguration extends BaseEntity {
*/ */
public void increment(boolean online) { public void increment(boolean online) {
this.total++; this.total++;
if (online) if (online) {
this.online++; this.online++;
}
} }
/** /**
...@@ -157,31 +158,41 @@ public class GroupConfiguration extends BaseEntity { ...@@ -157,31 +158,41 @@ public class GroupConfiguration extends BaseEntity {
int result = account.compareTo(another.getAccount()); int result = account.compareTo(another.getAccount());
if (result != 0) { if (result != 0) {
if (user.compareTo(another.getUser()) != 0) { if (user.compareTo(another.getUser()) != 0) {
if (user == GroupManager.ACTIVE_CHATS) if (user.equals(GroupManager.ACTIVE_CHATS)) {
return -1; return -1;
if (anotherUser == GroupManager.ACTIVE_CHATS) }
if (anotherUser.equals(GroupManager.ACTIVE_CHATS)) {
return 1; return 1;
}
} }
return result; return result;
} }
result = user.compareTo(anotherUser); result = user.compareTo(anotherUser);
if (result != 0) { if (result != 0) {
if (user == GroupManager.ACTIVE_CHATS) if (user.equals(GroupManager.ACTIVE_CHATS)) {
return -1; return -1;
if (anotherUser == GroupManager.ACTIVE_CHATS) }
if (anotherUser.equals(GroupManager.ACTIVE_CHATS)) {
return 1; return 1;
if (user == GroupManager.IS_ACCOUNT) }
if (user.equals(GroupManager.IS_ACCOUNT)) {
return -1; return -1;
if (anotherUser == GroupManager.IS_ACCOUNT) }
if (anotherUser.equals(GroupManager.IS_ACCOUNT)) {
return 1; return 1;
if (user == GroupManager.NO_GROUP) }
if (user.equals(GroupManager.NO_GROUP)) {
return -1; return -1;
if (anotherUser == GroupManager.NO_GROUP) }
if (anotherUser.equals(GroupManager.NO_GROUP)) {
return 1; return 1;
if (user == GroupManager.IS_ROOM) }
if (user.equals(GroupManager.IS_ROOM)) {
return -1; return -1;
if (anotherUser == GroupManager.IS_ROOM) }
if (anotherUser.equals(GroupManager.IS_ROOM)) {
return 1; return 1;
}
return result; return result;
} }
return 0; return 0;
......
/**
* 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.adapter;
import android.widget.EditText;
/**
* Listener for text to be changed.
*
* @author alexander.ivanov
*/
public interface OnTextChangedListener {
void onTextChanged(EditText editText, CharSequence text);
}
/**
* 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.adapter;
import android.view.View;
import android.widget.Adapter;
/**
* Adapter that can save state of view on activity paused or on element removed
* from layout.
* <p/>
* Warning: This interface is to be removed.
*
* @author alexander.ivanov
*/
public interface SaveStateAdapter extends Adapter {
/**
* Will be called before view will replaced with another or before activity
* will be paused.
*
* @param view
*/
void saveState(View view);
/**
* Requests to hide pages indicator.
*
* @param view
*/
void hidePages(View view);
/**
* Show pages indicator.
*
* @param view
*/
void showPages(View view);
}
/**
* 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.adapter;
import android.app.Activity;
import android.widget.ListView;
/**
* Enable smooth scrollbar depend on number of entities.
*
* @param <Inflater>
* @author alexander.ivanov
*/
public abstract class SmoothContactAdapter<Inflater extends BaseContactInflater>
extends BaseContactAdapter<Inflater> {
/**
* Minimum number of item when smooth scroll bar will be disabled.
*/
private static final int SMOOTH_SCROLLBAR_LIMIT = 20;
/**
* Managed list view.
*/
ListView listView;
public SmoothContactAdapter(Activity activity, ListView listView, Inflater inflater) {
super(activity, inflater);
this.listView = listView;
}
@Override
public void onChange() {
super.onChange();
listView.setSmoothScrollbarEnabled(baseEntities.size() < SMOOTH_SCROLLBAR_LIMIT);
}
}
/**
* 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.adapter;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
/**
* Inflate view with contact's status mode.
*
* @author alexander.ivanov
*/
public class StatusContactInflater extends BaseContactInflater {
public StatusContactInflater(Activity activity) {
super(activity);
}
@Override
View createView(int position, ViewGroup parent) {
return layoutInflater
.inflate(R.layout.base_contact_item, parent, false);
}
@Override
ViewHolder createViewHolder(int position, View view) {
return new StatusContactInflater.ViewHolder(view);
}
@Override
public void getView(View view, AbstractContact abstractContact) {
super.getView(view, abstractContact);
ViewHolder viewHolder = (ViewHolder) view.getTag();
viewHolder.statusMode.setImageLevel(abstractContact.getStatusMode()
.getStatusLevel());
}
static class ViewHolder extends BaseContactInflater.ViewHolder {
final ImageView statusMode;
public ViewHolder(View view) {
super(view);
statusMode = (ImageView) view.findViewById(R.id.status_icon);
}
}
}
...@@ -33,8 +33,7 @@ import com.xabber.androiddev.R; ...@@ -33,8 +33,7 @@ import com.xabber.androiddev.R;
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class StatusEditorAdapter extends BaseAdapter implements public class StatusEditorAdapter extends BaseAdapter implements UpdatableAdapter {
UpdatableAdapter {
private final Activity activity; private final Activity activity;
private final ArrayList<SavedStatus> statuses; private final ArrayList<SavedStatus> statuses;
...@@ -42,7 +41,7 @@ public class StatusEditorAdapter extends BaseAdapter implements ...@@ -42,7 +41,7 @@ public class StatusEditorAdapter extends BaseAdapter implements
public StatusEditorAdapter(Activity activity) { public StatusEditorAdapter(Activity activity) {
super(); super();
this.activity = activity; this.activity = activity;
statuses = new ArrayList<SavedStatus>(); statuses = new ArrayList<>();
} }
@Override @Override
...@@ -64,17 +63,16 @@ public class StatusEditorAdapter extends BaseAdapter implements ...@@ -64,17 +63,16 @@ public class StatusEditorAdapter extends BaseAdapter implements
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
View view; View view;
if (convertView == null) { if (convertView == null) {
view = activity.getLayoutInflater().inflate( view = activity.getLayoutInflater().inflate(R.layout.status_editor_item, parent, false);
R.layout.status_editor_item, parent, false);
} else { } else {
view = convertView; view = convertView;
} }
final SavedStatus status = (SavedStatus) getItem(position); final SavedStatus status = (SavedStatus) getItem(position);
((ImageView) view.findViewById(R.id.icon)).setImageLevel(status ((ImageView) view.findViewById(R.id.icon)).setImageLevel(status.getStatusMode().getStatusLevel());
.getStatusMode().getStatusLevel());
String text = status.getStatusText(); String text = status.getStatusText();
if ("".equals(text)) if ("".equals(text)) {
text = activity.getString(R.string.empty_status); text = activity.getString(R.string.empty_status);
}
((TextView) view.findViewById(R.id.name)).setText(text); ((TextView) view.findViewById(R.id.name)).setText(text);
return view; return view;
} }
......
...@@ -38,13 +38,12 @@ public class StatusModeAdapter extends BaseAdapter { ...@@ -38,13 +38,12 @@ public class StatusModeAdapter extends BaseAdapter {
public StatusModeAdapter(Activity activity) { public StatusModeAdapter(Activity activity) {
super(); super();
this.activity = activity; this.activity = activity;
statusModes = new ArrayList<StatusMode>(); statusModes = new ArrayList<>();
statusModes.add(StatusMode.chat); statusModes.add(StatusMode.chat);
statusModes.add(StatusMode.available); statusModes.add(StatusMode.available);
statusModes.add(StatusMode.away); statusModes.add(StatusMode.away);
statusModes.add(StatusMode.xa); statusModes.add(StatusMode.xa);
statusModes.add(StatusMode.dnd); statusModes.add(StatusMode.dnd);
// statusModes.add(StatusMode.invisible);
statusModes.add(StatusMode.unavailable); statusModes.add(StatusMode.unavailable);
} }
...@@ -65,18 +64,15 @@ public class StatusModeAdapter extends BaseAdapter { ...@@ -65,18 +64,15 @@ public class StatusModeAdapter extends BaseAdapter {
private void updateView(int position, View view) { private void updateView(int position, View view) {
StatusMode statusMode = (StatusMode) getItem(position); StatusMode statusMode = (StatusMode) getItem(position);
((ImageView) view.findViewById(R.id.icon)).setImageLevel(statusMode ((ImageView) view.findViewById(R.id.icon)).setImageLevel(statusMode.getStatusLevel());
.getStatusLevel()); ((TextView) view.findViewById(R.id.name)).setText(statusMode.getStringID());
((TextView) view.findViewById(R.id.name)).setText(statusMode
.getStringID());
} }
@Override @Override
public View getView(int position, View convertView, ViewGroup parent) { public View getView(int position, View convertView, ViewGroup parent) {
View view; View view;
if (convertView == null) { if (convertView == null) {
view = activity.getLayoutInflater().inflate( view = activity.getLayoutInflater().inflate(R.layout.status_mode_item, parent, false);
R.layout.status_mode_item, parent, false);
} else { } else {
view = convertView; view = convertView;
} }
...@@ -86,14 +82,6 @@ public class StatusModeAdapter extends BaseAdapter { ...@@ -86,14 +82,6 @@ public class StatusModeAdapter extends BaseAdapter {
@Override @Override
public View getDropDownView(int position, View convertView, ViewGroup parent) { public View getDropDownView(int position, View convertView, ViewGroup parent) {
View view; return getView(position, convertView, parent);
if (convertView == null) {
view = activity.getLayoutInflater().inflate(
R.layout.status_mode_dropdown, parent, false);
} else {
view = convertView;
}
updateView(position, view);
return view;
} }
} }
/**
* 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.dialog;
import java.util.ArrayList;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.view.View;
import android.view.ViewGroup;
import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
public class AccountChooseDialogBuilder extends ListenableDialogBuilder {
private final String user;
private String selected;
public AccountChooseDialogBuilder(Activity activity, int dialogId,
final ConfirmDialogListener listener, String user) {
super(activity, dialogId);
this.user = user;
this.selected = null;
setOnCancelListener(listener);
setOnDeclineListener(listener);
final Adapter adapter = new Adapter(activity);
setSingleChoiceItems(adapter, -1, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
selected = (String) adapter.getItem(which);
dialog.dismiss();
listener.onAccept(AccountChooseDialogBuilder.this);
}
});
}
/**
* @return <code>null</code> can be returned.
*/
public String getSelected() {
return selected;
}
private class Adapter extends AccountChooseAdapter {
public Adapter(Activity activity) {
super(activity);
ArrayList<String> available = new ArrayList<String>();
for (RosterContact check : RosterManager.getInstance()
.getContacts())
if (check.isEnabled() && check.getUser().equals(user))
available.add(check.getAccount());
if (!available.isEmpty()) {
accounts.clear();
accounts.addAll(available);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getDropDownView(position, convertView, parent);
}
}
}
/**
* 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.dialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class ExportChatDialogBuilder extends ConfirmDialogBuilder {
private final EditText nameView;
private final CheckBox sendView;
public ExportChatDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, String account, String user) {
super(activity, dialogId, listener);
setTitle(R.string.export_chat_title);
View layout = activity.getLayoutInflater().inflate(
R.layout.export_chat, null);
nameView = (EditText) layout.findViewById(R.id.name);
sendView = (CheckBox) layout.findViewById(R.id.send);
nameView.setText(activity.getString(R.string.export_chat_mask,
AccountManager.getInstance().getVerboseName(account),
RosterManager.getInstance().getName(account, user)));
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
if ("".equals(getName())) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
public boolean isSendChecked() {
return sendView.isChecked();
}
}
/**
* 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.dialog;
import java.util.Collection;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
public class GroupAddDialogBuilder extends ConfirmDialogBuilder {
private final Collection<String> groups;
private final EditText nameView;
public GroupAddDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, Collection<String> groups) {
super(activity, dialogId, listener);
setTitle(R.string.group_add);
this.groups = groups;
View layout = activity.getLayoutInflater().inflate(R.layout.group_name,
null);
nameView = (EditText) layout.findViewById(R.id.group_name);
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
String name = nameView.getText().toString();
if ("".equals(name)) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
if (groups.contains(name)) {
Toast.makeText(activity, activity.getString(R.string.group_exists),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
}
/**
* 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.dialog;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
import java.util.ArrayList;
public class GroupAddDialogFragment extends ConfirmDialogFragment {
private static final String GROUPS = "GROUPS";
/**
* @param account can be <code>null</code> to be used for all accounts.
* @param group can be <code>null</code> to be used for "no group".
* @return
*/
public static DialogFragment newInstance(ArrayList<String> groups) {
return new GroupAddDialogFragment().putAgrument(GROUPS, groups);
}
private ArrayList<String> groups;
private EditText nameView;
@Override
protected Builder getBuilder() {
groups = getArguments().getStringArrayList(GROUPS);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.group_add);
View layout = getActivity().getLayoutInflater().inflate(
R.layout.group_name, null);
nameView = (EditText) layout.findViewById(R.id.group_name);
builder.setView(layout);
return builder;
}
@Override
protected boolean onPositiveClick() {
String group = nameView.getText().toString();
if ("".equals(group)) {
Toast.makeText(getActivity(), getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return false;
}
if (groups.contains(group)) {
Toast.makeText(getActivity(), getString(R.string.group_exists),
Toast.LENGTH_LONG).show();
return false;
}
((OnGroupAddConfirmed) getActivity()).onGroupAddConfirmed(group);
return true;
}
public interface OnGroupAddConfirmed {
void onGroupAddConfirmed(String group);
}
}
/**
* 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.dialog;
import android.app.Activity;
import android.content.DialogInterface;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.androiddev.R;
public class GroupRenameDialogBuilder extends ConfirmDialogBuilder {
private final EditText nameView;
public GroupRenameDialogBuilder(Activity activity, int dialogId,
ConfirmDialogListener listener, String group) {
super(activity, dialogId, listener);
setTitle(R.string.group_rename);
View layout = activity.getLayoutInflater().inflate(R.layout.group_name,
null);
nameView = (EditText) layout.findViewById(R.id.group_name);
nameView.setText(group);
setView(layout);
}
@Override
public void onAccept(DialogInterface dialog) {
if ("".equals(getName())) {
Toast.makeText(activity,
activity.getString(R.string.group_is_empty),
Toast.LENGTH_LONG).show();
return;
}
super.onAccept(dialog);
}
public String getName() {
return nameView.getText().toString();
}
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
package com.xabber.android.ui.dialog; package com.xabber.android.ui.dialog;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
...@@ -27,26 +28,25 @@ import com.xabber.androiddev.R; ...@@ -27,26 +28,25 @@ import com.xabber.androiddev.R;
* *
* @author alexander.ivanov * @author alexander.ivanov
*/ */
public class OrbotInstallerDialogBuilder extends DialogBuilder { public class OrbotInstallerDialogBuilder {
private final static String MARKET_SEARCH = "market://search?q=pname:%s"; private final static String MARKET_SEARCH = "market://search?q=pname:%s";
public OrbotInstallerDialogBuilder(final Activity activity, int dialogId) { public static void show(final Activity activity) {
super(activity, dialogId); new AlertDialog.Builder(activity)
setIcon(android.R.drawable.ic_dialog_alert); .setTitle(R.string.orbot_required_title)
setTitle(R.string.orbot_required_title); .setMessage(R.string.orbot_required_message)
setMessage(R.string.orbot_required_message); .setPositiveButton(android.R.string.yes,
setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
new DialogInterface.OnClickListener() { @Override
@Override public void onClick(DialogInterface dialog, int w) {
public void onClick(DialogInterface dialog, int w) { Uri uri = Uri.parse(String.format(MARKET_SEARCH, OrbotHelper.URI_ORBOT));
Uri uri = Uri.parse(String.format(MARKET_SEARCH, Intent intent = new Intent(Intent.ACTION_VIEW, uri);
OrbotHelper.URI_ORBOT)); activity.startActivity(intent);
Intent intent = new Intent(Intent.ACTION_VIEW, uri); }
activity.startActivity(intent); })
} .setNegativeButton(android.R.string.no, null)
}); .show();
setNegativeButton(android.R.string.no, null);
} }
} }
...@@ -68,4 +68,9 @@ public class ActionBarPainter { ...@@ -68,4 +68,9 @@ public class ActionBarPainter {
} }
} }
} }
public int getAccountColor(String account) {
return accountActionBarColors[AccountManager.getInstance().getColorLevel(account)];
}
} }
...@@ -23,7 +23,6 @@ import android.widget.TextView; ...@@ -23,7 +23,6 @@ import android.widget.TextView;
import com.xabber.android.data.account.AccountManager; import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.cs.ChatStateManager; import com.xabber.android.data.extension.cs.ChatStateManager;
import com.xabber.android.data.roster.AbstractContact; import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.utils.Emoticons;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
import org.jivesoftware.smackx.ChatState; import org.jivesoftware.smackx.ChatState;
...@@ -84,7 +83,7 @@ public class ContactTitleInflater { ...@@ -84,7 +83,7 @@ public class ContactTitleInflater {
} else if (chatState == ChatState.paused) { } else if (chatState == ChatState.paused) {
statusText = activity.getString(R.string.chat_state_paused); statusText = activity.getString(R.string.chat_state_paused);
} else { } else {
statusText = Emoticons.getSmiledText(activity, abstractContact.getStatusText()).toString().trim(); statusText = abstractContact.getStatusText().trim();
if (statusText.toString().isEmpty()) { if (statusText.toString().isEmpty()) {
statusText = activity.getString(abstractContact.getStatusMode().getStringID()); statusText = activity.getString(abstractContact.getStatusMode().getStringID());
} }
......
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
package com.xabber.android.ui.helper; package com.xabber.android.ui.helper;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener; import android.view.View.OnClickListener;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView; import android.widget.TextView;
import com.xabber.androiddev.R; import com.xabber.androiddev.R;
...@@ -35,11 +35,13 @@ public abstract class ManagedDialog extends SingleActivity { ...@@ -35,11 +35,13 @@ public abstract class ManagedDialog extends SingleActivity {
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
setTheme(android.R.style.Theme_Dialog);
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.dialog); setContentView(R.layout.dialog);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
findViewById(android.R.id.button1).setOnClickListener( findViewById(android.R.id.button1).setOnClickListener(
new OnClickListener() { new OnClickListener() {
@Override @Override
...@@ -64,11 +66,11 @@ public abstract class ManagedDialog extends SingleActivity { ...@@ -64,11 +66,11 @@ public abstract class ManagedDialog extends SingleActivity {
} }
public void setDialogTitle(CharSequence title) { public void setDialogTitle(CharSequence title) {
((TextView) findViewById(android.R.id.title)).setText(title); getSupportActionBar().setTitle(title);
} }
public void setDialogTitle(int resid) { public void setDialogTitle(int resid) {
((TextView) findViewById(android.R.id.title)).setText(resid); getSupportActionBar().setTitle(resid);
} }
public void setDialogMessage(CharSequence title) { public void setDialogMessage(CharSequence title) {
...@@ -81,8 +83,9 @@ public abstract class ManagedDialog extends SingleActivity { ...@@ -81,8 +83,9 @@ public abstract class ManagedDialog extends SingleActivity {
public void setCustomView(View view, boolean hideContainer) { public void setCustomView(View view, boolean hideContainer) {
((ViewGroup) findViewById(android.R.id.custom)).addView(view); ((ViewGroup) findViewById(android.R.id.custom)).addView(view);
if (hideContainer) if (hideContainer) {
findViewById(R.id.container).setVisibility(View.GONE); findViewById(R.id.container).setVisibility(View.GONE);
}
} }
/** /**
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
package com.xabber.android.ui.preferences; package com.xabber.android.ui.preferences;
import android.app.Dialog;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
...@@ -41,8 +40,6 @@ public class AccountEditor extends ManagedActivity implements ...@@ -41,8 +40,6 @@ public class AccountEditor extends ManagedActivity implements
public static final String INVALIDATED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.INVALIDATED"; public static final String INVALIDATED_TOKEN = "com.xabber.android.ui.preferences.AccountEditor.INVALIDATED";
private static final int ORBOT_DIALOG_ID = 9050;
private String account; private String account;
private AccountItem accountItem; private AccountItem accountItem;
...@@ -122,14 +119,6 @@ public class AccountEditor extends ManagedActivity implements ...@@ -122,14 +119,6 @@ public class AccountEditor extends ManagedActivity implements
return false; return false;
} }
@Override
protected Dialog onCreateDialog(int id) {
if (id == ORBOT_DIALOG_ID) {
return new OrbotInstallerDialogBuilder(this, ORBOT_DIALOG_ID).create();
}
return super.onCreateDialog(id);
}
private static String getAccount(Intent intent) { private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent); return AccountIntentBuilder.getAccount(intent);
} }
...@@ -161,7 +150,7 @@ public class AccountEditor extends ManagedActivity implements ...@@ -161,7 +150,7 @@ public class AccountEditor extends ManagedActivity implements
@Override @Override
public void showOrbotDialog() { public void showOrbotDialog() {
showDialog(ORBOT_DIALOG_ID); OrbotInstallerDialogBuilder.show(this);
} }
@Override @Override
......
...@@ -46,7 +46,7 @@ public class AccountList extends BaseListEditor<String> implements ...@@ -46,7 +46,7 @@ public class AccountList extends BaseListEditor<String> implements
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default)); setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_accounts))); getSupportActionBar().setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_accounts)));
} }
@Override @Override
......
package com.xabber.android.ui.preferences;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.PreferenceSummaryHelper;
import com.xabber.androiddev.R;
public class ThemeSettings extends ManagedActivity
implements ThemeSettingsFragment.OnThemeSettingsFragmentInteractionListener {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isFinishing())
return;
setContentView(R.layout.activity_preferences);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar_default));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setTitle(PreferenceSummaryHelper.getPreferenceTitle(getString(R.string.preference_interface)));
if (savedInstanceState == null) {
getFragmentManager().beginTransaction()
.add(R.id.preferences_activity_container, new ThemeSettingsFragment()).commit();
}
}
@Override
public void onThemeChanged() {
ActivityManager.getInstance().clearStack(true);
startActivity(ContactList.createIntent(this));
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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