diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 87644ddfaf..8023000ff3 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -6,7 +6,7 @@
@@ -31,7 +31,7 @@
-
+
@@ -676,11 +676,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
+ android:layout_height="match_parent">
+ android:background="@drawable/default_session_background"
+ android:orientation="vertical">
+
+
+ android:text="@string/activity_pn_mode_explanation" />
-
+ android:layout_marginLeft="@dimen/very_large_spacing"
+ android:layout_marginTop="20dp"
+ android:layout_marginRight="@dimen/very_large_spacing"
+ android:padding="12dp"
+ android:orientation="vertical"
+ android:background="@drawable/pn_option_background">
-
+
+
+
+
+
+
+
+
+ android:layout_marginLeft="@dimen/very_large_spacing"
+ android:layout_marginTop="@dimen/small_spacing"
+ android:layout_marginRight="@dimen/very_large_spacing"
+ android:padding="12dp"
+ android:orientation="vertical"
+ android:background="@drawable/pn_option_background">
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/res/layout/activity_pn_mode.xml b/res/layout/activity_pn_mode.xml
index d06cdd8f4a..f8b2b75145 100644
--- a/res/layout/activity_pn_mode.xml
+++ b/res/layout/activity_pn_mode.xml
@@ -1,116 +1,114 @@
-
-
-
-
-
-
-
+ android:layout_height="wrap_content">
+ android:background="@drawable/default_session_background"
+ android:orientation="vertical">
-
-
+ android:text="@string/activity_pn_mode_title" />
+ android:layout_marginLeft="@dimen/very_large_spacing"
+ android:layout_marginTop="@dimen/small_spacing"
+ android:layout_marginRight="@dimen/very_large_spacing"
+ android:textSize="@dimen/small_font_size"
+ android:textColor="@color/text"
+ android:text="@string/activity_pn_mode_explanation" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/ApplicationContext.java b/src/org/thoughtcrime/securesms/ApplicationContext.java
index cca17e57e5..3121f02dd5 100644
--- a/src/org/thoughtcrime/securesms/ApplicationContext.java
+++ b/src/org/thoughtcrime/securesms/ApplicationContext.java
@@ -59,7 +59,6 @@ import org.thoughtcrime.securesms.logging.Log;
import org.thoughtcrime.securesms.logging.PersistentLogger;
import org.thoughtcrime.securesms.logging.UncaughtExceptionLogger;
import org.thoughtcrime.securesms.loki.activities.HomeActivity;
-import org.thoughtcrime.securesms.loki.api.BackgroundOpenGroupPollWorker;
import org.thoughtcrime.securesms.loki.api.BackgroundPollWorker;
import org.thoughtcrime.securesms.loki.api.LokiPublicChatManager;
import org.thoughtcrime.securesms.loki.api.LokiPushNotificationManager;
@@ -366,7 +365,6 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
LocalBackupListener.schedule(this);
RotateSenderCertificateListener.schedule(this);
BackgroundPollWorker.schedule(this); // Loki
- BackgroundOpenGroupPollWorker.schedule(this); // Loki
if (BuildConfig.PLAY_STORE_DISABLED) {
UpdateApkRefreshListener.schedule(this);
diff --git a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
index bab1f38ac8..b3446d3c85 100644
--- a/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
+++ b/src/org/thoughtcrime/securesms/conversation/ConversationActivity.java
@@ -2066,7 +2066,7 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
} else if (!isSecureText && !isDefaultSms) {
unblockButton.setVisibility(View.GONE);
inputPanel.setVisibility(View.GONE);
- makeDefaultSmsButton.setVisibility(View.VISIBLE);
+ makeDefaultSmsButton.setVisibility(View.GONE);
registerButton.setVisibility(View.GONE);
} else {
inputPanel.setVisibility(View.VISIBLE);
diff --git a/src/org/thoughtcrime/securesms/loki/api/BackgroundOpenGroupPollWorker.kt b/src/org/thoughtcrime/securesms/loki/api/BackgroundOpenGroupPollWorker.kt
deleted file mode 100644
index 499b0302d8..0000000000
--- a/src/org/thoughtcrime/securesms/loki/api/BackgroundOpenGroupPollWorker.kt
+++ /dev/null
@@ -1,38 +0,0 @@
-package org.thoughtcrime.securesms.loki.api
-
-import android.content.Context
-import android.content.Intent
-import org.thoughtcrime.securesms.database.DatabaseFactory
-import org.thoughtcrime.securesms.service.PersistentAlarmManagerListener
-import org.thoughtcrime.securesms.util.TextSecurePreferences
-import java.util.concurrent.TimeUnit
-
-class BackgroundOpenGroupPollWorker : PersistentAlarmManagerListener() {
-
- companion object {
- private val pollInterval = TimeUnit.MINUTES.toMillis(4)
-
- @JvmStatic
- fun schedule(context: Context) {
- BackgroundOpenGroupPollWorker().onReceive(context, Intent())
- }
- }
-
- override fun getNextScheduledExecutionTime(context: Context): Long {
- return TextSecurePreferences.getOpenGroupBackgroundPollTime(context)
- }
-
- override fun onAlarm(context: Context, scheduledTime: Long): Long {
- if (scheduledTime != 0L) {
- val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().map { it.value }
- for (openGroup in openGroups) {
- val poller = LokiPublicChatPoller(context, openGroup)
- poller.stop()
- poller.pollForNewMessages()
- }
- }
- val nextTime = System.currentTimeMillis() + pollInterval
- TextSecurePreferences.setOpenGroupBackgroundPollTime(context, nextTime)
- return nextTime
- }
-}
diff --git a/src/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt b/src/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt
index 2d64ec1489..22e774d308 100644
--- a/src/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt
+++ b/src/org/thoughtcrime/securesms/loki/api/BackgroundPollWorker.kt
@@ -15,7 +15,7 @@ import java.util.concurrent.TimeUnit
class BackgroundPollWorker : PersistentAlarmManagerListener() {
companion object {
- private val pollInterval = TimeUnit.MINUTES.toMillis(2)
+ private val pollInterval = TimeUnit.MINUTES.toMillis(10)
@JvmStatic
fun schedule(context: Context) {
@@ -28,21 +28,28 @@ class BackgroundPollWorker : PersistentAlarmManagerListener() {
}
override fun onAlarm(context: Context, scheduledTime: Long): Long {
- if (TextSecurePreferences.isUsingFCM(context)) { return 0L }
if (scheduledTime != 0L) {
- val userHexEncodedPublicKey = TextSecurePreferences.getLocalNumber(context)
- val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context)
- try {
- val applicationContext = context.applicationContext as ApplicationContext
- val broadcaster = applicationContext.broadcaster
- LokiAPI.configureIfNeeded(userHexEncodedPublicKey, lokiAPIDatabase, broadcaster)
- LokiAPI.shared.getMessages().map { messages ->
- messages.forEach {
- PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
+ if (TextSecurePreferences.isUsingFCM(context)) {
+ val userPublicKey = TextSecurePreferences.getLocalNumber(context)
+ val lokiAPIDatabase = DatabaseFactory.getLokiAPIDatabase(context)
+ try {
+ val applicationContext = context.applicationContext as ApplicationContext
+ val broadcaster = applicationContext.broadcaster
+ LokiAPI.configureIfNeeded(userPublicKey, lokiAPIDatabase, broadcaster)
+ LokiAPI.shared.getMessages().map { messages ->
+ messages.forEach {
+ PushContentReceiveJob(context).processEnvelope(SignalServiceEnvelope(it), false)
+ }
}
+ } catch (exception: Throwable) {
+ // Do nothing
}
- } catch (exception: Throwable) {
- // Do nothing
+ }
+ val openGroups = DatabaseFactory.getLokiThreadDatabase(context).getAllPublicChats().map { it.value }
+ for (openGroup in openGroups) {
+ val poller = LokiPublicChatPoller(context, openGroup)
+ poller.stop()
+ poller.pollForNewMessages()
}
}
val nextTime = System.currentTimeMillis() + pollInterval
diff --git a/src/org/thoughtcrime/securesms/loki/protocol/LokiSessionResetImplementation.kt b/src/org/thoughtcrime/securesms/loki/protocol/LokiSessionResetImplementation.kt
index 2a33dda63f..067a25b27c 100644
--- a/src/org/thoughtcrime/securesms/loki/protocol/LokiSessionResetImplementation.kt
+++ b/src/org/thoughtcrime/securesms/loki/protocol/LokiSessionResetImplementation.kt
@@ -26,8 +26,8 @@ class LokiSessionResetImplementation(private val context: Context) : LokiSession
}
override fun validatePreKeySignalMessage(sender: String, message: PreKeySignalMessage) {
- val preKeyRecord = DatabaseFactory.getLokiPreKeyRecordDatabase(context).getPreKeyRecord(sender)
- check(preKeyRecord != null) { "Received a background message from a user without an associated pre key record." }
+ val preKeyRecord = DatabaseFactory.getLokiPreKeyRecordDatabase(context).getPreKeyRecord(sender) ?: return
+ // TODO: Checking that the pre key record isn't null is causing issues when it shouldn't
check(preKeyRecord.id == (message.preKeyId ?: -1)) { "Received a background message from an unknown source." }
}
}
\ No newline at end of file
diff --git a/src/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt b/src/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt
index 3aefe5acbf..3f94883c6c 100644
--- a/src/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt
+++ b/src/org/thoughtcrime/securesms/loki/views/NewConversationButtonSetView.kt
@@ -14,7 +14,6 @@ import android.os.VibrationEffect
import android.os.VibrationEffect.DEFAULT_AMPLITUDE
import android.os.Vibrator
import android.support.annotation.ColorRes
-import android.support.annotation.DimenRes
import android.support.annotation.DrawableRes
import android.util.AttributeSet
import android.view.MotionEvent
@@ -198,12 +197,9 @@ class NewConversationButtonSetView : RelativeLayout {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
if (isExpanded) {
- if (sessionButton.contains(touch)) { delegate?.createNewPrivateChat(); collapse() }
- else if (closedGroupButton.contains(touch)) { delegate?.createNewClosedGroup(); collapse() }
- else if (openGroupButton.contains(touch)) { delegate?.joinOpenGroup(); collapse() }
- else if (mainButton.contains(touch)) { collapse() }
+ if (mainButton.contains(touch)) { collapse() }
} else {
- isExpanded = !isExpanded
+ isExpanded = true
expand()
}
val vibrator = context.getSystemService(VIBRATOR_SERVICE) as Vibrator
@@ -235,15 +231,17 @@ class NewConversationButtonSetView : RelativeLayout {
}
}
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
- val distanceFromRestPosition = touch.distanceTo(buttonRestPosition)
- if (distanceFromRestPosition > (minDragDistance + mainButton.collapsedSize / 2)) {
+ val mainButtonCenter = PointF(width.toFloat() / 2, height.toFloat() - bottomMargin - mainButton.expandedSize / 2)
+ val distanceFromMainButtonCenter = touch.distanceTo(mainButtonCenter)
+ fun collapse() {
+ isExpanded = false
+ this.collapse()
+ }
+ if (distanceFromMainButtonCenter > (minDragDistance + mainButton.collapsedSize / 2)) {
if (sessionButton.contains(touch) || touch.isAbove(sessionButton, dragMargin)) { delegate?.createNewPrivateChat(); collapse() }
else if (closedGroupButton.contains(touch) || touch.isRightOf(closedGroupButton, dragMargin)) { delegate?.createNewClosedGroup(); collapse() }
else if (openGroupButton.contains(touch) || touch.isLeftOf(openGroupButton, dragMargin)) { delegate?.joinOpenGroup(); collapse() }
- else {
- isExpanded = !isExpanded
- if (!isExpanded) { collapse() }
- }
+ else { collapse() }
} else {
val currentPosition = PointF(mainButton.x, mainButton.y)
mainButton.animatePositionChange(currentPosition, buttonRestPosition)
diff --git a/src/org/thoughtcrime/securesms/service/KeyCachingService.java b/src/org/thoughtcrime/securesms/service/KeyCachingService.java
index 4dc3e89cb5..796249b659 100644
--- a/src/org/thoughtcrime/securesms/service/KeyCachingService.java
+++ b/src/org/thoughtcrime/securesms/service/KeyCachingService.java
@@ -61,7 +61,7 @@ public class KeyCachingService extends Service {
public static final int SERVICE_RUNNING_ID = 4141;
- public static final String KEY_PERMISSION = "network.loki.messenger.ACCESS_SECRETS";
+ public static final String KEY_PERMISSION = "network.loki.messenger.ACCESS_SESSION_SECRETS";
public static final String NEW_KEY_EVENT = "org.thoughtcrime.securesms.service.action.NEW_KEY_EVENT";
public static final String CLEAR_KEY_EVENT = "org.thoughtcrime.securesms.service.action.CLEAR_KEY_EVENT";
public static final String LOCK_TOGGLED_EVENT = "org.thoughtcrime.securesms.service.action.LOCK_ENABLED_EVENT";
diff --git a/src/org/thoughtcrime/securesms/util/BitmapUtil.java b/src/org/thoughtcrime/securesms/util/BitmapUtil.java
index 4423405d73..90a51d9720 100644
--- a/src/org/thoughtcrime/securesms/util/BitmapUtil.java
+++ b/src/org/thoughtcrime/securesms/util/BitmapUtil.java
@@ -40,7 +40,7 @@ public class BitmapUtil {
private static final String TAG = BitmapUtil.class.getSimpleName();
- private static final int MAX_COMPRESSION_QUALITY = 90;
+ private static final int MAX_COMPRESSION_QUALITY = 95;
private static final int MIN_COMPRESSION_QUALITY = 45;
private static final int MAX_COMPRESSION_ATTEMPTS = 5;
private static final int MIN_COMPRESSION_QUALITY_DECREASE = 5;
@@ -255,7 +255,7 @@ public class BitmapUtil {
public static InputStream toCompressedJpeg(Bitmap bitmap) {
ByteArrayOutputStream thumbnailBytes = new ByteArrayOutputStream();
- bitmap.compress(CompressFormat.JPEG, 85, thumbnailBytes);
+ bitmap.compress(CompressFormat.JPEG, 95, thumbnailBytes);
return new ByteArrayInputStream(thumbnailBytes.toByteArray());
}