bug fixes for the previous ui refactoring

This commit is contained in:
iNPUTmice 2014-11-07 21:49:31 +01:00
parent e45d7bda38
commit 014f5a195b
3 changed files with 20 additions and 27 deletions

View file

@ -15,7 +15,6 @@ import android.os.SystemClock;
import android.provider.MediaStore; import android.provider.MediaStore;
import android.support.v4.widget.SlidingPaneLayout; import android.support.v4.widget.SlidingPaneLayout;
import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener; import android.support.v4.widget.SlidingPaneLayout.PanelSlideListener;
import android.util.Log;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -141,14 +140,9 @@ public class ConversationActivity extends XmppActivity implements
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
Log.d(Config.LOGTAG, "on create");
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
if (savedInstanceState != null) { if (savedInstanceState != null) {mOpenConverstaion = savedInstanceState.getString(
Log.d(Config.LOGTAG, savedInstanceState.toString());
mOpenConverstaion = savedInstanceState.getString(
STATE_OPEN_CONVERSATION, null); STATE_OPEN_CONVERSATION, null);
Log.d(Config.LOGTAG, "recovered " + mOpenConverstaion);
mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true); mPanelOpen = savedInstanceState.getBoolean(STATE_PANEL_OPEN, true);
String pending = savedInstanceState.getString(STATE_PENDING_URI, null); String pending = savedInstanceState.getString(STATE_PENDING_URI, null);
if (pending != null) { if (pending != null) {
@ -164,11 +158,11 @@ public class ConversationActivity extends XmppActivity implements
transaction.commit(); transaction.commit();
listView = (ListView) findViewById(R.id.list); listView = (ListView) findViewById(R.id.list);
this.listAdapter = new ConversationAdapter(this, conversationList);
listView.setAdapter(this.listAdapter);
getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setDisplayHomeAsUpEnabled(false);
getActionBar().setHomeButtonEnabled(false); getActionBar().setHomeButtonEnabled(false);
this.listAdapter = new ConversationAdapter(this, conversationList);
listView.setAdapter(this.listAdapter);
listView.setOnItemClickListener(new OnItemClickListener() { listView.setOnItemClickListener(new OnItemClickListener() {
@ -213,15 +207,7 @@ public class ConversationActivity extends XmppActivity implements
@Override @Override
public void onPanelClosed(View arg0) { public void onPanelClosed(View arg0) {
if ((conversationList.size() > 0) openConversation();
&& (getSelectedConversation() != null)) {
openConversation(getSelectedConversation());
if (!getSelectedConversation().isRead()) {
xmppConnectionService.markRead(
getSelectedConversation(), true);
listView.invalidateViews();
}
}
} }
@Override @Override
@ -233,7 +219,7 @@ public class ConversationActivity extends XmppActivity implements
} }
} }
public void openConversation(Conversation conversation) { public void openConversation() {
ActionBar ab = getActionBar(); ActionBar ab = getActionBar();
if (ab != null) { if (ab != null) {
ab.setDisplayHomeAsUpEnabled(true); ab.setDisplayHomeAsUpEnabled(true);
@ -249,8 +235,11 @@ public class ConversationActivity extends XmppActivity implements
} }
invalidateOptionsMenu(); invalidateOptionsMenu();
if (xmppConnectionServiceBound) { if (xmppConnectionServiceBound) {
xmppConnectionService.getNotificationService().setOpenConversation( xmppConnectionService.getNotificationService().setOpenConversation(getSelectedConversation());
conversation); if (!getSelectedConversation().isRead()) {
xmppConnectionService.markRead(getSelectedConversation(), true);
listView.invalidateViews();
}
} }
} }
@ -443,6 +432,7 @@ public class ConversationActivity extends XmppActivity implements
xmppConnectionService.archiveConversation(conversation); xmppConnectionService.archiveConversation(conversation);
if (conversationList.size() > 0) { if (conversationList.size() > 0) {
setSelectedConversation(conversationList.get(0)); setSelectedConversation(conversationList.get(0));
this.mConversationFragment.reInit(getSelectedConversation());
} else { } else {
setSelectedConversation(null); setSelectedConversation(null);
} }
@ -659,7 +649,6 @@ public class ConversationActivity extends XmppActivity implements
public void onSaveInstanceState(Bundle savedInstanceState) { public void onSaveInstanceState(Bundle savedInstanceState) {
Conversation conversation = getSelectedConversation(); Conversation conversation = getSelectedConversation();
if (conversation != null) { if (conversation != null) {
Log.d(Config.LOGTAG, "saving conversation: " + conversation.getName() + " " + conversation.getUuid());
savedInstanceState.putString(STATE_OPEN_CONVERSATION, savedInstanceState.putString(STATE_OPEN_CONVERSATION,
conversation.getUuid()); conversation.getUuid());
} }
@ -684,12 +673,14 @@ public class ConversationActivity extends XmppActivity implements
} else if (getIntent() != null } else if (getIntent() != null
&& VIEW_CONVERSATION.equals(getIntent().getType())) { && VIEW_CONVERSATION.equals(getIntent().getType())) {
handleViewConversationIntent(getIntent()); handleViewConversationIntent(getIntent());
setIntent(null);
} else if (mOpenConverstaion != null) { } else if (mOpenConverstaion != null) {
Log.d(Config.LOGTAG, "open conversation: " + mOpenConverstaion);
selectConversationByUuid(mOpenConverstaion); selectConversationByUuid(mOpenConverstaion);
if (mPanelOpen) { if (mPanelOpen) {
showConversationsOverview(); showConversationsOverview();
} else {
if (isConversationsOverviewHideable()) {
openConversation();
}
} }
this.mConversationFragment.reInit(getSelectedConversation()); this.mConversationFragment.reInit(getSelectedConversation());
mOpenConverstaion = null; mOpenConverstaion = null;
@ -706,6 +697,7 @@ public class ConversationActivity extends XmppActivity implements
mPendingImageUri = null; mPendingImageUri = null;
} }
ExceptionHelper.checkForCrash(this, this.xmppConnectionService); ExceptionHelper.checkForCrash(this, this.xmppConnectionService);
setIntent(new Intent());
} }
private void handleViewConversationIntent(Intent intent) { private void handleViewConversationIntent(Intent intent) {
@ -715,7 +707,9 @@ public class ConversationActivity extends XmppActivity implements
this.mConversationFragment.reInit(getSelectedConversation()); this.mConversationFragment.reInit(getSelectedConversation());
this.mConversationFragment.appendText(text); this.mConversationFragment.appendText(text);
hideConversationsOverview(); hideConversationsOverview();
openConversation(getSelectedConversation()); if (mContentView instanceof SlidingPaneLayout) {
openConversation();
}
} }
private void selectConversationByUuid(String uuid) { private void selectConversationByUuid(String uuid) {

View file

@ -566,7 +566,6 @@ public class ConversationFragment extends Fragment {
} }
} }
} }
getActivity().invalidateOptionsMenu();
updateChatMsgHint(); updateChatMsgHint();
if (!activity.isConversationsOverviewVisable() || !activity.isConversationsOverviewHideable()) { if (!activity.isConversationsOverviewVisable() || !activity.isConversationsOverviewHideable()) {
activity.xmppConnectionService.markRead(conversation, true); activity.xmppConnectionService.markRead(conversation, true);

View file

@ -364,6 +364,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
R.layout.message_status, parent, false); R.layout.message_status, parent, false);
viewHolder.contact_picture = (ImageView) view viewHolder.contact_picture = (ImageView) view
.findViewById(R.id.message_photo); .findViewById(R.id.message_photo);
view.setTag(viewHolder);
break; break;
default: default:
viewHolder = null; viewHolder = null;
@ -375,7 +376,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
if (type == STATUS) { if (type == STATUS) {
if (item.getConversation().getMode() == Conversation.MODE_SINGLE) { if (item.getConversation().getMode() == Conversation.MODE_SINGLE) {
viewHolder.contact_picture.setImageBitmap(activity viewHolder.contact_picture.setImageBitmap(activity
.avatarService().get( .avatarService().get(
item.getConversation().getContact(), item.getConversation().getContact(),