fixed take photo + do not reint twice
This commit is contained in:
parent
5f502e908e
commit
8aba540717
|
@ -126,12 +126,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
public static final String RECENTLY_USED_QUICK_ACTION = "recently_used_quick_action";
|
public static final String RECENTLY_USED_QUICK_ACTION = "recently_used_quick_action";
|
||||||
public static final String STATE_CONVERSATION_UUID = ConversationFragment.class.getName() + ".uuid";
|
public static final String STATE_CONVERSATION_UUID = ConversationFragment.class.getName() + ".uuid";
|
||||||
public static final String STATE_SCROLL_POSITION = ConversationFragment.class.getName() + ".scroll_position";
|
public static final String STATE_SCROLL_POSITION = ConversationFragment.class.getName() + ".scroll_position";
|
||||||
|
public static final String STATE_PHOTO_URI = ConversationFragment.class.getName()+".take_photo_uri";
|
||||||
|
|
||||||
|
|
||||||
final protected List<Message> messageList = new ArrayList<>();
|
final protected List<Message> messageList = new ArrayList<>();
|
||||||
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
||||||
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
||||||
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
|
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
|
||||||
|
private final PendingItem<Uri> pendingTakePhotoUri = new PendingItem<>();
|
||||||
public Uri mPendingEditorContent = null;
|
public Uri mPendingEditorContent = null;
|
||||||
protected MessageAdapter messageListAdapter;
|
protected MessageAdapter messageListAdapter;
|
||||||
private Conversation conversation;
|
private Conversation conversation;
|
||||||
|
@ -139,6 +141,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
private Toast messageLoaderToast;
|
private Toast messageLoaderToast;
|
||||||
private ConversationActivity activity;
|
private ConversationActivity activity;
|
||||||
|
|
||||||
|
private boolean reInitRequiredOnStart = true;
|
||||||
|
|
||||||
private OnClickListener clickToMuc = new OnClickListener() {
|
private OnClickListener clickToMuc = new OnClickListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -669,6 +673,14 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
attachImageToConversation(conversation, i.next());
|
attachImageToConversation(conversation, i.next());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ATTACHMENT_CHOICE_TAKE_PHOTO:
|
||||||
|
Uri takePhotoUri = pendingTakePhotoUri.pop();
|
||||||
|
if (takePhotoUri != null) {
|
||||||
|
attachImageToConversation(conversation, takePhotoUri);
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,"lost take photo uri. unable to to attach");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case ATTACHMENT_CHOICE_CHOOSE_FILE:
|
case ATTACHMENT_CHOICE_CHOOSE_FILE:
|
||||||
case ATTACHMENT_CHOICE_RECORD_VIDEO:
|
case ATTACHMENT_CHOICE_RECORD_VIDEO:
|
||||||
case ATTACHMENT_CHOICE_RECORD_VOICE:
|
case ATTACHMENT_CHOICE_RECORD_VOICE:
|
||||||
|
@ -1309,10 +1321,8 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
|
intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
|
||||||
break;
|
break;
|
||||||
case ATTACHMENT_CHOICE_TAKE_PHOTO:
|
case ATTACHMENT_CHOICE_TAKE_PHOTO:
|
||||||
Uri uri = activity.xmppConnectionService.getFileBackend().getTakePhotoUri();
|
final Uri uri = activity.xmppConnectionService.getFileBackend().getTakePhotoUri();
|
||||||
//TODO save photo uri
|
pendingTakePhotoUri.push(uri);
|
||||||
//mPendingImageUris.clear();
|
|
||||||
//mPendingImageUris.add(uri);
|
|
||||||
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
|
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
|
||||||
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
@ -1559,6 +1569,10 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
super.onSaveInstanceState(outState);
|
super.onSaveInstanceState(outState);
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid());
|
outState.putString(STATE_CONVERSATION_UUID, conversation.getUuid());
|
||||||
|
Uri uri = pendingTakePhotoUri.pop();
|
||||||
|
if (uri != null) {
|
||||||
|
outState.putString(STATE_PHOTO_URI, uri.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1571,16 +1585,24 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
String uuid = savedInstanceState.getString(STATE_CONVERSATION_UUID);
|
String uuid = savedInstanceState.getString(STATE_CONVERSATION_UUID);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
this.pendingConversationsUuid.push(uuid);
|
this.pendingConversationsUuid.push(uuid);
|
||||||
|
String takePhotoUri = savedInstanceState.getString(STATE_PHOTO_URI);
|
||||||
|
if (takePhotoUri != null) {
|
||||||
|
pendingTakePhotoUri.push(Uri.parse(takePhotoUri));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
reInit(conversation);
|
if (this.reInitRequiredOnStart) {
|
||||||
final Bundle extras = pendingExtras.pop();
|
reInit(conversation);
|
||||||
if (extras != null) {
|
final Bundle extras = pendingExtras.pop();
|
||||||
processExtras(extras);
|
if (extras != null) {
|
||||||
|
processExtras(extras);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Log.d(Config.LOGTAG,"skipped reinit on start");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1625,29 +1647,29 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
|
|
||||||
public void reInit(Conversation conversation, Bundle extras) {
|
public void reInit(Conversation conversation, Bundle extras) {
|
||||||
this.saveMessageDraftStopAudioPlayer();
|
this.saveMessageDraftStopAudioPlayer();
|
||||||
this.reInit(conversation);
|
if (this.reInit(conversation)) {
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
//if binding or activity does not exist we will retry in onStart()
|
|
||||||
if (this.activity != null && this.binding != null) {
|
|
||||||
processExtras(extras);
|
processExtras(extras);
|
||||||
} else {
|
|
||||||
pendingExtras.push(extras);
|
|
||||||
}
|
}
|
||||||
|
this.reInitRequiredOnStart = false;
|
||||||
|
} else {
|
||||||
|
this.reInitRequiredOnStart = true;
|
||||||
|
pendingExtras.push(extras);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reInit(Conversation conversation) {
|
private boolean reInit(Conversation conversation) {
|
||||||
reInit(conversation, false);
|
return reInit(conversation, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void reInit(Conversation conversation, boolean restore) {
|
private boolean reInit(Conversation conversation, boolean restore) {
|
||||||
if (conversation == null) {
|
if (conversation == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
this.conversation = conversation;
|
this.conversation = conversation;
|
||||||
//once we set the conversation all is good and it will automatically do the right thing in onStart()
|
//once we set the conversation all is good and it will automatically do the right thing in onStart()
|
||||||
if (this.activity == null || this.binding == null) {
|
if (this.activity == null || this.binding == null) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
Log.d(Config.LOGTAG, "reInit(restore="+Boolean.toString(restore)+")");
|
Log.d(Config.LOGTAG, "reInit(restore="+Boolean.toString(restore)+")");
|
||||||
setupIme();
|
setupIme();
|
||||||
|
@ -1682,6 +1704,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
activity.onConversationRead(this.conversation);
|
activity.onConversationRead(this.conversation);
|
||||||
//TODO if we only do this when this fragment is running on main it won't *bing* in tablet layout which might be unnecessary since we can *see* it
|
//TODO if we only do this when this fragment is running on main it won't *bing* in tablet layout which might be unnecessary since we can *see* it
|
||||||
activity.xmppConnectionService.getNotificationService().setOpenConversation(this.conversation);
|
activity.xmppConnectionService.getNotificationService().setOpenConversation(this.conversation);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processExtras(Bundle extras) {
|
private void processExtras(Bundle extras) {
|
||||||
|
|
Loading…
Reference in a new issue