aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de')
-rw-r--r--src/main/java/de/pixart/messenger/crypto/sasl/Plain.java10
-rw-r--r--src/main/java/de/pixart/messenger/generator/AbstractGenerator.java6
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java6
-rw-r--r--src/main/java/de/pixart/messenger/http/HttpUploadConnection.java2
-rw-r--r--src/main/java/de/pixart/messenger/ui/ActionBarActivity.java11
-rw-r--r--src/main/java/de/pixart/messenger/ui/StartConversationActivity.java8
-rw-r--r--src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java1
-rw-r--r--src/main/java/de/pixart/messenger/utils/AccountUtils.java8
8 files changed, 42 insertions, 10 deletions
diff --git a/src/main/java/de/pixart/messenger/crypto/sasl/Plain.java b/src/main/java/de/pixart/messenger/crypto/sasl/Plain.java
index 27de45247..e7e497d37 100644
--- a/src/main/java/de/pixart/messenger/crypto/sasl/Plain.java
+++ b/src/main/java/de/pixart/messenger/crypto/sasl/Plain.java
@@ -24,7 +24,11 @@ public class Plain extends SaslMechanism {
@Override
public String getClientFirstMessage() {
- final String sasl = '\u0000' + account.getUsername() + '\u0000' + account.getPassword();
- return Base64.encodeToString(sasl.getBytes(Charset.defaultCharset()), Base64.NO_WRAP);
+ return getMessage(account.getUsername(), account.getPassword());
}
-}
+
+ public static String getMessage(String username, String password) {
+ final String message = '\u0000' + username + '\u0000' + password;
+ return Base64.encodeToString(message.getBytes(Charset.defaultCharset()), Base64.NO_WRAP);
+ }
+} \ No newline at end of file
diff --git a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
index 507c0c39a..ac57c74d1 100644
--- a/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
+++ b/src/main/java/de/pixart/messenger/generator/AbstractGenerator.java
@@ -72,7 +72,11 @@ public abstract class AbstractGenerator {
}
public String getIdentityName() {
- return mXmppConnectionService.getString(R.string.app_name) + " " + getIdentityVersion();
+ return mXmppConnectionService.getString(R.string.app_name) + ' ' + getIdentityVersion();
+ }
+
+ public String getUserAgent() {
+ return mXmppConnectionService.getString(R.string.app_name) + '/' + getIdentityVersion();
}
String getIdentityType() {
diff --git a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
index 15bfc8825..cf867d796 100644
--- a/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpDownloadConnection.java
@@ -295,7 +295,7 @@ public class HttpDownloadConnection implements Transferable {
}
connection.setUseCaches(false);
Log.d(Config.LOGTAG, "url: " + connection.getURL().toString());
- connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
+ connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getUserAgent());
connection.setRequestProperty("Accept-Encoding", "identity");
if (connection instanceof HttpsURLConnection) {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
@@ -377,7 +377,7 @@ public class HttpDownloadConnection implements Transferable {
mHttpConnectionManager.setupTrustManager((HttpsURLConnection) connection, interactive);
}
connection.setUseCaches(false);
- connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
+ connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getUserAgent());
connection.setRequestProperty("Accept-Encoding", "identity");
final boolean tryResume = file.exists() && file.getKey() == null && file.getSize() > 0;
long resumeSize = 0;
@@ -392,7 +392,7 @@ public class HttpDownloadConnection implements Transferable {
connection.connect();
is = new BufferedInputStream(connection.getInputStream());
final String contentRange = connection.getHeaderField("Content-Range");
- boolean serverResumed = tryResume && contentRange != null && contentRange.startsWith("bytes "+resumeSize+"-");
+ boolean serverResumed = tryResume && contentRange != null && contentRange.startsWith("bytes " + resumeSize + "-");
long transmitted = 0;
if (tryResume && serverResumed) {
Log.d(Config.LOGTAG, "server resumed");
diff --git a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
index 589e46d6c..49debcb78 100644
--- a/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
+++ b/src/main/java/de/pixart/messenger/http/HttpUploadConnection.java
@@ -165,7 +165,7 @@ public class HttpUploadConnection implements Transferable {
connection.setUseCaches(false);
connection.setRequestMethod("PUT");
connection.setFixedLengthStreamingMode(expectedFileSize);
- connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getIdentityName());
+ connection.setRequestProperty("User-Agent", mXmppConnectionService.getIqGenerator().getUserAgent());
if (slot.getHeaders() != null) {
for (HashMap.Entry<String, String> entry : slot.getHeaders().entrySet()) {
connection.setRequestProperty(entry.getKey(), entry.getValue());
diff --git a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java
index 06dad3d13..bc0557f1f 100644
--- a/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ActionBarActivity.java
@@ -2,6 +2,7 @@ package de.pixart.messenger.ui;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
+import android.view.MenuItem;
public abstract class ActionBarActivity extends AppCompatActivity {
public static void configureActionBar(ActionBar actionBar) {
@@ -14,4 +15,14 @@ public abstract class ActionBarActivity extends AppCompatActivity {
actionBar.setDisplayHomeAsUpEnabled(upNavigation);
}
}
+
+ @Override
+ public boolean onOptionsItemSelected(final MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
}
diff --git a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
index 60c94042d..1edbafd67 100644
--- a/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/StartConversationActivity.java
@@ -99,6 +99,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
private EditText mSearchEditText;
private AtomicBoolean mRequestedContactsPermission = new AtomicBoolean(false);
private boolean mHideOfflineContacts = false;
+ private boolean createdByViewIntent = false;
private MenuItem.OnActionExpandListener mOnActionExpandListener = new MenuItem.OnActionExpandListener() {
@Override
@@ -302,6 +303,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (savedInstanceState == null) {
intent = getIntent();
} else {
+ createdByViewIntent = savedInstanceState.getBoolean("created_by_view_intent", false);
final String search = savedInstanceState.getString("search");
if (search != null) {
mInitialSearchValue.push(search);
@@ -311,6 +313,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (isViewIntent(intent)) {
pendingViewIntent.push(intent);
+ createdByViewIntent = true;
setIntent(createLauncherIntent(this));
} else if (startSearching && mInitialSearchValue.peek() == null) {
mInitialSearchValue.push("");
@@ -321,6 +324,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
public void onSaveInstanceState(Bundle savedInstanceState) {
Intent pendingIntent = pendingViewIntent.peek();
savedInstanceState.putParcelable("intent", pendingIntent != null ? pendingIntent : getIntent());
+ savedInstanceState.putBoolean("created_by_view_intent", createdByViewIntent);
if (mMenuSearchView != null && mMenuSearchView.isActionViewExpanded()) {
savedInstanceState.putString("search", mSearchEditText != null ? mSearchEditText.getText().toString() : null);
}
@@ -723,7 +727,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
if (actionBar == null) {
return;
}
- boolean openConversations = !xmppConnectionService.isConversationsListEmpty(null);
+ boolean openConversations = !createdByViewIntent && !xmppConnectionService.isConversationsListEmpty(null);
actionBar.setDisplayHomeAsUpEnabled(openConversations);
actionBar.setDisplayHomeAsUpEnabled(openConversations);
@@ -937,7 +941,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
}
private void navigateBack() {
- if (xmppConnectionService != null && !xmppConnectionService.isConversationsListEmpty(null)) {
+ if (!createdByViewIntent && xmppConnectionService != null && !xmppConnectionService.isConversationsListEmpty(null)) {
Intent intent = new Intent(this, ConversationsActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
startActivity(intent);
diff --git a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
index c640e42da..559e20648 100644
--- a/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/UriHandlerActivity.java
@@ -112,6 +112,7 @@ public class UriHandlerActivity extends AppCompatActivity {
intent.putExtra("body", body);
} else {
intent = new Intent(this, StartConversationActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
intent.setData(uri);
intent.putExtra("account", accounts.get(0).toEscapedString());
}
diff --git a/src/main/java/de/pixart/messenger/utils/AccountUtils.java b/src/main/java/de/pixart/messenger/utils/AccountUtils.java
index 430ebb573..d675ed680 100644
--- a/src/main/java/de/pixart/messenger/utils/AccountUtils.java
+++ b/src/main/java/de/pixart/messenger/utils/AccountUtils.java
@@ -29,6 +29,14 @@ public class AccountUtils {
return null;
}
+ public static Account getFirst(XmppConnectionService service) {
+ final List<Account> accounts = service.getAccounts();
+ for (Account account : accounts) {
+ return account;
+ }
+ return null;
+ }
+
public static Account getPendingAccount(XmppConnectionService service) {
Account pending = null;
for (Account account : service.getAccounts()) {