aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-03-30 22:11:11 +0200
committerChristian Schneppe <christian@pix-art.de>2018-03-30 22:11:11 +0200
commit47a6f6f5371842c68505acbf0a71dde935e7ee19 (patch)
treebe9fef300a0523e31550ab64f7c56be1867c2a36 /src/main/java
parent255406a86fd8bfa757b39b07c1adac7cfe493cc5 (diff)
added dedicated scan button
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java3
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java17
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java5
-rw-r--r--src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java8
4 files changed, 22 insertions, 11 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index 9d023f235..501a70961 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -261,6 +261,9 @@ public class ConversationActivity extends XmppActivity implements OnConversation
return true;
}
break;
+ case R.id.action_scan_qr_code:
+ UriHandlerActivity.scan(this);
+ return true;
}
return super.onOptionsItemSelected(item);
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index d056194a5..718b0d8b9 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -1851,28 +1851,31 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
private void reInit(Conversation conversation) {
- Log.d(Config.LOGTAG, "reInit()");
+ reInit(conversation, false);
+ }
+
+ private void reInit(Conversation conversation, boolean restore) {
if (conversation == null) {
- Log.d(Config.LOGTAG, "conversation was null :(");
return;
}
if (this.activity == null) {
- Log.d(Config.LOGTAG, "activity was null");
this.conversation = conversation;
return;
}
-
+ Log.d(Config.LOGTAG, "reInit(restore=" + Boolean.toString(restore) + ")");
setupIme();
if (this.conversation != null) {
final String msg = this.binding.textinput.getText().toString();
if (this.conversation.setNextMessage(msg)) {
activity.xmppConnectionService.updateConversation(conversation);
}
- if (this.conversation != conversation) {
+ if (this.conversation != conversation && !restore) {
updateChatState(this.conversation, msg);
messageListAdapter.stopAudioPlayer();
}
- this.conversation.trim();
+ if (!restore) {
+ this.conversation.trim();
+ }
}
if (activity != null) {
@@ -2624,7 +2627,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
clearPending();
return;
}
- reInit(conversation);
+ reInit(conversation, true);
}
ActivityResult activityResult = postponedActivityResult.pop();
if (activityResult != null) {
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 5c88dc0d2..0d658ebb2 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -645,10 +645,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
showJoinConferenceDialog(null);
return true;
case R.id.action_scan_qr_code:
- Intent intent = new Intent(this, UriHandlerActivity.class);
- intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
- intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(intent);
+ UriHandlerActivity.scan(this);
return true;
case R.id.action_hide_offline:
mHideOfflineContacts = !item.isChecked();
diff --git a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
index 09d4d26ac..c4374df33 100644
--- a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
@@ -1,5 +1,6 @@
package de.pixart.messenger.ui;
+import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
@@ -101,4 +102,11 @@ public class UriHandlerActivity extends AppCompatActivity {
finish();
super.onActivityResult(requestCode, requestCode, intent);
}
+
+ public static void scan(Activity activity) {
+ Intent intent = new Intent(activity, UriHandlerActivity.class);
+ intent.setAction(UriHandlerActivity.ACTION_SCAN_QR_CODE);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
+ activity.startActivity(intent);
+ }
} \ No newline at end of file