Final code review nitpicks.

This commit is contained in:
akwizgran
2021-04-15 16:12:38 +01:00
parent 2fc6741c99
commit 8991762b0c
9 changed files with 23 additions and 41 deletions

View File

@@ -26,6 +26,7 @@ import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity;
import androidx.lifecycle.ViewModelProvider;
import static java.util.logging.Level.INFO;
import static org.briarproject.briar.android.conversation.ConversationActivity.CONTACT_ID;
import static org.briarproject.briar.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
@@ -102,7 +103,9 @@ public class ConversationSettingsDialog extends DialogFragment {
viewModel.getAutoDeleteTimer()
.observe(getViewLifecycleOwner(), timer -> {
if (LOG.isLoggable(INFO)) {
LOG.info("Received auto delete timer: " + timer);
}
boolean disappearingMessages =
timer != NO_AUTO_DELETE_TIMER;
switchDisappearingMessages

View File

@@ -176,7 +176,7 @@ public class ConversationViewModel extends DbViewModel
} else if (e instanceof AutoDeleteTimerMirroredEvent) {
AutoDeleteTimerMirroredEvent a = (AutoDeleteTimerMirroredEvent) e;
if (a.getContactId().equals(contactId)) {
autoDeleteTimer.postValue(a.getNewTimer());
autoDeleteTimer.setValue(a.getNewTimer());
}
} else if (e instanceof AvatarUpdatedEvent) {
AvatarUpdatedEvent a = (AvatarUpdatedEvent) e;

View File

@@ -170,8 +170,7 @@ public class UiUtils {
/**
* Returns the given duration in a human-friendly format. For example,
* "7 days" or "1 hour". Returns only the largest meaningful unit of time,
* from days up to minutes.
* "7 days" or "1 hour 3 minutes".
*/
public static String formatDuration(Context ctx, long millis) {
Resources r = ctx.getResources();

View File

@@ -172,7 +172,7 @@
<string name="auto_delete_msg_you_enabled">Your messages will disappear after %1$s. %2$s</string>
<!-- The placeholder at the end will add "Tap to learn more." -->
<string name="auto_delete_msg_you_disabled">Your messages will not disappear. %1$s</string>
<!-- The second placeholder will show a duration like "7 days". The third placeholder at the end will add "Tap to learn more." -->
<!-- The first placeholder will show a contact's name. The second placeholder will show a duration like "7 days". The third placeholder at the end will add "Tap to learn more." -->
<string name="auto_delete_msg_contact_enabled">%1$s\'s messages will disappear after %2$s. %3$s</string>
<plurals name="duration_minutes">
<item quantity="one">%d minute</item>
@@ -186,7 +186,7 @@
<item quantity="one">%d day</item>
<item quantity="other">%d days</item>
</plurals>
<!-- The second placeholder at the end will add "Tap to learn more." -->
<!-- The first placeholder will show a contact's name. The second placeholder at the end will add "Tap to learn more." -->
<string name="auto_delete_msg_contact_disabled">%1$s\'s messages will not disappear. %2$s</string>
<string name="tap_to_learn_more">Tap to learn more.</string>
<string name="auto_delete_changed_warning_title">Disappearing messages changed</string>

View File

@@ -40,7 +40,8 @@ public interface AutoDeleteManager {
/**
* Returns the auto-delete timer duration for the given contact, for use in
* a message with the given timestamp. The timestamp is stored.
* a message with the given timestamp. The timestamp is stored. This method
* requires a read-write transaction.
*/
long getAutoDeleteTimer(Transaction txn, ContactId c, long timestamp)
throws DbException;

View File

@@ -17,7 +17,6 @@ import org.briarproject.briar.api.introduction.IntroductionResponse;
import org.briarproject.briar.api.introduction.event.IntroductionResponseReceivedEvent;
import org.briarproject.briar.autodelete.AbstractAutoDeleteTest;
import org.briarproject.briar.test.BriarIntegrationTestComponent;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -391,13 +390,13 @@ public class AutoDeleteIntegrationTest extends AbstractAutoDeleteTest {
// FIRST CYCLE
introduceAndAutoDecline();
Assert.assertTrue(c0.getIntroductionManager()
assertTrue(c0.getIntroductionManager()
.canIntroduce(contact1From0, contact2From0));
// SECOND CYCLE
introduceAndAutoDecline();
Assert.assertTrue(c0.getIntroductionManager()
assertTrue(c0.getIntroductionManager()
.canIntroduce(contact1From0, contact2From0));
}

View File

@@ -13,6 +13,7 @@ import org.briarproject.briar.api.sharing.Shareable;
import org.briarproject.briar.api.sharing.SharingInvitationItem;
import org.briarproject.briar.api.sharing.SharingManager;
import org.briarproject.briar.autodelete.AbstractAutoDeleteTest;
import org.junit.Test;
import java.util.Collection;
@@ -42,7 +43,8 @@ public abstract class AbstractAutoDeleteIntegrationTest
protected abstract Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass();
protected void testAutoDeclinedSharing() throws Exception {
@Test
public void testAutoDeclinedSharing() throws Exception {
setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS);
// Send invitation
@@ -191,7 +193,8 @@ public abstract class AbstractAutoDeleteIntegrationTest
assertGroupCount(c1, contactId0From1, 1, 1);
}
protected void testRespondAfterSenderDeletedInvitation() throws Exception {
@Test
public void testRespondAfterSenderDeletedInvitation() throws Exception {
setAutoDeleteTimer(c0, contactId1From0, MIN_AUTO_DELETE_TIMER_MS);
assertTrue(subscriptions0().contains(getShareable()));

View File

@@ -4,14 +4,13 @@ import org.briarproject.bramble.api.db.DbException;
import org.briarproject.briar.api.blog.Blog;
import org.briarproject.briar.api.blog.BlogManager;
import org.briarproject.briar.api.blog.event.BlogInvitationResponseReceivedEvent;
import org.briarproject.briar.api.conversation.ConversationManager;
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
import org.briarproject.briar.api.sharing.InvitationResponse;
import org.briarproject.briar.api.sharing.Shareable;
import org.briarproject.briar.api.sharing.SharingManager;
import org.briarproject.briar.test.BriarIntegrationTestComponent;
import org.junit.Before;
import org.junit.Test;
import java.util.Collection;
@@ -40,7 +39,7 @@ public class AutoDeleteBlogIntegrationTest
}
@Override
protected ConversationManager.ConversationClient getConversationClient(
protected ConversationClient getConversationClient(
BriarIntegrationTestComponent component) {
return component.getBlogSharingManager();
}
@@ -74,14 +73,4 @@ public class AutoDeleteBlogIntegrationTest
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
return responseReceivedEventClass;
}
@Test
public void testAutoDeclinedBlogSharing() throws Exception {
testAutoDeclinedSharing();
}
@Test
public void testRespondAfterSenderDeletedBlogInvitation() throws Exception {
testRespondAfterSenderDeletedInvitation();
}
}

View File

@@ -1,7 +1,7 @@
package org.briarproject.briar.sharing;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.briar.api.conversation.ConversationManager;
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
import org.briarproject.briar.api.conversation.event.ConversationMessageReceivedEvent;
import org.briarproject.briar.api.forum.Forum;
import org.briarproject.briar.api.forum.ForumManager;
@@ -11,7 +11,6 @@ import org.briarproject.briar.api.sharing.Shareable;
import org.briarproject.briar.api.sharing.SharingManager;
import org.briarproject.briar.test.BriarIntegrationTestComponent;
import org.junit.Before;
import org.junit.Test;
import java.util.Collection;
@@ -20,10 +19,10 @@ public class AutoDeleteForumIntegrationTest
private SharingManager<Forum> sharingManager0;
private SharingManager<Forum> sharingManager1;
protected Forum shareable;
private Forum shareable;
private ForumManager manager0;
private ForumManager manager1;
protected Class<ForumInvitationResponseReceivedEvent>
private Class<ForumInvitationResponseReceivedEvent>
responseReceivedEventClass;
@Before
@@ -39,7 +38,7 @@ public class AutoDeleteForumIntegrationTest
}
@Override
protected ConversationManager.ConversationClient getConversationClient(
protected ConversationClient getConversationClient(
BriarIntegrationTestComponent component) {
return component.getForumSharingManager();
}
@@ -73,15 +72,4 @@ public class AutoDeleteForumIntegrationTest
protected Class<? extends ConversationMessageReceivedEvent<? extends InvitationResponse>> getResponseReceivedEventClass() {
return responseReceivedEventClass;
}
@Test
public void testAutoDeclinedForumSharing() throws Exception {
testAutoDeclinedSharing();
}
@Test
public void testRespondAfterSenderDeletedForumInvitation()
throws Exception {
testRespondAfterSenderDeletedInvitation();
}
}