aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/eu/siacs
diff options
context:
space:
mode:
authorsteckbrief <steckbrief@chefmail.de>2015-10-05 16:05:56 +0200
committersteckbrief <steckbrief@chefmail.de>2015-10-05 16:05:56 +0200
commit383d1aa9e64a245f17dd7ec6d177bb286a489f62 (patch)
tree0b9d8a50cab4384063669b794ce91804b0a7545c /src/main/java/eu/siacs
parentc3c42e415ddd7832fea66766377fb4f0d935537a (diff)
parent1db6e6d5eadbad04768be823b8dbd32827b9b5c3 (diff)
Merge remote-tracking branch 'remotes/origin/trz/rename' into trz/rebase
Manually merged conflicting files: src/main/AndroidManifest.xml src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java src/main/java/eu/siacs/conversations/generator/IqGenerator.java src/main/java/eu/siacs/conversations/ui/AboutPreference.java
Diffstat (limited to 'src/main/java/eu/siacs')
-rw-r--r--src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java17
-rw-r--r--src/main/java/eu/siacs/conversations/generator/IqGenerator.java8
-rw-r--r--src/main/java/eu/siacs/conversations/services/NotificationService.java3
-rw-r--r--src/main/java/eu/siacs/conversations/ui/AboutPreference.java4
-rw-r--r--src/main/java/eu/siacs/conversations/utils/PhoneHelper.java15
5 files changed, 12 insertions, 35 deletions
diff --git a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
index 3607b69a..190e42bc 100644
--- a/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/AbstractGenerator.java
@@ -12,9 +12,9 @@ import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.tzur.conversations.Settings;
import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.utils.PhoneHelper;
public abstract class AbstractGenerator {
private final String[] FEATURES = {
@@ -35,8 +35,6 @@ public abstract class AbstractGenerator {
"urn:xmpp:receipts"
};
private String mVersion = null;
- //FIXME use appname or similar!!!!!!!!!!!11elf
- public final String IDENTITY_NAME = "Conversations+";
public final String IDENTITY_TYPE = "phone";
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
@@ -47,20 +45,9 @@ public abstract class AbstractGenerator {
this.mXmppConnectionService = service;
}
- protected String getIdentityVersion() {
- if (mVersion == null) {
- this.mVersion = PhoneHelper.getVersionName(mXmppConnectionService);
- }
- return this.mVersion;
- }
-
- protected String getIdentityName() {
- return IDENTITY_NAME + " " + getIdentityVersion();
- }
-
public String getCapHash() {
StringBuilder s = new StringBuilder();
- s.append("client/" + IDENTITY_TYPE + "//" + getIdentityName() + "<");
+ s.append("client/" + IDENTITY_TYPE + "//" + ConversationsPlusApplication.getNameAndVersion() + "<");
MessageDigest md;
try {
md = MessageDigest.getInstance("SHA-1");
diff --git a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
index 47915e3f..98122446 100644
--- a/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
+++ b/src/main/java/eu/siacs/conversations/generator/IqGenerator.java
@@ -4,12 +4,12 @@ package eu.siacs.conversations.generator;
import java.util.ArrayList;
import java.util.List;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.services.MessageArchiveService;
import eu.siacs.conversations.services.XmppConnectionService;
-import eu.siacs.conversations.utils.PhoneHelper;
import eu.siacs.conversations.utils.Xmlns;
import eu.siacs.conversations.xml.Element;
import eu.siacs.conversations.xmpp.forms.Data;
@@ -33,7 +33,7 @@ public class IqGenerator extends AbstractGenerator {
final Element identity = query.addChild("identity");
identity.setAttribute("category", "client");
identity.setAttribute("type", IDENTITY_TYPE);
- identity.setAttribute("name", getIdentityName());
+ identity.setAttribute("name", ConversationsPlusApplication.getNameAndVersion());
for (final String feature : getFeatures()) {
query.addChild("feature").setAttribute("var", feature);
}
@@ -43,8 +43,8 @@ public class IqGenerator extends AbstractGenerator {
public IqPacket versionResponse(final IqPacket request) {
final IqPacket packet = request.generateResponse(IqPacket.TYPE.RESULT);
Element query = packet.query("jabber:iq:version");
- query.addChild("name").setContent(IDENTITY_NAME);
- query.addChild("version").setContent(getIdentityVersion());
+ query.addChild("name").setContent(ConversationsPlusApplication.getName());
+ query.addChild("version").setContent(ConversationsPlusApplication.getVersion());
return packet;
}
diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java
index 683fcb04..a6194d6e 100644
--- a/src/main/java/eu/siacs/conversations/services/NotificationService.java
+++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java
@@ -31,6 +31,7 @@ import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
import de.tzur.conversations.Settings;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@@ -82,7 +83,7 @@ public class NotificationService {
final String notificationData = new JSONArray().put(jsonData).toString();
i.putExtra("messageType", "PEBBLE_ALERT");
- i.putExtra("sender", "Conversations"); /* XXX: Shouldn't be hardcoded, e.g., AbstractGenerator.APP_NAME); */
+ i.putExtra("sender", ConversationsPlusApplication.getName());
i.putExtra("notificationData", notificationData);
// notify Pebble App
i.setPackage("com.getpebble.android");
diff --git a/src/main/java/eu/siacs/conversations/ui/AboutPreference.java b/src/main/java/eu/siacs/conversations/ui/AboutPreference.java
index a57e1b89..6ad34257 100644
--- a/src/main/java/eu/siacs/conversations/ui/AboutPreference.java
+++ b/src/main/java/eu/siacs/conversations/ui/AboutPreference.java
@@ -6,7 +6,7 @@ import android.content.pm.PackageManager;
import android.preference.Preference;
import android.util.AttributeSet;
-import eu.siacs.conversations.utils.PhoneHelper;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
public class AboutPreference extends Preference {
public AboutPreference(final Context context, final AttributeSet attrs, final int defStyle) {
@@ -27,7 +27,7 @@ public class AboutPreference extends Preference {
}
private void setSummary() {
- setSummary("Conversations " + PhoneHelper.getVersionName(getContext()));
+ setSummary(ConversationsPlusApplication.getNameAndVersion());
}
}
diff --git a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
index 99e8ebb8..e0556af3 100644
--- a/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
+++ b/src/main/java/eu/siacs/conversations/utils/PhoneHelper.java
@@ -15,6 +15,8 @@ import android.os.Bundle;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Profile;
+import de.thedevstack.conversationsplus.ConversationsPlusApplication;
+
public class PhoneHelper {
public static void loadPhoneContacts(Context context,final List<Bundle> phoneContacts, final OnPhoneContactsLoadedListener listener) {
@@ -92,17 +94,4 @@ public class PhoneHelper {
}
}
}
-
- public static String getVersionName(Context context) {
- final String packageName = context == null ? null : context.getPackageName();
- if (packageName != null) {
- try {
- return context.getPackageManager().getPackageInfo(packageName, 0).versionName;
- } catch (final PackageManager.NameNotFoundException e) {
- return "unknown";
- }
- } else {
- return "unknown";
- }
- }
}