aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2016-10-23 22:04:20 +0200
committerChristian Schneppe <christian@pix-art.de>2016-10-23 22:04:20 +0200
commite3fc6efdb4c7ff96c55c711c9ffb0f109dee1c25 (patch)
treef1d06de3a85e17b92787ecccfa62793ebff7df62 /src/main/java/de/pixart/messenger
parent00d2b77d874152256dd2e43dcbdf510b0f1dde4a (diff)
fix duplicate file sharing via ShareWithActivity
Diffstat (limited to 'src/main/java/de/pixart/messenger')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ShareWithActivity.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
index e2280bdf2..329c03211 100644
--- a/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ShareWithActivity.java
@@ -36,6 +36,10 @@ import static java.lang.String.format;
public class ShareWithActivity extends XmppActivity implements XmppConnectionService.OnConversationUpdate {
private boolean mReturnToPrevious = false;
+ private static final String STATE_SHARING_IS_RUNNING = "state_sharing_is_running";
+ static boolean ContactChosen = false;
+ static boolean IntentReceived = false;
+ boolean SharingIsRunning = false;
@Override
public void onConversationUpdate() {
@@ -162,7 +166,16 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
}
});
- this.share = new Share();
+ if (savedInstanceState != null) {
+ SharingIsRunning = savedInstanceState.getBoolean(STATE_SHARING_IS_RUNNING, false);
+ }
+ if (!SharingIsRunning) {
+ Log.d(Config.LOGTAG, "ShareWithActivity onCreate: state restored");
+ this.share = new Share();
+ } else {
+ Log.d(Config.LOGTAG, "ShareWithActivity onCreate: shring running, finish()");
+ this.finish();
+ }
}
@Override
@@ -188,7 +201,10 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
Intent intent = getIntent();
if (intent == null) {
return;
- }
+ } else {
+ IntentReceived = true;
+ }
+ Log.d(Config.LOGTAG, "ShareWithActivity onStart() getIntent " + intent.toString());
this.mReturnToPrevious = getPreferences().getBoolean("return_to_previous", false);
final String type = intent.getType();
final String action = intent.getAction();
@@ -198,6 +214,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
final String subject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
final String text = intent.getStringExtra(Intent.EXTRA_TEXT);
final Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
+ Log.d(Config.LOGTAG, "ShareWithActivity onStart() Uri: " + uri);
if (type != null && uri != null && (text == null || !type.equals("text/plain"))) {
this.share.uris.clear();
this.share.uris.add(uri);
@@ -227,6 +244,18 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
}
+ @Override
+ public void onSaveInstanceState(final Bundle savedInstanceState) {
+ Log.d(Config.LOGTAG, "ShareWithActivity onSaveInstanceState: IntentReceived: " + IntentReceived + " ContactChosen: " + ContactChosen);
+ if (IntentReceived && ContactChosen) {
+ Log.d(Config.LOGTAG, "ShareWithActivity onSaveInstanceState: state saved");
+ savedInstanceState.putBoolean(STATE_SHARING_IS_RUNNING, true);
+ } else {
+ Log.d(Config.LOGTAG, "ShareWithActivity onSaveInstanceState: sharing is running, do nothing at this point");
+ }
+ super.onSaveInstanceState(savedInstanceState);
+ }
+
protected boolean isImage(Uri uri) {
try {
String guess = URLConnection.guessContentTypeFromName(uri.toString());
@@ -280,6 +309,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
return;
}
}
+ ContactChosen = true;
share(conversation);
}
@@ -303,6 +333,7 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
public void onPresenceSelected() {
attachmentCounter.set(share.uris.size());
if (share.image) {
+ Log.d(Config.LOGTAG, "ShareWithActivity share() image " + share.uris.size() + " uri(s) " + share.uris.toString());
share.multiple = share.uris.size() > 1;
replaceToast(getString(share.multiple ? R.string.preparing_images : R.string.preparing_image));
for (Iterator<Uri> i = share.uris.iterator(); i.hasNext(); i.remove()) {
@@ -311,11 +342,13 @@ public class ShareWithActivity extends XmppActivity implements XmppConnectionSer
attachFileCallback);
}
} else if (share.video) {
+ Log.d(Config.LOGTAG, "ShareWithActivity share() video " + share.uris.size() + " uri(s) " + share.uris.toString());
replaceToast(getString(R.string.preparing_video));
ShareWithActivity.this.xmppConnectionService
.attachVideoToConversation(conversation, share.uris.get(0),
attachFileCallback);
} else {
+ Log.d(Config.LOGTAG, "ShareWithActivity share() file " + share.uris.size() + " uri(s) " + share.uris.toString());
replaceToast(getString(R.string.preparing_file));
ShareWithActivity.this.xmppConnectionService
.attachFileToConversation(conversation, share.uris.get(0),