Commit d47ff0d3 authored by Grigory Fedorov's avatar Grigory Fedorov

If chat opened via shortcut widget, adapter created again, "intent" chat replaced. Fix #108

parent 1d11c4b1
...@@ -63,6 +63,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -63,6 +63,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
private static final String ACTION_ATTENTION = "com.xabber.android.data.ATTENTION"; private static final String ACTION_ATTENTION = "com.xabber.android.data.ATTENTION";
private static final String ACTION_RECENT_CHATS = "com.xabber.android.data.RECENT_CHATS"; private static final String ACTION_RECENT_CHATS = "com.xabber.android.data.RECENT_CHATS";
private static final String ACTION_SPECIFIC_CHAT = "com.xabber.android.data.ACTION_SPECIFIC_CHAT"; private static final String ACTION_SPECIFIC_CHAT = "com.xabber.android.data.ACTION_SPECIFIC_CHAT";
private static final String ACTION_SHORTCUT = "com.xabber.android.data.ACTION_SHORTCUT";
private static final String SAVED_INITIAL_ACCOUNT = "com.xabber.android.ui.ChatViewer.SAVED_INITIAL_ACCOUNT"; private static final String SAVED_INITIAL_ACCOUNT = "com.xabber.android.ui.ChatViewer.SAVED_INITIAL_ACCOUNT";
private static final String SAVED_INITIAL_USER = "com.xabber.android.ui.ChatViewer.SAVED_INITIAL_USER"; private static final String SAVED_INITIAL_USER = "com.xabber.android.ui.ChatViewer.SAVED_INITIAL_USER";
...@@ -135,6 +136,12 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -135,6 +136,12 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return intent; return intent;
} }
public static Intent createShortCutIntent(Context context, String account, String user) {
Intent intent = createClearTopIntent(context, account, user);
intent.setAction(ACTION_SHORTCUT);
return intent;
}
/** /**
* Create intent to send message. * Create intent to send message.
* <p/> * <p/>
...@@ -179,6 +186,10 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -179,6 +186,10 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
restoreInstanceState(savedInstanceState); restoreInstanceState(savedInstanceState);
} }
initChats();
}
private void initChats() {
if (initialChat != null) { if (initialChat != null) {
chatViewerAdapter = new ChatViewerAdapter(getFragmentManager(), initialChat, this); chatViewerAdapter = new ChatViewerAdapter(getFragmentManager(), initialChat, this);
} else { } else {
...@@ -223,6 +234,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -223,6 +234,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
case ACTION_SPECIFIC_CHAT: case ACTION_SPECIFIC_CHAT:
case ACTION_ATTENTION: case ACTION_ATTENTION:
case Intent.ACTION_SEND: case Intent.ACTION_SEND:
case ACTION_SHORTCUT:
isRecentChatsSelected = false; isRecentChatsSelected = false;
selectedChat = new BaseEntity(getAccount(intent), getUser(intent)); selectedChat = new BaseEntity(getAccount(intent), getUser(intent));
break; break;
...@@ -237,7 +249,13 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener ...@@ -237,7 +249,13 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
} }
setIntent(intent); setIntent(intent);
getSelectedPageDataFromIntent(); getSelectedPageDataFromIntent();
if (intent.getAction().equals(ACTION_SHORTCUT)) {
getInitialChatFromIntent();
initChats();
}
} }
private void restoreInstanceState(Bundle savedInstanceState) { private void restoreInstanceState(Bundle savedInstanceState) {
......
...@@ -548,7 +548,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList ...@@ -548,7 +548,7 @@ public class ContactList extends ManagedActivity implements OnAccountChangedList
private void createShortcut(AbstractContact abstractContact) { private void createShortcut(AbstractContact abstractContact) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, ChatViewer.createClearTopIntent(this, intent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, ChatViewer.createShortCutIntent(this,
abstractContact.getAccount(), abstractContact.getUser())); abstractContact.getAccount(), abstractContact.getUser()));
intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName()); intent.putExtra(Intent.EXTRA_SHORTCUT_NAME, abstractContact.getName());
Bitmap bitmap; Bitmap bitmap;
......
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