Commit 37a5ad52 authored by Grigory Fedorov's avatar Grigory Fedorov

Merge branch 'release/1.0.5'

parents 3ef61a50 7081e05d
......@@ -5,12 +5,10 @@ android {
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.xabber.androiddev"
minSdkVersion 14
targetSdkVersion 22
versionCode 175
versionName '1.0.3'
resValue 'string', 'application_package', applicationId
versionCode 177
versionName '1.0.5'
}
compileOptions {
......@@ -22,6 +20,20 @@ android {
// problems with generated "applicationId" string resource
disable 'MissingTranslation'
}
productFlavors {
dev {
applicationId "com.xabber.androiddev"
resValue 'string', 'application_package', applicationId
}
beta {
applicationId "com.xabber.android.beta"
resValue 'string', 'application_package', applicationId
}
}
}
repositories {
......
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2013, Redsolution LTD. All rights reserved.
<?xml version="1.0" encoding="utf-8"?><!-- 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.
......@@ -12,7 +11,8 @@
You should have received a copy of the GNU General Public License,
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
<string name="application_name">@string/development_title</string>
<resources>
<string name="application_title_short">Xabber</string>
<string name="application_title_full">Xabber Beta</string>
<string name="client_name">Xabber</string>
</resources>
<?xml version="1.0" encoding="utf-8"?><!-- 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/.
-->
<resources>
<string name="application_title_short">Xabber</string>
<string name="application_title_full">Xabber Dev</string>
<string name="client_name">Xabber</string>
</resources>
......@@ -13,7 +13,7 @@
along with this program. If not, see http://www.gnu.org/licenses/.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xabber.androiddev">
package="com.xabber.android">
<uses-feature android:name="android.hardware.touchscreen" android:required="false" />
<uses-feature android:name="android.hardware.location" android:required="false" />
......@@ -34,14 +34,14 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:label="@string/application_name"
android:icon="@drawable/ic_launcher"
android:name="com.xabber.android.data.Application"
android:theme="@style/Theme"
android:allowBackup="true">
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/application_title_full"
android:theme="@style/Theme">
<activity
android:label="@string/application_name"
android:name="com.xabber.android.ui.ContactList"
android:label="@string/application_title_full"
android:launchMode="singleTop"
>
<intent-filter>
......@@ -80,8 +80,8 @@
android:name="com.xabber.android.ui.LoadActivity"
/>
<activity
android:label="@string/about_viewer"
android:name="com.xabber.android.ui.preferences.AboutViewer"
android:label="@string/about_viewer"
android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor"
>
......@@ -91,8 +91,8 @@
android:value="com.xabber.android.ui.preferences.PreferenceEditor" />
</activity>
<activity
android:label="@string/preference_accounts"
android:name="com.xabber.android.ui.preferences.AccountList"
android:label="@string/preference_accounts"
android:parentActivityName="com.xabber.android.ui.preferences.PreferenceEditor"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -101,8 +101,8 @@
android:value="com.xabber.android.ui.preferences.PreferenceEditor" />
</activity>
<activity
android:label="@string/account_editor"
android:name="com.xabber.android.ui.preferences.AccountEditor"
android:label="@string/account_editor"
android:parentActivityName="com.xabber.android.ui.preferences.AccountList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -111,8 +111,8 @@
android:value="com.xabber.android.ui.preferences.AccountList" />
</activity>
<activity
android:label="@string/occupant_list"
android:name="com.xabber.android.ui.OccupantList"
android:label="@string/occupant_list"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -122,11 +122,11 @@
</activity>
<activity
android:label="@string/chat_viewer"
android:name="com.xabber.android.ui.ChatViewer"
android:windowSoftInputMode="adjustResize"
android:label="@string/chat_viewer"
android:launchMode="singleTop"
android:parentActivityName="com.xabber.android.ui.ContactList"
android:windowSoftInputMode="adjustResize"
>
<intent-filter>
......@@ -140,8 +140,8 @@
</activity>
<activity
android:label="@string/contact_editor"
android:name="com.xabber.android.ui.GroupEditor"
android:label="@string/contact_editor"
android:parentActivityName="com.xabber.android.ui.ContactViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -150,8 +150,8 @@
android:value="com.xabber.android.ui.ContactViewer" />
</activity>
<activity
android:label="@string/contact_add"
android:name="com.xabber.android.ui.ContactAdd"
android:label="@string/contact_add"
android:parentActivityName="com.xabber.android.ui.preferences.AccountList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -160,8 +160,8 @@
android:value="com.xabber.android.ui.preferences.AccountList" />
</activity>
<activity
android:label="@string/account_add"
android:name="com.xabber.android.ui.AccountAdd"
android:label="@string/account_add"
android:parentActivityName="com.xabber.android.ui.preferences.AccountList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -170,12 +170,12 @@
android:value="com.xabber.android.ui.preferences.AccountList" />
</activity>
<activity
android:label="@string/account_oauth"
android:name="com.xabber.android.ui.OAuthActivity"
android:label="@string/account_oauth"
/>
<activity
android:label="@string/muc_add"
android:name="com.xabber.android.ui.MUCEditor"
android:label="@string/muc_add"
android:parentActivityName="com.xabber.android.ui.ContactList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -184,8 +184,8 @@
android:value="com.xabber.android.ui.ContactList" />
</activity>
<activity
android:label="@string/status_editor"
android:name="com.xabber.android.ui.StatusEditor"
android:label="@string/status_editor"
android:parentActivityName="com.xabber.android.ui.ContactList"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -194,8 +194,8 @@
android:value="com.xabber.android.ui.ContactList" />
</activity>
<activity
android:label="@string/preference_editor"
android:name="com.xabber.android.ui.preferences.PreferenceEditor"
android:label="@string/preference_editor"
android:parentActivityName="com.xabber.android.ui.ContactList"
>
......@@ -206,8 +206,8 @@
</activity>
<activity
android:label="@string/chat_settings"
android:name="com.xabber.android.ui.preferences.ChatEditor"
android:label="@string/chat_settings"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
......@@ -218,8 +218,8 @@
</activity>
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.ContactViewer"
android:label="@string/contact_viewer"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -237,8 +237,8 @@
</activity>
<activity
android:label="@string/contact_viewer"
android:name="com.xabber.android.ui.ContactEditor"
android:label="@string/contact_viewer"
android:parentActivityName="com.xabber.android.ui.ChatViewer"
>
<!-- Parent activity meta-data to support 4.0 and lower -->
......@@ -322,13 +322,13 @@
android:name="com.xabber.android.ui.ReconnectionActivity"
/>
<activity
android:label="ClearNotifications"
android:name="com.xabber.android.ui.ClearNotifications"
android:taskAffinity=""
android:excludeFromRecents="true"
android:label="ClearNotifications"
android:launchMode="singleInstance"
android:noHistory="true"
android:stateNotNeeded="true"
android:excludeFromRecents="true"
android:taskAffinity=""
/>
<activity
......
......@@ -20,9 +20,9 @@ import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.LoadActivity;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Iterator;
......@@ -39,40 +39,31 @@ public class ActivityManager implements OnUnloadListener {
private static final String EXTRA_TASK_INDEX = "com.xabber.android.data.ActivityManager.EXTRA_TASK_INDEX";
private static final boolean LOG = true;
private final static ActivityManager instance;
private final Application application;
static {
instance = new ActivityManager();
Application.getInstance().addManager(instance);
}
private final Application application;
/**
* List of launched activities.
*/
private final ArrayList<Activity> activities;
/**
* Next index of task.
*/
private int nextTaskIndex;
/**
* Activity with index of it task.
*/
private final WeakHashMap<Activity, Integer> taskIndexes;
/**
* Next index of task.
*/
private int nextTaskIndex;
/**
* Listener for errors.
*/
private OnErrorListener onErrorListener;
private final static ActivityManager instance;
static {
instance = new ActivityManager();
Application.getInstance().addManager(instance);
}
public static ActivityManager getInstance() {
return instance;
}
private ActivityManager() {
this.application = Application.getInstance();
activities = new ArrayList<Activity>();
......@@ -80,6 +71,10 @@ public class ActivityManager implements OnUnloadListener {
taskIndexes = new WeakHashMap<Activity, Integer>();
}
public static ActivityManager getInstance() {
return instance;
}
/**
* Removes finished activities from stask.
*/
......
......@@ -14,6 +14,14 @@
*/
package com.xabber.android.data;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.os.Handler;
import com.xabber.android.R;
import com.xabber.android.service.XabberService;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
......@@ -26,14 +34,6 @@ import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadFactory;
import android.app.Activity;
import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.os.Handler;
import com.xabber.android.service.XabberService;
import com.xabber.androiddev.R;
/**
* Base entry point.
*
......@@ -42,64 +42,42 @@ import com.xabber.androiddev.R;
public class Application extends android.app.Application {
private static Application instance;
public static Application getInstance() {
if (instance == null)
throw new IllegalStateException();
return instance;
}
private final ArrayList<Object> registeredManagers;
/**
* Unmodifiable collections of managers that implement some common
* interface.
*/
private Map<Class<? extends BaseManagerInterface>, Collection<? extends BaseManagerInterface>> managerInterfaces;
private Map<Class<? extends BaseUIListener>, Collection<? extends BaseUIListener>> uiListeners;
/**
* Thread to execute tasks in background..
*/
private final ExecutorService backgroundExecutor;
/**
* Handler to execute runnable in UI thread.
*/
private final Handler handler;
/**
* Unmodifiable collections of managers that implement some common
* interface.
*/
private Map<Class<? extends BaseManagerInterface>, Collection<? extends BaseManagerInterface>> managerInterfaces;
private Map<Class<? extends BaseUIListener>, Collection<? extends BaseUIListener>> uiListeners;
/**
* Where data load was requested.
*/
private boolean serviceStarted;
/**
* Whether application was initialized.
*/
private boolean initialized;
/**
* Whether user was notified about some action in contact list activity
* after application initialization.
*/
private boolean notified;
/**
* Whether application is to be closed.
*/
private boolean closing;
/**
* Whether {@link #onServiceDestroy()} has been called.
*/
private boolean closed;
/**
* Future for loading process.
*/
private Future<Void> loadFuture;
private final Runnable timerRunnable = new Runnable() {
@Override
......@@ -111,6 +89,10 @@ public class Application extends android.app.Application {
}
};
/**
* Future for loading process.
*/
private Future<Void> loadFuture;
public Application() {
instance = this;
......@@ -137,6 +119,12 @@ public class Application extends android.app.Application {
});
}
public static Application getInstance() {
if (instance == null)
throw new IllegalStateException();
return instance;
}
/**
* Whether application is initialized.
*/
......
......@@ -23,6 +23,7 @@ import android.preference.PreferenceManager;
import android.provider.Settings;
import android.text.TextUtils;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.connection.NetworkManager;
......@@ -34,7 +35,6 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.service.XabberService;
import com.xabber.android.ui.adapter.ComparatorByName;
import com.xabber.android.ui.adapter.ComparatorByStatus;
import com.xabber.androiddev.R;
import com.xabber.xmpp.carbon.CarbonManager;
import java.util.Comparator;
......@@ -47,145 +47,6 @@ import java.util.Comparator;
public class SettingsManager implements OnInitializedListener,
OnMigrationListener, OnSharedPreferenceChangeListener {
public static enum ChatsHistory {
/**
* Don't store chat messages.
*/
none,
/**
* Store only unread messages.
*/
unread,
/**
* Store all messages.
*/
all;
}
public static enum InterfaceTheme {
/**
* All windows will be dark.
*/
dark,
/**
* All windows will be light.
*/
light,
/**
* Chat will be light, other windows will be dark.
*/
normal;
}
public static enum EventsMessage {
/**
* Never notify.
*/
none,
/**
* Notify in chat only.
*/
chat,
/**
* Notify in chat and muc.
*/
chatAndMuc;
}
;
public enum ChatsShowStatusChange {
/**
* Always show status change.
*/
always,
/**
* Show status change only in MUC.
*/
muc,
/**
* Never show status change.
*/
never;
}
public enum ChatsHideKeyboard {
/**
* Always hide keyboard.
*/
always,
/**
* Hide keyboard only in landscape mode.
*/
landscape,
/**
* Never hide keyboard.
*/
never,
}
public enum ChatsDivide {
/**
* Always divide message header from text.
*/
always,
/**
* Only in portial mode.
*/
portial,
/**
* Never.
*/
never;
}
public enum SecurityOtrMode {
/**
* OTR is disabled.
*/
disabled,
/**
* Manually send request and confirm requests.
*/
manual,
/**
* Automatically try to use OTR.
*/
auto,
/**
* Require to use OTR.
*/
required;
}
private static final SettingsManager instance;
static {
......@@ -193,17 +54,12 @@ public class SettingsManager implements OnInitializedListener,
Application.getInstance().addManager(instance);
}
public static SettingsManager getInstance() {
return instance;
}
private SettingsManager() {
getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
}
@Override
public void onInitialized() {
incrementBootCount();
public static SettingsManager getInstance() {
return instance;
}
private static SharedPreferences getSharedPreferences() {
......@@ -699,6 +555,11 @@ public class SettingsManager implements OnInitializedListener,
setString(R.string.status_text_key, statusText);
}
@Override
public void onInitialized() {
incrementBootCount();
}
@Override
public void onMigrate(int toVersion) {
switch (toVersion) {
......@@ -771,4 +632,141 @@ public class SettingsManager implements OnInitializedListener,
}
}
public enum ChatsHistory {
/**
* Don't store chat messages.
*/
none,
/**
* Store only unread messages.
*/
unread,
/**
* Store all messages.
*/
all
}
public enum InterfaceTheme {
/**
* All windows will be dark.
*/
dark,
/**
* All windows will be light.
*/
light,
/**
* Chat will be light, other windows will be dark.
*/
normal
}
public enum EventsMessage {
/**
* Never notify.
*/
none,
/**
* Notify in chat only.
*/
chat,
/**
* Notify in chat and muc.
*/
chatAndMuc
}
public enum ChatsShowStatusChange {
/**
* Always show status change.
*/
always,
/**
* Show status change only in MUC.
*/
muc,
/**
* Never show status change.
*/
never
}
public enum ChatsHideKeyboard {
/**
* Always hide keyboard.
*/
always,
/**
* Hide keyboard only in landscape mode.
*/
landscape,
/**
* Never hide keyboard.
*/
never,
}
public enum ChatsDivide {
/**
* Always divide message header from text.
*/
always,
/**
* Only in portial mode.
*/
portial,
/**
* Never.
*/
never
}
public enum SecurityOtrMode {
/**
* OTR is disabled.
*/
disabled,
/**
* Manually send request and confirm requests.
*/
manual,
/**
* Automatically try to use OTR.
*/
auto,
/**
* Require to use OTR.
*/
required
}
}
\ No newline at end of file
package com.xabber.android.data;
import com.xabber.androiddev.R;
import com.xabber.android.R;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
import com.xabber.xmpp.vcard.EmailType;
......
......@@ -16,11 +16,11 @@ package com.xabber.android.data.account;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.AccountRelated;
import com.xabber.android.data.notification.AccountNotificationItem;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.androiddev.R;
public class AccountAuthorizationError extends AccountRelated implements
AccountNotificationItem {
......
......@@ -14,6 +14,7 @@
*/
package com.xabber.android.data.account;
import com.xabber.android.R;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.connection.ConnectionItem;
......@@ -21,7 +22,6 @@ import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.connection.ConnectionThread;
import com.xabber.android.data.connection.ProxyType;
import com.xabber.android.data.connection.TLSMode;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Type;
......@@ -37,20 +37,17 @@ import java.util.Date;
public class AccountItem extends ConnectionItem {
public static final String UNDEFINED_PASSWORD = "com.xabber.android.data.core.AccountItem.UNDEFINED_PASSWORD";
/**
* Full jid calculated according to {@link #userName}, {@link #serverName},
* {@link #resource}.
*/
private final String account;
/**
* Id in database.
* <p/>
* MUST BE USED FROM BACKGROUND THREAD ONLY!
*/
private Long id;
/**
* Full jid calculated according to {@link #userName}, {@link #serverName},
* {@link #resource}.
*/
private final String account;
private int colorIndex;
/**
......@@ -131,6 +128,14 @@ public class AccountItem extends ConnectionItem {
passwordRequested = false;
}
/**
* @param priority
* @return Valid priority value between -128 and 128.
*/
static private int getValidPriority(int priority) {
return Math.min(128, Math.max(-128, priority));
}
/**
* @return ID in database.
*/
......@@ -163,6 +168,10 @@ public class AccountItem extends ConnectionItem {
return colorIndex;
}
public void setColorIndex(int colorIndex) {
this.colorIndex = colorIndex;
}
/**
* @return Whether roster contacts can be synchronized with system contact
* list.
......@@ -427,16 +436,4 @@ public class AccountItem extends ConnectionItem {
public String toString() {
return super.toString() + ":" + getAccount();
}
/**
* @param priority
* @return Valid priority value between -128 and 128.
*/
static private int getValidPriority(int priority) {
return Math.min(128, Math.max(-128, priority));
}
public void setColorIndex(int colorIndex) {
this.colorIndex = colorIndex;
}
}
......@@ -18,6 +18,7 @@ import android.content.res.TypedArray;
import android.database.Cursor;
import android.os.Build;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.OnLoadListener;
......@@ -32,7 +33,6 @@ import com.xabber.android.data.notification.BaseAccountNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import org.jivesoftware.smack.util.StringUtils;
......@@ -60,58 +60,47 @@ import java.util.Map;
*/
public class AccountManager implements OnLoadListener, OnWipeListener {
private final static AccountManager instance;
static {
instance = new AccountManager();
Application.getInstance().addManager(instance);
}
/**
* List of account presets.
*/
private final List<AccountType> accountTypes;
/**
* List of saved statuses.
*/
private final Collection<SavedStatus> savedStatuses;
/**
* Number of different account colors.
*/
private final int colors;
/**
* List of accounts.
*/
private final Map<String, AccountItem> accountItems;
/**
* List of enabled account.
*/
private final Collection<String> enabledAccounts;
private final BaseAccountNotificationProvider<AccountAuthorizationError> authorizationErrorProvider;
private final BaseAccountNotificationProvider<PasswordRequest> passwordRequestProvider;
private final Application application;
/**
* Whether away status mode is enabled.
*/
private boolean away;
/**
* Whether extended away mode is enabled.
*/
private boolean xa;
private final BaseAccountNotificationProvider<AccountAuthorizationError> authorizationErrorProvider;
private final BaseAccountNotificationProvider<PasswordRequest> passwordRequestProvider;
private final Application application;
private final static AccountManager instance;
static {
instance = new AccountManager();
Application.getInstance().addManager(instance);
}
public static AccountManager getInstance() {
return instance;
}
private AccountManager() {
this.application = Application.getInstance();
accountItems = new HashMap<>();
......@@ -148,6 +137,10 @@ public class AccountManager implements OnLoadListener, OnWipeListener {
xa = false;
}
public static AccountManager getInstance() {
return instance;
}
@Override
public void onLoad() {
final Collection<SavedStatus> savedStatuses = new ArrayList<>();
......
......@@ -14,7 +14,7 @@
*/
package com.xabber.android.data.account;
import com.xabber.androiddev.R;
import com.xabber.android.R;
/**
* Supported account protocols.
......
......@@ -16,10 +16,10 @@ package com.xabber.android.data.account;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.AccountRelated;
import com.xabber.android.data.notification.AccountNotificationItem;
import com.xabber.androiddev.R;
public class PasswordRequest extends AccountRelated implements
AccountNotificationItem {
......
......@@ -14,11 +14,11 @@
*/
package com.xabber.android.data.account;
import com.xabber.android.R;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
import com.xabber.androiddev.R;
/**
* Status mode.
*
......
......@@ -14,10 +14,12 @@
*/
package com.xabber.android.data.account;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
import android.net.Uri;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
......@@ -35,31 +37,13 @@ import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import android.net.Uri;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import com.xabber.androiddev.R;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.List;
class WLMManager implements OAuthProvider {
private static enum GrantType {
authorizationCode("authorization_code", "code"),
refreshToken("refresh_token", "refresh_token");
public final String name;
public final String value;
private GrantType(String name, String value) {
this.name = name;
this.value = value;
}
}
private static final String WLM_CLIENT_SECRET = "XEazfSKu0Iu2pt6Z64Lqm-1cRxtEYgS0";
private static final String WLM_CLIENT_ID = "00000000440923FF";
private static final String WLM_SCOPE = "wl.messenger wl.offline_access";
......@@ -69,7 +53,6 @@ class WLMManager implements OAuthProvider {
private static final String WLM_REDIRECT_URL = new Uri.Builder()
.scheme(WLM_SCHEME).authority(WLM_AUTHORITY)
.path(WLM_REDIRECT_PATH).build().toString();
private final static WLMManager instance;
static {
......@@ -77,11 +60,11 @@ class WLMManager implements OAuthProvider {
Application.getInstance().addManager(instance);
}
public static WLMManager getInstance() {
return instance;
private WLMManager() {
}
private WLMManager() {
public static WLMManager getInstance() {
return instance;
}
/**
......@@ -205,4 +188,20 @@ class WLMManager implements OAuthProvider {
&& WLM_REDIRECT_PATH.equals(uri.getPath());
}
private enum GrantType {
authorizationCode("authorization_code", "code"),
refreshToken("refresh_token", "refresh_token");
public final String name;
public final String value;
GrantType(String name, String value) {
this.name = name;
this.value = value;
}
}
}
......@@ -14,7 +14,7 @@
*/
package com.xabber.android.data.connection;
import com.xabber.androiddev.R;
import com.xabber.android.R;
/**
* Possible reasons for certificate invalidation.
......
......@@ -16,13 +16,13 @@ package com.xabber.android.data.connection;
import android.content.res.AssetManager;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.OnClearListener;
import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.notification.BaseNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.CertificateListener;
import org.jivesoftware.smack.util.StringUtils;
......@@ -79,20 +79,18 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
.getFilesDir(), reason.toString() + ".bsk"));
}
public static CertificateManager getInstance() {
return instance;
}
/**
* Key store for confirmed certificates.
*/
private final Map<CertificateInvalidReason, KeyStore> keyStores;
/**
* Key store for preset certificates.
*/
private final Map<CertificateInvalidReason, KeyStore> defaultStores;
/**
* Certificate issues not to be displayed to the user.
*/
private final Collection<PendingCertificate> ignoreCertificates;
private final BaseNotificationProvider<PendingCertificate> pendingCertificateProvider = new BaseNotificationProvider<PendingCertificate>(
R.drawable.ic_stat_error) {
......@@ -104,42 +102,14 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
};
/**
* Certificate issues not to be displayed to the user.
*/
private final Collection<PendingCertificate> ignoreCertificates;
private CertificateManager() {
defaultStores = new HashMap<CertificateInvalidReason, KeyStore>();
keyStores = new ConcurrentHashMap<CertificateInvalidReason, KeyStore>();
ignoreCertificates = new ArrayList<PendingCertificate>();
}
@Override
public void onLoad() {
final Map<CertificateInvalidReason, KeyStore> defaultStores = new HashMap<CertificateInvalidReason, KeyStore>();
final Map<CertificateInvalidReason, KeyStore> keyStores = new HashMap<CertificateInvalidReason, KeyStore>();
AssetManager assetManager = Application.getInstance().getResources()
.getAssets();
for (CertificateInvalidReason reason : CertificateInvalidReason
.values()) {
InputStream stream;
try {
stream = assetManager.open(reason.toString() + ".bsk");
} catch (IOException e) {
stream = null;
}
defaultStores.put(reason, loadKeyStore(stream));
stream = getInputStream(KEY_FILES.get(reason));
if (stream != null)
keyStores.put(reason, loadKeyStore(stream));
}
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
onLoaded(defaultStores, keyStores);
}
});
public static CertificateManager getInstance() {
return instance;
}
private static InputStream getInputStream(File file) {
......@@ -179,6 +149,89 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
return keyStore;
}
/**
* @param fingerprint
* @param reason
* @param collection
* @return Pending certificate or <code>null</code>.
*/
private static PendingCertificate getPendingCertificate(String fingerprint,
CertificateInvalidReason reason,
Collection<PendingCertificate> collection) {
for (PendingCertificate pendingCertificate : collection)
if (pendingCertificate.getFingerprint().equals(fingerprint)
&& reason == pendingCertificate.getReason())
return pendingCertificate;
return null;
}
/**
* @param x509Certificate
* @return Finger print for the given certificate.
*/
private static String getFingerprint(X509Certificate x509Certificate) {
byte[] data;
try {
data = x509Certificate.getEncoded();
} catch (CertificateEncodingException e) {
LogManager.exception(PendingCertificate.class, e);
return INVALID;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
LogManager.exception(PendingCertificate.class, e);
return INVALID;
}
digest.update(data);
byte[] bytes = digest.digest();
return StringUtils.encodeHex(bytes);
}
/**
* @param fingerprint
* @return Formatted fingerprint to be shown.
*/
public static String showFingerprint(String fingerprint) {
if (fingerprint == null)
return null;
StringBuffer buffer = new StringBuffer();
for (int index = 0; index < fingerprint.length(); index++) {
if (index > 0 && index % 2 == 0)
buffer.append(':');
buffer.append(fingerprint.charAt(index));
}
return buffer.toString().toUpperCase();
}
@Override
public void onLoad() {
final Map<CertificateInvalidReason, KeyStore> defaultStores = new HashMap<CertificateInvalidReason, KeyStore>();
final Map<CertificateInvalidReason, KeyStore> keyStores = new HashMap<CertificateInvalidReason, KeyStore>();
AssetManager assetManager = Application.getInstance().getResources()
.getAssets();
for (CertificateInvalidReason reason : CertificateInvalidReason
.values()) {
InputStream stream;
try {
stream = assetManager.open(reason.toString() + ".bsk");
} catch (IOException e) {
stream = null;
}
defaultStores.put(reason, loadKeyStore(stream));
stream = getInputStream(KEY_FILES.get(reason));
if (stream != null)
keyStores.put(reason, loadKeyStore(stream));
}
Application.getInstance().runOnUiThread(new Runnable() {
@Override
public void run() {
onLoaded(defaultStores, keyStores);
}
});
}
/**
* Create new key store instance based on default key store.
*
......@@ -255,22 +308,6 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
return false;
}
/**
* @param fingerprint
* @param reason
* @param collection
* @return Pending certificate or <code>null</code>.
*/
private static PendingCertificate getPendingCertificate(String fingerprint,
CertificateInvalidReason reason,
Collection<PendingCertificate> collection) {
for (PendingCertificate pendingCertificate : collection)
if (pendingCertificate.getFingerprint().equals(fingerprint)
&& reason == pendingCertificate.getReason())
return pendingCertificate;
return null;
}
public PendingCertificate getPendingCertificate(String fingerprint,
CertificateInvalidReason reason) {
return getPendingCertificate(fingerprint, reason,
......@@ -354,46 +391,6 @@ public class CertificateManager implements OnLoadListener, OnClearListener {
ignoreCertificates.add(pendingCertificate);
}
/**
* @param x509Certificate
* @return Finger print for the given certificate.
*/
private static String getFingerprint(X509Certificate x509Certificate) {
byte[] data;
try {
data = x509Certificate.getEncoded();
} catch (CertificateEncodingException e) {
LogManager.exception(PendingCertificate.class, e);
return INVALID;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
LogManager.exception(PendingCertificate.class, e);
return INVALID;
}
digest.update(data);
byte[] bytes = digest.digest();
return StringUtils.encodeHex(bytes);
}
/**
* @param fingerprint
* @return Formatted fingerprint to be shown.
*/
public static String showFingerprint(String fingerprint) {
if (fingerprint == null)
return null;
StringBuffer buffer = new StringBuffer();
for (int index = 0; index < fingerprint.length(); index++) {
if (index > 0 && index % 2 == 0)
buffer.append(':');
buffer.append(fingerprint.charAt(index));
}
return buffer.toString().toUpperCase();
}
@Override
public void onClear() {
for (File file : KEY_FILES.values())
......
......@@ -14,12 +14,12 @@
*/
package com.xabber.android.data.connection;
import org.jivesoftware.smack.XMPPConnection;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.account.AccountProtocol;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.XMPPConnection;
/**
* Abstract connection.
......@@ -214,7 +214,6 @@ public abstract class ConnectionItem {
}
}
;
};
thread.setPriority(Thread.MIN_PRIORITY);
thread.setDaemon(true);
......
......@@ -14,23 +14,7 @@
*/
package com.xabber.android.data.connection;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map.Entry;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -40,10 +24,26 @@ import com.xabber.android.data.OnTimerListener;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.entity.NestedMap;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.wlm.XMessengerOAuth2;
import org.jivesoftware.smack.Connection;
import org.jivesoftware.smack.ConnectionCreationListener;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.Iterator;
import java.util.Map.Entry;
/**
* Connection manager.
*
......@@ -61,18 +61,6 @@ public class ConnectionManager implements OnInitializedListener,
* Path to the trust store in this system.
*/
public final static String TRUST_STORE_PATH;
/**
* List of managed connection. Only managed connections can notify
* registered listeners.
*/
private final Collection<ConnectionThread> managedConnections;
/**
* Request holders for its packet id in accounts.
*/
private final NestedMap<RequestHolder> requests;
private final static ConnectionManager instance;
static {
......@@ -107,15 +95,25 @@ public class ConnectionManager implements OnInitializedListener,
});
}
public static ConnectionManager getInstance() {
return instance;
}
/**
* List of managed connection. Only managed connections can notify
* registered listeners.
*/
private final Collection<ConnectionThread> managedConnections;
/**
* Request holders for its packet id in accounts.
*/
private final NestedMap<RequestHolder> requests;
private ConnectionManager() {
managedConnections = new ArrayList<ConnectionThread>();
requests = new NestedMap<RequestHolder>();
}
public static ConnectionManager getInstance() {
return instance;
}
@Override
public void onInitialized() {
updateConnections(false);
......
......@@ -14,7 +14,7 @@
*/
package com.xabber.android.data.connection;
import com.xabber.androiddev.R;
import com.xabber.android.R;
/**
* State of connection.
......
......@@ -14,18 +14,18 @@
*/
package com.xabber.android.data.connection;
import java.security.Principal;
import java.security.cert.X509Certificate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.notification.NotificationItem;
import com.xabber.android.ui.CertificateConfirmation;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.security.Principal;
import java.security.cert.X509Certificate;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class PendingCertificate implements NotificationItem {
......
......@@ -16,12 +16,12 @@ package com.xabber.android.data.extension.archive;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.entity.AccountRelated;
import com.xabber.android.data.notification.AccountNotificationItem;
import com.xabber.android.ui.ArchiveRequest;
import com.xabber.androiddev.R;
public class AvailableArchiveRequest extends AccountRelated implements
AccountNotificationItem {
......
......@@ -14,6 +14,7 @@
*/
package com.xabber.android.data.extension.archive;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -39,7 +40,6 @@ import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.BaseAccountNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.archive.AbstractMessage;
import com.xabber.xmpp.archive.Auto;
......@@ -93,66 +93,52 @@ public class MessageArchiveManager implements OnPacketListener,
private static final String FEATURE_ARCH = "urn:xmpp:archive";
private static final String FEATURE_PREF = "urn:xmpp:archive:pref";
private static final String FEATURE_MANAGE = "urn:xmpp:archive:manage";
private final static MessageArchiveManager instance;
static {
instance = new MessageArchiveManager(Application.getInstance());
Application.getInstance().addManager(instance);
}
/**
* Custom auto setting per account.
*/
private final Map<String, Boolean> saves;
/**
* Default settings for each account.
*/
private final Map<String, ArchivePreference> defaults;
/**
* Per user settings for each account.
*/
private final Map<String, Map<MatchMode, Map<String, ArchivePreference>>> items;
/**
* Settings for session in each account.
*/
private final NestedMap<SaveMode> sessionSaves;
/**
* Contains whether chat modification has been requested for the given
* packet id in the accounts.
*/
private final NestedMap<Boolean> modificationRequests;
/**
* Store information about modifications received from the server.
*/
private final Map<String, ModificationStorage> modificationStorages;
/**
* Server side timestamp when connection has been established.
*/
private final Map<String, Date> connected;
/**
* Store current history request state for the user in each account.
*/
private final NestedMap<HistoryStorage> historyStorages;
/**
* Chat storages for tags for users in accounts.
*/
private final NestedNestedMaps<String, ChatStorage> chatStorages;
private final BaseAccountNotificationProvider<AvailableArchiveRequest> availableArchiveRequestProvider;
private final static MessageArchiveManager instance;
static {
instance = new MessageArchiveManager(Application.getInstance());
Application.getInstance().addManager(instance);
}
public static MessageArchiveManager getInstance() {
return instance;
}
private MessageArchiveManager(Application application) {
saves = new HashMap<String, Boolean>();
defaults = new HashMap<String, ArchivePreference>();
......@@ -167,6 +153,10 @@ public class MessageArchiveManager implements OnPacketListener,
R.drawable.ic_stat_ic_help_black);
}
public static MessageArchiveManager getInstance() {
return instance;
}
@Override
public void onLoad() {
Application.getInstance().runOnUiThread(new Runnable() {
......
......@@ -17,6 +17,7 @@ package com.xabber.android.data.extension.attention;
import android.media.AudioManager;
import android.net.Uri;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.OnLoadListener;
......@@ -38,7 +39,6 @@ import com.xabber.android.data.notification.EntityNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.attention.Attention;
......@@ -82,10 +82,6 @@ public class AttentionManager implements OnPacketListener, OnLoadListener {
});
}
public static AttentionManager getInstance() {
return instance;
}
private final EntityNotificationProvider<AttentionRequest> attentionRequestProvider = new EntityNotificationProvider<AttentionRequest>(
R.drawable.ic_stat_error) {
......@@ -104,6 +100,10 @@ public class AttentionManager implements OnPacketListener, OnLoadListener {
public AttentionManager() {
}
public static AttentionManager getInstance() {
return instance;
}
public void onSettingsChanged() {
synchronized (enabledLock) {
for (String account : AccountManager.getInstance().getAccounts()) {
......
......@@ -16,12 +16,12 @@ package com.xabber.android.data.extension.attention;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ChatViewer;
import com.xabber.androiddev.R;
public class AttentionRequest extends BaseEntity implements
EntityNotificationItem {
......
......@@ -23,6 +23,7 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.OnLowMemoryListener;
......@@ -33,7 +34,6 @@ import com.xabber.android.data.account.OAuthManager;
import com.xabber.android.data.connection.ConnectionItem;
import com.xabber.android.data.connection.OnPacketListener;
import com.xabber.android.data.extension.vcard.VCardManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.avatar.VCardUpdate;
......
......@@ -16,6 +16,7 @@ package com.xabber.android.data.extension.muc;
import android.database.Cursor;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -32,7 +33,6 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.EntityNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.muc.MUC;
import org.jivesoftware.smack.XMPPConnection;
......@@ -55,10 +55,6 @@ import java.util.Collections;
*/
public class MUCManager implements OnLoadListener, OnPacketListener {
private final EntityNotificationProvider<RoomInvite> inviteProvider;
private final EntityNotificationProvider<RoomAuthorizationError> authorizationErrorProvider;
private final static MUCManager instance;
static {
......@@ -66,9 +62,8 @@ public class MUCManager implements OnLoadListener, OnPacketListener {
Application.getInstance().addManager(instance);
}
public static MUCManager getInstance() {
return instance;
}
private final EntityNotificationProvider<RoomInvite> inviteProvider;
private final EntityNotificationProvider<RoomAuthorizationError> authorizationErrorProvider;
private MUCManager() {
inviteProvider = new EntityNotificationProvider<RoomInvite>(
......@@ -77,6 +72,10 @@ public class MUCManager implements OnLoadListener, OnPacketListener {
R.drawable.ic_stat_error);
}
public static MUCManager getInstance() {
return instance;
}
@Override
public void onLoad() {
final Collection<RoomChat> roomChats = new ArrayList<RoomChat>();
......
......@@ -16,11 +16,11 @@ package com.xabber.android.data.extension.muc;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.ui.MUCEditor;
import com.xabber.androiddev.R;
public class RoomAuthorizationError extends BaseEntity implements
EntityNotificationItem {
......
......@@ -14,21 +14,7 @@
*/
package com.xabber.android.data.extension.muc;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.packet.MUCUser;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.SettingsManager.ChatsShowStatusChange;
......@@ -37,13 +23,27 @@ import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.ChatAction;
import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.delay.Delay;
import com.xabber.xmpp.muc.Affiliation;
import com.xabber.xmpp.muc.MUC;
import com.xabber.xmpp.muc.Role;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Message.Type;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.muc.MultiUserChat;
import org.jivesoftware.smackx.packet.MUCUser;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.NoSuchElementException;
/**
* Chat room.
* <p/>
......@@ -53,35 +53,30 @@ import com.xabber.xmpp.muc.Role;
*/
public class RoomChat extends AbstractChat {
/**
* Information about occupants for STRING-PREPed resource.
*/
private final Map<String, Occupant> occupants;
/**
* Invited user for the sent packet ID.
*/
private final Map<String, String> invites;
/**
* Joining was requested from the UI.
*/
private boolean requested;
/**
* Nickname used in the room.
*/
private String nickname;
private String password;
private RoomState state;
private String subject;
/**
* SMACK MUC implementation.
*/
private MultiUserChat multiUserChat;
/**
* Information about occupants for STRING-PREPed resource.
*/
private final Map<String, Occupant> occupants;
/**
* Invited user for the sent packet ID.
*/
private final Map<String, String> invites;
RoomChat(String account, String user, String nickname, String password) {
super(account, user);
this.nickname = nickname;
......
......@@ -16,13 +16,13 @@ package com.xabber.android.data.extension.muc;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.MUCInvite;
import com.xabber.androiddev.R;
/**
* Invite to join the room.
......
......@@ -16,6 +16,8 @@ package com.xabber.android.data.extension.otr;
import android.database.Cursor;
import com.xabber.android.BuildConfig;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -39,8 +41,6 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.EntityNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.BuildConfig;
import com.xabber.androiddev.R;
import com.xabber.xmpp.archive.OtrMode;
import com.xabber.xmpp.archive.SaveMode;
......@@ -77,6 +77,7 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
OnLoadListener, OnAccountAddedListener, OnAccountRemovedListener,
OnCloseListener {
private final static OTRManager instance;
private static Map<SecurityOtrMode, OtrPolicy> POLICIES;
static {
......@@ -91,42 +92,30 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
OtrPolicy.OTRL_POLICY_ALWAYS & ~OtrPolicy.ALLOW_V1));
}
private final EntityNotificationProvider<SMRequest> smRequestProvider;
private final EntityNotificationProvider<SMProgress> smProgressProvider;
private final static OTRManager instance;
static {
instance = new OTRManager();
Application.getInstance().addManager(instance);
}
public static OTRManager getInstance() {
return instance;
}
private final EntityNotificationProvider<SMRequest> smRequestProvider;
private final EntityNotificationProvider<SMProgress> smProgressProvider;
/**
* Accepted fingerprints for user in account.
*/
private final NestedNestedMaps<String, Boolean> fingerprints;
/**
* Fingerprint of encrypted or encrypted and verified session for user in
* account.
*/
private final NestedMap<String> actives;
/**
* Finished entity's sessions for users in accounts.
*/
private final NestedMap<Boolean> finished;
/**
* Used OTR sessions for users in accounts.
*/
private final NestedMap<Session> sessions;
/**
* Service for keypair generation.
*/
......@@ -155,6 +144,10 @@ public class OTRManager implements OtrEngineHost, OtrEngineListener,
});
}
public static OTRManager getInstance() {
return instance;
}
@Override
public void onLoad() {
final NestedNestedMaps<String, Boolean> fingerprints = new NestedNestedMaps<String, Boolean>();
......
......@@ -16,12 +16,12 @@ package com.xabber.android.data.extension.otr;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.QuestionViewer;
import com.xabber.androiddev.R;
public class SMProgress extends BaseEntity implements EntityNotificationItem {
......
......@@ -16,12 +16,12 @@ package com.xabber.android.data.extension.otr;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.QuestionViewer;
import com.xabber.androiddev.R;
public class SMRequest extends BaseEntity implements EntityNotificationItem {
......
......@@ -16,8 +16,8 @@ package com.xabber.android.data.message;
import android.content.Context;
import com.xabber.android.R;
import com.xabber.android.data.account.StatusMode;
import com.xabber.androiddev.R;
/**
* Action in chat.
......
......@@ -14,14 +14,10 @@
*/
package com.xabber.android.data.message;
import java.util.Date;
import android.text.Spannable;
import android.text.Html;
import android.text.SpannableString;
import android.text.util.Linkify;
import com.xabber.xmpp.uri.XMPPUri;
import java.util.Date;
/**
* Message item.
......@@ -31,76 +27,62 @@ import com.xabber.xmpp.uri.XMPPUri;
public class MessageItem implements Comparable<MessageItem> {
private final AbstractChat chat;
/**
* Tag used to identify collection in server side message archive. Equals to
* collection's start attribute.
*/
private String tag;
/**
* Contact's resource.
*/
private final String resource;
/**
* Text representation.
*/
private final String text;
/**
* Cached text populated with smiles and link.
*/
private Spannable spannable;
/**
* Optional action. If set message represent not an actual message but some
* action in the chat.
*/
private final ChatAction action;
private final boolean incoming;
private final boolean unencypted;
/**
* Message was received from server side offline storage.
*/
private final boolean offline;
/**
* Tag used to identify collection in server side message archive. Equals to
* collection's start attribute.
*/
private String tag;
/**
* Cached text populated with smiles and link.
*/
private Spannable spannable;
/**
* Time when message was received or sent by Xabber.
*/
private Date timestamp;
/**
* Time when message was created.
*/
private Date delayTimestamp;
private final boolean incoming;
private final boolean unencypted;
/**
* ID in database.
*/
private Long id;
/**
* Error response received on send request.
*/
private boolean error;
/**
* Receipt was received for sent message.
*/
private boolean delivered;
/**
* Message was sent.
*/
private boolean sent;
/**
* Message was shown to the user.
*/
private boolean read;
/**
* Message was received from server side offline storage.
*/
private final boolean offline;
/**
* Outgoing packet id.
*/
......@@ -146,14 +128,12 @@ public class MessageItem implements Comparable<MessageItem> {
}
public String getText() {
return Html.fromHtml(text).toString();
return text;
}
public Spannable getSpannable() {
if (spannable == null) {
spannable = new SpannableString(Html.fromHtml(text));
Linkify.addLinks(this.spannable, Linkify.ALL);
XMPPUri.addLinks(this.spannable);
spannable = new SpannableString(text);
}
return spannable;
}
......
......@@ -17,6 +17,7 @@ package com.xabber.android.data.message;
import android.database.Cursor;
import android.os.Environment;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.OnLoadListener;
......@@ -39,7 +40,6 @@ import com.xabber.android.data.roster.OnRosterReceivedListener;
import com.xabber.android.data.roster.OnStatusChangeListener;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.carbon.CarbonManager.Direction;
import com.xabber.xmpp.delay.Delay;
......
......@@ -9,6 +9,7 @@ import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.StyleSpan;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.extension.avatar.AvatarManager;
......@@ -20,7 +21,6 @@ import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ChatViewer;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.util.List;
......
......@@ -24,6 +24,7 @@ import android.os.Handler;
import android.os.Vibrator;
import android.support.v4.app.NotificationCompat;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.OnCloseListener;
......@@ -45,7 +46,6 @@ import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.ReconnectionActivity;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
......@@ -154,7 +154,7 @@ public class NotificationManager implements OnInitializedListener, OnAccountChan
}
private void initPersistentNotification() {
persistentNotificationBuilder.setContentTitle(application.getString(R.string.application_name));
persistentNotificationBuilder.setContentTitle(application.getString(R.string.application_title_full));
persistentNotificationBuilder.setDeleteIntent(clearNotifications);
persistentNotificationBuilder.setOngoing(true);
persistentNotificationBuilder.setWhen(System.currentTimeMillis());
......
......@@ -16,6 +16,7 @@ package com.xabber.android.data.roster;
import android.database.Cursor;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.OnLoadListener;
import com.xabber.android.data.account.AccountItem;
......@@ -23,7 +24,6 @@ import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountRemovedListener;
import com.xabber.android.data.entity.NestedMap;
import com.xabber.android.data.entity.NestedMap.Entry;
import com.xabber.androiddev.R;
public class GroupManager implements OnLoadListener, OnAccountRemovedListener,
GroupStateProvider {
......@@ -52,12 +52,6 @@ public class GroupManager implements OnLoadListener, OnAccountRemovedListener,
* Account name used to store information that don't belong to any account.
*/
public static final String NO_ACCOUNT = "com.xabber.android.data.NO_ACCOUNT";
/**
* List of settings for roster groups in accounts.
*/
private final NestedMap<GroupConfiguration> groupConfigurations;
private final static GroupManager instance;
static {
......@@ -65,14 +59,19 @@ public class GroupManager implements OnLoadListener, OnAccountRemovedListener,
Application.getInstance().addManager(instance);
}
public static GroupManager getInstance() {
return instance;
}
/**
* List of settings for roster groups in accounts.
*/
private final NestedMap<GroupConfiguration> groupConfigurations;
private GroupManager() {
groupConfigurations = new NestedMap<GroupConfiguration>();
}
public static GroupManager getInstance() {
return instance;
}
@Override
public void onLoad() {
final NestedMap<GroupConfiguration> groupConfigurations = new NestedMap<GroupConfiguration>();
......
......@@ -14,6 +14,7 @@
*/
package com.xabber.android.data.roster;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.OnLoadListener;
......@@ -29,7 +30,6 @@ import com.xabber.android.data.entity.NestedMap;
import com.xabber.android.data.extension.archive.OnArchiveModificationsReceivedListener;
import com.xabber.android.data.notification.EntityNotificationProvider;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import org.jivesoftware.smack.packet.IQ;
......@@ -55,35 +55,28 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
OnPacketListener, OnLoadListener, OnAccountDisabledListener,
OnDisconnectListener {
private final EntityNotificationProvider<SubscriptionRequest> subscriptionRequestProvider;
private final static PresenceManager instance;
static {
instance = new PresenceManager();
Application.getInstance().addManager(instance);
}
private final EntityNotificationProvider<SubscriptionRequest> subscriptionRequestProvider;
/**
* List of account with requested subscriptions for auto accept incoming
* subscription request.
*/
private final HashMap<String, HashSet<String>> requestedSubscriptions;
/**
* Presence container for bare address in account.
*/
private final NestedMap<ResourceContainer> presenceContainers;
/**
* Account ready to send / update its presence information.
*/
private final ArrayList<String> readyAccounts;
private final static PresenceManager instance;
static {
instance = new PresenceManager();
Application.getInstance().addManager(instance);
}
public static PresenceManager getInstance() {
return instance;
}
private PresenceManager() {
subscriptionRequestProvider = new EntityNotificationProvider<SubscriptionRequest>(
R.drawable.ic_stat_ic_add_circle);
......@@ -92,6 +85,10 @@ public class PresenceManager implements OnArchiveModificationsReceivedListener,
readyAccounts = new ArrayList<String>();
}
public static PresenceManager getInstance() {
return instance;
}
@Override
public void onLoad() {
Application.getInstance().runOnUiThread(new Runnable() {
......
......@@ -14,19 +14,7 @@
*/
package com.xabber.android.data.roster;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
......@@ -47,9 +35,21 @@ import com.xabber.android.data.extension.muc.RoomContact;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.ChatContact;
import com.xabber.android.data.message.MessageManager;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.RosterPacket;
import org.jivesoftware.smack.packet.RosterPacket.ItemType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* Manage contact list (roster).
*
......@@ -59,37 +59,30 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
OnAccountEnabledListener, OnAccountDisabledListener,
OnArchiveModificationsReceivedListener, OnAccountRemovedListener {
private final static RosterManager instance;
static {
instance = new RosterManager();
Application.getInstance().addManager(instance);
}
/**
* List of roster groups for its names in accounts.
*/
private final NestedMap<RosterGroup> rosterGroups;
/**
* Managed contacts for bare addresses in accounts.
*/
private final NestedMap<RosterContact> rosterContacts;
/**
* List of accounts for witch roster was requested.
*/
private final Set<String> requestedRosters;
/**
* List of accounts for witch roster has been received.
*/
private final Set<String> receivedRosters;
private final static RosterManager instance;
static {
instance = new RosterManager();
Application.getInstance().addManager(instance);
}
public static RosterManager getInstance() {
return instance;
}
private RosterManager() {
rosterGroups = new NestedMap<RosterGroup>();
rosterContacts = new NestedMap<RosterContact>();
......@@ -97,6 +90,10 @@ public class RosterManager implements OnDisconnectListener, OnPacketListener,
requestedRosters = new HashSet<String>();
}
public static RosterManager getInstance() {
return instance;
}
public Collection<RosterContact> getContacts() {
return Collections.unmodifiableCollection(rosterContacts.values());
}
......
......@@ -16,12 +16,12 @@ package com.xabber.android.data.roster;
import android.content.Intent;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.notification.EntityNotificationItem;
import com.xabber.android.ui.ContactSubscription;
import com.xabber.androiddev.R;
public class SubscriptionRequest extends BaseEntity implements EntityNotificationItem {
......
......@@ -14,15 +14,6 @@
*/
package com.xabber.android.data.roster;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import android.accounts.Account;
import android.accounts.AccountManager;
import android.accounts.OnAccountsUpdateListener;
......@@ -49,6 +40,7 @@ import android.provider.ContactsContract.Groups;
import android.provider.ContactsContract.RawContacts;
import android.provider.ContactsContract.StatusUpdates;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.DatabaseManager;
import com.xabber.android.data.LogManager;
......@@ -62,7 +54,15 @@ import com.xabber.android.data.entity.AccountRelated;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.vcard.VCardManager;
import com.xabber.android.utils.DummyCursor;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* Manage integration with system accounts and contacts.
......@@ -79,63 +79,50 @@ public class SyncManager implements OnLoadListener, OnUnloadListener,
OnAccountSyncableChangedListener, OnAccountsUpdateListener,
OnRosterChangedListener {
private static boolean LOG = true;
private static final Uri RAW_CONTACTS_URI = RawContacts.CONTENT_URI
.buildUpon()
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,
"true").build();
private static final Uri GROUPS_URI = Groups.CONTENT_URI
.buildUpon()
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,
"true").build();
private static final Uri DATA_URI = Data.CONTENT_URI
.buildUpon()
.appendQueryParameter(ContactsContract.CALLER_IS_SYNCADAPTER,
"true").build();
private final static SyncManager instance;
private static boolean LOG = true;
private final Application application;
static {
instance = new SyncManager();
Application.getInstance().addManager(instance);
}
private final Application application;
/**
* List of contacts with specified status.
*/
private final HashMap<RosterContact, SystemContactStatus> statuses;
/**
* System account manager.
*/
private final AccountManager accountManager;
/**
* Accounts which contacts is indented to be synchronized.
*/
private final HashSet<String> syncableAccounts;
/**
* Whether system accounts must be created on xabber account add.
* <p/>
* Used to prevent system account creation on load.
*/
private boolean createAccounts;
/**
* Whether OnAccountsUpdatedListener was registered.
*/
private boolean registeredOnAccountsUpdatedListener;
/**
* Accounts which contacts is indented to be synchronized.
*/
private final HashSet<String> syncableAccounts;
private final static SyncManager instance;
static {
instance = new SyncManager();
Application.getInstance().addManager(instance);
}
public static SyncManager getInstance() {
return instance;
}
private SyncManager() {
this.application = Application.getInstance();
statuses = new HashMap<RosterContact, SystemContactStatus>();
......@@ -145,6 +132,10 @@ public class SyncManager implements OnLoadListener, OnUnloadListener,
registeredOnAccountsUpdatedListener = false;
}
public static SyncManager getInstance() {
return instance;
}
/**
* @return Account type used by system contact list.
*/
......
......@@ -22,10 +22,10 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.xabber.android.R;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class AccountAdd extends ManagedActivity {
......
......@@ -14,6 +14,7 @@ import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
......@@ -22,10 +23,10 @@ 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 static final String SAVED_ACCOUNT_TYPE = "com.xabber.android.ui.AccountAdd.ACCOUNT_TYPE";
private CheckBox storePasswordView;
private CheckBox useOrbotView;
private CheckBox createAccountCheckBox;
......@@ -34,8 +35,6 @@ public class AccountAddFragment extends Fragment implements View.OnClickListener
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;
......
......@@ -19,12 +19,12 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.ArchiveMode;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.helper.ManagedDialog;
import com.xabber.androiddev.R;
/**
* Dialog with request to enable message archive.
......@@ -35,6 +35,15 @@ public class ArchiveRequest extends ManagedDialog {
private String account;
public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, ArchiveRequest.class)
.setAccount(account).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -63,13 +72,4 @@ public class ArchiveRequest extends ManagedDialog {
finish();
}
public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, ArchiveRequest.class)
.setAccount(account).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
}
......@@ -14,8 +14,6 @@
*/
package com.xabber.android.ui;
import java.util.NoSuchElementException;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
......@@ -23,13 +21,15 @@ import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.connection.CertificateInvalidReason;
import com.xabber.android.data.connection.CertificateManager;
import com.xabber.android.data.connection.ConnectionManager;
import com.xabber.android.data.connection.PendingCertificate;
import com.xabber.android.data.intent.SegmentIntentBuilder;
import com.xabber.android.ui.helper.ManagedDialog;
import com.xabber.androiddev.R;
import java.util.NoSuchElementException;
/**
* Dialog to confirm invalid certificate.
......@@ -43,6 +43,27 @@ public class CertificateConfirmation extends ManagedDialog {
private PendingCertificate pendingCertificate;
private boolean showDetails;
public static Intent createIntent(Context context, String fingerPrint,
CertificateInvalidReason reason) {
return new SegmentIntentBuilder<SegmentIntentBuilder<?>>(context,
CertificateConfirmation.class).addSegment(fingerPrint)
.addSegment(reason.toString()).build();
}
private static String getFingerprint(Intent intent) {
return SegmentIntentBuilder.getSegment(intent, 0);
}
private static CertificateInvalidReason getReason(Intent intent) {
String value = SegmentIntentBuilder.getSegment(intent, 1);
if (value != null)
try {
return CertificateInvalidReason.valueOf(value);
} catch (NoSuchElementException e) {
}
return null;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -126,25 +147,4 @@ public class CertificateConfirmation extends ManagedDialog {
update();
}
public static Intent createIntent(Context context, String fingerPrint,
CertificateInvalidReason reason) {
return new SegmentIntentBuilder<SegmentIntentBuilder<?>>(context,
CertificateConfirmation.class).addSegment(fingerPrint)
.addSegment(reason.toString()).build();
}
private static String getFingerprint(Intent intent) {
return SegmentIntentBuilder.getSegment(intent, 0);
}
private static CertificateInvalidReason getReason(Intent intent) {
String value = SegmentIntentBuilder.getSegment(intent, 1);
if (value != null)
try {
return CertificateInvalidReason.valueOf(value);
} catch (NoSuchElementException e) {
}
return null;
}
}
......@@ -24,6 +24,7 @@ import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.LinearLayout;
import com.xabber.android.R;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener;
......@@ -40,7 +41,6 @@ import com.xabber.android.ui.adapter.ChatScrollIndicatorAdapter;
import com.xabber.android.ui.adapter.ChatViewerAdapter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.helper.StatusBarPainter;
import com.xabber.androiddev.R;
import java.util.Collection;
import java.util.HashSet;
......@@ -424,7 +424,6 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
@Override
public void onChatViewAdapterFinishUpdate() {
insertExtraText();
updateRegisteredChats();
}
private void insertExtraText() {
......
......@@ -26,6 +26,7 @@ import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.PopupMenu;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
......@@ -52,7 +53,6 @@ import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.android.ui.helper.ContactTitleInflater;
import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.androiddev.R;
public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItemClickListener,
View.OnClickListener, Toolbar.OnMenuItemClickListener, ChatMessageAdapter.Message.MessageClickListener {
......@@ -77,6 +77,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
private RecyclerView recyclerView;
private View contactTitleView;
private AbstractContact abstractContact;
private LinearLayoutManager layoutManager;
public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment();
......@@ -157,7 +158,7 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
recyclerView = (RecyclerView) view.findViewById(R.id.chat_messages_recycler_view);
recyclerView.setAdapter(chatMessageAdapter);
LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager);
......@@ -408,12 +409,19 @@ public class ChatViewerFragment extends Fragment implements PopupMenu.OnMenuItem
public void updateChat() {
ContactTitleInflater.updateTitle(contactTitleView, getActivity(), abstractContact);
int itemCountBeforeUpdate = recyclerView.getAdapter().getItemCount();
chatMessageAdapter.onChange();
recyclerView.scrollToPosition(chatMessageAdapter.getItemCount() - 1);
scrollChat(itemCountBeforeUpdate);
setUpOptionsMenu(toolbar.getMenu());
updateSecurityButton();
}
private void scrollChat(int itemCountBeforeUpdate) {
if (layoutManager.findLastVisibleItemPosition() == (itemCountBeforeUpdate - 1)) {
recyclerView.scrollToPosition(chatMessageAdapter.getItemCount() - 1);
}
}
private void updateSecurityButton() {
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
securityButton.setImageLevel(securityLevel.getImageLevel());
......
......@@ -22,10 +22,10 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import com.xabber.android.R;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
public class ContactAdd extends ManagedActivity implements ContactAddFragment.Listener {
......
......@@ -11,6 +11,7 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
......@@ -18,7 +19,6 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
import com.xabber.androiddev.R;
import java.util.Collection;
......@@ -27,13 +27,10 @@ public class ContactAddFragment extends GroupEditorFragment implements AdapterVi
private static final String SAVED_NAME = "com.xabber.android.ui.ContactAdd.SAVED_NAME";
private static final String SAVED_ACCOUNT = "com.xabber.android.ui.ContactAdd.SAVED_ACCOUNT";
private static final String SAVED_USER = "com.xabber.android.ui.ContactAdd.SAVED_USER";
Listener listenerActivity;
private Spinner accountView;
private EditText userView;
private EditText nameView;
Listener listenerActivity;
private String name;
private View accountSelectorPanel;
......
......@@ -9,16 +9,21 @@ import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import com.xabber.android.R;
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 {
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactEditor.class)
.setAccount(account).setUser(user).build();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.contact_viewer, menu);
......@@ -76,9 +81,4 @@ public class ContactEditor extends ContactViewer {
builder.show();
}
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactEditor.class)
.setAccount(account).setUser(user).build();
}
}
......@@ -40,6 +40,7 @@ import android.view.inputmethod.InputMethodManager;
import android.widget.SearchView;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
......@@ -67,7 +68,6 @@ import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.AboutViewer;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.android.ui.preferences.PreferenceEditor;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import com.xabber.xmpp.uri.XMPPUri;
......@@ -158,7 +158,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
setSupportActionBar(toolbar);
drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.production_title, R.string.production_title);
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar, R.string.application_title_short, R.string.application_title_short);
drawerLayout.setDrawerListener(drawerToggle);
getSupportActionBar().setHomeButtonEnabled(true);
......@@ -167,7 +167,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
barPainter = new BarPainter(this, toolbar);
barPainter.setDefaultColor();
setTitle(getString(R.string.application_name));
setTitle(getString(R.string.application_title_full));
if (savedInstanceState != null) {
sendText = savedInstanceState.getString(SAVED_SEND_TEXT);
......
......@@ -12,11 +12,11 @@ import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.ui.adapter.NavigationDrawerAccountAdapter;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.androiddev.R;
import java.util.Collection;
......
......@@ -22,6 +22,7 @@ import android.widget.PopupMenu;
import android.widget.TextView;
import com.melnykov.fab.FloatingActionButton;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
......@@ -44,7 +45,6 @@ import com.xabber.android.ui.adapter.UpdatableAdapter;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.android.ui.helper.ContextMenuHelper;
import com.xabber.android.ui.preferences.AccountList;
import com.xabber.androiddev.R;
import java.util.Collection;
......
......@@ -23,6 +23,7 @@ import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.intent.EntityIntentBuilder;
......@@ -33,7 +34,6 @@ import com.xabber.android.data.roster.SubscriptionRequest;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.SingleActivity;
import com.xabber.androiddev.R;
public class ContactSubscription extends SingleActivity implements View.OnClickListener {
......
......@@ -12,6 +12,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.VcardMaps;
......@@ -24,7 +25,6 @@ import com.xabber.android.data.extension.vcard.VCardManager;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.PresenceManager;
import com.xabber.android.data.roster.ResourceItem;
import com.xabber.androiddev.R;
import com.xabber.xmpp.vcard.Address;
import com.xabber.xmpp.vcard.AddressProperty;
import com.xabber.xmpp.vcard.AddressType;
......@@ -47,18 +47,14 @@ import java.util.Collection;
import java.util.List;
public class ContactVcardViewerFragment extends Fragment implements OnVCardListener, OnContactChangedListener, OnAccountChangedListener {
private static final String SAVED_VCARD = "com.xabber.android.ui.ContactVcardViewerFragment.SAVED_VCARD";
private static final String SAVED_VCARD_ERROR = "com.xabber.android.ui.ContactVcardViewerFragment.SAVED_VCARD_ERROR";
public static final String ARGUMENT_ACCOUNT = "com.xabber.android.ui.ContactVcardViewerFragment.ARGUMENT_ACCOUNT";
public static final String ARGUMENT_USER = "com.xabber.android.ui.ContactVcardViewerFragment.ARGUMENT_USER";
private LinearLayout xmppItems;
private LinearLayout contactInfoItems;
private static final String SAVED_VCARD = "com.xabber.android.ui.ContactVcardViewerFragment.SAVED_VCARD";
private static final String SAVED_VCARD_ERROR = "com.xabber.android.ui.ContactVcardViewerFragment.SAVED_VCARD_ERROR";
String account;
String user;
private LinearLayout xmppItems;
private LinearLayout contactInfoItems;
private VCard vCard;
private boolean vCardError;
......
......@@ -21,6 +21,7 @@ import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
......@@ -34,7 +35,6 @@ import com.xabber.android.data.roster.RosterContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleExpandableToolbarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
......@@ -49,6 +49,19 @@ public class ContactViewer extends ManagedActivity implements
private ContactTitleExpandableToolbarInflater contactTitleExpandableToolbarInflater;
private TextView contactNameView;
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactViewer.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -140,20 +153,6 @@ public class ContactViewer extends ManagedActivity implements
}
}
public static Intent createIntent(Context context, String account, String user) {
return new EntityIntentBuilder(context, ContactViewer.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
protected String getAccount() {
return account;
}
......
......@@ -32,6 +32,7 @@ import android.widget.TextView;
import com.google.zxing.integration.android.IntentIntegrator;
import com.google.zxing.integration.android.IntentResult;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
......@@ -50,7 +51,6 @@ import com.xabber.android.ui.dialog.NotificationDialogBuilder;
import com.xabber.android.ui.dialog.NotificationDialogListener;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
......
......@@ -19,6 +19,7 @@ import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
......@@ -29,7 +30,6 @@ import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
......
......@@ -13,11 +13,11 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ListView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.GroupEditorAdapter;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
......@@ -45,6 +45,13 @@ public class GroupEditorFragment extends ListFragment implements TextWatcher, Vi
private CheckBox groupAddCheckBox;
private View footerView;
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public GroupEditorFragment() {
}
public static GroupEditorFragment newInstance(String account, String user) {
GroupEditorFragment fragment = new GroupEditorFragment();
Bundle args = new Bundle();
......@@ -54,14 +61,15 @@ public class GroupEditorFragment extends ListFragment implements TextWatcher, Vi
return fragment;
}
/**
* Mandatory empty constructor for the fragment manager to instantiate the
* fragment (e.g. upon screen orientation changes).
*/
public GroupEditorFragment() {
public static void hideKeyboard(Activity activity) {
// Check if no view has focus:
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -134,7 +142,6 @@ public class GroupEditorFragment extends ListFragment implements TextWatcher, Vi
}
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
......@@ -218,15 +225,6 @@ public class GroupEditorFragment extends ListFragment implements TextWatcher, Vi
}
}
public static void hideKeyboard(Activity activity) {
// Check if no view has focus:
View view = activity.getCurrentFocus();
if (view != null) {
InputMethodManager inputManager = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(view.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
......@@ -241,14 +239,14 @@ public class GroupEditorFragment extends ListFragment implements TextWatcher, Vi
return account;
}
protected String getUser() {
return user;
}
protected void setAccount(String account) {
this.account = account;
}
protected String getUser() {
return user;
}
protected void setUser(String user) {
this.user = user;
}
......
......@@ -14,8 +14,6 @@
*/
package com.xabber.android.ui;
import java.util.Collection;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
......@@ -25,13 +23,15 @@ import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.service.XabberService;
import com.xabber.android.ui.helper.SingleActivity;
import com.xabber.androiddev.R;
import java.util.Collection;
public class LoadActivity extends SingleActivity implements
OnAccountChangedListener {
......@@ -39,6 +39,10 @@ public class LoadActivity extends SingleActivity implements
private Animation animation;
private View disconnectedView;
public static Intent createIntent(Context context) {
return new Intent(context, LoadActivity.class);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -98,8 +102,4 @@ public class LoadActivity extends SingleActivity implements
ActivityManager.getInstance().cancelTask(this);
}
public static Intent createIntent(Context context) {
return new Intent(context, LoadActivity.class);
}
}
......@@ -29,6 +29,7 @@ import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.RoomInvite;
......@@ -39,7 +40,6 @@ import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.ui.adapter.AccountChooseAdapter;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import org.jivesoftware.smack.util.StringUtils;
......
......@@ -19,13 +19,13 @@ import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.RoomInvite;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.ui.helper.ManagedDialog;
import com.xabber.androiddev.R;
public class MUCInvite extends ManagedDialog {
......@@ -33,6 +33,20 @@ public class MUCInvite extends ManagedDialog {
private String room;
private RoomInvite roomInvite;
public static Intent createIntent(Context context, String account,
String room) {
return new EntityIntentBuilder(context, MUCInvite.class)
.setAccount(account).setUser(room).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -64,18 +78,4 @@ public class MUCInvite extends ManagedDialog {
finish();
}
public static Intent createIntent(Context context, String account,
String room) {
return new EntityIntentBuilder(context, MUCInvite.class)
.setAccount(account).setUser(room).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
}
......@@ -24,12 +24,12 @@ import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.xabber.android.R;
import com.xabber.android.data.LogManager;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountProtocol;
import com.xabber.android.data.account.OAuthManager;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
/**
* Activity with WebView for OAuth authorization.
......@@ -48,6 +48,39 @@ public class OAuthActivity extends ManagedActivity {
private String code;
private boolean loaded;
private static Intent createResultIntent(Context context,
String refreshToken) {
Intent intent = new Intent();
intent.putExtra(EXTRA_INVALIDATE, false);
intent.putExtra(EXTRA_REFRESH_TOKEN, refreshToken);
return intent;
}
private static Intent createInvalidateIntent(Context context) {
Intent intent = new Intent();
intent.putExtra(EXTRA_INVALIDATE, true);
return intent;
}
public static Intent createIntent(Context context, AccountProtocol protocol) {
Intent intent = new Intent(context, OAuthActivity.class);
intent.setData(Uri.parse(String.valueOf(protocol.ordinal())));
return intent;
}
public static boolean isInvalidated(Intent intent) {
return intent.getBooleanExtra(OAuthActivity.EXTRA_INVALIDATE, false);
}
public static String getToken(Intent intent) {
return intent.getStringExtra(OAuthActivity.EXTRA_REFRESH_TOKEN);
}
private static AccountProtocol getAccountProtocol(Intent intent) {
int index = Integer.valueOf(intent.getData().toString());
return AccountProtocol.values()[index];
}
@SuppressLint("SetJavaScriptEnabled")
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -85,39 +118,6 @@ public class OAuthActivity extends ManagedActivity {
progress ? View.VISIBLE : View.GONE);
}
private static Intent createResultIntent(Context context,
String refreshToken) {
Intent intent = new Intent();
intent.putExtra(EXTRA_INVALIDATE, false);
intent.putExtra(EXTRA_REFRESH_TOKEN, refreshToken);
return intent;
}
private static Intent createInvalidateIntent(Context context) {
Intent intent = new Intent();
intent.putExtra(EXTRA_INVALIDATE, true);
return intent;
}
public static Intent createIntent(Context context, AccountProtocol protocol) {
Intent intent = new Intent(context, OAuthActivity.class);
intent.setData(Uri.parse(String.valueOf(protocol.ordinal())));
return intent;
}
public static boolean isInvalidated(Intent intent) {
return intent.getBooleanExtra(OAuthActivity.EXTRA_INVALIDATE, false);
}
public static String getToken(Intent intent) {
return intent.getStringExtra(OAuthActivity.EXTRA_REFRESH_TOKEN);
}
private static AccountProtocol getAccountProtocol(Intent intent) {
int index = Integer.valueOf(intent.getData().toString());
return AccountProtocol.values()[index];
}
private class OAuthWebViewClient extends WebViewClient {
@Override
......
......@@ -14,13 +14,12 @@
*/
package com.xabber.android.ui;
import java.util.Collection;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
......@@ -30,9 +29,10 @@ import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.ui.adapter.OccupantListAdapter;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
/**
* Represent list of occupants in the room.
*
......@@ -45,6 +45,20 @@ public class OccupantList extends ManagedListActivity implements
private String room;
private OccupantListAdapter listAdapter;
public static Intent createIntent(Context context, String account,
String user) {
return new EntityIntentBuilder(context, OccupantList.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -99,18 +113,4 @@ public class OccupantList extends ManagedListActivity implements
listAdapter.onChange();
}
public static Intent createIntent(Context context, String account,
String user) {
return new EntityIntentBuilder(context, OccupantList.class)
.setAccount(account).setUser(user).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
private static String getUser(Intent intent) {
return EntityIntentBuilder.getUser(intent);
}
}
......@@ -21,11 +21,11 @@ import android.view.View;
import android.widget.CheckBox;
import android.widget.EditText;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.intent.AccountIntentBuilder;
import com.xabber.android.ui.helper.ManagedDialog;
import com.xabber.androiddev.R;
/**
* Dialog with password request for authentication.
......@@ -39,6 +39,15 @@ public class PasswordRequest extends ManagedDialog {
private EditText passwordView;
private CheckBox storePasswordView;
public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, PasswordRequest.class)
.setAccount(account).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -72,13 +81,4 @@ public class PasswordRequest extends ManagedDialog {
finish();
}
public static Intent createIntent(Context context, String account) {
return new AccountIntentBuilder(context, PasswordRequest.class)
.setAccount(account).build();
}
private static String getAccount(Intent intent) {
return AccountIntentBuilder.getAccount(intent);
}
}
......@@ -23,6 +23,7 @@ import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
......@@ -36,7 +37,6 @@ import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.helper.ContactTitleActionBarInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.androiddev.R;
import com.xabber.xmpp.address.Jid;
import java.util.Collection;
......
......@@ -12,10 +12,10 @@ import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.ui.adapter.ChatListAdapter;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.List;
......
......@@ -32,6 +32,7 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountItem;
......@@ -43,7 +44,6 @@ import com.xabber.android.ui.adapter.StatusEditorAdapter;
import com.xabber.android.ui.adapter.StatusModeAdapter;
import com.xabber.android.ui.helper.BarPainter;
import com.xabber.android.ui.helper.ManagedListActivity;
import com.xabber.androiddev.R;
public class StatusEditor extends ManagedListActivity implements OnItemClickListener, Toolbar.OnMenuItemClickListener, View.OnClickListener {
......
......@@ -7,10 +7,10 @@ import android.view.View;
import android.widget.LinearLayout;
import com.melnykov.fab.FloatingActionButton;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.StatusMode;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -15,16 +15,15 @@
package com.xabber.android.ui.adapter;
import android.app.Activity;
import android.graphics.drawable.ColorDrawable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
......@@ -35,10 +34,9 @@ import java.util.Collections;
* @author alexander.ivanov
*/
public class AccountChooseAdapter extends BaseAdapter {
protected final ArrayList<String> accounts;
private final int[] accountColors;
private final Activity activity;
protected final ArrayList<String> accounts;
public AccountChooseAdapter(Activity activity) {
super();
......
......@@ -21,12 +21,12 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.ui.preferences.AccountList;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
......
......@@ -14,8 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.List;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
......@@ -23,9 +21,11 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.AccountType;
import com.xabber.androiddev.R;
import java.util.List;
/**
* Adapter for drop down list of account's types.
......
......@@ -22,6 +22,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
......@@ -34,7 +35,6 @@ import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
......@@ -43,23 +43,21 @@ import java.util.List;
public class ChatMessageAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements UpdatableAdapter {
private static final int VIEW_TYPE_HINT = 1;
public static final int VIEW_TYPE_INCOMING_MESSAGE = 2;
public static final int VIEW_TYPE_OUTGOING_MESSAGE = 3;
private static final int VIEW_TYPE_HINT = 1;
private static final int VIEW_TYPE_ACTION_MESSAGE = 4;
private final Context context;
private final Message.MessageClickListener messageClickListener;
private String account;
private String user;
private boolean isMUC;
private List<MessageItem> messages;
/**
* Message font appearance.
*/
private final int appearanceStyle;
private String account;
private String user;
private boolean isMUC;
private List<MessageItem> messages;
/**
* Text with extra information.
*/
......
......@@ -7,10 +7,10 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.ui.helper.AccountPainter;
import com.xabber.androiddev.R;
import java.util.ArrayList;
......
......@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.xabber.android.R;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.extension.capability.ClientSoftware;
import com.xabber.android.data.extension.muc.MUCManager;
......@@ -16,13 +17,12 @@ import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.ui.ContactEditor;
import com.xabber.android.ui.ContactViewer;
import com.xabber.android.utils.StringUtils;
import com.xabber.androiddev.R;
public class ContactItemInflater {
final Context context;
private int[] accountMainColors;
private final int elevation;
private int[] accountMainColors;
public ContactItemInflater(Context context) {
this.context = context;
......
......@@ -4,7 +4,7 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.androiddev.R;
import com.xabber.android.R;
class ContactListItemViewHolder {
......
......@@ -8,7 +8,7 @@ import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.xabber.androiddev.R;
import com.xabber.android.R;
import java.util.List;
......
......@@ -26,6 +26,7 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
......@@ -37,7 +38,6 @@ import com.xabber.android.data.roster.Group;
import com.xabber.android.data.roster.GroupManager;
import com.xabber.android.data.roster.ShowOfflineMode;
import com.xabber.android.ui.ContactViewer;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
......@@ -84,22 +84,19 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
NO_GROUP_LIST = Collections.unmodifiableCollection(groups);
}
final ArrayList<BaseEntity> baseEntities = new ArrayList<>();
/**
* Layout inflater
*/
private final LayoutInflater layoutInflater;
private final Activity activity;
private int[] accountGroupColors;
private final int[] accountSubgroupColors;
private final int activeChatsColor;
private final OnClickListener onClickListener;
final ArrayList<BaseEntity> baseEntities = new ArrayList<>();
protected Locale locale = Locale.getDefault();
private final ContactItemInflater contactItemInflater;
private final int accountElevation;
protected Locale locale = Locale.getDefault();
private int[] accountGroupColors;
public GroupedContactAdapter(Activity activity, OnClickListener onClickListener) {
this.activity = activity;
......@@ -554,6 +551,10 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
onChange();
}
public interface OnClickListener {
void onAccountMenuClick(View view, String account);
}
/**
* Holder for views in contact list group.
*/
......@@ -571,8 +572,4 @@ public abstract class GroupedContactAdapter extends BaseAdapter implements Updat
}
}
public interface OnClickListener {
void onAccountMenuClick(View view, String account);
}
}
......@@ -7,11 +7,11 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountItem;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.connection.ConnectionState;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collection;
......
......@@ -14,9 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collections;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
......@@ -24,13 +21,16 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.extension.avatar.AvatarManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.Occupant;
import com.xabber.android.ui.OccupantList;
import com.xabber.androiddev.R;
import com.xabber.xmpp.muc.Role;
import java.util.ArrayList;
import java.util.Collections;
/**
* Adapter for {@link OccupantList}.
*
......
......@@ -14,16 +14,16 @@
*/
package com.xabber.android.ui.adapter;
import java.util.Collection;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.message.phrase.Phrase;
import com.xabber.android.data.message.phrase.PhraseManager;
import com.xabber.androiddev.R;
import java.util.Collection;
/**
* This class manage list of phrases.
......
......@@ -14,9 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import java.util.Collections;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
......@@ -24,9 +21,12 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.SavedStatus;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
/**
* Adapter for saved statuses.
......
......@@ -14,8 +14,6 @@
*/
package com.xabber.android.ui.adapter;
import java.util.ArrayList;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
......@@ -23,8 +21,10 @@ import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.account.StatusMode;
import com.xabber.androiddev.R;
import java.util.ArrayList;
/**
* Adapter for available status modes.
......
......@@ -25,12 +25,12 @@ import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
import java.io.File;
......@@ -38,6 +38,10 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String USER = "USER";
private String account;
private String user;
private EditText nameView;
private CheckBox sendView;
/**
* @param account
......@@ -48,11 +52,6 @@ public class ChatExportDialogFragment extends ConfirmDialogFragment {
return new ChatExportDialogFragment().putAgrument(ACCOUNT, account).putAgrument(USER, user);
}
private String account;
private String user;
private EditText nameView;
private CheckBox sendView;
@Override
protected Builder getBuilder() {
account = getArguments().getString(ACCOUNT);
......
......@@ -3,18 +3,20 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.ContactList;
import com.xabber.android.ui.ContactViewer;
import com.xabber.androiddev.R;
public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String USER = "USER";
private String user;
private String account;
/**
* @param account
......@@ -26,9 +28,6 @@ public class ContactDeleteDialogFragment extends ConfirmDialogFragment {
.putAgrument(USER, user);
}
private String user;
private String account;
@Override
protected Builder getBuilder() {
user = getArguments().getString(USER);
......
......@@ -3,9 +3,9 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import com.xabber.android.R;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.androiddev.R;
public class ContactIntegrationDialogFragment extends ConfirmDialogFragment {
......
......@@ -3,15 +3,17 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class GroupDeleteDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String GROUP = "GROUP";
private String group;
private String account;
/**
* @param account can be <code>null</code> to be used for all accounts.
......@@ -23,9 +25,6 @@ public class GroupDeleteDialogFragment extends ConfirmDialogFragment {
.putAgrument(GROUP, group);
}
private String group;
private String account;
@Override
protected Builder getBuilder() {
group = getArguments().getString(GROUP);
......
......@@ -21,15 +21,18 @@ import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class GroupRenameDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String GROUP = "GROUP";
private String group;
private String account;
private EditText nameView;
/**
* @param account can be <code>null</code> to be used for all accounts.
......@@ -41,10 +44,6 @@ public class GroupRenameDialogFragment extends ConfirmDialogFragment {
.putAgrument(GROUP, group);
}
private String group;
private String account;
private EditText nameView;
@Override
protected Builder getBuilder() {
group = getArguments().getString(GROUP);
......
......@@ -3,17 +3,19 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.androiddev.R;
public class MUCDeleteDialogFragment extends ConfirmDialogFragment {
private static final String ACCOUNT = "ACCOUNT";
private static final String USER = "USER";
private String user;
private String account;
/**
* @param account
......@@ -25,9 +27,6 @@ public class MUCDeleteDialogFragment extends ConfirmDialogFragment {
.putAgrument(USER, user);
}
private String user;
private String account;
@Override
protected Builder getBuilder() {
user = getArguments().getString(USER);
......
......@@ -20,8 +20,8 @@ import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import com.xabber.android.R;
import com.xabber.android.ui.helper.OrbotHelper;
import com.xabber.androiddev.R;
/**
* Orbot installer dialog builder.
......
......@@ -3,8 +3,8 @@ package com.xabber.android.ui.dialog;
import android.app.AlertDialog.Builder;
import android.app.DialogFragment;
import com.xabber.android.R;
import com.xabber.android.data.SettingsManager;
import com.xabber.androiddev.R;
public class StartAtBootDialogFragment extends ConfirmDialogFragment {
......
......@@ -3,8 +3,8 @@ package com.xabber.android.ui.helper;
import android.content.Context;
import android.content.res.TypedArray;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.androiddev.R;
import java.util.ArrayList;
import java.util.Collections;
......
......@@ -7,8 +7,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
public class ContactTitleActionBarInflater {
......
......@@ -17,9 +17,9 @@ import com.github.ksoichiro.android.observablescrollview.ObservableScrollView;
import com.github.ksoichiro.android.observablescrollview.ObservableScrollViewCallbacks;
import com.github.ksoichiro.android.observablescrollview.ScrollState;
import com.github.ksoichiro.android.observablescrollview.ScrollUtils;
import com.xabber.android.R;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
import static java.lang.Math.pow;
import static java.lang.Math.round;
......
......@@ -19,9 +19,9 @@ import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.xabber.android.R;
import com.xabber.android.data.extension.cs.ChatStateManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.androiddev.R;
import org.jivesoftware.smackx.ChatState;
......
......@@ -22,6 +22,7 @@ import android.view.ContextMenu;
import android.view.Menu;
import android.view.MenuItem;
import com.xabber.android.R;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
......@@ -49,7 +50,6 @@ import com.xabber.android.ui.dialog.GroupDeleteDialogFragment;
import com.xabber.android.ui.dialog.GroupRenameDialogFragment;
import com.xabber.android.ui.dialog.MUCDeleteDialogFragment;
import com.xabber.android.ui.preferences.AccountEditor;
import com.xabber.androiddev.R;
/**
* Helper class for context menu creation.
......
......@@ -21,7 +21,7 @@ import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;
import com.xabber.androiddev.R;
import com.xabber.android.R;
/**
* Helper for dialog activities.
......
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