diff options
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services')
6 files changed, 171 insertions, 19 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index 8d02f975a..50bb83d30 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -46,11 +46,11 @@ public class AbstractConnectionManager { public long getAutoAcceptFileSize() { String config = this.mXmppConnectionService.getPreferences().getString( - "auto_accept_file_size", "524288"); + "auto_accept_file_size", "1048576"); try { return Long.parseLong(config); } catch (NumberFormatException e) { - return 524288; + return 1048576; } } diff --git a/src/main/java/eu/siacs/conversations/services/AvatarService.java b/src/main/java/eu/siacs/conversations/services/AvatarService.java index bb8ec5f29..4cf9ade14 100644 --- a/src/main/java/eu/siacs/conversations/services/AvatarService.java +++ b/src/main/java/eu/siacs/conversations/services/AvatarService.java @@ -49,12 +49,12 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { if (avatar != null || cachedOnly) { return avatar; } - if (contact.getProfilePhoto() != null) { - avatar = mXmppConnectionService.getFileBackend().cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size); - } if (avatar == null && contact.getAvatar() != null) { avatar = mXmppConnectionService.getFileBackend().getAvatar(contact.getAvatar(), size); } + if (avatar == null && contact.getProfilePhoto() != null) { + avatar = mXmppConnectionService.getFileBackend().cropCenterSquare(Uri.parse(contact.getProfilePhoto()), size); + } if (avatar == null) { avatar = get(contact.getDisplayName(), size, cachedOnly); } @@ -335,12 +335,22 @@ public class AvatarService implements OnAdvancedStreamFeaturesLoaded { Contact contact = user.getContact(); if (contact != null) { Uri uri = null; - if (contact.getProfilePhoto() != null) { - uri = Uri.parse(contact.getProfilePhoto()); - } else if (contact.getAvatar() != null) { + if (contact.getAvatar() != null) { uri = mXmppConnectionService.getFileBackend().getAvatarUri( contact.getAvatar()); + } else if (contact.getProfilePhoto() != null) { + uri = Uri.parse(contact.getProfilePhoto()); + } + if (drawTile(canvas, uri, left, top, right, bottom)) { + return true; + } + } else if (user.getAvatar() != null) { + Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar()); + if (drawTile(canvas, uri, left, top, right, bottom)) { + return true; } + } else if (user.getAvatar() != null) { + Uri uri = mXmppConnectionService.getFileBackend().getAvatarUri(user.getAvatar()); if (drawTile(canvas, uri, left, top, right, bottom)) { return true; } diff --git a/src/main/java/eu/siacs/conversations/services/CheckAppVersionService.java b/src/main/java/eu/siacs/conversations/services/CheckAppVersionService.java new file mode 100644 index 000000000..33faeaeca --- /dev/null +++ b/src/main/java/eu/siacs/conversations/services/CheckAppVersionService.java @@ -0,0 +1,43 @@ +package eu.siacs.conversations.services; + +import com.google.gson.JsonObject; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class CheckAppVersionService extends HttpServlet { + private static final long serialVersionUID = 1L; + + public CheckAppVersionService() { + super(); + } + + protected void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + doPost(request,response); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + PrintWriter out = response.getWriter(); + response.setContentType("text/html"); + + //send a JSON response with the app Version and file URI + JsonObject myObj = new JsonObject(); + myObj.addProperty("success", false); + myObj.addProperty("latestVersionCode", 2); + myObj.addProperty("latestVersion", "1.0.0"); + myObj.addProperty("changelog", ""); + myObj.addProperty("appURI", ""); + out.println(myObj.toString()); + out.close(); + + } + +} diff --git a/src/main/java/eu/siacs/conversations/services/NotificationService.java b/src/main/java/eu/siacs/conversations/services/NotificationService.java index 764a1d525..c7036c98c 100644 --- a/src/main/java/eu/siacs/conversations/services/NotificationService.java +++ b/src/main/java/eu/siacs/conversations/services/NotificationService.java @@ -304,7 +304,7 @@ public class NotificationService { final ArrayList<Message> messages, final boolean notify) { try { final Bitmap bitmap = mXmppConnectionService.getFileBackend() - .getThumbnail(message, getPixel(288), false); + .getThumbnail(message, getPixel(200), false); final ArrayList<Message> tmp = new ArrayList<>(); for (final Message msg : messages) { if (msg.getType() == Message.TYPE_TEXT @@ -544,7 +544,7 @@ public class NotificationService { cancelIcon = R.drawable.ic_action_cancel; } mBuilder.setSmallIcon(R.drawable.ic_link_white_24dp); - if (Config.SHOW_DISABLE_FOREGROUND) { + if (Config.SHOW_DISABLE_FOREGROUND && !Config.USE_ALWAYS_FOREGROUND) { mBuilder.addAction(cancelIcon, mXmppConnectionService.getString(R.string.disable_foreground_service), createDisableForeground()); @@ -564,7 +564,7 @@ public class NotificationService { errors.add(account); } } - if (mXmppConnectionService.getPreferences().getBoolean("keep_foreground_service", false)) { + if (Config.USE_ALWAYS_FOREGROUND) { notificationManager.notify(FOREGROUND_NOTIFICATION_ID, createForegroundNotification()); } final NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(mXmppConnectionService); diff --git a/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java b/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java new file mode 100644 index 000000000..cb58b49eb --- /dev/null +++ b/src/main/java/eu/siacs/conversations/services/UpdaterWebService.java @@ -0,0 +1,103 @@ +package eu.siacs.conversations.services; + +import android.app.IntentService; +import android.content.Intent; +import android.content.pm.PackageInfo; +import android.content.pm.PackageManager; +import android.util.Log; + +import org.apache.http.HttpResponse; +import org.apache.http.HttpStatus; +import org.apache.http.StatusLine; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.HttpClient; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.conn.params.ConnManagerParams; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.params.HttpConnectionParams; +import org.apache.http.params.HttpParams; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; + +import eu.siacs.conversations.Config; +import eu.siacs.conversations.R; +import eu.siacs.conversations.ui.UpdaterActivity.UpdateReceiver; + +public class UpdaterWebService extends IntentService{ + public static final String REQUEST_STRING = ""; + public static final String RESPONSE_MESSAGE = ""; + + private String URL = null; + public static final int REGISTRATION_TIMEOUT = 3 * 1000; + public static final int WAIT_TIMEOUT = 30 * 1000; + + public UpdaterWebService() { + super("UpdaterWebService"); + } + + @Override + protected void onHandleIntent(Intent intent) { + + String requestString = intent.getStringExtra(REQUEST_STRING); + Log.d(Config.LOGTAG, "AppUpdater: " + requestString); + String responseMessage; + PackageInfo pInfo = null; + try { + pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); + } + catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + //get the app version Name for display + final String versionName = pInfo.versionName; + + try { + + URL = requestString; + HttpClient httpclient = new DefaultHttpClient(); + HttpParams params = httpclient.getParams(); + + HttpConnectionParams.setConnectionTimeout(params, REGISTRATION_TIMEOUT); + HttpConnectionParams.setSoTimeout(params, WAIT_TIMEOUT); + ConnManagerParams.setTimeout(params, WAIT_TIMEOUT); + + HttpGet httpGet = new HttpGet(URL); + httpGet.setHeader("User-Agent", getString(R.string.app_name) + " " + versionName); + HttpResponse response = httpclient.execute(httpGet); + + StatusLine statusLine = response.getStatusLine(); + Log.d(Config.LOGTAG, "AppUpdater: HTTP Status Code: " + statusLine.getStatusCode()); + if(statusLine.getStatusCode() == HttpStatus.SC_OK){ + ByteArrayOutputStream out = new ByteArrayOutputStream(); + response.getEntity().writeTo(out); + out.close(); + responseMessage = out.toString(); + } else { + Log.e(Config.LOGTAG, "AppUpdater: HTTP1:" + statusLine.getReasonPhrase()); + response.getEntity().getContent().close(); + throw new IOException(statusLine.getReasonPhrase()); + } + + } catch (ClientProtocolException e) { + Log.e(Config.LOGTAG, "AppUpdater: HTTP2:" + e); + responseMessage = ""; + } catch (IOException e) { + Log.e(Config.LOGTAG, "AppUpdater: HTTP3:" + e); + responseMessage = ""; + }catch (Exception e) { + Log.e(Config.LOGTAG, "AppUpdater: HTTP4:" + e); + responseMessage = ""; + } + + + Intent broadcastIntent = new Intent(); + broadcastIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + broadcastIntent.setAction(UpdateReceiver.PROCESS_RESPONSE); + broadcastIntent.addCategory(Intent.CATEGORY_DEFAULT); + broadcastIntent.putExtra(RESPONSE_MESSAGE, responseMessage); + sendBroadcast(broadcastIntent); + + } + +}
\ No newline at end of file diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 5040664ab..82fe4a4e2 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -514,10 +514,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa case ACTION_CLEAR_NOTIFICATION: mNotificationService.clear(); break; - case ACTION_DISABLE_FOREGROUND: - getPreferences().edit().putBoolean("keep_foreground_service", false).commit(); - toggleForegroundService(); - break; case ACTION_TRY_AGAIN: resetAllAttemptCounts(false); interactive = true; @@ -776,7 +772,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public void toggleForegroundService() { - if (getPreferences().getBoolean("keep_foreground_service", false)) { + if (Config.USE_ALWAYS_FOREGROUND) { startForeground(NotificationService.FOREGROUND_NOTIFICATION_ID, this.mNotificationService.createForegroundNotification()); } else { stopForeground(true); @@ -2738,11 +2734,11 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public boolean allowMessageCorrection() { - return getPreferences().getBoolean("allow_message_correction", false); + return getPreferences().getBoolean("allow_message_correction", true); } public boolean sendChatStates() { - return getPreferences().getBoolean("chat_states", false); + return getPreferences().getBoolean("chat_states", true); } public boolean saveEncryptedMessages() { @@ -2754,7 +2750,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } public boolean indicateReceived() { - return getPreferences().getBoolean("indicate_received", false); + return getPreferences().getBoolean("indicate_received", true); } public boolean useTorToConnect() { |